From: Benoit Cousson <b-cousson@ti.com>
To: grant.likely@secretlab.ca, tony@atomide.com
Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
khilman@ti.com, devicetree-discuss@lists.ozlabs.org,
manjugk@ti.com, Benoit Cousson <b-cousson@ti.com>,
Charulatha V <charu@ti.com>,
Tarun Kanti DebBarma <tarun.kanti@ti.com>
Subject: [RFC PATCH 08/10] gpio/omap: Adapt GPIO driver to DT
Date: Wed, 24 Aug 2011 15:09:14 +0200 [thread overview]
Message-ID: <1314191356-10963-9-git-send-email-b-cousson@ti.com> (raw)
In-Reply-To: <1314191356-10963-1-git-send-email-b-cousson@ti.com>
Adapt the GPIO driver to retrieve information from a DT file.
Note that since the driver is currently under cleanup, some hacks
will have to be removed after.
Signed-off-by: Benoit Cousson <b-cousson@ti.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Charulatha V <charu@ti.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
---
drivers/gpio/gpio-omap.c | 103 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 94 insertions(+), 9 deletions(-)
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 0599854..96d19d7 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -21,6 +21,7 @@
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
+#include <linux/of_platform.h>
#include <mach/hardware.h>
#include <asm/irq.h>
@@ -521,7 +522,7 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)
unsigned long flags;
if (bank->non_wakeup_gpios & gpio_bit) {
- dev_err(bank->dev,
+ dev_err(bank->dev,
"Unable to modify wakeup on non-wakeup GPIO%d\n", gpio);
return -EINVAL;
}
@@ -1150,6 +1151,8 @@ static void __devinit omap_gpio_chip_init(struct gpio_bank *bank)
irq_set_handler_data(bank->irq, bank);
}
+static const struct of_device_id omap_gpio_match[];
+
static int __devinit omap_gpio_probe(struct platform_device *pdev)
{
static int gpio_init_done;
@@ -1157,11 +1160,25 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
struct resource *res;
int id;
struct gpio_bank *bank;
+ struct device_node *node = pdev->dev.of_node;
+ const struct of_device_id *match;
+
+ match = of_match_device(omap_gpio_match, &pdev->dev);
+ if (match) {
+ pdata = match->data;
+ /* XXX: big hack until the bank_count is removed */
+ of_property_read_u32(node, "bank_count", &gpio_bank_count);
+ if (of_property_read_u32(node, "id", &id))
+ return -EINVAL;
+ /* XXX: maybe the id in DT should be zero based to avoid that */
+ id -= 1;
+ } else {
+ if (!pdev->dev.platform_data)
+ return -EINVAL;
- if (!pdev->dev.platform_data)
- return -EINVAL;
-
- pdata = pdev->dev.platform_data;
+ pdata = pdev->dev.platform_data;
+ id = pdev->id;
+ }
if (!gpio_init_done) {
int ret;
@@ -1171,7 +1188,6 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
return ret;
}
- id = pdev->id;
bank = &gpio_bank[id];
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -1181,12 +1197,19 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
}
bank->irq = res->start;
- bank->virtual_irq_start = pdata->virtual_irq_start;
bank->method = pdata->bank_type;
bank->dev = &pdev->dev;
- bank->dbck_flag = pdata->dbck_flag;
bank->stride = pdata->bank_stride;
- bank->width = pdata->bank_width;
+ if (match) {
+ of_property_read_u32(node, "bank_width", &bank->width);
+ if (of_get_property(node, "debounce", NULL))
+ bank->dbck_flag = true;
+ bank->virtual_irq_start = IH_GPIO_BASE + 32 * id;
+ } else {
+ bank->width = pdata->bank_width;
+ bank->dbck_flag = pdata->dbck_flag;
+ bank->virtual_irq_start = pdata->virtual_irq_start;
+ }
bank->regs = pdata->regs;
@@ -1559,10 +1582,72 @@ void omap_gpio_restore_context(void)
}
#endif
+
+static struct omap_gpio_reg_offs omap2_gpio_regs = {
+ .revision = OMAP24XX_GPIO_REVISION,
+ .direction = OMAP24XX_GPIO_OE,
+ .datain = OMAP24XX_GPIO_DATAIN,
+ .dataout = OMAP24XX_GPIO_DATAOUT,
+ .set_dataout = OMAP24XX_GPIO_SETDATAOUT,
+ .clr_dataout = OMAP24XX_GPIO_CLEARDATAOUT,
+ .irqstatus = OMAP24XX_GPIO_IRQSTATUS1,
+ .irqstatus2 = OMAP24XX_GPIO_IRQSTATUS2,
+ .irqenable = OMAP24XX_GPIO_IRQENABLE1,
+ .set_irqenable = OMAP24XX_GPIO_SETIRQENABLE1,
+ .clr_irqenable = OMAP24XX_GPIO_CLEARIRQENABLE1,
+ .debounce = OMAP24XX_GPIO_DEBOUNCE_VAL,
+ .debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN,
+};
+
+static struct omap_gpio_platform_data omap2_pdata = {
+ .bank_type = METHOD_GPIO_24XX,
+ .regs = &omap2_gpio_regs,
+};
+
+static struct omap_gpio_reg_offs omap4_gpio_regs = {
+ .revision = OMAP4_GPIO_REVISION,
+ .direction = OMAP4_GPIO_OE,
+ .datain = OMAP4_GPIO_DATAIN,
+ .dataout = OMAP4_GPIO_DATAOUT,
+ .set_dataout = OMAP4_GPIO_SETDATAOUT,
+ .clr_dataout = OMAP4_GPIO_CLEARDATAOUT,
+ .irqstatus = OMAP4_GPIO_IRQSTATUS1,
+ .irqstatus2 = OMAP4_GPIO_IRQSTATUS2,
+ .irqenable = OMAP4_GPIO_IRQENABLE1,
+ .set_irqenable = OMAP4_GPIO_SETIRQENABLE1,
+ .clr_irqenable = OMAP4_GPIO_CLEARIRQENABLE1,
+ .debounce = OMAP4_GPIO_DEBOUNCINGTIME,
+ .debounce_en = OMAP4_GPIO_DEBOUNCENABLE,
+};
+
+static struct omap_gpio_platform_data omap4_pdata = {
+ .bank_type = METHOD_GPIO_44XX,
+ .regs = &omap4_gpio_regs,
+};
+
+
+#if defined(CONFIG_OF)
+ static const struct of_device_id omap_gpio_match[] = {
+ {
+ .compatible = "ti,omap4-gpio",
+ .data = &omap4_pdata,
+ },
+ {
+ .compatible = "ti,omap2-gpio",
+ .data = &omap2_pdata,
+ },
+ {},
+}
+MODULE_DEVICE_TABLE(of, omap_gpio_match);
+#else
+#define omap_gpio_match NULL
+#endif
+
static struct platform_driver omap_gpio_driver = {
.probe = omap_gpio_probe,
.driver = {
.name = "omap_gpio",
+ .of_match_table = omap_gpio_match,
},
};
--
1.7.0.4
next prev parent reply other threads:[~2011-08-24 13:09 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-24 13:09 [RFC PATCH 00/10] OMAP: Add DT support for early init OMAP4 devices Benoit Cousson
2011-08-24 13:09 ` [RFC PATCH 04/10] arm/dts: OMAP4: Add mpu, dsp and iva nodes Benoit Cousson
[not found] ` <1314191356-10963-5-git-send-email-b-cousson-l0cyMroinI0@public.gmane.org>
2011-09-08 18:07 ` Grant Likely
2011-08-24 13:09 ` [RFC PATCH 05/10] documentation/dt: Add mpu, dsp and iva bindings Benoit Cousson
[not found] ` <1314191356-10963-6-git-send-email-b-cousson-l0cyMroinI0@public.gmane.org>
2011-09-08 18:09 ` Grant Likely
2011-09-09 0:30 ` Cousson, Benoit
2011-09-09 2:40 ` Grant Likely
[not found] ` <1314191356-10963-1-git-send-email-b-cousson-l0cyMroinI0@public.gmane.org>
2011-08-24 13:09 ` [RFC PATCH 01/10] OMAP2+: l3-noc: Add support for device-tree Benoit Cousson
2011-09-08 18:01 ` Grant Likely
[not found] ` <20110908180148.GA2967-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-09-08 21:59 ` Cousson, Benoit
2011-09-08 23:35 ` Grant Likely
2011-08-24 13:09 ` [RFC PATCH 02/10] arm/dts: OMAP4: Add a main ocp entry bound to l3-noc driver Benoit Cousson
[not found] ` <1314191356-10963-3-git-send-email-b-cousson-l0cyMroinI0@public.gmane.org>
2011-09-08 18:03 ` Grant Likely
2011-09-09 0:10 ` Cousson, Benoit
2011-09-09 2:41 ` Grant Likely
2011-08-24 13:09 ` [RFC PATCH 03/10] documentation/dt: Add l3-noc bindings Benoit Cousson
2011-09-08 18:06 ` Grant Likely
2011-09-09 0:18 ` Cousson, Benoit
2011-08-24 13:09 ` [RFC PATCH 06/10] hwspinlock: OMAP4: Add spinlock support in DT Benoit Cousson
2011-09-07 19:58 ` Ohad Ben-Cohen
2011-09-08 7:14 ` Cousson, Benoit
2011-09-08 7:56 ` Ohad Ben-Cohen
2011-09-08 8:07 ` Cousson, Benoit
2011-09-08 8:11 ` Ohad Ben-Cohen
2011-09-08 14:47 ` Arnd Bergmann
2011-09-08 15:34 ` Cousson, Benoit
[not found] ` <4E68E09B.4050006-l0cyMroinI0@public.gmane.org>
2011-09-08 16:03 ` Arnd Bergmann
[not found] ` <201109081647.55377.arnd-r2nGTMty4D4@public.gmane.org>
2011-09-08 16:36 ` Ohad Ben-Cohen
2011-09-09 12:58 ` Arnd Bergmann
2011-09-11 7:57 ` Ohad Ben-Cohen
2011-09-12 14:32 ` Arnd Bergmann
2011-08-24 13:09 ` [RFC PATCH 07/10] documentation/dt: Add spinlock bindings Benoit Cousson
[not found] ` <1314191356-10963-8-git-send-email-b-cousson-l0cyMroinI0@public.gmane.org>
2011-09-08 18:10 ` Grant Likely
2011-09-09 0:32 ` Cousson, Benoit
2011-08-24 13:09 ` Benoit Cousson [this message]
[not found] ` <1314191356-10963-9-git-send-email-b-cousson-l0cyMroinI0@public.gmane.org>
2011-09-08 18:15 ` [RFC PATCH 08/10] gpio/omap: Adapt GPIO driver to DT Grant Likely
2011-09-09 1:48 ` Cousson, Benoit
2011-08-24 13:09 ` [RFC PATCH 09/10] arm/dts: OMAP4: Add gpio nodes Benoit Cousson
[not found] ` <1314191356-10963-10-git-send-email-b-cousson-l0cyMroinI0@public.gmane.org>
2011-09-08 18:16 ` Grant Likely
2011-08-24 13:09 ` [RFC PATCH 10/10] documentation/dt: Add OMAP GPIO properties Benoit Cousson
[not found] ` <1314191356-10963-11-git-send-email-b-cousson-l0cyMroinI0@public.gmane.org>
2011-09-08 18:18 ` Grant Likely
2011-09-09 1:51 ` Cousson, Benoit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1314191356-10963-9-git-send-email-b-cousson@ti.com \
--to=b-cousson@ti.com \
--cc=charu@ti.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=khilman@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=manjugk@ti.com \
--cc=tarun.kanti@ti.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).