Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 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> |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 11 | #include <linux/irq.h> |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 12 | |
| 13 | #include <asm/mach/map.h> |
Linus Walleij | df93f1f | 2011-01-21 09:19:05 +0100 | [diff] [blame^] | 14 | #include <asm/pmu.h> |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 15 | |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 16 | #include <plat/gpio.h> |
| 17 | |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 18 | #include <mach/hardware.h> |
| 19 | #include <mach/devices.h> |
| 20 | #include <mach/setup.h> |
Linus Walleij | 4d4a4b0 | 2010-09-27 22:09:52 +0100 | [diff] [blame] | 21 | #include <mach/irqs.h> |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 22 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 23 | #include "devices-db5500.h" |
| 24 | |
Rabin Vincent | abf12d7 | 2010-12-08 11:07:59 +0530 | [diff] [blame] | 25 | static struct map_desc u5500_uart_io_desc[] __initdata = { |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 26 | __IO_DEV_DESC(U5500_UART0_BASE, SZ_4K), |
| 27 | __IO_DEV_DESC(U5500_UART2_BASE, SZ_4K), |
Rabin Vincent | abf12d7 | 2010-12-08 11:07:59 +0530 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | static struct map_desc u5500_io_desc[] __initdata = { |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 31 | __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 Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 39 | __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 Walleij | d9e3804 | 2010-06-23 07:59:48 +0100 | [diff] [blame] | 44 | __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K), |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 45 | }; |
| 46 | |
Linus Walleij | df93f1f | 2011-01-21 09:19:05 +0100 | [diff] [blame^] | 47 | static 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 | |
| 60 | static 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 Walleij | 4d4a4b0 | 2010-09-27 22:09:52 +0100 | [diff] [blame] | 67 | static 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 | |
| 88 | static 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 | |
| 109 | static 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 | |
| 130 | static struct platform_device mbox0_device = { |
| 131 | .id = 0, |
| 132 | .name = "mbox", |
| 133 | .resource = mbox0_resources, |
| 134 | .num_resources = ARRAY_SIZE(mbox0_resources), |
| 135 | }; |
| 136 | |
| 137 | static struct platform_device mbox1_device = { |
| 138 | .id = 1, |
| 139 | .name = "mbox", |
| 140 | .resource = mbox1_resources, |
| 141 | .num_resources = ARRAY_SIZE(mbox1_resources), |
| 142 | }; |
| 143 | |
| 144 | static 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 Walleij | df93f1f | 2011-01-21 09:19:05 +0100 | [diff] [blame^] | 151 | static struct platform_device *db5500_platform_devs[] __initdata = { |
| 152 | &db5500_pmu_device, |
Linus Walleij | 4d4a4b0 | 2010-09-27 22:09:52 +0100 | [diff] [blame] | 153 | &mbox0_device, |
| 154 | &mbox1_device, |
| 155 | &mbox2_device, |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 156 | }; |
| 157 | |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 158 | static 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 | |
| 169 | static 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 Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 179 | void __init u5500_map_io(void) |
| 180 | { |
Rabin Vincent | abf12d7 | 2010-12-08 11:07:59 +0530 | [diff] [blame] | 181 | /* |
| 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 Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 188 | iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc)); |
| 189 | } |
| 190 | |
| 191 | void __init u5500_init_devices(void) |
| 192 | { |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 193 | db5500_add_gpios(); |
Per Forlin | e8b1cc3 | 2010-12-05 13:35:12 +0100 | [diff] [blame] | 194 | db5500_dma_init(); |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 195 | db5500_add_rtc(); |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 196 | |
Linus Walleij | df93f1f | 2011-01-21 09:19:05 +0100 | [diff] [blame^] | 197 | platform_add_devices(db5500_platform_devs, |
| 198 | ARRAY_SIZE(db5500_platform_devs)); |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 199 | } |