blob: f6a354f1712a6f6ee6dff2328cf8684d962b9143 [file] [log] [blame]
Rohit Vaswani3fc60342012-04-23 18:55:15 -07001/* Copyright (c) 2012, 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#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/io.h>
16#include <linux/irq.h>
17#include <linux/irqdomain.h>
18#include <linux/of.h>
19#include <linux/of_address.h>
20#include <linux/of_platform.h>
21#include <linux/of_irq.h>
22#include <linux/memory.h>
23#include <asm/mach/map.h>
24#include <asm/hardware/gic.h>
Rohit Vaswani3fc60342012-04-23 18:55:15 -070025#include <asm/mach/arch.h>
Rohit Vaswani3fc60342012-04-23 18:55:15 -070026#include <mach/socinfo.h>
27#include <mach/board.h>
Abhimanyu Kapur46e5e2b2012-10-02 20:45:37 -070028#include <mach/restart.h>
Rohit Vaswani3fc60342012-04-23 18:55:15 -070029#include <mach/gpio.h>
Matt Wagantall33d01f52012-02-23 23:27:44 -080030#include <mach/clk-provider.h>
David Collinsc407db82012-09-17 14:11:55 -070031#include <mach/qpnp-int.h>
Mitchel Humpherys385c24d2012-10-02 16:57:02 -070032#include <mach/msm_memtypes.h>
Jeff Hugod7572e52012-09-17 16:00:40 -060033#include <mach/msm_iomap.h>
34#include <mach/msm_smd.h>
Girish Mahadevand8179212012-09-19 11:50:57 -060035#include <mach/rpm-smd.h>
David Collins757c4282012-09-24 10:45:40 -070036#include <mach/rpm-regulator-smd.h>
Rohit Vaswani7af3b532012-09-21 10:54:49 -070037#include "board-dt.h"
Gagan Mac8a7324c2012-10-11 19:23:16 -060038#include <mach/msm_bus_board.h>
Rohit Vaswani3fc60342012-04-23 18:55:15 -070039#include "clock.h"
Jeff Hugod7572e52012-09-17 16:00:40 -060040#include "modem_notifier.h"
Girish Mahadevan6ea975e2012-09-19 12:36:36 -060041#include "lpm_resources.h"
42#include "spm.h"
Rohit Vaswani3fc60342012-04-23 18:55:15 -070043
Mitchel Humpherys385c24d2012-10-02 16:57:02 -070044#define MSM_KERNEL_EBI_SIZE 0x51000
45
46static struct memtype_reserve msm9625_reserve_table[] __initdata = {
47 [MEMTYPE_SMI] = {
48 },
49 [MEMTYPE_EBI0] = {
50 .flags = MEMTYPE_FLAGS_1M_ALIGN,
51 },
52 [MEMTYPE_EBI1] = {
53 .flags = MEMTYPE_FLAGS_1M_ALIGN,
54 },
55};
56
57static int msm9625_paddr_to_memtype(unsigned int paddr)
58{
59 return MEMTYPE_EBI1;
60}
61
62static void __init msm9625_calculate_reserve_sizes(void)
63{
64 msm9625_reserve_table[MEMTYPE_EBI1].size += MSM_KERNEL_EBI_SIZE;
65}
66
67static struct reserve_info msm9625_reserve_info __initdata = {
68 .memtype_reserve_table = msm9625_reserve_table,
69 .calculate_reserve_sizes = msm9625_calculate_reserve_sizes,
70 .paddr_to_memtype = msm9625_paddr_to_memtype,
71};
72
Rohit Vaswani3fc60342012-04-23 18:55:15 -070073static struct clk_lookup msm_clocks_dummy[] = {
Jin Hong8d328582012-05-01 15:45:29 -070074 CLK_DUMMY("core_clk", BLSP1_UART_CLK, "msm_serial_hsl.0", OFF),
75 CLK_DUMMY("iface_clk", BLSP1_UART_CLK, "msm_serial_hsl.0", OFF),
Rohit Vaswani3fc60342012-04-23 18:55:15 -070076 CLK_DUMMY("phy_clk", NULL, "msm_otg", OFF),
77 CLK_DUMMY("core_clk", NULL, "msm_otg", OFF),
78 CLK_DUMMY("alt_core_clk", NULL, "msm_otg", OFF),
79 CLK_DUMMY("iface_clk", NULL, "msm_otg", OFF),
80 CLK_DUMMY("xo", NULL, "msm_otg", OFF),
81 CLK_DUMMY("dfab_clk", DFAB_CLK, NULL, 0),
82 CLK_DUMMY("dma_bam_pclk", DMA_BAM_P_CLK, NULL, 0),
83 CLK_DUMMY("mem_clk", NULL, NULL, 0),
Rohit Vaswani0045df42012-06-29 16:21:48 -070084 CLK_DUMMY("core_clk", SPI_CLK, "spi_qsd.1", OFF),
85 CLK_DUMMY("iface_clk", SPI_P_CLK, "spi_qsd.1", OFF),
Rohit Vaswani3fc60342012-04-23 18:55:15 -070086 CLK_DUMMY("core_clk", NULL, "f9966000.i2c", 0),
87 CLK_DUMMY("iface_clk", NULL, "f9966000.i2c", 0),
88 CLK_DUMMY("core_clk", NULL, "fe12f000.slim", OFF),
89};
90
91struct clock_init_data msm_dummy_clock_init_data __initdata = {
92 .table = msm_clocks_dummy,
93 .size = ARRAY_SIZE(msm_clocks_dummy),
94};
95
Rohit Vaswani3fc60342012-04-23 18:55:15 -070096static const char *msm9625_dt_match[] __initconst = {
97 "qcom,msm9625",
98 NULL
99};
100
101static struct of_dev_auxdata msm9625_auxdata_lookup[] __initdata = {
Jin Hong8d328582012-05-01 15:45:29 -0700102 OF_DEV_AUXDATA("qcom,msm-lsuart-v14", 0xF991F000, \
103 "msm_serial_hsl.0", NULL),
Kenneth Heitkec2642402012-09-18 18:56:47 -0600104 OF_DEV_AUXDATA("qcom,spmi-pmic-arb", 0xFC4C0000, \
105 "spmi-pmic-arb.0", NULL),
Oluwafemi Adeyemi61df1182012-10-12 18:51:11 -0700106 OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF98A4000, \
107 "msm_sdcc.2", NULL),
108 OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF9864000, \
109 "msm_sdcc.3", NULL),
Siddartha Mohanadossbcf5fe02012-10-25 20:06:51 -0700110 OF_DEV_AUXDATA("qcom,msm-tsens", 0xFC4A8000, \
111 "msm-tsens", NULL),
Jack Phamd61ff562012-11-21 19:25:53 +0200112 OF_DEV_AUXDATA("qcom,usb-bam-msm", 0xF9A44000, \
113 "usb_bam", NULL),
Rohit Vaswani3fc60342012-04-23 18:55:15 -0700114 {}
115};
116
Mitchel Humpherysc372fa9a2012-10-11 16:42:59 -0700117static void __init msm9625_early_memory(void)
Mitchel Humpherys385c24d2012-10-02 16:57:02 -0700118{
119 reserve_info = &msm9625_reserve_info;
Mitchel Humpherysc372fa9a2012-10-11 16:42:59 -0700120 of_scan_flat_dt(dt_scan_for_memory_reserve, msm9625_reserve_table);
121}
122
123static void __init msm9625_reserve(void)
124{
Mitchel Humpherys385c24d2012-10-02 16:57:02 -0700125 msm_reserve();
126}
127
Gagan Mac8a7324c2012-10-11 19:23:16 -0600128#define BIMC_BASE 0xfc380000
129#define BIMC_SIZE 0x0006A000
130#define SYS_NOC_BASE 0xfc460000
131#define PERIPH_NOC_BASE 0xFC468000
132#define CONFIG_NOC_BASE 0xfc480000
133#define NOC_SIZE 0x00004000
134
135static struct resource bimc_res[] = {
136 {
137 .start = BIMC_BASE,
138 .end = BIMC_BASE + BIMC_SIZE,
139 .flags = IORESOURCE_MEM,
140 .name = "bimc_mem",
141 },
142};
143
144static struct resource sys_noc_res[] = {
145 {
146 .start = SYS_NOC_BASE,
147 .end = SYS_NOC_BASE + NOC_SIZE,
148 .flags = IORESOURCE_MEM,
149 .name = "sys_noc_mem",
150 },
151};
152
153static struct resource config_noc_res[] = {
154 {
155 .start = CONFIG_NOC_BASE,
156 .end = CONFIG_NOC_BASE + NOC_SIZE,
157 .flags = IORESOURCE_MEM,
158 .name = "config_noc_mem",
159 },
160};
161
162static struct resource periph_noc_res[] = {
163 {
164 .start = PERIPH_NOC_BASE,
165 .end = PERIPH_NOC_BASE + NOC_SIZE,
166 .flags = IORESOURCE_MEM,
167 .name = "periph_noc_mem",
168 },
169};
170
171static struct platform_device msm_bus_sys_noc = {
172 .name = "msm_bus_fabric",
173 .id = MSM_BUS_FAB_SYS_NOC,
174 .num_resources = ARRAY_SIZE(sys_noc_res),
175 .resource = sys_noc_res,
176};
177
178static struct platform_device msm_bus_bimc = {
179 .name = "msm_bus_fabric",
180 .id = MSM_BUS_FAB_BIMC,
181 .num_resources = ARRAY_SIZE(bimc_res),
182 .resource = bimc_res,
183};
184
185static struct platform_device msm_bus_periph_noc = {
186 .name = "msm_bus_fabric",
187 .id = MSM_BUS_FAB_PERIPH_NOC,
188 .num_resources = ARRAY_SIZE(periph_noc_res),
189 .resource = periph_noc_res,
190};
191
192static struct platform_device msm_bus_config_noc = {
193 .name = "msm_bus_fabric",
194 .id = MSM_BUS_FAB_CONFIG_NOC,
195 .num_resources = ARRAY_SIZE(config_noc_res),
196 .resource = config_noc_res,
197};
198
199static struct platform_device *msm_bus_9625_devices[] = {
200 &msm_bus_sys_noc,
201 &msm_bus_bimc,
202 &msm_bus_periph_noc,
203 &msm_bus_config_noc,
204};
205
206static void __init msm9625_init_buses(void)
207{
208#ifdef CONFIG_MSM_BUS_SCALING
209 msm_bus_sys_noc.dev.platform_data =
210 &msm_bus_9625_sys_noc_pdata;
211 msm_bus_bimc.dev.platform_data = &msm_bus_9625_bimc_pdata;
212 msm_bus_periph_noc.dev.platform_data = &msm_bus_9625_periph_noc_pdata;
213 msm_bus_config_noc.dev.platform_data = &msm_bus_9625_config_noc_pdata;
214#endif
215 platform_add_devices(msm_bus_9625_devices,
216 ARRAY_SIZE(msm_bus_9625_devices));
217}
218
Jeff Hugod7572e52012-09-17 16:00:40 -0600219/*
220 * Used to satisfy dependencies for devices that need to be
221 * run early or in a particular order. Most likely your device doesn't fall
222 * into this category, and thus the driver should not be added here.
223 * EPROBE_DEFER can satisfy most dependency problems.
224 */
225void __init msm9625_add_drivers(void)
226{
227 msm_init_modem_notifier_list();
228 msm_smd_init();
Girish Mahadevand8179212012-09-19 11:50:57 -0600229 msm_rpm_driver_init();
Girish Mahadevan6ea975e2012-09-19 12:36:36 -0600230 msm_lpmrs_module_init();
David Collins757c4282012-09-24 10:45:40 -0700231 rpm_regulator_smd_driver_init();
Girish Mahadevan6ea975e2012-09-19 12:36:36 -0600232 msm_spm_device_init();
Tianyi Gou389ba432012-10-01 13:58:38 -0700233 msm_clock_init(&msm9625_clock_init_data);
Gagan Mac8a7324c2012-10-11 19:23:16 -0600234 msm9625_init_buses();
Jeff Hugod7572e52012-09-17 16:00:40 -0600235}
Mitchel Humpherys385c24d2012-10-02 16:57:02 -0700236
Rohit Vaswani3fc60342012-04-23 18:55:15 -0700237void __init msm9625_init(void)
238{
239 if (socinfo_init() < 0)
240 pr_err("%s: socinfo_init() failed\n", __func__);
Rohit Vaswani5a06e792012-06-29 16:03:23 -0700241
242 msm9625_init_gpiomux();
Rohit Vaswani3fc60342012-04-23 18:55:15 -0700243 of_platform_populate(NULL, of_default_bus_match_table,
244 msm9625_auxdata_lookup, NULL);
Jeff Hugod7572e52012-09-17 16:00:40 -0600245 msm9625_add_drivers();
Rohit Vaswani3fc60342012-04-23 18:55:15 -0700246}
247
Rohit Vaswani7af3b532012-09-21 10:54:49 -0700248DT_MACHINE_START(MSM9625_DT, "Qualcomm MSM 9625 (Flattened Device Tree)")
Rohit Vaswani3fc60342012-04-23 18:55:15 -0700249 .map_io = msm_map_msm9625_io,
Rohit Vaswani7af3b532012-09-21 10:54:49 -0700250 .init_irq = msm_dt_init_irq_l2x0,
Rohit Vaswani3fc60342012-04-23 18:55:15 -0700251 .init_machine = msm9625_init,
252 .handle_irq = gic_handle_irq,
253 .timer = &msm_dt_timer,
254 .dt_compat = msm9625_dt_match,
Mitchel Humpherys385c24d2012-10-02 16:57:02 -0700255 .reserve = msm9625_reserve,
Mitchel Humpherysc372fa9a2012-10-11 16:42:59 -0700256 .init_very_early = msm9625_early_memory,
Abhimanyu Kapur46e5e2b2012-10-02 20:45:37 -0700257 .restart = msm_restart,
Rohit Vaswani3fc60342012-04-23 18:55:15 -0700258MACHINE_END