This client driver allows you to use a GPIO pin as a source for PPS
[linux-2.6/next.git] / arch / arm / mach-ux500 / cpu-db5500.c
blob9de1af0080944cdcd57c3da3dd48634da24fd279
1 /*
2 * Copyright (C) ST-Ericsson SA 2010
4 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5 * License terms: GNU General Public License (GPL) version 2
6 */
8 #include <linux/platform_device.h>
9 #include <linux/amba/bus.h>
10 #include <linux/io.h>
11 #include <linux/irq.h>
13 #include <asm/mach/map.h>
14 #include <asm/pmu.h>
16 #include <plat/gpio-nomadik.h>
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>
24 #include "devices-db5500.h"
25 #include "ste-dma40-db5500.h"
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),
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),
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 __IO_DEV_DESC(U5500_PRCMU_TCDM_BASE, SZ_4K),
50 static struct resource db5500_pmu_resources[] = {
51 [0] = {
52 .start = IRQ_DB5500_PMU0,
53 .end = IRQ_DB5500_PMU0,
54 .flags = IORESOURCE_IRQ,
56 [1] = {
57 .start = IRQ_DB5500_PMU1,
58 .end = IRQ_DB5500_PMU1,
59 .flags = IORESOURCE_IRQ,
63 static struct platform_device db5500_pmu_device = {
64 .name = "arm-pmu",
65 .id = ARM_PMU_DEVICE_CPU,
66 .num_resources = ARRAY_SIZE(db5500_pmu_resources),
67 .resource = db5500_pmu_resources,
70 static struct resource mbox0_resources[] = {
72 .name = "mbox_peer",
73 .start = U5500_MBOX0_PEER_START,
74 .end = U5500_MBOX0_PEER_END,
75 .flags = IORESOURCE_MEM,
78 .name = "mbox_local",
79 .start = U5500_MBOX0_LOCAL_START,
80 .end = U5500_MBOX0_LOCAL_END,
81 .flags = IORESOURCE_MEM,
84 .name = "mbox_irq",
85 .start = MBOX_PAIR0_VIRT_IRQ,
86 .end = MBOX_PAIR0_VIRT_IRQ,
87 .flags = IORESOURCE_IRQ,
91 static struct resource mbox1_resources[] = {
93 .name = "mbox_peer",
94 .start = U5500_MBOX1_PEER_START,
95 .end = U5500_MBOX1_PEER_END,
96 .flags = IORESOURCE_MEM,
99 .name = "mbox_local",
100 .start = U5500_MBOX1_LOCAL_START,
101 .end = U5500_MBOX1_LOCAL_END,
102 .flags = IORESOURCE_MEM,
105 .name = "mbox_irq",
106 .start = MBOX_PAIR1_VIRT_IRQ,
107 .end = MBOX_PAIR1_VIRT_IRQ,
108 .flags = IORESOURCE_IRQ,
112 static struct resource mbox2_resources[] = {
114 .name = "mbox_peer",
115 .start = U5500_MBOX2_PEER_START,
116 .end = U5500_MBOX2_PEER_END,
117 .flags = IORESOURCE_MEM,
120 .name = "mbox_local",
121 .start = U5500_MBOX2_LOCAL_START,
122 .end = U5500_MBOX2_LOCAL_END,
123 .flags = IORESOURCE_MEM,
126 .name = "mbox_irq",
127 .start = MBOX_PAIR2_VIRT_IRQ,
128 .end = MBOX_PAIR2_VIRT_IRQ,
129 .flags = IORESOURCE_IRQ,
133 static struct platform_device mbox0_device = {
134 .id = 0,
135 .name = "mbox",
136 .resource = mbox0_resources,
137 .num_resources = ARRAY_SIZE(mbox0_resources),
140 static struct platform_device mbox1_device = {
141 .id = 1,
142 .name = "mbox",
143 .resource = mbox1_resources,
144 .num_resources = ARRAY_SIZE(mbox1_resources),
147 static struct platform_device mbox2_device = {
148 .id = 2,
149 .name = "mbox",
150 .resource = mbox2_resources,
151 .num_resources = ARRAY_SIZE(mbox2_resources),
154 static struct platform_device *db5500_platform_devs[] __initdata = {
155 &db5500_pmu_device,
156 &mbox0_device,
157 &mbox1_device,
158 &mbox2_device,
161 static resource_size_t __initdata db5500_gpio_base[] = {
162 U5500_GPIOBANK0_BASE,
163 U5500_GPIOBANK1_BASE,
164 U5500_GPIOBANK2_BASE,
165 U5500_GPIOBANK3_BASE,
166 U5500_GPIOBANK4_BASE,
167 U5500_GPIOBANK5_BASE,
168 U5500_GPIOBANK6_BASE,
169 U5500_GPIOBANK7_BASE,
172 static void __init db5500_add_gpios(void)
174 struct nmk_gpio_platform_data pdata = {
175 /* No custom data yet */
178 dbx500_add_gpios(ARRAY_AND_SIZE(db5500_gpio_base),
179 IRQ_DB5500_GPIO0, &pdata);
182 void __init u5500_map_io(void)
185 * Map the UARTs early so that the DEBUG_LL stuff continues to work.
187 iotable_init(u5500_uart_io_desc, ARRAY_SIZE(u5500_uart_io_desc));
189 ux500_map_io();
191 iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc));
193 _PRCMU_BASE = __io_address(U5500_PRCMU_BASE);
196 static int usb_db5500_rx_dma_cfg[] = {
197 DB5500_DMA_DEV4_USB_OTG_IEP_1_9,
198 DB5500_DMA_DEV5_USB_OTG_IEP_2_10,
199 DB5500_DMA_DEV6_USB_OTG_IEP_3_11,
200 DB5500_DMA_DEV20_USB_OTG_IEP_4_12,
201 DB5500_DMA_DEV21_USB_OTG_IEP_5_13,
202 DB5500_DMA_DEV22_USB_OTG_IEP_6_14,
203 DB5500_DMA_DEV23_USB_OTG_IEP_7_15,
204 DB5500_DMA_DEV38_USB_OTG_IEP_8
207 static int usb_db5500_tx_dma_cfg[] = {
208 DB5500_DMA_DEV4_USB_OTG_OEP_1_9,
209 DB5500_DMA_DEV5_USB_OTG_OEP_2_10,
210 DB5500_DMA_DEV6_USB_OTG_OEP_3_11,
211 DB5500_DMA_DEV20_USB_OTG_OEP_4_12,
212 DB5500_DMA_DEV21_USB_OTG_OEP_5_13,
213 DB5500_DMA_DEV22_USB_OTG_OEP_6_14,
214 DB5500_DMA_DEV23_USB_OTG_OEP_7_15,
215 DB5500_DMA_DEV38_USB_OTG_OEP_8
218 void __init u5500_init_devices(void)
220 db5500_add_gpios();
221 db5500_dma_init();
222 db5500_add_rtc();
223 db5500_add_usb(usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);
225 platform_add_devices(db5500_platform_devs,
226 ARRAY_SIZE(db5500_platform_devs));