From patchwork Mon Aug 8 05:19:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song X-Patchwork-Id: 1042992 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p785Lt0e032761 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 8 Aug 2011 05:22:16 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QqIHU-0000Jk-0I; Mon, 08 Aug 2011 05:21:40 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QqIHT-0000j1-HE; Mon, 08 Aug 2011 05:21:39 +0000 Received: from cluster-d.mailcontrol.com ([85.115.60.190]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QqIHP-0000ih-W0 for linux-arm-kernel@lists.infradead.org; Mon, 08 Aug 2011 05:21:37 +0000 Received: from rly05d.srv.mailcontrol.com (localhost.localdomain [127.0.0.1]) by rly05d.srv.mailcontrol.com (MailControl) with ESMTP id p785KlvT023956 for ; Mon, 8 Aug 2011 06:21:32 +0100 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by rly05d.srv.mailcontrol.com (MailControl) id p785KCce019837 for ; Mon, 8 Aug 2011 06:20:12 +0100 Received: from banasiexc01.ASIA.ROOT.PRI ([202.80.51.114]) by rly05d-eth0.srv.mailcontrol.com (envelope-sender ) (MIMEDefang) with ESMTP id p785K8nI019374 (TLS bits=128 verify=FAIL); Mon, 08 Aug 2011 06:20:12 +0100 (BST) Received: from SHAASIEXC01.ASIA.ROOT.PRI (10.125.12.84) by banasiexc01.ASIA.ROOT.PRI (10.190.12.21) with Microsoft SMTP Server (TLS) id 14.1.270.1; Mon, 8 Aug 2011 10:50:07 +0530 Received: from localhost.localdomain (10.125.36.59) by asimail.csr.com (10.125.12.88) with Microsoft SMTP Server (TLS) id 14.1.270.1; Mon, 8 Aug 2011 13:20:05 +0800 From: Barry Song To: Subject: [PATCH] GPIOLIB: add generic gpio_set_pull API Date: Sun, 7 Aug 2011 22:19:33 -0700 Message-ID: <1312780773-23142-1-git-send-email-Baohua.Song@csr.com> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 X-Originating-IP: [10.125.36.59] X-Scanned-By: MailControl A-12-01-02 (www.mailcontrol.com) on 10.68.1.115 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110808_012136_279431_53A02D3E X-CRM114-Status: GOOD ( 14.84 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [85.115.60.190 listed in list.dnswl.org] Cc: workgroup.linux@csr.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Barry Song X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 08 Aug 2011 05:22:16 +0000 (UTC) Now there are many different implementations for GPIO pull configuration, for example: s3c_gpio_setpull() tegra_pinmux_set_pullupdown() chipcHw_setPinPullup() gpio_pullup() s3c2410_gpio_pullup() This patch adds a new generic gpio_set_pull API so that all SoCs can have unified codes. Signed-off-by: Barry Song --- drivers/gpio/gpiolib.c | 17 +++++++++++++++++ include/asm-generic/gpio.h | 3 +++ include/linux/gpio.h | 4 ++++ 3 files changed, 24 insertions(+), 0 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a971e3d..a2afa95 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1620,6 +1620,23 @@ int __gpio_to_irq(unsigned gpio) } EXPORT_SYMBOL_GPL(__gpio_to_irq); +/** + * __gpio_set_pull() - set pull up, pull down or no pull for a gpio + * @gpio: gpio which will be configurated + * @mode: one of GPIO_PULL_NONE, GPIO_PULL_UP and GPIO_PULL_DOWN + * Context: any + * + * This is used directly or indirectly to implement gpio_set_pull(). + */ +void __gpio_set_pull(unsigned gpio, unsigned mode) +{ + struct gpio_chip *chip; + + chip = gpio_to_chip(gpio); + + chip->pull(chip, gpio, mode); +} +EXPORT_SYMBOL_GPL(__gpio_set_pull); /* There's no value in making it easy to inline GPIO calls that may sleep. diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index d494001..f953835 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -112,6 +112,9 @@ struct gpio_chip { int (*to_irq)(struct gpio_chip *chip, unsigned offset); + void (*pull)(struct gpio_chip *chip, + unsigned offset, unsigned mode); + void (*dbg_show)(struct seq_file *s, struct gpio_chip *chip); int base; diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 17b5a0d..ac48166 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -14,6 +14,10 @@ #define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW) #define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH) +#define GPIO_PULL_NONE 0 +#define GPIO_PULL_UP 1 +#define GPIO_PULL_DOWN 2 + #ifdef CONFIG_GENERIC_GPIO #include