Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 1 | /* 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 Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 25 | #include <asm/mach/arch.h> |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 26 | #include <mach/socinfo.h> |
| 27 | #include <mach/board.h> |
Abhimanyu Kapur | 46e5e2b | 2012-10-02 20:45:37 -0700 | [diff] [blame] | 28 | #include <mach/restart.h> |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 29 | #include <mach/gpio.h> |
Matt Wagantall | 33d01f5 | 2012-02-23 23:27:44 -0800 | [diff] [blame] | 30 | #include <mach/clk-provider.h> |
David Collins | c407db8 | 2012-09-17 14:11:55 -0700 | [diff] [blame] | 31 | #include <mach/qpnp-int.h> |
Mitchel Humpherys | 385c24d | 2012-10-02 16:57:02 -0700 | [diff] [blame] | 32 | #include <mach/msm_memtypes.h> |
Jeff Hugo | d7572e5 | 2012-09-17 16:00:40 -0600 | [diff] [blame] | 33 | #include <mach/msm_iomap.h> |
| 34 | #include <mach/msm_smd.h> |
Girish Mahadevan | d817921 | 2012-09-19 11:50:57 -0600 | [diff] [blame] | 35 | #include <mach/rpm-smd.h> |
David Collins | 757c428 | 2012-09-24 10:45:40 -0700 | [diff] [blame] | 36 | #include <mach/rpm-regulator-smd.h> |
Rohit Vaswani | 7af3b53 | 2012-09-21 10:54:49 -0700 | [diff] [blame] | 37 | #include "board-dt.h" |
Gagan Mac | 8a7324c | 2012-10-11 19:23:16 -0600 | [diff] [blame] | 38 | #include <mach/msm_bus_board.h> |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 39 | #include "clock.h" |
Jeff Hugo | d7572e5 | 2012-09-17 16:00:40 -0600 | [diff] [blame] | 40 | #include "modem_notifier.h" |
Girish Mahadevan | 6ea975e | 2012-09-19 12:36:36 -0600 | [diff] [blame] | 41 | #include "lpm_resources.h" |
| 42 | #include "spm.h" |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 43 | |
Mitchel Humpherys | 385c24d | 2012-10-02 16:57:02 -0700 | [diff] [blame] | 44 | #define MSM_KERNEL_EBI_SIZE 0x51000 |
| 45 | |
| 46 | static 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 | |
| 57 | static int msm9625_paddr_to_memtype(unsigned int paddr) |
| 58 | { |
| 59 | return MEMTYPE_EBI1; |
| 60 | } |
| 61 | |
| 62 | static void __init msm9625_calculate_reserve_sizes(void) |
| 63 | { |
| 64 | msm9625_reserve_table[MEMTYPE_EBI1].size += MSM_KERNEL_EBI_SIZE; |
| 65 | } |
| 66 | |
| 67 | static 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 Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 73 | static struct clk_lookup msm_clocks_dummy[] = { |
Jin Hong | 8d32858 | 2012-05-01 15:45:29 -0700 | [diff] [blame] | 74 | 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 Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 76 | 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 Vaswani | 0045df4 | 2012-06-29 16:21:48 -0700 | [diff] [blame] | 84 | CLK_DUMMY("core_clk", SPI_CLK, "spi_qsd.1", OFF), |
| 85 | CLK_DUMMY("iface_clk", SPI_P_CLK, "spi_qsd.1", OFF), |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 86 | 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 | |
| 91 | struct clock_init_data msm_dummy_clock_init_data __initdata = { |
| 92 | .table = msm_clocks_dummy, |
| 93 | .size = ARRAY_SIZE(msm_clocks_dummy), |
| 94 | }; |
| 95 | |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 96 | static const char *msm9625_dt_match[] __initconst = { |
| 97 | "qcom,msm9625", |
| 98 | NULL |
| 99 | }; |
| 100 | |
| 101 | static struct of_dev_auxdata msm9625_auxdata_lookup[] __initdata = { |
Jin Hong | 8d32858 | 2012-05-01 15:45:29 -0700 | [diff] [blame] | 102 | OF_DEV_AUXDATA("qcom,msm-lsuart-v14", 0xF991F000, \ |
| 103 | "msm_serial_hsl.0", NULL), |
Kenneth Heitke | c264240 | 2012-09-18 18:56:47 -0600 | [diff] [blame] | 104 | OF_DEV_AUXDATA("qcom,spmi-pmic-arb", 0xFC4C0000, \ |
| 105 | "spmi-pmic-arb.0", NULL), |
Oluwafemi Adeyemi | 61df118 | 2012-10-12 18:51:11 -0700 | [diff] [blame] | 106 | 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 Mohanadoss | bcf5fe0 | 2012-10-25 20:06:51 -0700 | [diff] [blame] | 110 | OF_DEV_AUXDATA("qcom,msm-tsens", 0xFC4A8000, \ |
| 111 | "msm-tsens", NULL), |
Jack Pham | d61ff56 | 2012-11-21 19:25:53 +0200 | [diff] [blame] | 112 | OF_DEV_AUXDATA("qcom,usb-bam-msm", 0xF9A44000, \ |
| 113 | "usb_bam", NULL), |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 114 | {} |
| 115 | }; |
| 116 | |
Mitchel Humpherys | c372fa9a | 2012-10-11 16:42:59 -0700 | [diff] [blame] | 117 | static void __init msm9625_early_memory(void) |
Mitchel Humpherys | 385c24d | 2012-10-02 16:57:02 -0700 | [diff] [blame] | 118 | { |
| 119 | reserve_info = &msm9625_reserve_info; |
Mitchel Humpherys | c372fa9a | 2012-10-11 16:42:59 -0700 | [diff] [blame] | 120 | of_scan_flat_dt(dt_scan_for_memory_reserve, msm9625_reserve_table); |
| 121 | } |
| 122 | |
| 123 | static void __init msm9625_reserve(void) |
| 124 | { |
Mitchel Humpherys | 385c24d | 2012-10-02 16:57:02 -0700 | [diff] [blame] | 125 | msm_reserve(); |
| 126 | } |
| 127 | |
Gagan Mac | 8a7324c | 2012-10-11 19:23:16 -0600 | [diff] [blame] | 128 | #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 | |
| 135 | static 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 | |
| 144 | static 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 | |
| 153 | static 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 | |
| 162 | static 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 | |
| 171 | static 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 | |
| 178 | static 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 | |
| 185 | static 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 | |
| 192 | static 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 | |
| 199 | static 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 | |
| 206 | static 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 Hugo | d7572e5 | 2012-09-17 16:00:40 -0600 | [diff] [blame] | 219 | /* |
| 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 | */ |
| 225 | void __init msm9625_add_drivers(void) |
| 226 | { |
| 227 | msm_init_modem_notifier_list(); |
| 228 | msm_smd_init(); |
Girish Mahadevan | d817921 | 2012-09-19 11:50:57 -0600 | [diff] [blame] | 229 | msm_rpm_driver_init(); |
Girish Mahadevan | 6ea975e | 2012-09-19 12:36:36 -0600 | [diff] [blame] | 230 | msm_lpmrs_module_init(); |
David Collins | 757c428 | 2012-09-24 10:45:40 -0700 | [diff] [blame] | 231 | rpm_regulator_smd_driver_init(); |
Girish Mahadevan | 6ea975e | 2012-09-19 12:36:36 -0600 | [diff] [blame] | 232 | msm_spm_device_init(); |
Tianyi Gou | 389ba43 | 2012-10-01 13:58:38 -0700 | [diff] [blame] | 233 | msm_clock_init(&msm9625_clock_init_data); |
Gagan Mac | 8a7324c | 2012-10-11 19:23:16 -0600 | [diff] [blame] | 234 | msm9625_init_buses(); |
Jeff Hugo | d7572e5 | 2012-09-17 16:00:40 -0600 | [diff] [blame] | 235 | } |
Mitchel Humpherys | 385c24d | 2012-10-02 16:57:02 -0700 | [diff] [blame] | 236 | |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 237 | void __init msm9625_init(void) |
| 238 | { |
| 239 | if (socinfo_init() < 0) |
| 240 | pr_err("%s: socinfo_init() failed\n", __func__); |
Rohit Vaswani | 5a06e79 | 2012-06-29 16:03:23 -0700 | [diff] [blame] | 241 | |
| 242 | msm9625_init_gpiomux(); |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 243 | of_platform_populate(NULL, of_default_bus_match_table, |
| 244 | msm9625_auxdata_lookup, NULL); |
Jeff Hugo | d7572e5 | 2012-09-17 16:00:40 -0600 | [diff] [blame] | 245 | msm9625_add_drivers(); |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 246 | } |
| 247 | |
Rohit Vaswani | 7af3b53 | 2012-09-21 10:54:49 -0700 | [diff] [blame] | 248 | DT_MACHINE_START(MSM9625_DT, "Qualcomm MSM 9625 (Flattened Device Tree)") |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 249 | .map_io = msm_map_msm9625_io, |
Rohit Vaswani | 7af3b53 | 2012-09-21 10:54:49 -0700 | [diff] [blame] | 250 | .init_irq = msm_dt_init_irq_l2x0, |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 251 | .init_machine = msm9625_init, |
| 252 | .handle_irq = gic_handle_irq, |
| 253 | .timer = &msm_dt_timer, |
| 254 | .dt_compat = msm9625_dt_match, |
Mitchel Humpherys | 385c24d | 2012-10-02 16:57:02 -0700 | [diff] [blame] | 255 | .reserve = msm9625_reserve, |
Mitchel Humpherys | c372fa9a | 2012-10-11 16:42:59 -0700 | [diff] [blame] | 256 | .init_very_early = msm9625_early_memory, |
Abhimanyu Kapur | 46e5e2b | 2012-10-02 20:45:37 -0700 | [diff] [blame] | 257 | .restart = msm_restart, |
Rohit Vaswani | 3fc6034 | 2012-04-23 18:55:15 -0700 | [diff] [blame] | 258 | MACHINE_END |