Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph...
[pandora-kernel.git] / arch / arm / mach-ux500 / cpu-db5500.c
1 /*
2  * Copyright (C) ST-Ericsson SA 2010
3  *
4  * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5  * License terms: GNU General Public License (GPL) version 2
6  */
7
8 #include <linux/platform_device.h>
9 #include <linux/amba/bus.h>
10 #include <linux/io.h>
11 #include <linux/irq.h>
12
13 #include <asm/mach/map.h>
14
15 #include <plat/gpio.h>
16
17 #include <mach/hardware.h>
18 #include <mach/devices.h>
19 #include <mach/setup.h>
20 #include <mach/irqs.h>
21
22 #include "devices-db5500.h"
23
24 static struct map_desc u5500_uart_io_desc[] __initdata = {
25         __IO_DEV_DESC(U5500_UART0_BASE, SZ_4K),
26         __IO_DEV_DESC(U5500_UART2_BASE, SZ_4K),
27 };
28
29 static struct map_desc u5500_io_desc[] __initdata = {
30         __IO_DEV_DESC(U5500_GIC_CPU_BASE, SZ_4K),
31         __IO_DEV_DESC(U5500_GIC_DIST_BASE, SZ_4K),
32         __IO_DEV_DESC(U5500_L2CC_BASE, SZ_4K),
33         __IO_DEV_DESC(U5500_TWD_BASE, SZ_4K),
34         __IO_DEV_DESC(U5500_MTU0_BASE, SZ_4K),
35         __IO_DEV_DESC(U5500_SCU_BASE, SZ_4K),
36         __IO_DEV_DESC(U5500_BACKUPRAM0_BASE, SZ_8K),
37
38         __IO_DEV_DESC(U5500_GPIO0_BASE, SZ_4K),
39         __IO_DEV_DESC(U5500_GPIO1_BASE, SZ_4K),
40         __IO_DEV_DESC(U5500_GPIO2_BASE, SZ_4K),
41         __IO_DEV_DESC(U5500_GPIO3_BASE, SZ_4K),
42         __IO_DEV_DESC(U5500_GPIO4_BASE, SZ_4K),
43         __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K),
44 };
45
46 static struct resource mbox0_resources[] = {
47         {
48                 .name = "mbox_peer",
49                 .start = U5500_MBOX0_PEER_START,
50                 .end = U5500_MBOX0_PEER_END,
51                 .flags = IORESOURCE_MEM,
52         },
53         {
54                 .name = "mbox_local",
55                 .start = U5500_MBOX0_LOCAL_START,
56                 .end = U5500_MBOX0_LOCAL_END,
57                 .flags = IORESOURCE_MEM,
58         },
59         {
60                 .name = "mbox_irq",
61                 .start = MBOX_PAIR0_VIRT_IRQ,
62                 .end = MBOX_PAIR0_VIRT_IRQ,
63                 .flags = IORESOURCE_IRQ,
64         }
65 };
66
67 static struct resource mbox1_resources[] = {
68         {
69                 .name = "mbox_peer",
70                 .start = U5500_MBOX1_PEER_START,
71                 .end = U5500_MBOX1_PEER_END,
72                 .flags = IORESOURCE_MEM,
73         },
74         {
75                 .name = "mbox_local",
76                 .start = U5500_MBOX1_LOCAL_START,
77                 .end = U5500_MBOX1_LOCAL_END,
78                 .flags = IORESOURCE_MEM,
79         },
80         {
81                 .name = "mbox_irq",
82                 .start = MBOX_PAIR1_VIRT_IRQ,
83                 .end = MBOX_PAIR1_VIRT_IRQ,
84                 .flags = IORESOURCE_IRQ,
85         }
86 };
87
88 static struct resource mbox2_resources[] = {
89         {
90                 .name = "mbox_peer",
91                 .start = U5500_MBOX2_PEER_START,
92                 .end = U5500_MBOX2_PEER_END,
93                 .flags = IORESOURCE_MEM,
94         },
95         {
96                 .name = "mbox_local",
97                 .start = U5500_MBOX2_LOCAL_START,
98                 .end = U5500_MBOX2_LOCAL_END,
99                 .flags = IORESOURCE_MEM,
100         },
101         {
102                 .name = "mbox_irq",
103                 .start = MBOX_PAIR2_VIRT_IRQ,
104                 .end = MBOX_PAIR2_VIRT_IRQ,
105                 .flags = IORESOURCE_IRQ,
106         }
107 };
108
109 static struct platform_device mbox0_device = {
110         .id = 0,
111         .name = "mbox",
112         .resource = mbox0_resources,
113         .num_resources = ARRAY_SIZE(mbox0_resources),
114 };
115
116 static struct platform_device mbox1_device = {
117         .id = 1,
118         .name = "mbox",
119         .resource = mbox1_resources,
120         .num_resources = ARRAY_SIZE(mbox1_resources),
121 };
122
123 static struct platform_device mbox2_device = {
124         .id = 2,
125         .name = "mbox",
126         .resource = mbox2_resources,
127         .num_resources = ARRAY_SIZE(mbox2_resources),
128 };
129
130 static struct platform_device *u5500_platform_devs[] __initdata = {
131         &mbox0_device,
132         &mbox1_device,
133         &mbox2_device,
134 };
135
136 static resource_size_t __initdata db5500_gpio_base[] = {
137         U5500_GPIOBANK0_BASE,
138         U5500_GPIOBANK1_BASE,
139         U5500_GPIOBANK2_BASE,
140         U5500_GPIOBANK3_BASE,
141         U5500_GPIOBANK4_BASE,
142         U5500_GPIOBANK5_BASE,
143         U5500_GPIOBANK6_BASE,
144         U5500_GPIOBANK7_BASE,
145 };
146
147 static void __init db5500_add_gpios(void)
148 {
149         struct nmk_gpio_platform_data pdata = {
150                 /* No custom data yet */
151         };
152
153         dbx500_add_gpios(ARRAY_AND_SIZE(db5500_gpio_base),
154                          IRQ_DB5500_GPIO0, &pdata);
155 }
156
157 void __init u5500_map_io(void)
158 {
159         /*
160          * Map the UARTs early so that the DEBUG_LL stuff continues to work.
161          */
162         iotable_init(u5500_uart_io_desc, ARRAY_SIZE(u5500_uart_io_desc));
163
164         ux500_map_io();
165
166         iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc));
167 }
168
169 void __init u5500_init_devices(void)
170 {
171         db5500_add_gpios();
172         db5500_dma_init();
173         db5500_add_rtc();
174
175         platform_add_devices(u5500_platform_devs,
176                              ARRAY_SIZE(u5500_platform_devs));
177 }