blob: 38a01c36126345ce4681602aee5e13eddd97ee88 [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
Rabin Vincent01afdd12010-12-08 11:07:55 +053016#include <plat/gpio.h>
17
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>
Rabin Vincent591d8dd2010-05-03 08:46:51 +010022
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053023#include "devices-db5500.h"
24
Rabin Vincentabf12d72010-12-08 11:07:59 +053025static struct map_desc u5500_uart_io_desc[] __initdata = {
Rabin Vincent92389ca2010-12-08 11:07:57 +053026 __IO_DEV_DESC(U5500_UART0_BASE, SZ_4K),
27 __IO_DEV_DESC(U5500_UART2_BASE, SZ_4K),
Rabin Vincentabf12d72010-12-08 11:07:59 +053028};
29
30static struct map_desc u5500_io_desc[] __initdata = {
Rabin Vincent92389ca2010-12-08 11:07:57 +053031 __IO_DEV_DESC(U5500_GIC_CPU_BASE, SZ_4K),
32 __IO_DEV_DESC(U5500_GIC_DIST_BASE, SZ_4K),
33 __IO_DEV_DESC(U5500_L2CC_BASE, SZ_4K),
34 __IO_DEV_DESC(U5500_TWD_BASE, SZ_4K),
35 __IO_DEV_DESC(U5500_MTU0_BASE, SZ_4K),
36 __IO_DEV_DESC(U5500_SCU_BASE, SZ_4K),
37 __IO_DEV_DESC(U5500_BACKUPRAM0_BASE, SZ_8K),
38
Rabin Vincent591d8dd2010-05-03 08:46:51 +010039 __IO_DEV_DESC(U5500_GPIO0_BASE, SZ_4K),
40 __IO_DEV_DESC(U5500_GPIO1_BASE, SZ_4K),
41 __IO_DEV_DESC(U5500_GPIO2_BASE, SZ_4K),
42 __IO_DEV_DESC(U5500_GPIO3_BASE, SZ_4K),
43 __IO_DEV_DESC(U5500_GPIO4_BASE, SZ_4K),
Linus Walleijd9e38042010-06-23 07:59:48 +010044 __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K),
Rabin Vincent591d8dd2010-05-03 08:46:51 +010045};
46
Linus Walleijdf93f1f2011-01-21 09:19:05 +010047static struct resource db5500_pmu_resources[] = {
48 [0] = {
49 .start = IRQ_DB5500_PMU0,
50 .end = IRQ_DB5500_PMU0,
51 .flags = IORESOURCE_IRQ,
52 },
53 [1] = {
54 .start = IRQ_DB5500_PMU1,
55 .end = IRQ_DB5500_PMU1,
56 .flags = IORESOURCE_IRQ,
57 },
58};
59
60static struct platform_device db5500_pmu_device = {
61 .name = "arm-pmu",
62 .id = ARM_PMU_DEVICE_CPU,
63 .num_resources = ARRAY_SIZE(db5500_pmu_resources),
64 .resource = db5500_pmu_resources,
65};
66
Linus Walleij4d4a4b02010-09-27 22:09:52 +010067static struct resource mbox0_resources[] = {
68 {
69 .name = "mbox_peer",
70 .start = U5500_MBOX0_PEER_START,
71 .end = U5500_MBOX0_PEER_END,
72 .flags = IORESOURCE_MEM,
73 },
74 {
75 .name = "mbox_local",
76 .start = U5500_MBOX0_LOCAL_START,
77 .end = U5500_MBOX0_LOCAL_END,
78 .flags = IORESOURCE_MEM,
79 },
80 {
81 .name = "mbox_irq",
82 .start = MBOX_PAIR0_VIRT_IRQ,
83 .end = MBOX_PAIR0_VIRT_IRQ,
84 .flags = IORESOURCE_IRQ,
85 }
86};
87
88static struct resource mbox1_resources[] = {
89 {
90 .name = "mbox_peer",
91 .start = U5500_MBOX1_PEER_START,
92 .end = U5500_MBOX1_PEER_END,
93 .flags = IORESOURCE_MEM,
94 },
95 {
96 .name = "mbox_local",
97 .start = U5500_MBOX1_LOCAL_START,
98 .end = U5500_MBOX1_LOCAL_END,
99 .flags = IORESOURCE_MEM,
100 },
101 {
102 .name = "mbox_irq",
103 .start = MBOX_PAIR1_VIRT_IRQ,
104 .end = MBOX_PAIR1_VIRT_IRQ,
105 .flags = IORESOURCE_IRQ,
106 }
107};
108
109static struct resource mbox2_resources[] = {
110 {
111 .name = "mbox_peer",
112 .start = U5500_MBOX2_PEER_START,
113 .end = U5500_MBOX2_PEER_END,
114 .flags = IORESOURCE_MEM,
115 },
116 {
117 .name = "mbox_local",
118 .start = U5500_MBOX2_LOCAL_START,
119 .end = U5500_MBOX2_LOCAL_END,
120 .flags = IORESOURCE_MEM,
121 },
122 {
123 .name = "mbox_irq",
124 .start = MBOX_PAIR2_VIRT_IRQ,
125 .end = MBOX_PAIR2_VIRT_IRQ,
126 .flags = IORESOURCE_IRQ,
127 }
128};
129
130static struct platform_device mbox0_device = {
131 .id = 0,
132 .name = "mbox",
133 .resource = mbox0_resources,
134 .num_resources = ARRAY_SIZE(mbox0_resources),
135};
136
137static struct platform_device mbox1_device = {
138 .id = 1,
139 .name = "mbox",
140 .resource = mbox1_resources,
141 .num_resources = ARRAY_SIZE(mbox1_resources),
142};
143
144static struct platform_device mbox2_device = {
145 .id = 2,
146 .name = "mbox",
147 .resource = mbox2_resources,
148 .num_resources = ARRAY_SIZE(mbox2_resources),
149};
150
Linus Walleijdf93f1f2011-01-21 09:19:05 +0100151static struct platform_device *db5500_platform_devs[] __initdata = {
152 &db5500_pmu_device,
Linus Walleij4d4a4b02010-09-27 22:09:52 +0100153 &mbox0_device,
154 &mbox1_device,
155 &mbox2_device,
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100156};
157
Rabin Vincent01afdd12010-12-08 11:07:55 +0530158static resource_size_t __initdata db5500_gpio_base[] = {
159 U5500_GPIOBANK0_BASE,
160 U5500_GPIOBANK1_BASE,
161 U5500_GPIOBANK2_BASE,
162 U5500_GPIOBANK3_BASE,
163 U5500_GPIOBANK4_BASE,
164 U5500_GPIOBANK5_BASE,
165 U5500_GPIOBANK6_BASE,
166 U5500_GPIOBANK7_BASE,
167};
168
169static void __init db5500_add_gpios(void)
170{
171 struct nmk_gpio_platform_data pdata = {
172 /* No custom data yet */
173 };
174
175 dbx500_add_gpios(ARRAY_AND_SIZE(db5500_gpio_base),
176 IRQ_DB5500_GPIO0, &pdata);
177}
178
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100179void __init u5500_map_io(void)
180{
Rabin Vincentabf12d72010-12-08 11:07:59 +0530181 /*
182 * Map the UARTs early so that the DEBUG_LL stuff continues to work.
183 */
184 iotable_init(u5500_uart_io_desc, ARRAY_SIZE(u5500_uart_io_desc));
185
186 ux500_map_io();
187
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100188 iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc));
189}
190
191void __init u5500_init_devices(void)
192{
Rabin Vincent01afdd12010-12-08 11:07:55 +0530193 db5500_add_gpios();
Per Forline8b1cc32010-12-05 13:35:12 +0100194 db5500_dma_init();
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530195 db5500_add_rtc();
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100196
Linus Walleijdf93f1f2011-01-21 09:19:05 +0100197 platform_add_devices(db5500_platform_devs,
198 ARRAY_SIZE(db5500_platform_devs));
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100199}