Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* 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 | #include <linux/kernel.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/io.h> |
| 16 | #include <linux/irq.h> |
Kenneth Heitke | 748593a | 2011-07-15 15:45:11 -0600 | [diff] [blame] | 17 | #include <linux/i2c.h> |
Kenneth Heitke | 36920d3 | 2011-07-20 16:44:30 -0600 | [diff] [blame] | 18 | #include <linux/msm_ssbi.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 19 | #include <asm/mach-types.h> |
| 20 | #include <asm/mach/arch.h> |
| 21 | #include <asm/hardware/gic.h> |
Sahitya Tummala | 3586ed9 | 2011-08-03 09:13:23 +0530 | [diff] [blame] | 22 | #include <asm/mach/mmc.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 23 | |
| 24 | #include <mach/board.h> |
| 25 | #include <mach/msm_iomap.h> |
| 26 | #include <linux/usb/msm_hsusb.h> |
| 27 | #include <linux/usb/android.h> |
| 28 | #include <mach/socinfo.h> |
Harini Jayaraman | c4c5869 | 2011-07-19 14:50:10 -0600 | [diff] [blame] | 29 | #include <mach/msm_spi.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 30 | #include "timer.h" |
| 31 | #include "devices.h" |
Joel King | 4ebccc6 | 2011-07-22 09:43:22 -0700 | [diff] [blame] | 32 | #include <mach/gpio.h> |
| 33 | #include <mach/gpiomux.h> |
| 34 | |
Jay Chokshi | ea67c62 | 2011-07-29 17:12:26 -0700 | [diff] [blame] | 35 | #include "board-apq8064.h" |
| 36 | |
Joel King | 4ebccc6 | 2011-07-22 09:43:22 -0700 | [diff] [blame] | 37 | static int __init gpiomux_init(void) |
| 38 | { |
| 39 | int rc; |
| 40 | |
| 41 | rc = msm_gpiomux_init(NR_GPIO_IRQS); |
| 42 | if (rc) { |
| 43 | pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc); |
| 44 | return rc; |
| 45 | } |
| 46 | return 0; |
| 47 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 48 | |
Sahitya Tummala | 3586ed9 | 2011-08-03 09:13:23 +0530 | [diff] [blame] | 49 | #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT |
| 50 | static unsigned int sdc1_sup_clk_rates[] = { |
| 51 | 400000, 24000000, 48000000, 96000000 |
| 52 | }; |
| 53 | |
| 54 | static struct mmc_platform_data sdc1_data = { |
| 55 | .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, |
| 56 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 57 | .sup_clk_table = sdc1_sup_clk_rates, |
| 58 | .sup_clk_cnt = ARRAY_SIZE(sdc1_sup_clk_rates), |
| 59 | }; |
| 60 | static struct mmc_platform_data *apq8064_sdc1_pdata = &sdc1_data; |
| 61 | #else |
| 62 | static struct mmc_platform_data *apq8064_sdc1_pdata; |
| 63 | #endif |
| 64 | |
| 65 | #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT |
| 66 | static unsigned int sdc3_sup_clk_rates[] = { |
| 67 | 400000, 24000000, 48000000, 96000000 |
| 68 | }; |
| 69 | |
| 70 | static struct mmc_platform_data sdc3_data = { |
| 71 | .ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, |
| 72 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 73 | .sup_clk_table = sdc3_sup_clk_rates, |
| 74 | .sup_clk_cnt = ARRAY_SIZE(sdc3_sup_clk_rates), |
| 75 | }; |
| 76 | static struct mmc_platform_data *apq8064_sdc3_pdata = &sdc3_data; |
| 77 | #else |
| 78 | static struct mmc_platform_data *apq8064_sdc3_pdata; |
| 79 | #endif |
| 80 | |
| 81 | static void __init apq8064_init_mmc(void) |
| 82 | { |
Amol Jadi | 7d4ce03 | 2011-09-09 17:07:18 -0700 | [diff] [blame] | 83 | if ((machine_is_apq8064_rumi3()) || machine_is_apq8064_sim()) { |
Sahitya Tummala | b07e1ae | 2011-09-02 11:58:42 +0530 | [diff] [blame] | 84 | if (apq8064_sdc1_pdata) { |
Sahitya Tummala | d9df327 | 2011-08-19 16:50:46 +0530 | [diff] [blame] | 85 | apq8064_sdc1_pdata->disable_bam = true; |
Sahitya Tummala | b07e1ae | 2011-09-02 11:58:42 +0530 | [diff] [blame] | 86 | apq8064_sdc1_pdata->disable_runtime_pm = true; |
| 87 | } |
| 88 | if (apq8064_sdc3_pdata) { |
Sahitya Tummala | d9df327 | 2011-08-19 16:50:46 +0530 | [diff] [blame] | 89 | apq8064_sdc3_pdata->disable_bam = true; |
Sahitya Tummala | b07e1ae | 2011-09-02 11:58:42 +0530 | [diff] [blame] | 90 | apq8064_sdc3_pdata->disable_runtime_pm = true; |
| 91 | } |
Sahitya Tummala | d9df327 | 2011-08-19 16:50:46 +0530 | [diff] [blame] | 92 | } |
Sahitya Tummala | 3586ed9 | 2011-08-03 09:13:23 +0530 | [diff] [blame] | 93 | apq8064_add_sdcc(1, apq8064_sdc1_pdata); |
| 94 | apq8064_add_sdcc(3, apq8064_sdc3_pdata); |
| 95 | } |
| 96 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 97 | static void __init apq8064_map_io(void) |
| 98 | { |
| 99 | msm_map_apq8064_io(); |
| 100 | } |
| 101 | |
| 102 | static void __init apq8064_init_irq(void) |
| 103 | { |
| 104 | unsigned int i; |
| 105 | gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE, |
| 106 | (void *)MSM_QGIC_CPU_BASE); |
| 107 | |
| 108 | /* Edge trigger PPIs except AVS_SVICINT and AVS_SVICINTSWDONE */ |
| 109 | writel_relaxed(0xFFFFD7FF, MSM_QGIC_DIST_BASE + GIC_DIST_CONFIG + 4); |
| 110 | |
| 111 | writel_relaxed(0x0000FFFF, MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_SET); |
| 112 | mb(); |
| 113 | |
| 114 | /* |
| 115 | * FIXME: Not installing AVS_SVICINT and AVS_SVICINTSWDONE yet |
| 116 | * as they are configured as level, which does not play nice with |
| 117 | * handle_percpu_irq. |
| 118 | */ |
| 119 | for (i = GIC_PPI_START; i < GIC_SPI_START; i++) { |
| 120 | if (i != AVS_SVICINT && i != AVS_SVICINTSWDONE) |
| 121 | irq_set_handler(i, handle_percpu_irq); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | static struct platform_device *common_devices[] __initdata = { |
Kenneth Heitke | 748593a | 2011-07-15 15:45:11 -0600 | [diff] [blame] | 126 | &apq8064_device_qup_i2c_gsbi4, |
Harini Jayaraman | c4c5869 | 2011-07-19 14:50:10 -0600 | [diff] [blame] | 127 | &apq8064_device_qup_spi_gsbi5, |
| 128 | }; |
| 129 | |
Joel King | 4e7ad22 | 2011-08-17 15:47:38 -0700 | [diff] [blame] | 130 | static struct platform_device *sim_devices[] __initdata = { |
| 131 | &apq8064_device_dmov, |
Stepan Moskovchenko | 2701a44 | 2011-08-19 13:47:22 -0700 | [diff] [blame] | 132 | &apq8064_device_uart_gsbi3, |
Stepan Moskovchenko | 250557b | 2011-09-01 12:26:50 -0700 | [diff] [blame] | 133 | &apq8064_device_ssbi_pmic1, |
| 134 | &apq8064_device_ssbi_pmic2, |
Stepan Moskovchenko | 2701a44 | 2011-08-19 13:47:22 -0700 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | static struct platform_device *rumi3_devices[] __initdata = { |
| 138 | &apq8064_device_uart_gsbi1, |
Joel King | 4e7ad22 | 2011-08-17 15:47:38 -0700 | [diff] [blame] | 139 | }; |
| 140 | |
Harini Jayaraman | c4c5869 | 2011-07-19 14:50:10 -0600 | [diff] [blame] | 141 | static struct msm_spi_platform_data apq8064_qup_spi_gsbi5_pdata = { |
| 142 | .max_clock_speed = 26000000, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | static struct msm_otg_platform_data msm_otg_pdata = { |
| 146 | .mode = USB_PERIPHERAL, |
| 147 | .otg_control = OTG_PHY_CONTROL, |
| 148 | .phy_type = SNPS_28NM_INTEGRATED_PHY, |
| 149 | .pclk_src_name = "dfab_usb_hs_clk", |
| 150 | }; |
| 151 | |
Jay Chokshi | bc3d98d | 2011-08-10 17:14:23 -0700 | [diff] [blame] | 152 | static struct pm8xxx_mpp_platform_data |
| 153 | apq8064_pm8921_mpp_pdata __devinitdata = { |
| 154 | .mpp_base = PM8921_MPP_PM_TO_SYS(1), |
| 155 | }; |
| 156 | |
| 157 | static struct pm8xxx_gpio_platform_data |
| 158 | apq8064_pm8921_gpio_pdata __devinitdata = { |
| 159 | .gpio_base = PM8921_GPIO_PM_TO_SYS(1), |
| 160 | }; |
| 161 | |
| 162 | static struct pm8xxx_irq_platform_data |
| 163 | apq8064_pm8921_irq_pdata __devinitdata = { |
| 164 | .irq_base = PM8921_IRQ_BASE, |
Jay Chokshi | 44873f7 | 2011-08-30 17:24:26 -0700 | [diff] [blame^] | 165 | .devirq = PM8921_USR_IRQ_N, |
| 166 | .irq_trigger_flag = IRQF_TRIGGER_HIGH, |
Jay Chokshi | bc3d98d | 2011-08-10 17:14:23 -0700 | [diff] [blame] | 167 | }; |
| 168 | |
| 169 | static struct pm8921_platform_data |
| 170 | apq8064_pm8921_platform_data __devinitdata = { |
Jay Chokshi | ea67c62 | 2011-07-29 17:12:26 -0700 | [diff] [blame] | 171 | .regulator_pdatas = msm8064_pm8921_regulator_pdata, |
Jay Chokshi | bc3d98d | 2011-08-10 17:14:23 -0700 | [diff] [blame] | 172 | .irq_pdata = &apq8064_pm8921_irq_pdata, |
| 173 | .gpio_pdata = &apq8064_pm8921_gpio_pdata, |
| 174 | .mpp_pdata = &apq8064_pm8921_mpp_pdata, |
Jay Chokshi | ea67c62 | 2011-07-29 17:12:26 -0700 | [diff] [blame] | 175 | }; |
| 176 | |
Jay Chokshi | 44873f7 | 2011-08-30 17:24:26 -0700 | [diff] [blame^] | 177 | static struct pm8xxx_irq_platform_data |
| 178 | apq8064_pm8821_irq_pdata __devinitdata = { |
| 179 | .irq_base = PM8821_IRQ_BASE, |
| 180 | .devirq = PM8821_USR_IRQ_N, |
| 181 | .irq_trigger_flag = IRQF_TRIGGER_HIGH, |
| 182 | }; |
| 183 | |
| 184 | static struct pm8xxx_mpp_platform_data |
| 185 | apq8064_pm8821_mpp_pdata __devinitdata = { |
| 186 | .mpp_base = PM8821_MPP_PM_TO_SYS(1), |
| 187 | }; |
| 188 | |
| 189 | static struct pm8821_platform_data |
| 190 | apq8064_pm8821_platform_data __devinitdata = { |
| 191 | .irq_pdata = &apq8064_pm8821_irq_pdata, |
| 192 | .mpp_pdata = &apq8064_pm8821_mpp_pdata, |
| 193 | }; |
| 194 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 195 | static struct msm_ssbi_platform_data apq8064_ssbi_pm8921_pdata __devinitdata = { |
| 196 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 197 | .slave = { |
Jay Chokshi | ea67c62 | 2011-07-29 17:12:26 -0700 | [diff] [blame] | 198 | .name = "pm8921-core", |
Jay Chokshi | bc3d98d | 2011-08-10 17:14:23 -0700 | [diff] [blame] | 199 | .platform_data = &apq8064_pm8921_platform_data, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 200 | }, |
| 201 | }; |
| 202 | |
| 203 | static struct msm_ssbi_platform_data apq8064_ssbi_pm8821_pdata __devinitdata = { |
| 204 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 205 | .slave = { |
Jay Chokshi | 44873f7 | 2011-08-30 17:24:26 -0700 | [diff] [blame^] | 206 | .name = "pm8821-core", |
| 207 | .platform_data = &apq8064_pm8821_platform_data, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 208 | }, |
| 209 | }; |
| 210 | |
Kenneth Heitke | 748593a | 2011-07-15 15:45:11 -0600 | [diff] [blame] | 211 | static struct msm_i2c_platform_data apq8064_i2c_qup_gsbi4_pdata = { |
| 212 | .clk_freq = 100000, |
| 213 | .src_clk_rate = 24000000, |
Kenneth Heitke | 748593a | 2011-07-15 15:45:11 -0600 | [diff] [blame] | 214 | }; |
| 215 | |
| 216 | static void __init apq8064_i2c_init(void) |
| 217 | { |
| 218 | apq8064_device_qup_i2c_gsbi4.dev.platform_data = |
| 219 | &apq8064_i2c_qup_gsbi4_pdata; |
| 220 | } |
| 221 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 222 | static void __init apq8064_common_init(void) |
| 223 | { |
| 224 | if (socinfo_init() < 0) |
| 225 | pr_err("socinfo_init() failed!\n"); |
Stephen Boyd | bb600ae | 2011-08-02 20:11:40 -0700 | [diff] [blame] | 226 | msm_clock_init(&apq8064_dummy_clock_init_data); |
Joel King | 4ebccc6 | 2011-07-22 09:43:22 -0700 | [diff] [blame] | 227 | gpiomux_init(); |
Kenneth Heitke | 748593a | 2011-07-15 15:45:11 -0600 | [diff] [blame] | 228 | apq8064_i2c_init(); |
Kenneth Heitke | 36920d3 | 2011-07-20 16:44:30 -0600 | [diff] [blame] | 229 | |
Harini Jayaraman | c4c5869 | 2011-07-19 14:50:10 -0600 | [diff] [blame] | 230 | apq8064_device_qup_spi_gsbi5.dev.platform_data = |
| 231 | &apq8064_qup_spi_gsbi5_pdata; |
Kenneth Heitke | 36920d3 | 2011-07-20 16:44:30 -0600 | [diff] [blame] | 232 | apq8064_device_ssbi_pmic1.dev.platform_data = |
Jay Chokshi | ea67c62 | 2011-07-29 17:12:26 -0700 | [diff] [blame] | 233 | &apq8064_ssbi_pm8921_pdata; |
Kenneth Heitke | 36920d3 | 2011-07-20 16:44:30 -0600 | [diff] [blame] | 234 | apq8064_device_ssbi_pmic2.dev.platform_data = |
| 235 | &apq8064_ssbi_pm8821_pdata; |
Stepan Moskovchenko | 14aa649 | 2011-08-08 15:15:01 -0700 | [diff] [blame] | 236 | apq8064_device_otg.dev.platform_data = &msm_otg_pdata; |
| 237 | apq8064_device_gadget_peripheral.dev.parent = &apq8064_device_otg.dev; |
Jay Chokshi | bc3d98d | 2011-08-10 17:14:23 -0700 | [diff] [blame] | 238 | apq8064_pm8921_platform_data.num_regulators = |
Jay Chokshi | ea67c62 | 2011-07-29 17:12:26 -0700 | [diff] [blame] | 239 | msm8064_pm8921_regulator_pdata_len; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 240 | platform_add_devices(common_devices, ARRAY_SIZE(common_devices)); |
Sahitya Tummala | 3586ed9 | 2011-08-03 09:13:23 +0530 | [diff] [blame] | 241 | apq8064_init_mmc(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | static void __init apq8064_sim_init(void) |
| 245 | { |
| 246 | apq8064_common_init(); |
Joel King | 4e7ad22 | 2011-08-17 15:47:38 -0700 | [diff] [blame] | 247 | platform_add_devices(sim_devices, ARRAY_SIZE(sim_devices)); |
| 248 | } |
| 249 | |
| 250 | static void __init apq8064_rumi3_init(void) |
| 251 | { |
| 252 | apq8064_common_init(); |
Stepan Moskovchenko | 2701a44 | 2011-08-19 13:47:22 -0700 | [diff] [blame] | 253 | platform_add_devices(rumi3_devices, ARRAY_SIZE(rumi3_devices)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | MACHINE_START(APQ8064_SIM, "QCT APQ8064 SIMULATOR") |
| 257 | .map_io = apq8064_map_io, |
| 258 | .init_irq = apq8064_init_irq, |
| 259 | .timer = &msm_timer, |
| 260 | .init_machine = apq8064_sim_init, |
| 261 | MACHINE_END |
| 262 | |
Joel King | 4e7ad22 | 2011-08-17 15:47:38 -0700 | [diff] [blame] | 263 | MACHINE_START(APQ8064_RUMI3, "QCT APQ8064 RUMI3") |
| 264 | .map_io = apq8064_map_io, |
| 265 | .init_irq = apq8064_init_irq, |
| 266 | .timer = &msm_timer, |
| 267 | .init_machine = apq8064_rumi3_init, |
| 268 | MACHINE_END |
| 269 | |