From patchwork Tue Jan 22 13:48:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 14211 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E1DA423E57 for ; Tue, 22 Jan 2013 13:42:19 +0000 (UTC) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by fiordland.canonical.com (Postfix) with ESMTP id 8D4ABA1982F for ; Tue, 22 Jan 2013 13:42:19 +0000 (UTC) Received: by mail-ve0-f172.google.com with SMTP id 15so529528vea.17 for ; Tue, 22 Jan 2013 05:42:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-brightmail-tracker:x-brightmail-tracker :dlp-filter:x-mtr:x-cfilter-loop:x-gm-message-state; bh=1tTwUT4oywNi5OU9IbtJ0/Kob/0ZniWu8OBUbAyLPos=; b=Q2SGHSrAKMr+7szFJFzHHqDt6uki5gk1SUpSRCRmPivJF7ajS0mBkkGzFXSVtMji65 lzCb5J3lihnc8XZzEVbWQ8S3fVDKCY4QmPq65IS3/slMNwERo2n2c0QcvjXHXrvJ8WsZ P1vIV2X3y31eY+igTMOr5WrE9d4CX4hlyD7+nWEOlT2QIol66D9IYEdOgTrRFyxvjas1 3hZIVqkPp2Jf3Jjsyw6AllY6j15y8Fq9AbAoBYmzRVafHZJ2oxil6RsPuM/AXchYVAJO ieyB0KPgPzEzQuNxKjklPx1VUWU71Xc7c4RNpM+iBtz35jQQKmS96AJKTCv079J68nvK zZqA== X-Received: by 10.52.18.147 with SMTP id w19mr20638052vdd.94.1358862139079; Tue, 22 Jan 2013 05:42:19 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp251111veb; Tue, 22 Jan 2013 05:42:18 -0800 (PST) X-Received: by 10.66.83.232 with SMTP id t8mr55881091pay.73.1358862138135; Tue, 22 Jan 2013 05:42:18 -0800 (PST) Received: from mailout1.samsung.com (mailout1.samsung.com. [203.254.224.24]) by mx.google.com with ESMTP id c9si17269387pax.336.2013.01.22.05.42.17; Tue, 22 Jan 2013 05:42:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.24 as permitted sender) client-ip=203.254.224.24; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.24 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MH1008GV4QE0630@mailout1.samsung.com>; Tue, 22 Jan 2013 22:42:16 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.122]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 70.57.03880.8379EF05; Tue, 22 Jan 2013 22:42:16 +0900 (KST) X-AuditID: cbfee61b-b7fb06d000000f28-b0-50fe97382aee Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id DF.47.03880.8379EF05; Tue, 22 Jan 2013 22:42:16 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MH100D7F4N8JQB0@mmp1.samsung.com>; Tue, 22 Jan 2013 22:42:16 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org Subject: [PATCH 3/3 V2] EXYNOS5: GPIO: Enable GPIO Command for EXYNOS5 Date: Tue, 22 Jan 2013 19:18:09 +0530 Message-id: <1358862489-28818-4-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1358862489-28818-1-git-send-email-rajeshwari.s@samsung.com> References: <1358862489-28818-1-git-send-email-rajeshwari.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRmVeSWpSXmKPExsWyRsSkStdi+r8Ag1sb9Cwerr/JYjHl8BcW ByaPO9f2sAUwRnHZpKTmZJalFunbJXBlnJ3XwVZwRKHixYu3zA2MnyS6GDk5JARMJO5/fswG YYtJXLi3Hsjm4hASWMoocblpByNM0fKvB5ghEosYJV5e+QpVNZFJ4tvxBnaQKjYBI4mtJ6eB dYgISEj86r8KZjMLxEi83v8DbIWwgJvE8xWnWUBsFgFVia87XoPZvAIeEt9X/WGB2KYgcWzq V1YQm1PAU+LmjElgvUJANa8fXmcCWSwhcJtNYuW+92wQgwQkvk0+BNTMAZSQldgEcinIHEmJ gytusExgFF7AyLCKUTS1ILmgOCk910ivODG3uDQvXS85P3cTIzAgT/97Jr2DcVWDxSFGAQ5G JR7eB/f/BgixJpYVV+YeYpTgYFYS4dWt/xcgxJuSWFmVWpQfX1Sak1p8iDEZaPlEZinR5Hxg tOSVxBsam5ibGptaGhmZmZqSJqwkzst46kmAkEB6YklqdmpqQWoRzBYmDk6pBsb5Dl9rBf82 pR5av7pz/ZLjNXWum69N+7OAweJ1Sqieq35IgIL3anmdQqHArFMnOVTsLE+3ubyX7+jUt73L Lf/iT/CCfvXFyyM4j9e/6XzbPOuiifgFg/NSVi4f758y13F73Hj0aOHrCtcfJzicHvZJzfv0 x/moedPtPAXVuDCNO4v3XvrO4KfEUpyRaKjFXFScCAABb7MFjAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsVy+t9jAV2L6f8CDPY3Klg8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzDg7r4Ot4IhC xYsXb5kbGD9JdDFyckgImEgs/3qAGcIWk7hwbz1bFyMXh5DAIkaJl1e+QjkTmSS+HW9gB6li EzCS2HpyGiOILSIgIfGr/yqYzSwQI/F6/w82EFtYwE3i+YrTLCA2i4CqxNcdr8FsXgEPie+r /rBAbFOQODb1KyuIzSngKXFzxiSwXiGgmtcPrzNNYORdwMiwilE0tSC5oDgpPddIrzgxt7g0 L10vOT93EyM43J9J72Bc1WBxiFGAg1GJh/fB/b8BQqyJZcWVuYcYJTiYlUR4dev/BQjxpiRW VqUW5ccXleakFh9iTAa6aiKzlGhyPjAW80riDY1NzE2NTS1NLEzMLEkTVhLnZTz1JEBIID2x JDU7NbUgtQhmCxMHp1QDo/cGwVm7Dp/o3yJdOmNV56UX2/kWPJRfwf0k8/b62sWxZwT1hB+7 Nf23cg+ft6/9ee+GC5MstjG4HovwNbISvXJ6pmup++w48UK3oACNLQuV26cv392zTH07h+1K a6u8bquORYol0zRMRHM+6bMxp8R5rTt4fI3elU4RLeHqH6m+h57GLjbUVmIpzkg01GIuKk4E AHuDXbS7AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQm9ZS0WMtsGC7LdB4GY530NznKKRUe6DuC32Kug6qxtP9oVg0wD3j90Zl4Cs1S6HEKM4qCV This patch enables GPIO Command for EXYNOS5. Function has been added to asm/gpio.h to decode the input gpio name to gpio number. example: gpio set gpa00 GPIO_INPUT in cmd_gpio.c has been modified to GPIO_DIRECTION_INPUT as GPIO_INPUT is alraedy defined in exynos5 and leading to a error. Signed-off-by: Rajeshwari Shinde --- Chnages in V2: - New patch arch/arm/include/asm/arch-exynos/gpio.h | 88 +++++++++++++++++++++++++++++++ common/cmd_gpio.c | 6 +- include/configs/exynos5250-dt.h | 1 + 3 files changed, 92 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/arch-exynos/gpio.h b/arch/arm/include/asm/arch-exynos/gpio.h index af882dd..66e4a8e 100644 --- a/arch/arm/include/asm/arch-exynos/gpio.h +++ b/arch/arm/include/asm/arch-exynos/gpio.h @@ -657,6 +657,94 @@ static inline unsigned int s5p_gpio_part_max(int nr) void gpio_cfg_pin(int gpio, int cfg); void gpio_set_pull(int gpio, int mode); void gpio_set_drv(int gpio, int mode); + +#include + +static inline int name_to_gpio(const char *name) +{ + int num; + + name++; + + if (*name == 'p') { + ++name; + + switch (*name) { + case 'a': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_A00 + num; + break; + case 'b': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_B00 + num; + break; + case 'c': + name++; + num = simple_strtoul(name, NULL, 10); + if (num >= 40) + num = GPIO_C40 + (num - 40); + else { + num = simple_strtoul(name, NULL, 8); + num = GPIO_C00 + num; + } + break; + case 'd': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_D00 + num; + break; + case 'y': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_Y00 + num; + break; + case 'x': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_X00 + num; + break; + case 'e': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_E00 + num; + break; + case 'f': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_F00 + num; + break; + case 'g': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_G00 + num; + break; + case 'h': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_H00 + num; + break; + case 'v': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_V00 + num; + break; + case 'z': + name++; + num = simple_strtoul(name, NULL, 8); + num = GPIO_Z0 + num; + break; + default: + return -1; + } + } else + return -1; + + return num; +} + +#define name_to_gpio(n) name_to_gpio(n) #endif /* Pin configurations */ diff --git a/common/cmd_gpio.c b/common/cmd_gpio.c index 47eee89..450e6d1 100644 --- a/common/cmd_gpio.c +++ b/common/cmd_gpio.c @@ -16,7 +16,7 @@ #endif enum gpio_cmd { - GPIO_INPUT, + GPIO_DIRECTION_INPUT, GPIO_SET, GPIO_CLEAR, GPIO_TOGGLE, @@ -44,7 +44,7 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* parse the behavior */ switch (*str_cmd) { - case 'i': sub_cmd = GPIO_INPUT; break; + case 'i': sub_cmd = GPIO_DIRECTION_INPUT; break; case 's': sub_cmd = GPIO_SET; break; case 'c': sub_cmd = GPIO_CLEAR; break; case 't': sub_cmd = GPIO_TOGGLE; break; @@ -63,7 +63,7 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } /* finally, let's do it: set direction and exec command */ - if (sub_cmd == GPIO_INPUT) { + if (sub_cmd == GPIO_DIRECTION_INPUT) { gpio_direction_input(gpio); value = gpio_get_value(gpio); } else { diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h index 7b9c393..b20b8f2 100644 --- a/include/configs/exynos5250-dt.h +++ b/include/configs/exynos5250-dt.h @@ -113,6 +113,7 @@ #define CONFIG_CMD_EXT2 #define CONFIG_CMD_FAT #define CONFIG_CMD_NET +#define CONFIG_CMD_GPIO #define CONFIG_BOOTDELAY 3 #define CONFIG_ZERO_BOOTDELAY_CHECK