diff options
author | Rabin Vincent <rabin.vincent@stericsson.com> | 2010-03-02 22:52:34 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-03-19 14:29:32 -0400 |
commit | 3e3c62ca5395df48319b808379bc9fd487ff3c29 (patch) | |
tree | e4f9146aefc7401fc5e201c2f7bb1c0f92ea65f1 /arch/arm/mach-nomadik/cpu-8815.c | |
parent | aaedaa2b5c610ae97f863078075d8d3c6ef91575 (diff) |
ARM: 5972/1: nomadik-gpio: convert to platform driver
On the U8500 platform there are four GPIO blocks, each with a 4K address
space, including the peripheral identification. However, each of these
blocks have a varying number of banks, each of which have 32 GPIOs and
an interrupt line.
The current nomadik-gpio driver implementation can handle each of these
sub-banks easily with one instance each, but cannot as-is be hooked up
to them because it is an AMBA driver and it expects to see a peripheral
with the appropriate peripheral ids but having only one bank and only
one interrupt.
Solve this by converting the driver to a platform driver.
Acked-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-nomadik/cpu-8815.c')
-rw-r--r-- | arch/arm/mach-nomadik/cpu-8815.c | 83 |
1 files changed, 47 insertions, 36 deletions
diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index 9bf33b30a025..91c3c901b469 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/device.h> | 21 | #include <linux/device.h> |
22 | #include <linux/amba/bus.h> | 22 | #include <linux/amba/bus.h> |
23 | #include <linux/platform_device.h> | ||
23 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
24 | 25 | ||
25 | #include <mach/hardware.h> | 26 | #include <mach/hardware.h> |
@@ -30,60 +31,66 @@ | |||
30 | #include <asm/cacheflush.h> | 31 | #include <asm/cacheflush.h> |
31 | #include <asm/hardware/cache-l2x0.h> | 32 | #include <asm/hardware/cache-l2x0.h> |
32 | 33 | ||
34 | #define __MEM_4K_RESOURCE(x) \ | ||
35 | .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM} | ||
36 | |||
33 | /* The 8815 has 4 GPIO blocks, let's register them immediately */ | 37 | /* The 8815 has 4 GPIO blocks, let's register them immediately */ |
38 | |||
39 | #define GPIO_RESOURCE(block) \ | ||
40 | { \ | ||
41 | .start = NOMADIK_GPIO##block##_BASE, \ | ||
42 | .end = NOMADIK_GPIO##block##_BASE + SZ_4K - 1, \ | ||
43 | .flags = IORESOURCE_MEM, \ | ||
44 | }, \ | ||
45 | { \ | ||
46 | .start = IRQ_GPIO##block, \ | ||
47 | .end = IRQ_GPIO##block, \ | ||
48 | .flags = IORESOURCE_IRQ, \ | ||
49 | } | ||
50 | |||
51 | #define GPIO_DEVICE(block) \ | ||
52 | { \ | ||
53 | .name = "gpio", \ | ||
54 | .id = block, \ | ||
55 | .num_resources = 2, \ | ||
56 | .resource = &cpu8815_gpio_resources[block * 2], \ | ||
57 | .dev = { \ | ||
58 | .platform_data = &cpu8815_gpio[block], \ | ||
59 | }, \ | ||
60 | } | ||
61 | |||
34 | static struct nmk_gpio_platform_data cpu8815_gpio[] = { | 62 | static struct nmk_gpio_platform_data cpu8815_gpio[] = { |
35 | { | 63 | { |
36 | .name = "GPIO-0-31", | 64 | .name = "GPIO-0-31", |
37 | .first_gpio = 0, | 65 | .first_gpio = 0, |
38 | .first_irq = NOMADIK_GPIO_TO_IRQ(0), | 66 | .first_irq = NOMADIK_GPIO_TO_IRQ(0), |
39 | .parent_irq = IRQ_GPIO0, | ||
40 | }, { | 67 | }, { |
41 | .name = "GPIO-32-63", | 68 | .name = "GPIO-32-63", |
42 | .first_gpio = 32, | 69 | .first_gpio = 32, |
43 | .first_irq = NOMADIK_GPIO_TO_IRQ(32), | 70 | .first_irq = NOMADIK_GPIO_TO_IRQ(32), |
44 | .parent_irq = IRQ_GPIO1, | ||
45 | }, { | 71 | }, { |
46 | .name = "GPIO-64-95", | 72 | .name = "GPIO-64-95", |
47 | .first_gpio = 64, | 73 | .first_gpio = 64, |
48 | .first_irq = NOMADIK_GPIO_TO_IRQ(64), | 74 | .first_irq = NOMADIK_GPIO_TO_IRQ(64), |
49 | .parent_irq = IRQ_GPIO2, | ||
50 | }, { | 75 | }, { |
51 | .name = "GPIO-96-127", /* 124..127 not routed to pin */ | 76 | .name = "GPIO-96-127", /* 124..127 not routed to pin */ |
52 | .first_gpio = 96, | 77 | .first_gpio = 96, |
53 | .first_irq = NOMADIK_GPIO_TO_IRQ(96), | 78 | .first_irq = NOMADIK_GPIO_TO_IRQ(96), |
54 | .parent_irq = IRQ_GPIO3, | ||
55 | } | 79 | } |
56 | }; | 80 | }; |
57 | 81 | ||
58 | #define __MEM_4K_RESOURCE(x) \ | 82 | static struct resource cpu8815_gpio_resources[] = { |
59 | .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM} | 83 | GPIO_RESOURCE(0), |
84 | GPIO_RESOURCE(1), | ||
85 | GPIO_RESOURCE(2), | ||
86 | GPIO_RESOURCE(3), | ||
87 | }; | ||
60 | 88 | ||
61 | static struct amba_device cpu8815_amba_gpio[] = { | 89 | static struct platform_device cpu8815_platform_gpio[] = { |
62 | { | 90 | GPIO_DEVICE(0), |
63 | .dev = { | 91 | GPIO_DEVICE(1), |
64 | .init_name = "gpio0", | 92 | GPIO_DEVICE(2), |
65 | .platform_data = cpu8815_gpio + 0, | 93 | GPIO_DEVICE(3), |
66 | }, | ||
67 | __MEM_4K_RESOURCE(NOMADIK_GPIO0_BASE), | ||
68 | }, { | ||
69 | .dev = { | ||
70 | .init_name = "gpio1", | ||
71 | .platform_data = cpu8815_gpio + 1, | ||
72 | }, | ||
73 | __MEM_4K_RESOURCE(NOMADIK_GPIO1_BASE), | ||
74 | }, { | ||
75 | .dev = { | ||
76 | .init_name = "gpio2", | ||
77 | .platform_data = cpu8815_gpio + 2, | ||
78 | }, | ||
79 | __MEM_4K_RESOURCE(NOMADIK_GPIO2_BASE), | ||
80 | }, { | ||
81 | .dev = { | ||
82 | .init_name = "gpio3", | ||
83 | .platform_data = cpu8815_gpio + 3, | ||
84 | }, | ||
85 | __MEM_4K_RESOURCE(NOMADIK_GPIO3_BASE), | ||
86 | }, | ||
87 | }; | 94 | }; |
88 | 95 | ||
89 | static struct amba_device cpu8815_amba_rng = { | 96 | static struct amba_device cpu8815_amba_rng = { |
@@ -93,11 +100,14 @@ static struct amba_device cpu8815_amba_rng = { | |||
93 | __MEM_4K_RESOURCE(NOMADIK_RNG_BASE), | 100 | __MEM_4K_RESOURCE(NOMADIK_RNG_BASE), |
94 | }; | 101 | }; |
95 | 102 | ||
103 | static struct platform_device *platform_devs[] __initdata = { | ||
104 | cpu8815_platform_gpio + 0, | ||
105 | cpu8815_platform_gpio + 1, | ||
106 | cpu8815_platform_gpio + 2, | ||
107 | cpu8815_platform_gpio + 3, | ||
108 | }; | ||
109 | |||
96 | static struct amba_device *amba_devs[] __initdata = { | 110 | static struct amba_device *amba_devs[] __initdata = { |
97 | cpu8815_amba_gpio + 0, | ||
98 | cpu8815_amba_gpio + 1, | ||
99 | cpu8815_amba_gpio + 2, | ||
100 | cpu8815_amba_gpio + 3, | ||
101 | &cpu8815_amba_rng | 111 | &cpu8815_amba_rng |
102 | }; | 112 | }; |
103 | 113 | ||
@@ -105,6 +115,7 @@ static int __init cpu8815_init(void) | |||
105 | { | 115 | { |
106 | int i; | 116 | int i; |
107 | 117 | ||
118 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); | ||
108 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) | 119 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) |
109 | amba_device_register(amba_devs[i], &iomem_resource); | 120 | amba_device_register(amba_devs[i], &iomem_resource); |
110 | return 0; | 121 | return 0; |