提交 056c78d3 编写于 作者: L Linus Walleij

ARM: nomadik: register GPIOs dynamically

Register the NHK8815 GPIO devices dynamically like the Ux500 does
it.
Acked-by: NArnd Bergmann <arnd@arndb.de>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 f8f5701b
...@@ -35,86 +35,66 @@ ...@@ -35,86 +35,66 @@
#include "clock.h" #include "clock.h"
#include "cpu-8815.h" #include "cpu-8815.h"
#define __MEM_4K_RESOURCE(x) \ static AMBA_APB_DEVICE(cpu8815_amba_rng, "rng", 0, NOMADIK_RNG_BASE, { }, NULL);
.res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
/* The 8815 has 4 GPIO blocks, let's register them immediately */
#define GPIO_RESOURCE(block) \ static struct amba_device *amba_devs[] __initdata = {
{ \ &cpu8815_amba_rng_device
.start = NOMADIK_GPIO##block##_BASE, \ };
.end = NOMADIK_GPIO##block##_BASE + SZ_4K - 1, \
.flags = IORESOURCE_MEM, \
}, \
{ \
.start = IRQ_GPIO##block, \
.end = IRQ_GPIO##block, \
.flags = IORESOURCE_IRQ, \
}
#define GPIO_DEVICE(block) \ /* The 8815 has 4 GPIO blocks, let's register them immediately */
{ \ static resource_size_t __initdata cpu8815_gpio_base[] = {
.name = "gpio", \ NOMADIK_GPIO0_BASE,
.id = block, \ NOMADIK_GPIO1_BASE,
.num_resources = 2, \ NOMADIK_GPIO2_BASE,
.resource = &cpu8815_gpio_resources[block * 2], \ NOMADIK_GPIO3_BASE,
.dev = { \ };
.platform_data = &cpu8815_gpio[block], \
}, \
}
static struct nmk_gpio_platform_data cpu8815_gpio[] = { static struct platform_device *
cpu8815_add_gpio(int id, resource_size_t addr, int irq,
struct nmk_gpio_platform_data *pdata)
{
struct resource resources[] = {
{
.start = addr,
.end = addr + 127,
.flags = IORESOURCE_MEM,
},
{ {
.name = "GPIO-0-31", .start = irq,
.first_gpio = 0, .end = irq,
.first_irq = NOMADIK_GPIO_TO_IRQ(0), .flags = IORESOURCE_IRQ,
}, {
.name = "GPIO-32-63",
.first_gpio = 32,
.first_irq = NOMADIK_GPIO_TO_IRQ(32),
}, {
.name = "GPIO-64-95",
.first_gpio = 64,
.first_irq = NOMADIK_GPIO_TO_IRQ(64),
}, {
.name = "GPIO-96-127", /* 124..127 not routed to pin */
.first_gpio = 96,
.first_irq = NOMADIK_GPIO_TO_IRQ(96),
} }
}; };
static struct resource cpu8815_gpio_resources[] = { return platform_device_register_resndata(NULL, "gpio", id,
GPIO_RESOURCE(0), resources, ARRAY_SIZE(resources),
GPIO_RESOURCE(1), pdata, sizeof(*pdata));
GPIO_RESOURCE(2), }
GPIO_RESOURCE(3),
};
static struct platform_device cpu8815_platform_gpio[] = { void cpu8815_add_gpios(resource_size_t *base, int num, int irq,
GPIO_DEVICE(0), struct nmk_gpio_platform_data *pdata)
GPIO_DEVICE(1), {
GPIO_DEVICE(2), int first = 0;
GPIO_DEVICE(3), int i;
};
static AMBA_APB_DEVICE(cpu8815_amba_rng, "rng", 0, NOMADIK_RNG_BASE, { }, NULL); for (i = 0; i < num; i++, first += 32, irq++) {
pdata->first_gpio = first;
pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
pdata->num_gpio = 32;
static struct platform_device *platform_devs[] __initdata = { cpu8815_add_gpio(i, base[i], irq, pdata);
cpu8815_platform_gpio + 0, }
cpu8815_platform_gpio + 1, }
cpu8815_platform_gpio + 2,
cpu8815_platform_gpio + 3,
};
static struct amba_device *amba_devs[] __initdata = {
&cpu8815_amba_rng_device
};
static int __init cpu8815_init(void) static int __init cpu8815_init(void)
{ {
int i; int i;
struct nmk_gpio_platform_data pdata = {
/* No custom data yet */
};
platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base),
IRQ_GPIO0, &pdata);
for (i = 0; i < ARRAY_SIZE(amba_devs); i++) for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
amba_device_register(amba_devs[i], &iomem_resource); amba_device_register(amba_devs[i], &iomem_resource);
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册