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> |
| 18 | #include <asm/hardware/gic.h> |
| 19 | #include <mach/board.h> |
| 20 | #include <mach/msm_iomap.h> |
| 21 | #include <mach/irqs.h> |
| 22 | #include <mach/socinfo.h> |
Rohit Vaswani | f0ce9ae | 2011-08-23 22:18:38 -0700 | [diff] [blame] | 23 | #include <asm/hardware/cache-l2x0.h> |
Yan He | 092b727 | 2011-09-21 15:25:03 -0700 | [diff] [blame^] | 24 | #include <mach/msm_sps.h> |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 25 | #include "devices.h" |
Matt Wagantall | 44f672e | 2011-09-07 20:31:16 -0700 | [diff] [blame] | 26 | #include "acpuclock.h" |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 27 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 28 | /* Address of GSBI blocks */ |
| 29 | #define MSM_GSBI1_PHYS 0x16000000 |
| 30 | #define MSM_GSBI2_PHYS 0x16100000 |
| 31 | #define MSM_GSBI3_PHYS 0x16200000 |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 32 | #define MSM_GSBI4_PHYS 0x16300000 |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 33 | #define MSM_GSBI5_PHYS 0x16400000 |
| 34 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 35 | #define MSM_UART4DM_PHYS (MSM_GSBI4_PHYS + 0x40000) |
| 36 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 37 | /* GSBI QUP devices */ |
| 38 | #define MSM_GSBI1_QUP_PHYS (MSM_GSBI1_PHYS + 0x80000) |
| 39 | #define MSM_GSBI2_QUP_PHYS (MSM_GSBI2_PHYS + 0x80000) |
| 40 | #define MSM_GSBI3_QUP_PHYS (MSM_GSBI3_PHYS + 0x80000) |
| 41 | #define MSM_GSBI4_QUP_PHYS (MSM_GSBI4_PHYS + 0x80000) |
| 42 | #define MSM_GSBI5_QUP_PHYS (MSM_GSBI5_PHYS + 0x80000) |
| 43 | #define MSM_QUP_SIZE SZ_4K |
| 44 | |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 45 | /* Address of SSBI CMD */ |
| 46 | #define MSM_PMIC1_SSBI_CMD_PHYS 0x00500000 |
| 47 | #define MSM_PMIC_SSBI_SIZE SZ_4K |
| 48 | |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 49 | static struct resource resources_uart_gsbi4[] = { |
| 50 | { |
| 51 | .start = GSBI4_UARTDM_IRQ, |
| 52 | .end = GSBI4_UARTDM_IRQ, |
| 53 | .flags = IORESOURCE_IRQ, |
| 54 | }, |
| 55 | { |
| 56 | .start = MSM_UART4DM_PHYS, |
| 57 | .end = MSM_UART4DM_PHYS + PAGE_SIZE - 1, |
| 58 | .name = "uartdm_resource", |
| 59 | .flags = IORESOURCE_MEM, |
| 60 | }, |
| 61 | { |
| 62 | .start = MSM_GSBI4_PHYS, |
| 63 | .end = MSM_GSBI4_PHYS + PAGE_SIZE - 1, |
| 64 | .name = "gsbi_resource", |
| 65 | .flags = IORESOURCE_MEM, |
| 66 | }, |
| 67 | }; |
| 68 | |
| 69 | struct platform_device msm9615_device_uart_gsbi4 = { |
| 70 | .name = "msm_serial_hsl", |
| 71 | .id = 0, |
| 72 | .num_resources = ARRAY_SIZE(resources_uart_gsbi4), |
| 73 | .resource = resources_uart_gsbi4, |
| 74 | }; |
| 75 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 76 | static struct resource resources_qup_i2c_gsbi5[] = { |
| 77 | { |
| 78 | .name = "gsbi_qup_i2c_addr", |
| 79 | .start = MSM_GSBI5_PHYS, |
Harini Jayaraman | 7a60bc1 | 2011-09-15 14:58:54 -0600 | [diff] [blame] | 80 | .end = MSM_GSBI5_PHYS + 4 - 1, |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 81 | .flags = IORESOURCE_MEM, |
| 82 | }, |
| 83 | { |
| 84 | .name = "qup_phys_addr", |
| 85 | .start = MSM_GSBI5_QUP_PHYS, |
Harini Jayaraman | 7a60bc1 | 2011-09-15 14:58:54 -0600 | [diff] [blame] | 86 | .end = MSM_GSBI5_QUP_PHYS + MSM_QUP_SIZE - 1, |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 87 | .flags = IORESOURCE_MEM, |
| 88 | }, |
| 89 | { |
| 90 | .name = "qup_err_intr", |
| 91 | .start = GSBI5_QUP_IRQ, |
| 92 | .end = GSBI5_QUP_IRQ, |
| 93 | .flags = IORESOURCE_IRQ, |
| 94 | }, |
| 95 | }; |
| 96 | |
| 97 | struct platform_device msm9615_device_qup_i2c_gsbi5 = { |
| 98 | .name = "qup_i2c", |
| 99 | .id = 0, |
| 100 | .num_resources = ARRAY_SIZE(resources_qup_i2c_gsbi5), |
| 101 | .resource = resources_qup_i2c_gsbi5, |
| 102 | }; |
| 103 | |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 104 | static struct resource resources_qup_spi_gsbi3[] = { |
| 105 | { |
| 106 | .name = "spi_base", |
| 107 | .start = MSM_GSBI3_QUP_PHYS, |
| 108 | .end = MSM_GSBI3_QUP_PHYS + SZ_4K - 1, |
| 109 | .flags = IORESOURCE_MEM, |
| 110 | }, |
| 111 | { |
| 112 | .name = "gsbi_base", |
| 113 | .start = MSM_GSBI3_PHYS, |
| 114 | .end = MSM_GSBI3_PHYS + 4 - 1, |
| 115 | .flags = IORESOURCE_MEM, |
| 116 | }, |
| 117 | { |
| 118 | .name = "spi_irq_in", |
| 119 | .start = GSBI3_QUP_IRQ, |
| 120 | .end = GSBI3_QUP_IRQ, |
| 121 | .flags = IORESOURCE_IRQ, |
| 122 | }, |
| 123 | }; |
| 124 | |
| 125 | struct platform_device msm9615_device_qup_spi_gsbi3 = { |
| 126 | .name = "spi_qsd", |
| 127 | .id = 0, |
| 128 | .num_resources = ARRAY_SIZE(resources_qup_spi_gsbi3), |
| 129 | .resource = resources_qup_spi_gsbi3, |
| 130 | }; |
| 131 | |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 132 | static struct resource resources_ssbi_pmic1[] = { |
| 133 | { |
| 134 | .start = MSM_PMIC1_SSBI_CMD_PHYS, |
| 135 | .end = MSM_PMIC1_SSBI_CMD_PHYS + MSM_PMIC_SSBI_SIZE - 1, |
| 136 | .flags = IORESOURCE_MEM, |
| 137 | }, |
| 138 | }; |
| 139 | |
| 140 | struct platform_device msm9615_device_ssbi_pmic1 = { |
| 141 | .name = "msm_ssbi", |
| 142 | .id = 0, |
| 143 | .resource = resources_ssbi_pmic1, |
| 144 | .num_resources = ARRAY_SIZE(resources_ssbi_pmic1), |
| 145 | }; |
| 146 | |
Yan He | 092b727 | 2011-09-21 15:25:03 -0700 | [diff] [blame^] | 147 | static struct resource resources_sps[] = { |
| 148 | { |
| 149 | .name = "pipe_mem", |
| 150 | .start = 0x12800000, |
| 151 | .end = 0x12800000 + 0x4000 - 1, |
| 152 | .flags = IORESOURCE_MEM, |
| 153 | }, |
| 154 | { |
| 155 | .name = "bamdma_dma", |
| 156 | .start = 0x12240000, |
| 157 | .end = 0x12240000 + 0x1000 - 1, |
| 158 | .flags = IORESOURCE_MEM, |
| 159 | }, |
| 160 | { |
| 161 | .name = "bamdma_bam", |
| 162 | .start = 0x12244000, |
| 163 | .end = 0x12244000 + 0x4000 - 1, |
| 164 | .flags = IORESOURCE_MEM, |
| 165 | }, |
| 166 | { |
| 167 | .name = "bamdma_irq", |
| 168 | .start = SPS_BAM_DMA_IRQ, |
| 169 | .end = SPS_BAM_DMA_IRQ, |
| 170 | .flags = IORESOURCE_IRQ, |
| 171 | }, |
| 172 | }; |
| 173 | |
| 174 | struct msm_sps_platform_data msm_sps_pdata = { |
| 175 | .bamdma_restricted_pipes = 0x06, |
| 176 | }; |
| 177 | |
| 178 | struct platform_device msm_device_sps = { |
| 179 | .name = "msm_sps", |
| 180 | .id = -1, |
| 181 | .num_resources = ARRAY_SIZE(resources_sps), |
| 182 | .resource = resources_sps, |
| 183 | .dev.platform_data = &msm_sps_pdata, |
| 184 | }; |
| 185 | |
Rohit Vaswani | f0ce9ae | 2011-08-23 22:18:38 -0700 | [diff] [blame] | 186 | #ifdef CONFIG_CACHE_L2X0 |
| 187 | static int __init l2x0_cache_init(void) |
| 188 | { |
| 189 | int aux_ctrl = 0; |
| 190 | |
| 191 | /* Way Size 010(0x2) 32KB */ |
| 192 | aux_ctrl = (0x1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | \ |
| 193 | (0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | \ |
| 194 | (0x1 << L2X0_AUX_CTRL_EVNT_MON_BUS_EN_SHIFT); |
| 195 | |
| 196 | /* L2 Latency setting required by hardware. Default is 0x20 |
| 197 | which is no good. |
| 198 | */ |
| 199 | writel_relaxed(0x220, MSM_L2CC_BASE + L2X0_DATA_LATENCY_CTRL); |
| 200 | l2x0_init(MSM_L2CC_BASE, aux_ctrl, L2X0_AUX_CTRL_MASK); |
| 201 | |
| 202 | return 0; |
| 203 | } |
| 204 | #else |
| 205 | static int __init l2x0_cache_init(void){ return 0; } |
| 206 | #endif |
| 207 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 208 | void __init msm9615_device_init(void) |
| 209 | { |
| 210 | if (socinfo_init() < 0) |
| 211 | pr_err("socinfo_init() failed!\n"); |
| 212 | |
Vikram Mulukutla | 489e39e | 2011-08-31 18:04:05 -0700 | [diff] [blame] | 213 | msm_clock_init(&msm9615_clock_init_data); |
Matt Wagantall | 44f672e | 2011-09-07 20:31:16 -0700 | [diff] [blame] | 214 | acpuclk_init(&acpuclk_9615_soc_data); |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | void __init msm9615_map_io(void) |
| 218 | { |
| 219 | msm_map_msm9615_io(); |
Rohit Vaswani | f0ce9ae | 2011-08-23 22:18:38 -0700 | [diff] [blame] | 220 | l2x0_cache_init(); |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | void __init msm9615_init_irq(void) |
| 224 | { |
| 225 | unsigned int i; |
| 226 | gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE, |
| 227 | (void *)MSM_QGIC_CPU_BASE); |
| 228 | |
| 229 | /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */ |
| 230 | writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4); |
| 231 | |
| 232 | writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET); |
| 233 | mb(); |
| 234 | |
| 235 | /* |
| 236 | * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet |
| 237 | * as they are configured as level, which does not play nice with |
| 238 | * handle_percpu_irq. |
| 239 | */ |
| 240 | for (i = GIC_PPI_START; i < GIC_SPI_START; i++) { |
| 241 | if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE) |
| 242 | irq_set_handler(i, handle_percpu_irq); |
| 243 | } |
| 244 | } |