blob: d1147142a7b45471ac3fa8e8f357585a46dc391b [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>
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 Vaswanif0ce9ae2011-08-23 22:18:38 -070023#include <asm/hardware/cache-l2x0.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070024#include "devices.h"
25
Harini Jayaramaneba52672011-09-08 15:13:00 -060026/* Address of GSBI blocks */
27#define MSM_GSBI1_PHYS 0x16000000
28#define MSM_GSBI2_PHYS 0x16100000
29#define MSM_GSBI3_PHYS 0x16200000
Rohit Vaswani09666872011-08-23 17:41:54 -070030#define MSM_GSBI4_PHYS 0x16300000
Harini Jayaramaneba52672011-09-08 15:13:00 -060031#define MSM_GSBI5_PHYS 0x16400000
32
Rohit Vaswani09666872011-08-23 17:41:54 -070033#define MSM_UART4DM_PHYS (MSM_GSBI4_PHYS + 0x40000)
34
Harini Jayaramaneba52672011-09-08 15:13:00 -060035/* GSBI QUP devices */
36#define MSM_GSBI1_QUP_PHYS (MSM_GSBI1_PHYS + 0x80000)
37#define MSM_GSBI2_QUP_PHYS (MSM_GSBI2_PHYS + 0x80000)
38#define MSM_GSBI3_QUP_PHYS (MSM_GSBI3_PHYS + 0x80000)
39#define MSM_GSBI4_QUP_PHYS (MSM_GSBI4_PHYS + 0x80000)
40#define MSM_GSBI5_QUP_PHYS (MSM_GSBI5_PHYS + 0x80000)
41#define MSM_QUP_SIZE SZ_4K
42
Rohit Vaswani09666872011-08-23 17:41:54 -070043static struct resource resources_uart_gsbi4[] = {
44 {
45 .start = GSBI4_UARTDM_IRQ,
46 .end = GSBI4_UARTDM_IRQ,
47 .flags = IORESOURCE_IRQ,
48 },
49 {
50 .start = MSM_UART4DM_PHYS,
51 .end = MSM_UART4DM_PHYS + PAGE_SIZE - 1,
52 .name = "uartdm_resource",
53 .flags = IORESOURCE_MEM,
54 },
55 {
56 .start = MSM_GSBI4_PHYS,
57 .end = MSM_GSBI4_PHYS + PAGE_SIZE - 1,
58 .name = "gsbi_resource",
59 .flags = IORESOURCE_MEM,
60 },
61};
62
63struct platform_device msm9615_device_uart_gsbi4 = {
64 .name = "msm_serial_hsl",
65 .id = 0,
66 .num_resources = ARRAY_SIZE(resources_uart_gsbi4),
67 .resource = resources_uart_gsbi4,
68};
69
Harini Jayaramaneba52672011-09-08 15:13:00 -060070static struct resource resources_qup_i2c_gsbi5[] = {
71 {
72 .name = "gsbi_qup_i2c_addr",
73 .start = MSM_GSBI5_PHYS,
74 .end = MSM_GSBI5_PHYS + MSM_QUP_SIZE - 1,
75 .flags = IORESOURCE_MEM,
76 },
77 {
78 .name = "qup_phys_addr",
79 .start = MSM_GSBI5_QUP_PHYS,
80 .end = MSM_GSBI5_QUP_PHYS + 4 - 1,
81 .flags = IORESOURCE_MEM,
82 },
83 {
84 .name = "qup_err_intr",
85 .start = GSBI5_QUP_IRQ,
86 .end = GSBI5_QUP_IRQ,
87 .flags = IORESOURCE_IRQ,
88 },
89};
90
91struct platform_device msm9615_device_qup_i2c_gsbi5 = {
92 .name = "qup_i2c",
93 .id = 0,
94 .num_resources = ARRAY_SIZE(resources_qup_i2c_gsbi5),
95 .resource = resources_qup_i2c_gsbi5,
96};
97
Harini Jayaraman738c9312011-09-08 15:22:38 -060098static struct resource resources_qup_spi_gsbi3[] = {
99 {
100 .name = "spi_base",
101 .start = MSM_GSBI3_QUP_PHYS,
102 .end = MSM_GSBI3_QUP_PHYS + SZ_4K - 1,
103 .flags = IORESOURCE_MEM,
104 },
105 {
106 .name = "gsbi_base",
107 .start = MSM_GSBI3_PHYS,
108 .end = MSM_GSBI3_PHYS + 4 - 1,
109 .flags = IORESOURCE_MEM,
110 },
111 {
112 .name = "spi_irq_in",
113 .start = GSBI3_QUP_IRQ,
114 .end = GSBI3_QUP_IRQ,
115 .flags = IORESOURCE_IRQ,
116 },
117};
118
119struct platform_device msm9615_device_qup_spi_gsbi3 = {
120 .name = "spi_qsd",
121 .id = 0,
122 .num_resources = ARRAY_SIZE(resources_qup_spi_gsbi3),
123 .resource = resources_qup_spi_gsbi3,
124};
125
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -0700126#ifdef CONFIG_CACHE_L2X0
127static int __init l2x0_cache_init(void)
128{
129 int aux_ctrl = 0;
130
131 /* Way Size 010(0x2) 32KB */
132 aux_ctrl = (0x1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | \
133 (0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | \
134 (0x1 << L2X0_AUX_CTRL_EVNT_MON_BUS_EN_SHIFT);
135
136 /* L2 Latency setting required by hardware. Default is 0x20
137 which is no good.
138 */
139 writel_relaxed(0x220, MSM_L2CC_BASE + L2X0_DATA_LATENCY_CTRL);
140 l2x0_init(MSM_L2CC_BASE, aux_ctrl, L2X0_AUX_CTRL_MASK);
141
142 return 0;
143}
144#else
145static int __init l2x0_cache_init(void){ return 0; }
146#endif
147
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700148void __init msm9615_device_init(void)
149{
150 if (socinfo_init() < 0)
151 pr_err("socinfo_init() failed!\n");
152
Vikram Mulukutla489e39e2011-08-31 18:04:05 -0700153 msm_clock_init(&msm9615_clock_init_data);
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700154}
155
156void __init msm9615_map_io(void)
157{
158 msm_map_msm9615_io();
Rohit Vaswanif0ce9ae2011-08-23 22:18:38 -0700159 l2x0_cache_init();
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700160}
161
162void __init msm9615_init_irq(void)
163{
164 unsigned int i;
165 gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
166 (void *)MSM_QGIC_CPU_BASE);
167
168 /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */
169 writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4);
170
171 writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET);
172 mb();
173
174 /*
175 * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet
176 * as they are configured as level, which does not play nice with
177 * handle_percpu_irq.
178 */
179 for (i = GIC_PPI_START; i < GIC_SPI_START; i++) {
180 if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE)
181 irq_set_handler(i, handle_percpu_irq);
182 }
183}