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: 1555 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:53:00 -0000 Delivered-To: patches@linaro.org Received: by 10.224.54.134 with SMTP id q6cs153635qag; Fri, 20 May 2011 02:51:06 -0700 (PDT) Received: by 10.68.35.67 with SMTP id f3mr6850156pbj.290.1305885065808; Fri, 20 May 2011 02:51:05 -0700 (PDT) Received: from mail-pw0-f50.google.com (mail-pw0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id n7si2508039pbe.48.2011.05.20.02.51.05 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 20 May 2011 02:51:05 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) smtp.mail=shawn.guo@linaro.org Received: by pwi3 with SMTP id 3so2117213pwi.37 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 Cc: grant.likely@secretlab.ca, linus.walleij@linaro.org, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, patches@linaro.org, Shawn Guo 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> 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);