From patchwork Mon Sep 5 12:49:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Kaloz X-Patchwork-Id: 1124882 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p85CoeJd006147 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 5 Sep 2011 12:51:01 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1R0Ycl-0000Qh-SK; Mon, 05 Sep 2011 12:50:03 +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 1R0Ycl-0003SH-Gg; Mon, 05 Sep 2011 12:50:03 +0000 Received: from mail.ahiv.hu ([195.228.168.219]) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1R0Yce-0003Ru-AS for linux-arm-kernel@lists.infradead.org; Mon, 05 Sep 2011 12:50:00 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.ahiv.hu (Postfix) with ESMTP id B5C33E94082; Mon, 5 Sep 2011 14:50:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at mail.ahiv.hu X-Spam-Flag: NO X-Spam-Score: -2.289 X-Spam-Level: X-Spam-Status: No, score=-2.289 required=6.31 tests=[AWL=0.310, BAYES_00=-2.599] Received: from mail.ahiv.hu ([127.0.0.1]) by localhost (mail.ahiv.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sDXIdmqXee6d; Mon, 5 Sep 2011 14:50:09 +0200 (CEST) Received: from ecaz.afh.b-m.hu (firewall.ahiv.hu [195.228.168.220]) by mail.ahiv.hu (Postfix) with ESMTP id 8D555E9407E; Mon, 5 Sep 2011 14:50:09 +0200 (CEST) From: Imre Kaloz To: linux-arm-kernel@lists.infradead.org Subject: [RFC/PATCH] ARM: ixp4xx gpiolib support Date: Mon, 5 Sep 2011 14:49:51 +0200 Message-Id: <1315226991-3835-1-git-send-email-kaloz@openwrt.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <20110905104133.GH6619@n2100.arm.linux.org.uk> References: <20110905104133.GH6619@n2100.arm.linux.org.uk> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110905_084956_657784_EB94D497 X-CRM114-Status: GOOD ( 15.07 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- Cc: grant.likely@secretlab.ca, ben@decadent.org.uk, linux@arm.linux.org.uk, arnaud.patard@rtp-net.org, debian-kernel@lists.debian.org 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: , MIME-Version: 1.0 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 (demeter1.kernel.org [140.211.167.41]); Mon, 05 Sep 2011 12:51:01 +0000 (UTC) This patch adds gpiolib support for the IXP4xx platform Signed-off-by: Imre Kaloz --- arch/arm/Kconfig | 2 +- arch/arm/mach-ixp4xx/common.c | 39 +++++++++++++++++++++++++ arch/arm/mach-ixp4xx/include/mach/gpio.h | 46 ++++++++++-------------------- 3 files changed, 55 insertions(+), 32 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 3269576..e793a75 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -481,7 +481,7 @@ config ARCH_IXP4XX depends on MMU select CLKSRC_MMIO select CPU_XSCALE - select GENERIC_GPIO + select ARCH_REQUIRE_GPIOLIB select GENERIC_CLOCKEVENTS select HAVE_SCHED_CLOCK select MIGHT_HAVE_PCI diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c index 0777257..7603456 100644 --- a/arch/arm/mach-ixp4xx/common.c +++ b/arch/arm/mach-ixp4xx/common.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -375,12 +376,50 @@ static struct platform_device *ixp46x_devices[] __initdata = { unsigned long ixp4xx_exp_bus_size; EXPORT_SYMBOL(ixp4xx_exp_bus_size); +static int ixp4xx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) +{ + gpio_line_config(gpio, IXP4XX_GPIO_IN); + return 0; +} + +static int ixp4xx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level) +{ + gpio_line_set(gpio, level); + gpio_line_config(gpio, IXP4XX_GPIO_OUT); + return 0; +} + +static int ixp4xx_gpio_get_value(struct gpio_chip *chip, unsigned gpio) +{ + int value; + + gpio_line_get(gpio, &value); + return value; +} + +static void ixp4xx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value) +{ + gpio_line_set(gpio, value); +} + +static struct gpio_chip ixp4xx_gpio_chip = { + .label = "IXP4XX_GPIO_CHIP", + .direction_input = ixp4xx_gpio_direction_input, + .direction_output = ixp4xx_gpio_direction_output, + .get = ixp4xx_gpio_get_value, + .set = ixp4xx_gpio_set_value, + .base = 0, + .ngpio = 16, +}; + void __init ixp4xx_sys_init(void) { ixp4xx_exp_bus_size = SZ_16M; platform_add_devices(ixp4xx_devices, ARRAY_SIZE(ixp4xx_devices)); + gpiochip_add(&ixp4xx_gpio_chip); + if (cpu_is_ixp46x()) { int region; diff --git a/arch/arm/mach-ixp4xx/include/mach/gpio.h b/arch/arm/mach-ixp4xx/include/mach/gpio.h index a5f87de..86f3596 100644 --- a/arch/arm/mach-ixp4xx/include/mach/gpio.h +++ b/arch/arm/mach-ixp4xx/include/mach/gpio.h @@ -27,47 +27,31 @@ #include #include +#include /* cansleep wrappers */ -static inline int gpio_request(unsigned gpio, const char *label) -{ - return 0; -} - -static inline void gpio_free(unsigned gpio) -{ - might_sleep(); - - return; -} - -static inline int gpio_direction_input(unsigned gpio) -{ - gpio_line_config(gpio, IXP4XX_GPIO_IN); - return 0; -} - -static inline int gpio_direction_output(unsigned gpio, int level) -{ - gpio_line_set(gpio, level); - gpio_line_config(gpio, IXP4XX_GPIO_OUT); - return 0; -} +#define NR_BUILTIN_GPIO 16 static inline int gpio_get_value(unsigned gpio) { - int value; - - gpio_line_get(gpio, &value); - - return value; + if (gpio < NR_BUILTIN_GPIO) + { + int value; + gpio_line_get(gpio, &value); + return value; + } + else + return __gpio_get_value(gpio); } static inline void gpio_set_value(unsigned gpio, int value) { - gpio_line_set(gpio, value); + if (gpio < NR_BUILTIN_GPIO) + gpio_line_set(gpio, value); + else + __gpio_set_value(gpio, value); } -#include /* cansleep wrappers */ +#define gpio_cansleep __gpio_cansleep extern int gpio_to_irq(int gpio); extern int irq_to_gpio(unsigned int irq);