Merge branch 'stable/generic' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
[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_io_desc[] __initdata = {
25         __IO_DEV_DESC(U5500_GPIO0_BASE, SZ_4K),
26         __IO_DEV_DESC(U5500_GPIO1_BASE, SZ_4K),
27         __IO_DEV_DESC(U5500_GPIO2_BASE, SZ_4K),
28         __IO_DEV_DESC(U5500_GPIO3_BASE, SZ_4K),
29         __IO_DEV_DESC(U5500_GPIO4_BASE, SZ_4K),
30         __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K),
31 };
32
33 static struct resource mbox0_resources[] = {
34         {
35                 .name = "mbox_peer",
36                 .start = U5500_MBOX0_PEER_START,
37                 .end = U5500_MBOX0_PEER_END,
38                 .flags = IORESOURCE_MEM,
39         },
40         {
41                 .name = "mbox_local",
42                 .start = U5500_MBOX0_LOCAL_START,
43                 .end = U5500_MBOX0_LOCAL_END,
44                 .flags = IORESOURCE_MEM,
45         },
46         {
47                 .name = "mbox_irq",
48                 .start = MBOX_PAIR0_VIRT_IRQ,
49                 .end = MBOX_PAIR0_VIRT_IRQ,
50                 .flags = IORESOURCE_IRQ,
51         }
52 };
53
54 static struct resource mbox1_resources[] = {
55         {
56                 .name = "mbox_peer",
57                 .start = U5500_MBOX1_PEER_START,
58                 .end = U5500_MBOX1_PEER_END,
59                 .flags = IORESOURCE_MEM,
60         },
61         {
62                 .name = "mbox_local",
63                 .start = U5500_MBOX1_LOCAL_START,
64                 .end = U5500_MBOX1_LOCAL_END,
65                 .flags = IORESOURCE_MEM,
66         },
67         {
68                 .name = "mbox_irq",
69                 .start = MBOX_PAIR1_VIRT_IRQ,
70                 .end = MBOX_PAIR1_VIRT_IRQ,
71                 .flags = IORESOURCE_IRQ,
72         }
73 };
74
75 static struct resource mbox2_resources[] = {
76         {
77                 .name = "mbox_peer",
78                 .start = U5500_MBOX2_PEER_START,
79                 .end = U5500_MBOX2_PEER_END,
80                 .flags = IORESOURCE_MEM,
81         },
82         {
83                 .name = "mbox_local",
84                 .start = U5500_MBOX2_LOCAL_START,
85                 .end = U5500_MBOX2_LOCAL_END,
86                 .flags = IORESOURCE_MEM,
87         },
88         {
89                 .name = "mbox_irq",
90                 .start = MBOX_PAIR2_VIRT_IRQ,
91                 .end = MBOX_PAIR2_VIRT_IRQ,
92                 .flags = IORESOURCE_IRQ,
93         }
94 };
95
96 static struct platform_device mbox0_device = {
97         .id = 0,
98         .name = "mbox",
99         .resource = mbox0_resources,
100         .num_resources = ARRAY_SIZE(mbox0_resources),
101 };
102
103 static struct platform_device mbox1_device = {
104         .id = 1,
105         .name = "mbox",
106         .resource = mbox1_resources,
107         .num_resources = ARRAY_SIZE(mbox1_resources),
108 };
109
110 static struct platform_device mbox2_device = {
111         .id = 2,
112         .name = "mbox",
113         .resource = mbox2_resources,
114         .num_resources = ARRAY_SIZE(mbox2_resources),
115 };
116
117 static struct platform_device *u5500_platform_devs[] __initdata = {
118         &mbox0_device,
119         &mbox1_device,
120         &mbox2_device,
121 };
122
123 static resource_size_t __initdata db5500_gpio_base[] = {
124         U5500_GPIOBANK0_BASE,
125         U5500_GPIOBANK1_BASE,
126         U5500_GPIOBANK2_BASE,
127         U5500_GPIOBANK3_BASE,
128         U5500_GPIOBANK4_BASE,
129         U5500_GPIOBANK5_BASE,
130         U5500_GPIOBANK6_BASE,
131         U5500_GPIOBANK7_BASE,
132 };
133
134 static void __init db5500_add_gpios(void)
135 {
136         struct nmk_gpio_platform_data pdata = {
137                 /* No custom data yet */
138         };
139
140         dbx500_add_gpios(ARRAY_AND_SIZE(db5500_gpio_base),
141                          IRQ_DB5500_GPIO0, &pdata);
142 }
143
144 void __init u5500_map_io(void)
145 {
146         ux500_map_io();
147
148         iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc));
149 }
150
151 void __init u5500_init_devices(void)
152 {
153         db5500_add_gpios();
154         db5500_dma_init();
155         db5500_add_rtc();
156
157         platform_add_devices(u5500_platform_devs,
158                              ARRAY_SIZE(u5500_platform_devs));
159 }