From patchwork Mon Jan 19 11:33:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martyn Welch X-Patchwork-Id: 19281 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id A70EA47CCB for ; Mon, 19 Jan 2009 22:35:06 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from ext-nj2ut-10.online-age.net (ext-nj2ut-10.online-age.net [64.14.54.240]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "ext-nj2ut.online-age.net", Issuer "Savvis Communications Root CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 219D947620 for ; Mon, 19 Jan 2009 22:33:37 +1100 (EST) Received: from int-nj2ut-5.online-age.net (int-nj2ut-5.online-age.net [3.159.237.74]) by ext-nj2ut-10.online-age.net (8.13.6/8.13.6/20051114-SVVS-TLS-DNSBL) with ESMTP id n0JBXY6J032173 for ; Mon, 19 Jan 2009 06:33:34 -0500 Received: from cinmlip01.e2k.ad.ge.com (int-nj2ut-5.online-age.net [3.159.237.74]) by int-nj2ut-5.online-age.net (8.13.6/8.13.6/20050510-SVVS) with ESMTP id n0JBXYnI010806 for ; Mon, 19 Jan 2009 06:33:34 -0500 Received: from ind-3n4b83jh1.amer.consind.ge.com (HELO ubuntu8041.localdomain) ([3.138.54.81]) by cinmlip01.e2k.ad.ge.com with ESMTP; 19 Jan 2009 06:33:33 -0500 Received: from ubuntu8041.localdomain (localhost [127.0.0.1]) by ubuntu8041.localdomain (Postfix) with ESMTP id 0BA895E130; Mon, 19 Jan 2009 11:33:34 +0000 (GMT) From: Martyn Welch Subject: [PATCH 3/3] powerpc/86xx: Extend GE Fanuc GPIO driver for the SBC310 To: linuxppc-dev@ozlabs.org Date: Mon, 19 Jan 2009 11:33:34 +0000 Message-ID: <20090119113329.9225.83409.stgit@ubuntu8041.localdomain> In-Reply-To: <20090119112130.9225.82681.stgit@ubuntu8041.localdomain> References: <20090119112130.9225.82681.stgit@ubuntu8041.localdomain> User-Agent: StGIT/0.13 MIME-Version: 1.0 X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org This patch adds basic support for the 6 GPIO lines found on GE Fanucs SBC310 to the GE Fanuc GPIO driver. Signed-off-by: Martyn Welch --- arch/powerpc/configs/86xx/gef_sbc310_defconfig | 2 + arch/powerpc/platforms/86xx/gef_gpio.c | 36 +++++++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/configs/86xx/gef_sbc310_defconfig b/arch/powerpc/configs/86xx/gef_sbc310_defconfig index 157fdcd..79542ce 100644 --- a/arch/powerpc/configs/86xx/gef_sbc310_defconfig +++ b/arch/powerpc/configs/86xx/gef_sbc310_defconfig @@ -880,7 +880,7 @@ CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y CONFIG_ARCH_REQUIRE_GPIOLIB=y CONFIG_GPIOLIB=y # CONFIG_DEBUG_GPIO is not set -# CONFIG_GPIO_SYSFS is not set +CONFIG_GPIO_SYSFS=y # # Memory mapped GPIO expanders: diff --git a/arch/powerpc/platforms/86xx/gef_gpio.c b/arch/powerpc/platforms/86xx/gef_gpio.c index 85b2800..b2ea887 100644 --- a/arch/powerpc/platforms/86xx/gef_gpio.c +++ b/arch/powerpc/platforms/86xx/gef_gpio.c @@ -37,8 +37,6 @@ #define GEF_GPIO_OVERRUN 0x1C #define GEF_GPIO_MODE 0x20 -#define NUM_GPIO 19 - static void _gef_gpio_set(void __iomem *reg, unsigned int offset, int value) { unsigned int data; @@ -103,10 +101,10 @@ static void gef_gpio_set(struct gpio_chip *chip, unsigned offset, int value) static int __init gef_gpio_init(void) { struct device_node *np; + int retval; + struct of_mm_gpio_chip *gef_gpio_chip; for_each_compatible_node(np, NULL, "gef,sbc610-gpio") { - int retval; - struct of_mm_gpio_chip *gef_gpio_chip; pr_debug("%s: Initialising GEF GPIO\n", np->full_name); @@ -120,7 +118,35 @@ static int __init gef_gpio_init(void) /* Setup pointers to chip functions */ gef_gpio_chip->of_gc.gpio_cells = 2; - gef_gpio_chip->of_gc.gc.ngpio = NUM_GPIO; + gef_gpio_chip->of_gc.gc.ngpio = 19; + gef_gpio_chip->of_gc.gc.direction_input = gef_gpio_dir_in; + gef_gpio_chip->of_gc.gc.direction_output = gef_gpio_dir_out; + gef_gpio_chip->of_gc.gc.get = gef_gpio_get; + gef_gpio_chip->of_gc.gc.set = gef_gpio_set; + + /* This function adds a memory mapped GPIO chip */ + retval = of_mm_gpiochip_add(np, gef_gpio_chip); + if (retval) { + kfree(gef_gpio_chip); + pr_err("%s: Unable to add GPIO\n", np->full_name); + } + } + + for_each_compatible_node(np, NULL, "gef,sbc310-gpio") { + + pr_debug("%s: Initialising GEF GPIO\n", np->full_name); + + /* Allocate chip structure */ + gef_gpio_chip = kzalloc(sizeof(*gef_gpio_chip), GFP_KERNEL); + if (!gef_gpio_chip) { + pr_err("%s: Unable to allocate structure\n", + np->full_name); + continue; + } + + /* Setup pointers to chip functions */ + gef_gpio_chip->of_gc.gpio_cells = 2; + gef_gpio_chip->of_gc.gc.ngpio = 6; gef_gpio_chip->of_gc.gc.direction_input = gef_gpio_dir_in; gef_gpio_chip->of_gc.gc.direction_output = gef_gpio_dir_out; gef_gpio_chip->of_gc.gc.get = gef_gpio_get;