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 | |
Linus Walleij | 0f33286 | 2011-08-22 08:33:30 +0100 | [diff] [blame] | 16 | #include <plat/gpio-nomadik.h> |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 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> |
Mian Yousaf Kaukab | 741caea | 2011-01-21 18:24:19 +0100 | [diff] [blame] | 22 | #include <mach/usb.h> |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 23 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 24 | #include "devices-db5500.h" |
Mian Yousaf Kaukab | 741caea | 2011-01-21 18:24:19 +0100 | [diff] [blame] | 25 | #include "ste-dma40-db5500.h" |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 26 | |
Rabin Vincent | abf12d7 | 2010-12-08 11:07:59 +0530 | [diff] [blame] | 27 | static struct map_desc u5500_uart_io_desc[] __initdata = { |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 28 | __IO_DEV_DESC(U5500_UART0_BASE, SZ_4K), |
| 29 | __IO_DEV_DESC(U5500_UART2_BASE, SZ_4K), |
Rabin Vincent | abf12d7 | 2010-12-08 11:07:59 +0530 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | static struct map_desc u5500_io_desc[] __initdata = { |
Linus Walleij | 215e83d | 2011-12-14 18:15:42 +0100 | [diff] [blame] | 33 | /* SCU base also covers GIC CPU BASE and TWD with its 4K page */ |
| 34 | __IO_DEV_DESC(U5500_SCU_BASE, SZ_4K), |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 35 | __IO_DEV_DESC(U5500_GIC_DIST_BASE, SZ_4K), |
| 36 | __IO_DEV_DESC(U5500_L2CC_BASE, SZ_4K), |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 37 | __IO_DEV_DESC(U5500_MTU0_BASE, SZ_4K), |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 38 | __IO_DEV_DESC(U5500_BACKUPRAM0_BASE, SZ_8K), |
| 39 | |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 40 | __IO_DEV_DESC(U5500_GPIO0_BASE, SZ_4K), |
| 41 | __IO_DEV_DESC(U5500_GPIO1_BASE, SZ_4K), |
| 42 | __IO_DEV_DESC(U5500_GPIO2_BASE, SZ_4K), |
| 43 | __IO_DEV_DESC(U5500_GPIO3_BASE, SZ_4K), |
| 44 | __IO_DEV_DESC(U5500_GPIO4_BASE, SZ_4K), |
Linus Walleij | d9e3804 | 2010-06-23 07:59:48 +0100 | [diff] [blame] | 45 | __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K), |
Mattias Wallin | dd367e9 | 2011-06-09 11:50:35 +0200 | [diff] [blame] | 46 | __IO_DEV_DESC(U5500_PRCMU_TCDM_BASE, SZ_4K), |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 47 | }; |
| 48 | |
Linus Walleij | 4d4a4b0 | 2010-09-27 22:09:52 +0100 | [diff] [blame] | 49 | static struct resource mbox0_resources[] = { |
| 50 | { |
| 51 | .name = "mbox_peer", |
| 52 | .start = U5500_MBOX0_PEER_START, |
| 53 | .end = U5500_MBOX0_PEER_END, |
| 54 | .flags = IORESOURCE_MEM, |
| 55 | }, |
| 56 | { |
| 57 | .name = "mbox_local", |
| 58 | .start = U5500_MBOX0_LOCAL_START, |
| 59 | .end = U5500_MBOX0_LOCAL_END, |
| 60 | .flags = IORESOURCE_MEM, |
| 61 | }, |
| 62 | { |
| 63 | .name = "mbox_irq", |
| 64 | .start = MBOX_PAIR0_VIRT_IRQ, |
| 65 | .end = MBOX_PAIR0_VIRT_IRQ, |
| 66 | .flags = IORESOURCE_IRQ, |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | static struct resource mbox1_resources[] = { |
| 71 | { |
| 72 | .name = "mbox_peer", |
| 73 | .start = U5500_MBOX1_PEER_START, |
| 74 | .end = U5500_MBOX1_PEER_END, |
| 75 | .flags = IORESOURCE_MEM, |
| 76 | }, |
| 77 | { |
| 78 | .name = "mbox_local", |
| 79 | .start = U5500_MBOX1_LOCAL_START, |
| 80 | .end = U5500_MBOX1_LOCAL_END, |
| 81 | .flags = IORESOURCE_MEM, |
| 82 | }, |
| 83 | { |
| 84 | .name = "mbox_irq", |
| 85 | .start = MBOX_PAIR1_VIRT_IRQ, |
| 86 | .end = MBOX_PAIR1_VIRT_IRQ, |
| 87 | .flags = IORESOURCE_IRQ, |
| 88 | } |
| 89 | }; |
| 90 | |
| 91 | static struct resource mbox2_resources[] = { |
| 92 | { |
| 93 | .name = "mbox_peer", |
| 94 | .start = U5500_MBOX2_PEER_START, |
| 95 | .end = U5500_MBOX2_PEER_END, |
| 96 | .flags = IORESOURCE_MEM, |
| 97 | }, |
| 98 | { |
| 99 | .name = "mbox_local", |
| 100 | .start = U5500_MBOX2_LOCAL_START, |
| 101 | .end = U5500_MBOX2_LOCAL_END, |
| 102 | .flags = IORESOURCE_MEM, |
| 103 | }, |
| 104 | { |
| 105 | .name = "mbox_irq", |
| 106 | .start = MBOX_PAIR2_VIRT_IRQ, |
| 107 | .end = MBOX_PAIR2_VIRT_IRQ, |
| 108 | .flags = IORESOURCE_IRQ, |
| 109 | } |
| 110 | }; |
| 111 | |
| 112 | static struct platform_device mbox0_device = { |
| 113 | .id = 0, |
| 114 | .name = "mbox", |
| 115 | .resource = mbox0_resources, |
| 116 | .num_resources = ARRAY_SIZE(mbox0_resources), |
| 117 | }; |
| 118 | |
| 119 | static struct platform_device mbox1_device = { |
| 120 | .id = 1, |
| 121 | .name = "mbox", |
| 122 | .resource = mbox1_resources, |
| 123 | .num_resources = ARRAY_SIZE(mbox1_resources), |
| 124 | }; |
| 125 | |
| 126 | static struct platform_device mbox2_device = { |
| 127 | .id = 2, |
| 128 | .name = "mbox", |
| 129 | .resource = mbox2_resources, |
| 130 | .num_resources = ARRAY_SIZE(mbox2_resources), |
| 131 | }; |
| 132 | |
Linus Walleij | df93f1f | 2011-01-21 09:19:05 +0100 | [diff] [blame] | 133 | static struct platform_device *db5500_platform_devs[] __initdata = { |
Linus Walleij | 4d4a4b0 | 2010-09-27 22:09:52 +0100 | [diff] [blame] | 134 | &mbox0_device, |
| 135 | &mbox1_device, |
| 136 | &mbox2_device, |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 137 | }; |
| 138 | |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 139 | static resource_size_t __initdata db5500_gpio_base[] = { |
| 140 | U5500_GPIOBANK0_BASE, |
| 141 | U5500_GPIOBANK1_BASE, |
| 142 | U5500_GPIOBANK2_BASE, |
| 143 | U5500_GPIOBANK3_BASE, |
| 144 | U5500_GPIOBANK4_BASE, |
| 145 | U5500_GPIOBANK5_BASE, |
| 146 | U5500_GPIOBANK6_BASE, |
| 147 | U5500_GPIOBANK7_BASE, |
| 148 | }; |
| 149 | |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 150 | static void __init db5500_add_gpios(struct device *parent) |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 151 | { |
| 152 | struct nmk_gpio_platform_data pdata = { |
| 153 | /* No custom data yet */ |
| 154 | }; |
| 155 | |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 156 | dbx500_add_gpios(parent, ARRAY_AND_SIZE(db5500_gpio_base), |
Rabin Vincent | 01afdd1 | 2010-12-08 11:07:55 +0530 | [diff] [blame] | 157 | IRQ_DB5500_GPIO0, &pdata); |
| 158 | } |
| 159 | |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 160 | void __init u5500_map_io(void) |
| 161 | { |
Rabin Vincent | abf12d7 | 2010-12-08 11:07:59 +0530 | [diff] [blame] | 162 | /* |
| 163 | * Map the UARTs early so that the DEBUG_LL stuff continues to work. |
| 164 | */ |
| 165 | iotable_init(u5500_uart_io_desc, ARRAY_SIZE(u5500_uart_io_desc)); |
| 166 | |
| 167 | ux500_map_io(); |
| 168 | |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 169 | iotable_init(u5500_io_desc, ARRAY_SIZE(u5500_io_desc)); |
Linus Walleij | 1187189 | 2011-03-29 16:53:29 +0200 | [diff] [blame] | 170 | |
| 171 | _PRCMU_BASE = __io_address(U5500_PRCMU_BASE); |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 172 | } |
| 173 | |
Rabin Vincent | ebe6c6f | 2011-12-15 11:49:43 +0100 | [diff] [blame] | 174 | static void __init db5500_pmu_init(void) |
| 175 | { |
| 176 | struct resource res[] = { |
| 177 | [0] = { |
| 178 | .start = IRQ_DB5500_PMU0, |
| 179 | .end = IRQ_DB5500_PMU0, |
| 180 | .flags = IORESOURCE_IRQ, |
| 181 | }, |
| 182 | [1] = { |
| 183 | .start = IRQ_DB5500_PMU1, |
| 184 | .end = IRQ_DB5500_PMU1, |
| 185 | .flags = IORESOURCE_IRQ, |
| 186 | }, |
| 187 | }; |
| 188 | |
| 189 | platform_device_register_simple("arm-pmu", ARM_PMU_DEVICE_CPU, |
| 190 | res, ARRAY_SIZE(res)); |
| 191 | } |
| 192 | |
Mian Yousaf Kaukab | 741caea | 2011-01-21 18:24:19 +0100 | [diff] [blame] | 193 | static int usb_db5500_rx_dma_cfg[] = { |
| 194 | DB5500_DMA_DEV4_USB_OTG_IEP_1_9, |
| 195 | DB5500_DMA_DEV5_USB_OTG_IEP_2_10, |
| 196 | DB5500_DMA_DEV6_USB_OTG_IEP_3_11, |
| 197 | DB5500_DMA_DEV20_USB_OTG_IEP_4_12, |
| 198 | DB5500_DMA_DEV21_USB_OTG_IEP_5_13, |
| 199 | DB5500_DMA_DEV22_USB_OTG_IEP_6_14, |
| 200 | DB5500_DMA_DEV23_USB_OTG_IEP_7_15, |
| 201 | DB5500_DMA_DEV38_USB_OTG_IEP_8 |
| 202 | }; |
| 203 | |
| 204 | static int usb_db5500_tx_dma_cfg[] = { |
| 205 | DB5500_DMA_DEV4_USB_OTG_OEP_1_9, |
| 206 | DB5500_DMA_DEV5_USB_OTG_OEP_2_10, |
| 207 | DB5500_DMA_DEV6_USB_OTG_OEP_3_11, |
| 208 | DB5500_DMA_DEV20_USB_OTG_OEP_4_12, |
| 209 | DB5500_DMA_DEV21_USB_OTG_OEP_5_13, |
| 210 | DB5500_DMA_DEV22_USB_OTG_OEP_6_14, |
| 211 | DB5500_DMA_DEV23_USB_OTG_OEP_7_15, |
| 212 | DB5500_DMA_DEV38_USB_OTG_OEP_8 |
| 213 | }; |
| 214 | |
Lee Jones | eda413c | 2012-02-06 11:22:24 -0800 | [diff] [blame] | 215 | static const char *db5500_read_soc_id(void) |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 216 | { |
Lee Jones | eda413c | 2012-02-06 11:22:24 -0800 | [diff] [blame] | 217 | return kasprintf(GFP_KERNEL, "u5500 currently unsupported\n"); |
| 218 | } |
| 219 | |
| 220 | static struct device * __init db5500_soc_device_init(void) |
| 221 | { |
| 222 | const char *soc_id = db5500_read_soc_id(); |
| 223 | |
| 224 | return ux500_soc_device_init(soc_id); |
| 225 | } |
| 226 | |
| 227 | struct device * __init u5500_init_devices(void) |
| 228 | { |
| 229 | struct device *parent; |
Lee Jones | b024a0c | 2012-02-06 11:22:25 -0800 | [diff] [blame] | 230 | int i; |
Lee Jones | eda413c | 2012-02-06 11:22:24 -0800 | [diff] [blame] | 231 | |
| 232 | parent = db5500_soc_device_init(); |
| 233 | |
| 234 | db5500_add_gpios(parent); |
Rabin Vincent | ebe6c6f | 2011-12-15 11:49:43 +0100 | [diff] [blame] | 235 | db5500_pmu_init(); |
Lee Jones | eda413c | 2012-02-06 11:22:24 -0800 | [diff] [blame] | 236 | db5500_dma_init(parent); |
| 237 | db5500_add_rtc(parent); |
| 238 | db5500_add_usb(parent, usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg); |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 239 | |
Lee Jones | b024a0c | 2012-02-06 11:22:25 -0800 | [diff] [blame] | 240 | for (i = 0; i < ARRAY_SIZE(db5500_platform_devs); i++) |
| 241 | db5500_platform_devs[i]->dev.parent = parent; |
| 242 | |
Linus Walleij | df93f1f | 2011-01-21 09:19:05 +0100 | [diff] [blame] | 243 | platform_add_devices(db5500_platform_devs, |
| 244 | ARRAY_SIZE(db5500_platform_devs)); |
Lee Jones | 1840342 | 2012-02-06 11:22:21 -0800 | [diff] [blame] | 245 | |
Lee Jones | eda413c | 2012-02-06 11:22:24 -0800 | [diff] [blame] | 246 | return parent; |
Rabin Vincent | 591d8dd | 2010-05-03 08:46:51 +0100 | [diff] [blame] | 247 | } |