diff options
Diffstat (limited to 'arch/arm/mach-nomadik/cpu-8815.c')
-rw-r--r-- | arch/arm/mach-nomadik/cpu-8815.c | 126 |
1 files changed, 51 insertions, 75 deletions
diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index 27f43a46985e..6fd8e46567a4 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c | |||
@@ -22,6 +22,10 @@ | |||
22 | #include <linux/amba/bus.h> | 22 | #include <linux/amba/bus.h> |
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | #include <linux/slab.h> | ||
26 | #include <linux/irq.h> | ||
27 | #include <linux/dma-mapping.h> | ||
28 | #include <linux/platform_data/clk-nomadik.h> | ||
25 | 29 | ||
26 | #include <plat/gpio-nomadik.h> | 30 | #include <plat/gpio-nomadik.h> |
27 | #include <mach/hardware.h> | 31 | #include <mach/hardware.h> |
@@ -32,91 +36,63 @@ | |||
32 | #include <asm/cacheflush.h> | 36 | #include <asm/cacheflush.h> |
33 | #include <asm/hardware/cache-l2x0.h> | 37 | #include <asm/hardware/cache-l2x0.h> |
34 | 38 | ||
35 | #include "clock.h" | ||
36 | #include "cpu-8815.h" | 39 | #include "cpu-8815.h" |
37 | 40 | ||
38 | #define __MEM_4K_RESOURCE(x) \ | ||
39 | .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM} | ||
40 | |||
41 | /* The 8815 has 4 GPIO blocks, let's register them immediately */ | 41 | /* The 8815 has 4 GPIO blocks, let's register them immediately */ |
42 | 42 | static resource_size_t __initdata cpu8815_gpio_base[] = { | |
43 | #define GPIO_RESOURCE(block) \ | 43 | NOMADIK_GPIO0_BASE, |
44 | { \ | 44 | NOMADIK_GPIO1_BASE, |
45 | .start = NOMADIK_GPIO##block##_BASE, \ | 45 | NOMADIK_GPIO2_BASE, |
46 | .end = NOMADIK_GPIO##block##_BASE + SZ_4K - 1, \ | 46 | NOMADIK_GPIO3_BASE, |
47 | .flags = IORESOURCE_MEM, \ | ||
48 | }, \ | ||
49 | { \ | ||
50 | .start = IRQ_GPIO##block, \ | ||
51 | .end = IRQ_GPIO##block, \ | ||
52 | .flags = IORESOURCE_IRQ, \ | ||
53 | } | ||
54 | |||
55 | #define GPIO_DEVICE(block) \ | ||
56 | { \ | ||
57 | .name = "gpio", \ | ||
58 | .id = block, \ | ||
59 | .num_resources = 2, \ | ||
60 | .resource = &cpu8815_gpio_resources[block * 2], \ | ||
61 | .dev = { \ | ||
62 | .platform_data = &cpu8815_gpio[block], \ | ||
63 | }, \ | ||
64 | } | ||
65 | |||
66 | static struct nmk_gpio_platform_data cpu8815_gpio[] = { | ||
67 | { | ||
68 | .name = "GPIO-0-31", | ||
69 | .first_gpio = 0, | ||
70 | .first_irq = NOMADIK_GPIO_TO_IRQ(0), | ||
71 | }, { | ||
72 | .name = "GPIO-32-63", | ||
73 | .first_gpio = 32, | ||
74 | .first_irq = NOMADIK_GPIO_TO_IRQ(32), | ||
75 | }, { | ||
76 | .name = "GPIO-64-95", | ||
77 | .first_gpio = 64, | ||
78 | .first_irq = NOMADIK_GPIO_TO_IRQ(64), | ||
79 | }, { | ||
80 | .name = "GPIO-96-127", /* 124..127 not routed to pin */ | ||
81 | .first_gpio = 96, | ||
82 | .first_irq = NOMADIK_GPIO_TO_IRQ(96), | ||
83 | } | ||
84 | }; | 47 | }; |
85 | 48 | ||
86 | static struct resource cpu8815_gpio_resources[] = { | 49 | static struct platform_device * |
87 | GPIO_RESOURCE(0), | 50 | cpu8815_add_gpio(int id, resource_size_t addr, int irq, |
88 | GPIO_RESOURCE(1), | 51 | struct nmk_gpio_platform_data *pdata) |
89 | GPIO_RESOURCE(2), | 52 | { |
90 | GPIO_RESOURCE(3), | 53 | struct resource resources[] = { |
91 | }; | 54 | { |
92 | 55 | .start = addr, | |
93 | static struct platform_device cpu8815_platform_gpio[] = { | 56 | .end = addr + 127, |
94 | GPIO_DEVICE(0), | 57 | .flags = IORESOURCE_MEM, |
95 | GPIO_DEVICE(1), | 58 | }, |
96 | GPIO_DEVICE(2), | 59 | { |
97 | GPIO_DEVICE(3), | 60 | .start = irq, |
98 | }; | 61 | .end = irq, |
62 | .flags = IORESOURCE_IRQ, | ||
63 | } | ||
64 | }; | ||
65 | |||
66 | return platform_device_register_resndata(NULL, "gpio", id, | ||
67 | resources, ARRAY_SIZE(resources), | ||
68 | pdata, sizeof(*pdata)); | ||
69 | } | ||
99 | 70 | ||
100 | static AMBA_APB_DEVICE(cpu8815_amba_rng, "rng", 0, NOMADIK_RNG_BASE, { }, NULL); | 71 | void cpu8815_add_gpios(resource_size_t *base, int num, int irq, |
72 | struct nmk_gpio_platform_data *pdata) | ||
73 | { | ||
74 | int first = 0; | ||
75 | int i; | ||
101 | 76 | ||
102 | static struct platform_device *platform_devs[] __initdata = { | 77 | for (i = 0; i < num; i++, first += 32, irq++) { |
103 | cpu8815_platform_gpio + 0, | 78 | pdata->first_gpio = first; |
104 | cpu8815_platform_gpio + 1, | 79 | pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first); |
105 | cpu8815_platform_gpio + 2, | 80 | pdata->num_gpio = 32; |
106 | cpu8815_platform_gpio + 3, | ||
107 | }; | ||
108 | 81 | ||
109 | static struct amba_device *amba_devs[] __initdata = { | 82 | cpu8815_add_gpio(i, base[i], irq, pdata); |
110 | &cpu8815_amba_rng_device | 83 | } |
111 | }; | 84 | } |
112 | 85 | ||
113 | static int __init cpu8815_init(void) | 86 | static int __init cpu8815_init(void) |
114 | { | 87 | { |
115 | int i; | 88 | struct nmk_gpio_platform_data pdata = { |
116 | 89 | /* No custom data yet */ | |
117 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); | 90 | }; |
118 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) | 91 | |
119 | amba_device_register(amba_devs[i], &iomem_resource); | 92 | cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base), |
93 | IRQ_GPIO0, &pdata); | ||
94 | amba_apb_device_add(NULL, "rng", NOMADIK_RNG_BASE, SZ_4K, 0, 0, NULL, 0); | ||
95 | amba_apb_device_add(NULL, "rtc-pl031", NOMADIK_RTC_BASE, SZ_4K, IRQ_RTC_RTT, 0, NULL, 0); | ||
120 | return 0; | 96 | return 0; |
121 | } | 97 | } |
122 | arch_initcall(cpu8815_init); | 98 | arch_initcall(cpu8815_init); |
@@ -147,7 +123,7 @@ void __init cpu8815_init_irq(void) | |||
147 | * Init clocks here so that they are available for system timer | 123 | * Init clocks here so that they are available for system timer |
148 | * initialization. | 124 | * initialization. |
149 | */ | 125 | */ |
150 | clk_init(); | 126 | nomadik_clk_init(); |
151 | } | 127 | } |
152 | 128 | ||
153 | /* | 129 | /* |