Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/irq.h> |
| 17 | #include <linux/io.h> |
Siddartha Mohanadoss | 5d49cec | 2011-09-21 10:26:15 -0700 | [diff] [blame] | 18 | #include <linux/msm_tsens.h> |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 19 | #include <asm/hardware/gic.h> |
Sahitya Tummala | 3829543 | 2011-09-29 10:08:45 +0530 | [diff] [blame] | 20 | #include <asm/mach/flash.h> |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 21 | #include <mach/board.h> |
| 22 | #include <mach/msm_iomap.h> |
| 23 | #include <mach/irqs.h> |
| 24 | #include <mach/socinfo.h> |
Rohit Vaswani | f0ce9ae | 2011-08-23 22:18:38 -0700 | [diff] [blame] | 25 | #include <asm/hardware/cache-l2x0.h> |
Yan He | 092b727 | 2011-09-21 15:25:03 -0700 | [diff] [blame] | 26 | #include <mach/msm_sps.h> |
Jeff Ohlstein | d19bf44 | 2011-09-09 12:48:18 -0700 | [diff] [blame] | 27 | #include <mach/dma.h> |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 28 | #include "devices.h" |
Matt Wagantall | 44f672e | 2011-09-07 20:31:16 -0700 | [diff] [blame] | 29 | #include "acpuclock.h" |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 30 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 31 | /* Address of GSBI blocks */ |
| 32 | #define MSM_GSBI1_PHYS 0x16000000 |
| 33 | #define MSM_GSBI2_PHYS 0x16100000 |
| 34 | #define MSM_GSBI3_PHYS 0x16200000 |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 35 | #define MSM_GSBI4_PHYS 0x16300000 |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 36 | #define MSM_GSBI5_PHYS 0x16400000 |
| 37 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 38 | #define MSM_UART4DM_PHYS (MSM_GSBI4_PHYS + 0x40000) |
| 39 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 40 | /* GSBI QUP devices */ |
| 41 | #define MSM_GSBI1_QUP_PHYS (MSM_GSBI1_PHYS + 0x80000) |
| 42 | #define MSM_GSBI2_QUP_PHYS (MSM_GSBI2_PHYS + 0x80000) |
| 43 | #define MSM_GSBI3_QUP_PHYS (MSM_GSBI3_PHYS + 0x80000) |
| 44 | #define MSM_GSBI4_QUP_PHYS (MSM_GSBI4_PHYS + 0x80000) |
| 45 | #define MSM_GSBI5_QUP_PHYS (MSM_GSBI5_PHYS + 0x80000) |
| 46 | #define MSM_QUP_SIZE SZ_4K |
| 47 | |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 48 | /* Address of SSBI CMD */ |
| 49 | #define MSM_PMIC1_SSBI_CMD_PHYS 0x00500000 |
| 50 | #define MSM_PMIC_SSBI_SIZE SZ_4K |
| 51 | |
Jeff Ohlstein | d19bf44 | 2011-09-09 12:48:18 -0700 | [diff] [blame] | 52 | static struct resource msm_dmov_resource[] = { |
| 53 | { |
| 54 | .start = ADM_0_SCSS_1_IRQ, |
| 55 | .end = (resource_size_t)MSM_DMOV_BASE, |
| 56 | .flags = IORESOURCE_IRQ, |
| 57 | }, |
| 58 | }; |
| 59 | |
| 60 | struct platform_device msm9615_device_dmov = { |
| 61 | .name = "msm_dmov", |
| 62 | .id = -1, |
| 63 | .resource = msm_dmov_resource, |
| 64 | .num_resources = ARRAY_SIZE(msm_dmov_resource), |
| 65 | }; |
| 66 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 67 | static struct resource resources_uart_gsbi4[] = { |
| 68 | { |
| 69 | .start = GSBI4_UARTDM_IRQ, |
| 70 | .end = GSBI4_UARTDM_IRQ, |
| 71 | .flags = IORESOURCE_IRQ, |
| 72 | }, |
| 73 | { |
| 74 | .start = MSM_UART4DM_PHYS, |
| 75 | .end = MSM_UART4DM_PHYS + PAGE_SIZE - 1, |
| 76 | .name = "uartdm_resource", |
| 77 | .flags = IORESOURCE_MEM, |
| 78 | }, |
| 79 | { |
| 80 | .start = MSM_GSBI4_PHYS, |
| 81 | .end = MSM_GSBI4_PHYS + PAGE_SIZE - 1, |
| 82 | .name = "gsbi_resource", |
| 83 | .flags = IORESOURCE_MEM, |
| 84 | }, |
| 85 | }; |
| 86 | |
| 87 | struct platform_device msm9615_device_uart_gsbi4 = { |
| 88 | .name = "msm_serial_hsl", |
| 89 | .id = 0, |
| 90 | .num_resources = ARRAY_SIZE(resources_uart_gsbi4), |
| 91 | .resource = resources_uart_gsbi4, |
| 92 | }; |
| 93 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 94 | static struct resource resources_qup_i2c_gsbi5[] = { |
| 95 | { |
| 96 | .name = "gsbi_qup_i2c_addr", |
| 97 | .start = MSM_GSBI5_PHYS, |
Harini Jayaraman | 7a60bc1 | 2011-09-15 14:58:54 -0600 | [diff] [blame] | 98 | .end = MSM_GSBI5_PHYS + 4 - 1, |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 99 | .flags = IORESOURCE_MEM, |
| 100 | }, |
| 101 | { |
| 102 | .name = "qup_phys_addr", |
| 103 | .start = MSM_GSBI5_QUP_PHYS, |
Harini Jayaraman | 7a60bc1 | 2011-09-15 14:58:54 -0600 | [diff] [blame] | 104 | .end = MSM_GSBI5_QUP_PHYS + MSM_QUP_SIZE - 1, |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 105 | .flags = IORESOURCE_MEM, |
| 106 | }, |
| 107 | { |
| 108 | .name = "qup_err_intr", |
| 109 | .start = GSBI5_QUP_IRQ, |
| 110 | .end = GSBI5_QUP_IRQ, |
| 111 | .flags = IORESOURCE_IRQ, |
| 112 | }, |
| 113 | }; |
| 114 | |
| 115 | struct platform_device msm9615_device_qup_i2c_gsbi5 = { |
| 116 | .name = "qup_i2c", |
| 117 | .id = 0, |
| 118 | .num_resources = ARRAY_SIZE(resources_qup_i2c_gsbi5), |
| 119 | .resource = resources_qup_i2c_gsbi5, |
| 120 | }; |
| 121 | |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 122 | static struct resource resources_qup_spi_gsbi3[] = { |
| 123 | { |
| 124 | .name = "spi_base", |
| 125 | .start = MSM_GSBI3_QUP_PHYS, |
| 126 | .end = MSM_GSBI3_QUP_PHYS + SZ_4K - 1, |
| 127 | .flags = IORESOURCE_MEM, |
| 128 | }, |
| 129 | { |
| 130 | .name = "gsbi_base", |
| 131 | .start = MSM_GSBI3_PHYS, |
| 132 | .end = MSM_GSBI3_PHYS + 4 - 1, |
| 133 | .flags = IORESOURCE_MEM, |
| 134 | }, |
| 135 | { |
| 136 | .name = "spi_irq_in", |
| 137 | .start = GSBI3_QUP_IRQ, |
| 138 | .end = GSBI3_QUP_IRQ, |
| 139 | .flags = IORESOURCE_IRQ, |
| 140 | }, |
| 141 | }; |
| 142 | |
| 143 | struct platform_device msm9615_device_qup_spi_gsbi3 = { |
| 144 | .name = "spi_qsd", |
| 145 | .id = 0, |
| 146 | .num_resources = ARRAY_SIZE(resources_qup_spi_gsbi3), |
| 147 | .resource = resources_qup_spi_gsbi3, |
| 148 | }; |
| 149 | |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 150 | static struct resource resources_ssbi_pmic1[] = { |
| 151 | { |
| 152 | .start = MSM_PMIC1_SSBI_CMD_PHYS, |
| 153 | .end = MSM_PMIC1_SSBI_CMD_PHYS + MSM_PMIC_SSBI_SIZE - 1, |
| 154 | .flags = IORESOURCE_MEM, |
| 155 | }, |
| 156 | }; |
| 157 | |
| 158 | struct platform_device msm9615_device_ssbi_pmic1 = { |
| 159 | .name = "msm_ssbi", |
| 160 | .id = 0, |
| 161 | .resource = resources_ssbi_pmic1, |
| 162 | .num_resources = ARRAY_SIZE(resources_ssbi_pmic1), |
| 163 | }; |
| 164 | |
Yan He | 092b727 | 2011-09-21 15:25:03 -0700 | [diff] [blame] | 165 | static struct resource resources_sps[] = { |
| 166 | { |
| 167 | .name = "pipe_mem", |
| 168 | .start = 0x12800000, |
| 169 | .end = 0x12800000 + 0x4000 - 1, |
| 170 | .flags = IORESOURCE_MEM, |
| 171 | }, |
| 172 | { |
| 173 | .name = "bamdma_dma", |
| 174 | .start = 0x12240000, |
| 175 | .end = 0x12240000 + 0x1000 - 1, |
| 176 | .flags = IORESOURCE_MEM, |
| 177 | }, |
| 178 | { |
| 179 | .name = "bamdma_bam", |
| 180 | .start = 0x12244000, |
| 181 | .end = 0x12244000 + 0x4000 - 1, |
| 182 | .flags = IORESOURCE_MEM, |
| 183 | }, |
| 184 | { |
| 185 | .name = "bamdma_irq", |
| 186 | .start = SPS_BAM_DMA_IRQ, |
| 187 | .end = SPS_BAM_DMA_IRQ, |
| 188 | .flags = IORESOURCE_IRQ, |
| 189 | }, |
| 190 | }; |
| 191 | |
| 192 | struct msm_sps_platform_data msm_sps_pdata = { |
| 193 | .bamdma_restricted_pipes = 0x06, |
| 194 | }; |
| 195 | |
| 196 | struct platform_device msm_device_sps = { |
| 197 | .name = "msm_sps", |
| 198 | .id = -1, |
| 199 | .num_resources = ARRAY_SIZE(resources_sps), |
| 200 | .resource = resources_sps, |
| 201 | .dev.platform_data = &msm_sps_pdata, |
| 202 | }; |
| 203 | |
Siddartha Mohanadoss | 5d49cec | 2011-09-21 10:26:15 -0700 | [diff] [blame] | 204 | static struct tsens_platform_data msm_tsens_pdata = { |
| 205 | .slope = 910, |
| 206 | .tsens_factor = 1000, |
| 207 | .hw_type = MSM_9615, |
| 208 | .tsens_num_sensor = 5, |
| 209 | }; |
| 210 | |
Sahitya Tummala | 3829543 | 2011-09-29 10:08:45 +0530 | [diff] [blame] | 211 | struct platform_device msm9615_device_tsens = { |
Siddartha Mohanadoss | 5d49cec | 2011-09-21 10:26:15 -0700 | [diff] [blame] | 212 | .name = "tsens8960-tm", |
| 213 | .id = -1, |
Sahitya Tummala | 3829543 | 2011-09-29 10:08:45 +0530 | [diff] [blame] | 214 | .dev = { |
| 215 | .platform_data = &msm_tsens_pdata, |
| 216 | }, |
| 217 | }; |
| 218 | |
| 219 | #define MSM_NAND_PHYS 0x1B400000 |
| 220 | static struct resource resources_nand[] = { |
| 221 | [0] = { |
| 222 | .name = "msm_nand_dmac", |
| 223 | .start = DMOV_NAND_CHAN, |
| 224 | .end = DMOV_NAND_CHAN, |
| 225 | .flags = IORESOURCE_DMA, |
| 226 | }, |
| 227 | [1] = { |
| 228 | .name = "msm_nand_phys", |
| 229 | .start = MSM_NAND_PHYS, |
| 230 | .end = MSM_NAND_PHYS + 0x7FF, |
| 231 | .flags = IORESOURCE_MEM, |
| 232 | }, |
| 233 | }; |
| 234 | |
| 235 | struct flash_platform_data msm_nand_data = { |
| 236 | .parts = NULL, |
| 237 | .nr_parts = 0, |
| 238 | }; |
| 239 | |
| 240 | struct platform_device msm_device_nand = { |
| 241 | .name = "msm_nand", |
| 242 | .id = -1, |
| 243 | .num_resources = ARRAY_SIZE(resources_nand), |
| 244 | .resource = resources_nand, |
Siddartha Mohanadoss | 5d49cec | 2011-09-21 10:26:15 -0700 | [diff] [blame] | 245 | .dev = { |
Sahitya Tummala | 3829543 | 2011-09-29 10:08:45 +0530 | [diff] [blame] | 246 | .platform_data = &msm_nand_data, |
Siddartha Mohanadoss | 5d49cec | 2011-09-21 10:26:15 -0700 | [diff] [blame] | 247 | }, |
| 248 | }; |
| 249 | |
Jeff Hugo | 56b933a | 2011-09-28 14:42:05 -0600 | [diff] [blame] | 250 | struct platform_device msm_device_smd = { |
| 251 | .name = "msm_smd", |
| 252 | .id = -1, |
| 253 | }; |
| 254 | |
Krishna Konda | dd79446 | 2011-10-01 00:19:29 -0700 | [diff] [blame^] | 255 | |
| 256 | #define MSM_SDC1_BASE 0x12180000 |
| 257 | #define MSM_SDC1_DML_BASE (MSM_SDC1_BASE + 0x800) |
| 258 | #define MSM_SDC1_BAM_BASE (MSM_SDC1_BASE + 0x2000) |
| 259 | |
| 260 | static struct resource resources_sdc1[] = { |
| 261 | { |
| 262 | .name = "core_mem", |
| 263 | .flags = IORESOURCE_MEM, |
| 264 | .start = MSM_SDC1_BASE, |
| 265 | .end = MSM_SDC1_DML_BASE - 1, |
| 266 | }, |
| 267 | { |
| 268 | .name = "core_irq", |
| 269 | .flags = IORESOURCE_IRQ, |
| 270 | .start = SDC1_IRQ_0, |
| 271 | .end = SDC1_IRQ_0 |
| 272 | }, |
| 273 | #ifdef CONFIG_MMC_MSM_SPS_SUPPORT |
| 274 | { |
| 275 | .name = "sdcc_dml_addr", |
| 276 | .start = MSM_SDC1_DML_BASE, |
| 277 | .end = MSM_SDC1_BAM_BASE - 1, |
| 278 | .flags = IORESOURCE_MEM, |
| 279 | }, |
| 280 | { |
| 281 | .name = "sdcc_bam_addr", |
| 282 | .start = MSM_SDC1_BAM_BASE, |
| 283 | .end = MSM_SDC1_BAM_BASE + (2 * SZ_4K) - 1, |
| 284 | .flags = IORESOURCE_MEM, |
| 285 | }, |
| 286 | { |
| 287 | .name = "sdcc_bam_irq", |
| 288 | .start = SDC1_BAM_IRQ, |
| 289 | .end = SDC1_BAM_IRQ, |
| 290 | .flags = IORESOURCE_IRQ, |
| 291 | }, |
| 292 | #endif |
| 293 | }; |
| 294 | |
| 295 | struct platform_device msm_device_sdc1 = { |
| 296 | .name = "msm_sdcc", |
| 297 | .id = 1, |
| 298 | .num_resources = ARRAY_SIZE(resources_sdc1), |
| 299 | .resource = resources_sdc1, |
| 300 | .dev = { |
| 301 | .coherent_dma_mask = 0xffffffff, |
| 302 | }, |
| 303 | }; |
| 304 | |
| 305 | static struct platform_device *msm_sdcc_devices[] __initdata = { |
| 306 | &msm_device_sdc1, |
| 307 | }; |
| 308 | |
| 309 | int __init msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat) |
| 310 | { |
| 311 | struct platform_device *pdev; |
| 312 | |
| 313 | if (controller < 1 || controller > 2) |
| 314 | return -EINVAL; |
| 315 | |
| 316 | pdev = msm_sdcc_devices[controller - 1]; |
| 317 | pdev->dev.platform_data = plat; |
| 318 | return platform_device_register(pdev); |
| 319 | } |
| 320 | |
Rohit Vaswani | f0ce9ae | 2011-08-23 22:18:38 -0700 | [diff] [blame] | 321 | #ifdef CONFIG_CACHE_L2X0 |
| 322 | static int __init l2x0_cache_init(void) |
| 323 | { |
| 324 | int aux_ctrl = 0; |
| 325 | |
| 326 | /* Way Size 010(0x2) 32KB */ |
| 327 | aux_ctrl = (0x1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | \ |
| 328 | (0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | \ |
| 329 | (0x1 << L2X0_AUX_CTRL_EVNT_MON_BUS_EN_SHIFT); |
| 330 | |
| 331 | /* L2 Latency setting required by hardware. Default is 0x20 |
| 332 | which is no good. |
| 333 | */ |
| 334 | writel_relaxed(0x220, MSM_L2CC_BASE + L2X0_DATA_LATENCY_CTRL); |
| 335 | l2x0_init(MSM_L2CC_BASE, aux_ctrl, L2X0_AUX_CTRL_MASK); |
| 336 | |
| 337 | return 0; |
| 338 | } |
| 339 | #else |
| 340 | static int __init l2x0_cache_init(void){ return 0; } |
| 341 | #endif |
| 342 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 343 | void __init msm9615_device_init(void) |
| 344 | { |
| 345 | if (socinfo_init() < 0) |
| 346 | pr_err("socinfo_init() failed!\n"); |
| 347 | |
Vikram Mulukutla | 489e39e | 2011-08-31 18:04:05 -0700 | [diff] [blame] | 348 | msm_clock_init(&msm9615_clock_init_data); |
Matt Wagantall | 44f672e | 2011-09-07 20:31:16 -0700 | [diff] [blame] | 349 | acpuclk_init(&acpuclk_9615_soc_data); |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Jeff Hugo | 56b933a | 2011-09-28 14:42:05 -0600 | [diff] [blame] | 352 | #define MSM_SHARED_RAM_PHYS 0x40000000 |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 353 | void __init msm9615_map_io(void) |
| 354 | { |
Jeff Hugo | 56b933a | 2011-09-28 14:42:05 -0600 | [diff] [blame] | 355 | msm_shared_ram_phys = MSM_SHARED_RAM_PHYS; |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 356 | msm_map_msm9615_io(); |
Rohit Vaswani | f0ce9ae | 2011-08-23 22:18:38 -0700 | [diff] [blame] | 357 | l2x0_cache_init(); |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | void __init msm9615_init_irq(void) |
| 361 | { |
| 362 | unsigned int i; |
| 363 | gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE, |
| 364 | (void *)MSM_QGIC_CPU_BASE); |
| 365 | |
| 366 | /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */ |
| 367 | writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4); |
| 368 | |
| 369 | writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET); |
| 370 | mb(); |
| 371 | |
| 372 | /* |
| 373 | * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet |
| 374 | * as they are configured as level, which does not play nice with |
| 375 | * handle_percpu_irq. |
| 376 | */ |
| 377 | for (i = GIC_PPI_START; i < GIC_SPI_START; i++) { |
| 378 | if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE) |
| 379 | irq_set_handler(i, handle_percpu_irq); |
| 380 | } |
| 381 | } |