blob: 5805ecd9b161c835532829a026a380108d3712bd [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
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -0700250#ifdef CONFIG_CACHE_L2X0
251static int __init l2x0_cache_init(void)
252{
253 int aux_ctrl = 0;
254
255 /* Way Size 010(0x2) 32KB */
256 aux_ctrl = (0x1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | \
257 (0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | \
258 (0x1 << L2X0_AUX_CTRL_EVNT_MON_BUS_EN_SHIFT);
259
260 /* L2 Latency setting required by hardware. Default is 0x20
261 which is no good.
262 */
263 writel_relaxed(0x220, MSM_L2CC_BASE + L2X0_DATA_LATENCY_CTRL);
264 l2x0_init(MSM_L2CC_BASE, aux_ctrl, L2X0_AUX_CTRL_MASK);
265
266 return 0;
267}
268#else
269static int __init l2x0_cache_init(void){ return 0; }
270#endif
271
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700272void __init msm9615_device_init(void)
273{
274 if (socinfo_init() < 0)
275 pr_err("socinfo_init() failed!\n");
276
Vikram Mulukutla489e39e2011-08-31 18:04:05 -0700277 msm_clock_init(&msm9615_clock_init_data);
Matt Wagantall44f672e2011-09-07 20:31:16 -0700278 acpuclk_init(&acpuclk_9615_soc_data);
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700279}
280
281void __init msm9615_map_io(void)
282{
283 msm_map_msm9615_io();
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -0700284 l2x0_cache_init();
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700285}
286
287void __init msm9615_init_irq(void)
288{
289 unsigned int i;
290 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
291 (void *)MSM_QGIC_CPU_BASE);
292
293 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
294 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
295
296 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
297 mb();
298
299 /*
300 * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
301 * as they are configured as level, which does not play nice with
302 * handle_percpu_irq.
303 */
304 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
305 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
306 irq_set_handler(i, handle_percpu_irq);
307 }
308}