blob: 8187909c29ef835d473091f24bde70dd263c1048 [file] [log] [blame]
Rabin Vincent591d8dd2010-05-03 08:46:51 +01001/*
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>
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053011#include <linux/irq.h>
Rabin Vincent591d8dd2010-05-03 08:46:51 +010012
13#include <asm/mach/map.h>
Linus Walleijdf93f1f2011-01-21 09:19:05 +010014#include <asm/pmu.h>
Rabin Vincent591d8dd2010-05-03 08:46:51 +010015
Linus Walleij0f332862011-08-22 08:33:30 +010016#include <plat/gpio-nomadik.h>
Rabin Vincent01afdd12010-12-08 11:07:55 +053017
Rabin Vincent591d8dd2010-05-03 08:46:51 +010018#include <mach/hardware.h>
19#include <mach/devices.h>
20#include <mach/setup.h>
Linus Walleij4d4a4b02010-09-27 22:09:52 +010021#include <mach/irqs.h>
Mian Yousaf Kaukab741caea2011-01-21 18:24:19 +010022#include <mach/usb.h>
Rabin Vincent591d8dd2010-05-03 08:46:51 +010023
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053024#include "devices-db5500.h"
Mian Yousaf Kaukab741caea2011-01-21 18:24:19 +010025#include "ste-dma40-db5500.h"
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053026
Rabin Vincentabf12d72010-12-08 11:07:59 +053027static struct map_desc u5500_uart_io_desc[] __initdata = {
Rabin Vincent92389ca2010-12-08 11:07:57 +053028 __IO_DEV_DESC(U5500_UART0_BASE, SZ_4K),
29 __IO_DEV_DESC(U5500_UART2_BASE, SZ_4K),
Rabin Vincentabf12d72010-12-08 11:07:59 +053030};
31
32static struct map_desc u5500_io_desc[] __initdata = {
Rabin Vincent92389ca2010-12-08 11:07:57 +053033 __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
Rabin Vincent591d8dd2010-05-03 08:46:51 +010041 __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),
Linus Walleijd9e38042010-06-23 07:59:48 +010046 __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K),
Mattias Wallindd367e92011-06-09 11:50:35 +020047 __IO_DEV_DESC(U5500_PRCMU_TCDM_BASE, SZ_4K),
Rabin Vincent591d8dd2010-05-03 08:46:51 +010048};
49
Linus Walleij4d4a4b02010-09-27 22:09:52 +010050static struct resource mbox0_resources[] = {
51 {
52 .name = "mbox_peer",
53 .start = U5500_MBOX0_PEER_START,
54 .end = U5500_MBOX0_PEER_END,
55 .flags = IORESOURCE_MEM,
56 },
57 {
58 .name = "mbox_local",
59 .start = U5500_MBOX0_LOCAL_START,
60 .end = U5500_MBOX0_LOCAL_END,
61 .flags = IORESOURCE_MEM,
62 },
63 {
64 .name = "mbox_irq",
65 .start = MBOX_PAIR0_VIRT_IRQ,
66 .end = MBOX_PAIR0_VIRT_IRQ,
67 .flags = IORESOURCE_IRQ,
68 }
69};
70
71static struct resource mbox1_resources[] = {
72 {
73 .name = "mbox_peer",
74 .start = U5500_MBOX1_PEER_START,
75 .end = U5500_MBOX1_PEER_END,
76 .flags = IORESOURCE_MEM,
77 },
78 {
79 .name = "mbox_local",
80 .start = U5500_MBOX1_LOCAL_START,
81 .end = U5500_MBOX1_LOCAL_END,
82 .flags = IORESOURCE_MEM,
83 },
84 {
85 .name = "mbox_irq",
86 .start = MBOX_PAIR1_VIRT_IRQ,
87 .end = MBOX_PAIR1_VIRT_IRQ,
88 .flags = IORESOURCE_IRQ,
89 }
90};
91
92static struct resource mbox2_resources[] = {
93 {
94 .name = "mbox_peer",
95 .start = U5500_MBOX2_PEER_START,
96 .end = U5500_MBOX2_PEER_END,
97 .flags = IORESOURCE_MEM,
98 },
99 {
100 .name = "mbox_local",
101 .start = U5500_MBOX2_LOCAL_START,
102 .end = U5500_MBOX2_LOCAL_END,
103 .flags = IORESOURCE_MEM,
104 },
105 {
106 .name = "mbox_irq",
107 .start = MBOX_PAIR2_VIRT_IRQ,
108 .end = MBOX_PAIR2_VIRT_IRQ,
109 .flags = IORESOURCE_IRQ,
110 }
111};
112
113static struct platform_device mbox0_device = {
114 .id = 0,
115 .name = "mbox",
116 .resource = mbox0_resources,
117 .num_resources = ARRAY_SIZE(mbox0_resources),
118};
119
120static struct platform_device mbox1_device = {
121 .id = 1,
122 .name = "mbox",
123 .resource = mbox1_resources,
124 .num_resources = ARRAY_SIZE(mbox1_resources),
125};
126
127static struct platform_device mbox2_device = {
128 .id = 2,
129 .name = "mbox",
130 .resource = mbox2_resources,
131 .num_resources = ARRAY_SIZE(mbox2_resources),
132};
133
Linus Walleijdf93f1f2011-01-21 09:19:05 +0100134static struct platform_device *db5500_platform_devs[] __initdata = {
Linus Walleij4d4a4b02010-09-27 22:09:52 +0100135 &mbox0_device,
136 &mbox1_device,
137 &mbox2_device,
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100138};
139
Rabin Vincent01afdd12010-12-08 11:07:55 +0530140static resource_size_t __initdata db5500_gpio_base[] = {
141 U5500_GPIOBANK0_BASE,
142 U5500_GPIOBANK1_BASE,
143 U5500_GPIOBANK2_BASE,
144 U5500_GPIOBANK3_BASE,
145 U5500_GPIOBANK4_BASE,
146 U5500_GPIOBANK5_BASE,
147 U5500_GPIOBANK6_BASE,
148 U5500_GPIOBANK7_BASE,
149};
150
151static void __init db5500_add_gpios(void)
152{
153 struct nmk_gpio_platform_data pdata = {
154 /* No custom data yet */
155 };
156
157 dbx500_add_gpios(ARRAY_AND_SIZE(db5500_gpio_base),
158 IRQ_DB5500_GPIO0, &pdata);
159}
160
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100161void __init u5500_map_io(void)
162{
Rabin Vincentabf12d72010-12-08 11:07:59 +0530163 /*
164 * Map the UARTs early so that the DEBUG_LL stuff continues to work.
165 */
166 iotable_init(u5500_uart_io_desc, ARRAY_SIZE(u5500_uart_io_desc));
167
168 ux500_map_io();
169
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100170 iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc));
Linus Walleij11871892011-03-29 16:53:29 +0200171
172 _PRCMU_BASE = __io_address(U5500_PRCMU_BASE);
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100173}
174
Rabin Vincentebe6c6f2011-12-15 11:49:43 +0100175static void __init db5500_pmu_init(void)
176{
177 struct resource res[] = {
178 [0] = {
179 .start = IRQ_DB5500_PMU0,
180 .end = IRQ_DB5500_PMU0,
181 .flags = IORESOURCE_IRQ,
182 },
183 [1] = {
184 .start = IRQ_DB5500_PMU1,
185 .end = IRQ_DB5500_PMU1,
186 .flags = IORESOURCE_IRQ,
187 },
188 };
189
190 platform_device_register_simple("arm-pmu", ARM_PMU_DEVICE_CPU,
191 res, ARRAY_SIZE(res));
192}
193
Mian Yousaf Kaukab741caea2011-01-21 18:24:19 +0100194static int usb_db5500_rx_dma_cfg[] = {
195 DB5500_DMA_DEV4_USB_OTG_IEP_1_9,
196 DB5500_DMA_DEV5_USB_OTG_IEP_2_10,
197 DB5500_DMA_DEV6_USB_OTG_IEP_3_11,
198 DB5500_DMA_DEV20_USB_OTG_IEP_4_12,
199 DB5500_DMA_DEV21_USB_OTG_IEP_5_13,
200 DB5500_DMA_DEV22_USB_OTG_IEP_6_14,
201 DB5500_DMA_DEV23_USB_OTG_IEP_7_15,
202 DB5500_DMA_DEV38_USB_OTG_IEP_8
203};
204
205static int usb_db5500_tx_dma_cfg[] = {
206 DB5500_DMA_DEV4_USB_OTG_OEP_1_9,
207 DB5500_DMA_DEV5_USB_OTG_OEP_2_10,
208 DB5500_DMA_DEV6_USB_OTG_OEP_3_11,
209 DB5500_DMA_DEV20_USB_OTG_OEP_4_12,
210 DB5500_DMA_DEV21_USB_OTG_OEP_5_13,
211 DB5500_DMA_DEV22_USB_OTG_OEP_6_14,
212 DB5500_DMA_DEV23_USB_OTG_OEP_7_15,
213 DB5500_DMA_DEV38_USB_OTG_OEP_8
214};
215
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100216void __init u5500_init_devices(void)
217{
Rabin Vincent01afdd12010-12-08 11:07:55 +0530218 db5500_add_gpios();
Rabin Vincentebe6c6f2011-12-15 11:49:43 +0100219 db5500_pmu_init();
Per Forline8b1cc32010-12-05 13:35:12 +0100220 db5500_dma_init();
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530221 db5500_add_rtc();
Mian Yousaf Kaukab741caea2011-01-21 18:24:19 +0100222 db5500_add_usb(usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100223
Linus Walleijdf93f1f2011-01-21 09:19:05 +0100224 platform_add_devices(db5500_platform_devs,
225 ARRAY_SIZE(db5500_platform_devs));
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100226}