From patchwork Fri May 20 09:57:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 96574 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 76942B718D for ; Fri, 20 May 2011 19:51:20 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QNMMV-0004kh-Um; Fri, 20 May 2011 09:51:16 +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 1QNMMU-0005Fr-FV; Fri, 20 May 2011 09:51:14 +0000 Received: from mail-px0-f171.google.com ([209.85.212.171]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QNMMM-0005Ex-3N for linux-arm-kernel@lists.infradead.org; Fri, 20 May 2011 09:51:07 +0000 Received: by pxi7 with SMTP id 7so2424420pxi.30 for ; Fri, 20 May 2011 02:51:05 -0700 (PDT) Received: by 10.68.46.65 with SMTP id t1mr6778249pbm.231.1305885065021; Fri, 20 May 2011 02:51:05 -0700 (PDT) Received: from localhost.localdomain ([114.216.156.157]) by mx.google.com with ESMTPS id v6sm2283673pbc.27.2011.05.20.02.50.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 May 2011 02:51:04 -0700 (PDT) From: Shawn Guo To: linux-kernel@vger.kernel.org Subject: [PATCH 2/3] ARM: mxs: add gpio-mxs platform devices Date: Fri, 20 May 2011 17:57:25 +0800 Message-Id: <1305885446-27404-3-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1305885446-27404-1-git-send-email-shawn.guo@linaro.org> References: <1305885446-27404-1-git-send-email-shawn.guo@linaro.org> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110520_055106_372375_115C37BD X-CRM114-Status: GOOD ( 15.97 ) 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 [209.85.212.171 listed in list.dnswl.org] Cc: patches@linaro.org, linus.walleij@linaro.org, grant.likely@secretlab.ca, kernel@pengutronix.de, Shawn Guo , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list 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+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Signed-off-by: Shawn Guo --- arch/arm/mach-mxs/devices/Makefile | 1 + arch/arm/mach-mxs/devices/platform-gpio-mxs.c | 92 +++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-mxs/devices/platform-gpio-mxs.c diff --git a/arch/arm/mach-mxs/devices/Makefile b/arch/arm/mach-mxs/devices/Makefile index 324f282..351915c 100644 --- a/arch/arm/mach-mxs/devices/Makefile +++ b/arch/arm/mach-mxs/devices/Makefile @@ -6,4 +6,5 @@ obj-$(CONFIG_MXS_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_I2C) += platform-mxs-i2c.o obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_MMC) += platform-mxs-mmc.o obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_PWM) += platform-mxs-pwm.o +obj-y += platform-gpio-mxs.o obj-$(CONFIG_MXS_HAVE_PLATFORM_MXSFB) += platform-mxsfb.o diff --git a/arch/arm/mach-mxs/devices/platform-gpio-mxs.c b/arch/arm/mach-mxs/devices/platform-gpio-mxs.c new file mode 100644 index 0000000..3840d8c --- /dev/null +++ b/arch/arm/mach-mxs/devices/platform-gpio-mxs.c @@ -0,0 +1,92 @@ +/* + * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation. + */ +#include +#include +#include + +#include +#include +#include + +struct mxs_gpio_data { + int id; + resource_size_t iobase; + resource_size_t iosize; + resource_size_t irq; +}; + +#define mxs_gpio_data_entry_single(soc, _id) \ + { \ + .id = _id, \ + .iobase = soc ## _PINCTRL ## _BASE_ADDR, \ + .irq = soc ## _INT_GPIO ## _id, \ + } + +#define mxs_gpio_data_entry(soc, _id) \ + [_id] = mxs_gpio_data_entry_single(soc, _id) + +#ifdef CONFIG_SOC_IMX23 +const struct mxs_gpio_data mx23_gpio_data[] __initconst = { +#define mx23_gpio_data_entry(_id) \ + mxs_gpio_data_entry(MX23, _id) + mx23_gpio_data_entry(0), + mx23_gpio_data_entry(1), + mx23_gpio_data_entry(2), +}; +#endif + +#ifdef CONFIG_SOC_IMX28 +const struct mxs_gpio_data mx28_gpio_data[] __initconst = { +#define mx28_gpio_data_entry(_id) \ + mxs_gpio_data_entry(MX28, _id) + mx28_gpio_data_entry(0), + mx28_gpio_data_entry(1), + mx28_gpio_data_entry(2), + mx28_gpio_data_entry(3), + mx28_gpio_data_entry(4), +}; +#endif + +struct platform_device *__init mxs_add_gpio( + const struct mxs_gpio_data *data) +{ + struct resource res[] = { + { + .start = data->iobase, + .end = data->iobase + SZ_8K - 1, + .flags = IORESOURCE_MEM, + }, { + .start = data->irq, + .end = data->irq, + .flags = IORESOURCE_IRQ, + }, + }; + + return mxs_add_platform_device("mxs-gpio", data->id, + res, ARRAY_SIZE(res), NULL, 0); +} + +static int __init mxs_add_mxs_gpio(void) +{ + int i; + +#ifdef CONFIG_SOC_IMX23 + if (cpu_is_mx23()) + for (i = 0; i < ARRAY_SIZE(mx23_gpio_data); i++) + mxs_add_gpio(&mx23_gpio_data[i]); +#endif + +#ifdef CONFIG_SOC_IMX28 + if (cpu_is_mx28()) + for (i = 0; i < ARRAY_SIZE(mx28_gpio_data); i++) + mxs_add_gpio(&mx28_gpio_data[i]); +#endif + + return 0; +} +postcore_initcall(mxs_add_mxs_gpio);