blob: 3f662d175b62e67d71b192e5bdd9ba3f63f10db1 [file] [log] [blame]
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -07001/* 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 Mohanadoss5d49cec2011-09-21 10:26:15 -070018#include <linux/msm_tsens.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070019#include <asm/hardware/gic.h>
Sahitya Tummala38295432011-09-29 10:08:45 +053020#include <asm/mach/flash.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070021#include <mach/board.h>
22#include <mach/msm_iomap.h>
23#include <mach/irqs.h>
24#include <mach/socinfo.h>
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -070025#include <asm/hardware/cache-l2x0.h>
Yan He092b7272011-09-21 15:25:03 -070026#include <mach/msm_sps.h>
Jeff Ohlsteind19bf442011-09-09 12:48:18 -070027#include <mach/dma.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070028#include "devices.h"
Matt Wagantall44f672e2011-09-07 20:31:16 -070029#include "acpuclock.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070030
Harini Jayaramaneba52672011-09-08 15:13:00 -060031/* Address of GSBI blocks */
32#define MSM_GSBI1_PHYS 0x16000000
33#define MSM_GSBI2_PHYS 0x16100000
34#define MSM_GSBI3_PHYS 0x16200000
Rohit Vaswani09666872011-08-23 17:41:54 -070035#define MSM_GSBI4_PHYS 0x16300000
Harini Jayaramaneba52672011-09-08 15:13:00 -060036#define MSM_GSBI5_PHYS 0x16400000
37
Rohit Vaswani09666872011-08-23 17:41:54 -070038#define MSM_UART4DM_PHYS (MSM_GSBI4_PHYS + 0x40000)
39
Harini Jayaramaneba52672011-09-08 15:13:00 -060040/* 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 Heitkeaf3d3cf2011-09-08 11:45:31 -070048/* Address of SSBI CMD */
49#define MSM_PMIC1_SSBI_CMD_PHYS 0x00500000
50#define MSM_PMIC_SSBI_SIZE SZ_4K
51
Jeff Ohlsteind19bf442011-09-09 12:48:18 -070052static 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
60struct 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 Vaswani09666872011-08-23 17:41:54 -070067static 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
87struct 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 Jayaramaneba52672011-09-08 15:13:00 -060094static struct resource resources_qup_i2c_gsbi5[] = {
95 {
96 .name = "gsbi_qup_i2c_addr",
97 .start = MSM_GSBI5_PHYS,
Harini Jayaraman7a60bc12011-09-15 14:58:54 -060098 .end = MSM_GSBI5_PHYS + 4 - 1,
Harini Jayaramaneba52672011-09-08 15:13:00 -060099 .flags = IORESOURCE_MEM,
100 },
101 {
102 .name = "qup_phys_addr",
103 .start = MSM_GSBI5_QUP_PHYS,
Harini Jayaraman7a60bc12011-09-15 14:58:54 -0600104 .end = MSM_GSBI5_QUP_PHYS + MSM_QUP_SIZE - 1,
Harini Jayaramaneba52672011-09-08 15:13:00 -0600105 .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
115struct 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 Jayaraman738c9312011-09-08 15:22:38 -0600122static 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
143struct 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 Heitkeaf3d3cf2011-09-08 11:45:31 -0700150static 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
158struct 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 He092b7272011-09-21 15:25:03 -0700165static 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
192struct msm_sps_platform_data msm_sps_pdata = {
193 .bamdma_restricted_pipes = 0x06,
194};
195
196struct 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 Mohanadoss5d49cec2011-09-21 10:26:15 -0700204static 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 Tummala38295432011-09-29 10:08:45 +0530211struct platform_device msm9615_device_tsens = {
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700212 .name = "tsens8960-tm",
213 .id = -1,
Sahitya Tummala38295432011-09-29 10:08:45 +0530214 .dev = {
215 .platform_data = &msm_tsens_pdata,
216 },
217};
218
219#define MSM_NAND_PHYS 0x1B400000
220static 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
235struct flash_platform_data msm_nand_data = {
236 .parts = NULL,
237 .nr_parts = 0,
238};
239
240struct platform_device msm_device_nand = {
241 .name = "msm_nand",
242 .id = -1,
243 .num_resources = ARRAY_SIZE(resources_nand),
244 .resource = resources_nand,
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700245 .dev = {
Sahitya Tummala38295432011-09-29 10:08:45 +0530246 .platform_data = &msm_nand_data,
Siddartha Mohanadoss5d49cec2011-09-21 10:26:15 -0700247 },
248};
249
Jeff Hugo56b933a2011-09-28 14:42:05 -0600250struct platform_device msm_device_smd = {
251 .name = "msm_smd",
252 .id = -1,
253};
254
Krishna Kondadd794462011-10-01 00:19:29 -0700255
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
260static 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
295struct 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
305static struct platform_device *msm_sdcc_devices[] __initdata = {
306 &msm_device_sdc1,
307};
308
309int __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 Vaswanif0ce9ae2011-08-23 22:18:38 -0700321#ifdef CONFIG_CACHE_L2X0
322static 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
340static int __init l2x0_cache_init(void){ return 0; }
341#endif
342
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700343void __init msm9615_device_init(void)
344{
345 if (socinfo_init() < 0)
346 pr_err("socinfo_init() failed!\n");
347
Vikram Mulukutla489e39e2011-08-31 18:04:05 -0700348 msm_clock_init(&msm9615_clock_init_data);
Matt Wagantall44f672e2011-09-07 20:31:16 -0700349 acpuclk_init(&acpuclk_9615_soc_data);
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700350}
351
Jeff Hugo56b933a2011-09-28 14:42:05 -0600352#define MSM_SHARED_RAM_PHYS 0x40000000
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700353void __init msm9615_map_io(void)
354{
Jeff Hugo56b933a2011-09-28 14:42:05 -0600355 msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700356 msm_map_msm9615_io();
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -0700357 l2x0_cache_init();
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700358}
359
360void __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}