Commit 513c27f8 authored by Lee Jones's avatar Lee Jones Committed by Linus Walleij

drivers/gpio: gpio-nomadik: Apply Device Tree bindings

This creates Device Tree bindings for the Nomadik GPIO driver.
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 1baa5743
...@@ -746,10 +746,22 @@ MACHINE_END ...@@ -746,10 +746,22 @@ MACHINE_END
#ifdef CONFIG_MACH_UX500_DT #ifdef CONFIG_MACH_UX500_DT
struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = { struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
/* Requires DMA and call-back bindings. */
OF_DEV_AUXDATA("arm,pl011", 0x80120000, "uart0", &uart0_plat), OF_DEV_AUXDATA("arm,pl011", 0x80120000, "uart0", &uart0_plat),
OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", &uart1_plat), OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", &uart1_plat),
OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", &uart2_plat), OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", &uart2_plat),
/* Requires DMA bindings. */
OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0", &ssp0_plat), OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0", &ssp0_plat),
/* Requires clock name bindings. */
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e000, "gpio.0", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8012e080, "gpio.1", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8000e000, "gpio.2", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8000e080, "gpio.3", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8000e100, "gpio.4", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8000e180, "gpio.5", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e000, "gpio.6", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0x8011e080, "gpio.7", NULL),
OF_DEV_AUXDATA("st,nomadik-gpio", 0xa03fe000, "gpio.8", NULL),
{}, {},
}; };
......
...@@ -1132,6 +1132,7 @@ void nmk_gpio_read_pull(int gpio_bank, u32 *pull_up) ...@@ -1132,6 +1132,7 @@ void nmk_gpio_read_pull(int gpio_bank, u32 *pull_up)
static int __devinit nmk_gpio_probe(struct platform_device *dev) static int __devinit nmk_gpio_probe(struct platform_device *dev)
{ {
struct nmk_gpio_platform_data *pdata = dev->dev.platform_data; struct nmk_gpio_platform_data *pdata = dev->dev.platform_data;
struct device_node *np = dev->dev.of_node;
struct nmk_gpio_chip *nmk_chip; struct nmk_gpio_chip *nmk_chip;
struct gpio_chip *chip; struct gpio_chip *chip;
struct resource *res; struct resource *res;
...@@ -1141,8 +1142,28 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) ...@@ -1141,8 +1142,28 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
int irq; int irq;
int ret; int ret;
if (!pdata) if (!pdata && !np) {
dev_err(&dev->dev, "No platform data or device tree found\n");
return -ENODEV; return -ENODEV;
}
if (np) {
pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return -ENOMEM;
if (of_get_property(np, "supports-sleepmode", NULL))
pdata->supports_sleepmode = true;
if (of_property_read_u32(np, "gpio-bank", &dev->id)) {
dev_err(&dev->dev, "gpio-bank property not found\n");
ret = -EINVAL;
goto out_dt;
}
pdata->first_gpio = dev->id * NMK_GPIO_PER_CHIP;
pdata->num_gpio = NMK_GPIO_PER_CHIP;
}
res = platform_get_resource(dev, IORESOURCE_MEM, 0); res = platform_get_resource(dev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
...@@ -1185,6 +1206,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) ...@@ -1185,6 +1206,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
ret = -ENOMEM; ret = -ENOMEM;
goto out_clk; goto out_clk;
} }
/* /*
* The virt address in nmk_chip->addr is in the nomadik register space, * The virt address in nmk_chip->addr is in the nomadik register space,
* so we can simply convert the resource address, without remapping * so we can simply convert the resource address, without remapping
...@@ -1211,6 +1233,8 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) ...@@ -1211,6 +1233,8 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
nmk_chip->lowemi = readl_relaxed(nmk_chip->addr + NMK_GPIO_LOWEMI); nmk_chip->lowemi = readl_relaxed(nmk_chip->addr + NMK_GPIO_LOWEMI);
clk_disable(nmk_chip->clk); clk_disable(nmk_chip->clk);
chip->of_node = np;
ret = gpiochip_add(&nmk_chip->chip); ret = gpiochip_add(&nmk_chip->chip);
if (ret) if (ret)
goto out_free; goto out_free;
...@@ -1218,12 +1242,13 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) ...@@ -1218,12 +1242,13 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips)); BUG_ON(nmk_chip->bank >= ARRAY_SIZE(nmk_gpio_chips));
nmk_gpio_chips[nmk_chip->bank] = nmk_chip; nmk_gpio_chips[nmk_chip->bank] = nmk_chip;
platform_set_drvdata(dev, nmk_chip); platform_set_drvdata(dev, nmk_chip);
nmk_gpio_init_irq(nmk_chip); nmk_gpio_init_irq(nmk_chip);
dev_info(&dev->dev, "at address %p\n", dev_info(&dev->dev, "at address %p\n", nmk_chip->addr);
nmk_chip->addr);
return 0; return 0;
out_free: out_free:
...@@ -1238,13 +1263,23 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) ...@@ -1238,13 +1263,23 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
out: out:
dev_err(&dev->dev, "Failure %i for GPIO %i-%i\n", ret, dev_err(&dev->dev, "Failure %i for GPIO %i-%i\n", ret,
pdata->first_gpio, pdata->first_gpio+31); pdata->first_gpio, pdata->first_gpio+31);
out_dt:
if (np)
kfree(pdata);
return ret; return ret;
} }
static const struct of_device_id nmk_gpio_match[] = {
{ .compatible = "st,nomadik-gpio", },
{}
};
static struct platform_driver nmk_gpio_driver = { static struct platform_driver nmk_gpio_driver = {
.driver = { .driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "gpio", .name = "gpio",
.of_match_table = nmk_gpio_match,
}, },
.probe = nmk_gpio_probe, .probe = nmk_gpio_probe,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment