mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 14/17] gpio: omap: Add devicetree probe support
Date: Fri, 22 Nov 2013 15:48:58 +0100	[thread overview]
Message-ID: <1385131741-28280-15-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1385131741-28280-1-git-send-email-s.hauer@pengutronix.de>

This adds devicetree probe support for the OMAP gpio ports and
also makes sure the corresponding platform_devices don't get
registered when they are already present from devicetree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/gpio/gpio-omap.c | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 49ffbda..e66a614 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -48,6 +48,18 @@ struct omap_gpio_chip {
 	struct gpio_chip chip;
 };
 
+struct omap_gpio_drvdata {
+	unsigned int regofs;
+};
+
+static struct omap_gpio_drvdata gpio_omap3_drvdata = {
+	.regofs = 0x0,
+};
+
+static struct omap_gpio_drvdata gpio_omap4_drvdata = {
+	.regofs = 0x100,
+};
+
 static inline int omap_get_gpio_index(int gpio)
 {
 	return gpio & 0x1f;
@@ -129,11 +141,24 @@ static struct gpio_ops omap_gpio_ops = {
 static int omap_gpio_probe(struct device_d *dev)
 {
 	struct omap_gpio_chip *omapgpio;
+	struct omap_gpio_drvdata *drvdata = NULL;
+
+	dev_get_drvdata(dev, (unsigned long *)&drvdata);
 
 	omapgpio = xzalloc(sizeof(*omapgpio));
 	omapgpio->base = dev_request_mem_region(dev, 0);
+	if (drvdata)
+		omapgpio->base += drvdata->regofs;
+
 	omapgpio->chip.ops = &omap_gpio_ops;
-	omapgpio->chip.base = dev->id * 32;
+	if (dev->id < 0) {
+		omapgpio->chip.base = of_alias_get_id(dev->device_node, "gpio");
+		if (omapgpio->chip.base < 0)
+			return omapgpio->chip.base;
+		omapgpio->chip.base *= 32;
+	} else {
+		omapgpio->chip.base = dev->id * 32;
+	}
 	omapgpio->chip.ngpio = 32;
 	omapgpio->chip.dev = dev;
 	gpiochip_add(&omapgpio->chip);
@@ -144,9 +169,21 @@ static int omap_gpio_probe(struct device_d *dev)
 	return 0;
 }
 
+static __maybe_unused struct of_device_id omap_gpio_dt_ids[] = {
+	{
+		.compatible = "ti,omap4-gpio",
+		.data = (unsigned long)&gpio_omap4_drvdata,
+	}, {
+		.compatible = "ti,omap3-gpio",
+		.data = (unsigned long)&gpio_omap3_drvdata,
+	}, {
+	}
+};
+
 static struct driver_d omap_gpio_driver = {
 	.name = "omap-gpio",
 	.probe = omap_gpio_probe,
+	.of_compatible = DRV_OF_COMPAT(omap_gpio_dt_ids),
 };
 
 static int omap_gpio_add(void)
-- 
1.8.4.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-11-22 14:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-22 14:48 Add devicetree support to OMAP drivers Sascha Hauer
2013-11-22 14:48 ` [PATCH 01/17] serial: ns16550: Add device ids for omap Sascha Hauer
2013-11-22 14:48 ` [PATCH 02/17] pinctrl: Add pinctrl-single driver Sascha Hauer
2013-11-22 14:48 ` [PATCH 03/17] spi: omap: encode register offset into device_id Sascha Hauer
2013-11-22 14:48 ` [PATCH 04/17] spi: omap: Add devicetree probe support Sascha Hauer
2013-11-22 14:48 ` [PATCH 05/17] i2c: omap: Add devicetree support Sascha Hauer
2013-11-22 14:48 ` [PATCH 06/17] net: cpsw: inline slave_data Sascha Hauer
2013-11-22 14:48 ` [PATCH 07/17] cpsw: Add devicetree probe support Sascha Hauer
2013-11-22 14:48 ` [PATCH 08/17] net: cpsw: move eth_device into slave Sascha Hauer
2013-11-22 14:48 ` [PATCH 09/17] net: cpsw: drop for_each_slave Sascha Hauer
2013-11-22 14:48 ` [PATCH 10/17] net: cpsw: attach slave to edev->priv Sascha Hauer
2013-11-22 14:48 ` [PATCH 11/17] net: cpsw: straighten error path Sascha Hauer
2013-11-22 14:48 ` [PATCH 12/17] gpio: omap: move to drivers/gpio/ Sascha Hauer
2013-11-22 14:48 ` [PATCH 13/17] omap: gpmc: some refactoring Sascha Hauer
2013-11-22 14:48 ` Sascha Hauer [this message]
2013-11-22 14:48 ` [PATCH 15/17] mtd: omap gpmc: Use dev_add_param_enum Sascha Hauer
2013-11-22 14:49 ` [PATCH 16/17] bus: Add omap gpmc driver Sascha Hauer
2013-11-22 14:49 ` [PATCH 17/17] mmc: omap: Add devicetree support Sascha Hauer

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=1385131741-28280-15-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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