Merge branch 'docs-move' of git://git.kernel.org/pub/scm/linux/kernel/git/rdunlap...
[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 #include <asm/pmu.h>
15
16 #include <plat/gpio.h>
17
18 #include <mach/hardware.h>
19 #include <mach/devices.h>
20 #include <mach/setup.h>
21 #include <mach/irqs.h>
22 #include <mach/usb.h>
23
24 #include "devices-db5500.h"
25 #include "ste-dma40-db5500.h"
26
27 static struct map_desc u5500_uart_io_desc[] __initdata = {
28         __IO_DEV_DESC(U5500_UART0_BASE, SZ_4K),
29         __IO_DEV_DESC(U5500_UART2_BASE, SZ_4K),
30 };
31
32 static struct map_desc u5500_io_desc[] __initdata = {
33         __IO_DEV_DESC(U5500_GIC_CPU_BASE, SZ_4K),
34         __IO_DEV_DESC(U5500_GIC_DIST_BASE, SZ_4K),
35         __IO_DEV_DESC(U5500_L2CC_BASE, SZ_4K),
36         __IO_DEV_DESC(U5500_TWD_BASE, SZ_4K),
37         __IO_DEV_DESC(U5500_MTU0_BASE, SZ_4K),
38         __IO_DEV_DESC(U5500_SCU_BASE, SZ_4K),
39         __IO_DEV_DESC(U5500_BACKUPRAM0_BASE, SZ_8K),
40
41         __IO_DEV_DESC(U5500_GPIO0_BASE, SZ_4K),
42         __IO_DEV_DESC(U5500_GPIO1_BASE, SZ_4K),
43         __IO_DEV_DESC(U5500_GPIO2_BASE, SZ_4K),
44         __IO_DEV_DESC(U5500_GPIO3_BASE, SZ_4K),
45         __IO_DEV_DESC(U5500_GPIO4_BASE, SZ_4K),
46         __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K),
47 };
48
49 static struct resource db5500_pmu_resources[] = {
50         [0] = {
51                 .start          = IRQ_DB5500_PMU0,
52                 .end            = IRQ_DB5500_PMU0,
53                 .flags          = IORESOURCE_IRQ,
54         },
55         [1] = {
56                 .start          = IRQ_DB5500_PMU1,
57                 .end            = IRQ_DB5500_PMU1,
58                 .flags          = IORESOURCE_IRQ,
59         },
60 };
61
62 static struct platform_device db5500_pmu_device = {
63         .name                   = "arm-pmu",
64         .id                     = ARM_PMU_DEVICE_CPU,
65         .num_resources          = ARRAY_SIZE(db5500_pmu_resources),
66         .resource               = db5500_pmu_resources,
67 };
68
69 static struct resource mbox0_resources[] = {
70         {
71                 .name = "mbox_peer",
72                 .start = U5500_MBOX0_PEER_START,
73                 .end = U5500_MBOX0_PEER_END,
74                 .flags = IORESOURCE_MEM,
75         },
76         {
77                 .name = "mbox_local",
78                 .start = U5500_MBOX0_LOCAL_START,
79                 .end = U5500_MBOX0_LOCAL_END,
80                 .flags = IORESOURCE_MEM,
81         },
82         {
83                 .name = "mbox_irq",
84                 .start = MBOX_PAIR0_VIRT_IRQ,
85                 .end = MBOX_PAIR0_VIRT_IRQ,
86                 .flags = IORESOURCE_IRQ,
87         }
88 };
89
90 static struct resource mbox1_resources[] = {
91         {
92                 .name = "mbox_peer",
93                 .start = U5500_MBOX1_PEER_START,
94                 .end = U5500_MBOX1_PEER_END,
95                 .flags = IORESOURCE_MEM,
96         },
97         {
98                 .name = "mbox_local",
99                 .start = U5500_MBOX1_LOCAL_START,
100                 .end = U5500_MBOX1_LOCAL_END,
101                 .flags = IORESOURCE_MEM,
102         },
103         {
104                 .name = "mbox_irq",
105                 .start = MBOX_PAIR1_VIRT_IRQ,
106                 .end = MBOX_PAIR1_VIRT_IRQ,
107                 .flags = IORESOURCE_IRQ,
108         }
109 };
110
111 static struct resource mbox2_resources[] = {
112         {
113                 .name = "mbox_peer",
114                 .start = U5500_MBOX2_PEER_START,
115                 .end = U5500_MBOX2_PEER_END,
116                 .flags = IORESOURCE_MEM,
117         },
118         {
119                 .name = "mbox_local",
120                 .start = U5500_MBOX2_LOCAL_START,
121                 .end = U5500_MBOX2_LOCAL_END,
122                 .flags = IORESOURCE_MEM,
123         },
124         {
125                 .name = "mbox_irq",
126                 .start = MBOX_PAIR2_VIRT_IRQ,
127                 .end = MBOX_PAIR2_VIRT_IRQ,
128                 .flags = IORESOURCE_IRQ,
129         }
130 };
131
132 static struct platform_device mbox0_device = {
133         .id = 0,
134         .name = "mbox",
135         .resource = mbox0_resources,
136         .num_resources = ARRAY_SIZE(mbox0_resources),
137 };
138
139 static struct platform_device mbox1_device = {
140         .id = 1,
141         .name = "mbox",
142         .resource = mbox1_resources,
143         .num_resources = ARRAY_SIZE(mbox1_resources),
144 };
145
146 static struct platform_device mbox2_device = {
147         .id = 2,
148         .name = "mbox",
149         .resource = mbox2_resources,
150         .num_resources = ARRAY_SIZE(mbox2_resources),
151 };
152
153 static struct platform_device *db5500_platform_devs[] __initdata = {
154         &db5500_pmu_device,
155         &mbox0_device,
156         &mbox1_device,
157         &mbox2_device,
158 };
159
160 static resource_size_t __initdata db5500_gpio_base[] = {
161         U5500_GPIOBANK0_BASE,
162         U5500_GPIOBANK1_BASE,
163         U5500_GPIOBANK2_BASE,
164         U5500_GPIOBANK3_BASE,
165         U5500_GPIOBANK4_BASE,
166         U5500_GPIOBANK5_BASE,
167         U5500_GPIOBANK6_BASE,
168         U5500_GPIOBANK7_BASE,
169 };
170
171 static void __init db5500_add_gpios(void)
172 {
173         struct nmk_gpio_platform_data pdata = {
174                 /* No custom data yet */
175         };
176
177         dbx500_add_gpios(ARRAY_AND_SIZE(db5500_gpio_base),
178                          IRQ_DB5500_GPIO0, &pdata);
179 }
180
181 void __init u5500_map_io(void)
182 {
183         /*
184          * Map the UARTs early so that the DEBUG_LL stuff continues to work.
185          */
186         iotable_init(u5500_uart_io_desc, ARRAY_SIZE(u5500_uart_io_desc));
187
188         ux500_map_io();
189
190         iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc));
191
192         _PRCMU_BASE = __io_address(U5500_PRCMU_BASE);
193 }
194
195 static int usb_db5500_rx_dma_cfg[] = {
196         DB5500_DMA_DEV4_USB_OTG_IEP_1_9,
197         DB5500_DMA_DEV5_USB_OTG_IEP_2_10,
198         DB5500_DMA_DEV6_USB_OTG_IEP_3_11,
199         DB5500_DMA_DEV20_USB_OTG_IEP_4_12,
200         DB5500_DMA_DEV21_USB_OTG_IEP_5_13,
201         DB5500_DMA_DEV22_USB_OTG_IEP_6_14,
202         DB5500_DMA_DEV23_USB_OTG_IEP_7_15,
203         DB5500_DMA_DEV38_USB_OTG_IEP_8
204 };
205
206 static int usb_db5500_tx_dma_cfg[] = {
207         DB5500_DMA_DEV4_USB_OTG_OEP_1_9,
208         DB5500_DMA_DEV5_USB_OTG_OEP_2_10,
209         DB5500_DMA_DEV6_USB_OTG_OEP_3_11,
210         DB5500_DMA_DEV20_USB_OTG_OEP_4_12,
211         DB5500_DMA_DEV21_USB_OTG_OEP_5_13,
212         DB5500_DMA_DEV22_USB_OTG_OEP_6_14,
213         DB5500_DMA_DEV23_USB_OTG_OEP_7_15,
214         DB5500_DMA_DEV38_USB_OTG_OEP_8
215 };
216
217 void __init u5500_init_devices(void)
218 {
219         db5500_add_gpios();
220         db5500_dma_init();
221         db5500_add_rtc();
222         db5500_add_usb(usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);
223
224         platform_add_devices(db5500_platform_devs,
225                              ARRAY_SIZE(db5500_platform_devs));
226 }