[PATCH 14/15] ARM i.MX: add devicetree support for gpio driver
Sascha Hauer
s.hauer at pengutronix.de
Wed Sep 12 16:06:46 EDT 2012
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
arch/arm/mach-imx/gpio.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-imx/gpio.c b/arch/arm/mach-imx/gpio.c
index b7426fe..df0b455 100644
--- a/arch/arm/mach-imx/gpio.c
+++ b/arch/arm/mach-imx/gpio.c
@@ -136,7 +136,13 @@ static int imx_gpio_probe(struct device_d *dev)
imxgpio = xzalloc(sizeof(*imxgpio));
imxgpio->base = dev_request_mem_region(dev, 0);
imxgpio->chip.ops = &imx_gpio_ops;
- imxgpio->chip.base = -1;
+ if (dev->id < 0) {
+ imxgpio->chip.base = of_alias_get_id(dev->device_node, "gpio");
+ if (imxgpio->chip.base < 0)
+ return imxgpio->chip.base;
+ } else {
+ imxgpio->chip.base = dev->id * 32;
+ }
imxgpio->chip.ngpio = 32;
imxgpio->chip.dev = dev;
imxgpio->regs = regs;
@@ -147,6 +153,36 @@ static int imx_gpio_probe(struct device_d *dev)
return 0;
}
+static __maybe_unused struct of_device_id imx_gpio_dt_ids[] = {
+ {
+ .compatible = "fsl,imx1-gpio",
+ .data = (unsigned long)®s_imx1,
+ }, {
+ .compatible = "fsl,imx21-gpio",
+ .data = (unsigned long)®s_imx1,
+ }, {
+ .compatible = "fsl,imx27-gpio",
+ .data = (unsigned long)®s_imx1,
+ }, {
+ .compatible = "fsl,imx31-gpio",
+ .data = (unsigned long)®s_imx31,
+ }, {
+ .compatible = "fsl,imx35-gpio",
+ .data = (unsigned long)®s_imx31,
+ }, {
+ .compatible = "fsl,imx51-gpio",
+ .data = (unsigned long)®s_imx31,
+ }, {
+ .compatible = "fsl,imx53-gpio",
+ .data = (unsigned long)®s_imx31,
+ }, {
+ .compatible = "fsl,imx6q-gpio",
+ .data = (unsigned long)®s_imx31,
+ }, {
+ /* sentinel */
+ }
+};
+
static struct platform_device_id imx_gpio_ids[] = {
{
.name = "imx1-gpio",
@@ -162,6 +198,7 @@ static struct platform_device_id imx_gpio_ids[] = {
static struct driver_d imx_gpio_driver = {
.name = "imx-gpio",
.probe = imx_gpio_probe,
+ .of_compatible = DRV_OF_COMPAT(imx_gpio_dt_ids),
.id_table = imx_gpio_ids,
};
--
1.7.10.4
More information about the barebox
mailing list