Manu Gautam | 5143b25 | 2012-01-05 19:25:23 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 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> |
Amit Blay | 5f968cf | 2012-01-22 12:04:01 +0200 | [diff] [blame] | 15 | #include <linux/io.h> |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 16 | #include <linux/i2c.h> |
Sagar Dharia | 2a5378d | 2011-12-01 20:00:11 -0700 | [diff] [blame] | 17 | #include <linux/slimbus/slimbus.h> |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 18 | #include <linux/msm_ssbi.h> |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 19 | #include <linux/memblock.h> |
Rohit Vaswani | a681589 | 2011-12-15 20:20:39 -0800 | [diff] [blame] | 20 | #include <linux/usb/android.h> |
| 21 | #include <linux/usb/msm_hsusb.h> |
| 22 | #include <linux/mfd/pm8xxx/pm8xxx-adc.h> |
| 23 | #include <linux/leds.h> |
| 24 | #include <linux/leds-pm8xxx.h> |
| 25 | #include <linux/power/ltc4088-charger.h> |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 26 | #include <asm/mach-types.h> |
| 27 | #include <asm/mach/arch.h> |
Marc Zyngier | 89bdafd1 | 2011-12-22 11:39:20 +0530 | [diff] [blame] | 28 | #include <asm/hardware/gic.h> |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 29 | #include <mach/board.h> |
| 30 | #include <mach/msm_iomap.h> |
| 31 | #include <mach/gpio.h> |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 32 | #include <mach/msm_spi.h> |
Gagan Mac | 7a82764 | 2011-09-22 19:42:21 -0600 | [diff] [blame] | 33 | #include <mach/msm_bus_board.h> |
Vikram Mulukutla | 2021c00 | 2011-12-16 12:32:59 -0800 | [diff] [blame] | 34 | #include <mach/msm_xo.h> |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 35 | #include "timer.h" |
| 36 | #include "devices.h" |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 37 | #include "board-9615.h" |
Abhijeet Dharmapurikar | efaca4f | 2011-12-27 16:24:07 -0800 | [diff] [blame] | 38 | #include <mach/cpuidle.h> |
Matt Wagantall | 7cca464 | 2012-02-01 16:43:24 -0800 | [diff] [blame] | 39 | #include "pm.h" |
Vikram Mulukutla | b5e1cda | 2011-10-04 16:17:22 -0700 | [diff] [blame] | 40 | #include "acpuclock.h" |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 41 | #include "pm-boot.h" |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 42 | |
Siddartha Mohanadoss | 5f60b45 | 2011-10-05 11:49:00 -0700 | [diff] [blame] | 43 | static struct pm8xxx_adc_amux pm8018_adc_channels_data[] = { |
| 44 | {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1, |
| 45 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 46 | {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1, |
| 47 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 48 | {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1, |
| 49 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 50 | {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2, |
| 51 | ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM}, |
| 52 | {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2, |
| 53 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 54 | {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 55 | ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM}, |
| 56 | {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 57 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 58 | {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 59 | ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT}, |
| 60 | {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1, |
| 61 | ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM}, |
| 62 | }; |
| 63 | |
| 64 | static struct pm8xxx_adc_properties pm8018_adc_data = { |
| 65 | .adc_vdd_reference = 1800, /* milli-voltage for this adc */ |
| 66 | .bitresolution = 15, |
| 67 | .bipolar = 0, |
| 68 | }; |
| 69 | |
| 70 | static struct pm8xxx_adc_platform_data pm8018_adc_pdata = { |
| 71 | .adc_channel = pm8018_adc_channels_data, |
| 72 | .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data), |
| 73 | .adc_prop = &pm8018_adc_data, |
| 74 | }; |
| 75 | |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 76 | static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = { |
| 77 | .irq_base = PM8018_IRQ_BASE, |
| 78 | .devirq = MSM_GPIO_TO_INT(87), |
| 79 | .irq_trigger_flag = IRQF_TRIGGER_LOW, |
| 80 | }; |
| 81 | |
| 82 | static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = { |
| 83 | .gpio_base = PM8018_GPIO_PM_TO_SYS(1), |
| 84 | }; |
| 85 | |
| 86 | static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = { |
| 87 | .mpp_base = PM8018_MPP_PM_TO_SYS(1), |
| 88 | }; |
| 89 | |
| 90 | static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = { |
| 91 | .rtc_write_enable = false, |
Ashay Jaiswal | db5e6dc | 2011-10-12 11:02:47 +0530 | [diff] [blame] | 92 | .rtc_alarm_powerup = false, |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = { |
| 96 | .pull_up = 1, |
Jing Lin | eecdc06 | 2011-11-17 09:47:09 -0800 | [diff] [blame] | 97 | .kpd_trigger_delay_us = 15625, |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 98 | .wakeup = 1, |
| 99 | }; |
| 100 | |
| 101 | static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = { |
| 102 | .priority = 0, |
| 103 | }; |
| 104 | |
Jay Chokshi | eb5d0d5 | 2011-09-28 17:16:20 -0700 | [diff] [blame] | 105 | #define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */ |
| 106 | #define PM8XXX_LED_PWM_PERIOD_US 1000 |
| 107 | |
| 108 | /** |
| 109 | * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be |
| 110 | * driven using PWM feature. |
| 111 | */ |
| 112 | #define PM8XXX_PWM_CHANNEL_NONE -1 |
| 113 | |
| 114 | static struct led_info pm8018_led_info[] = { |
| 115 | [0] = { |
| 116 | .name = "led:kb", |
| 117 | }, |
| 118 | }; |
| 119 | |
| 120 | static struct led_platform_data pm8018_led_core_pdata = { |
| 121 | .num_leds = ARRAY_SIZE(pm8018_led_info), |
| 122 | .leds = pm8018_led_info, |
| 123 | }; |
| 124 | |
| 125 | static struct pm8xxx_led_config pm8018_led_configs[] = { |
| 126 | [0] = { |
| 127 | .id = PM8XXX_ID_LED_KB_LIGHT, |
| 128 | .mode = PM8XXX_LED_MODE_PWM3, |
| 129 | .max_current = PM8018_LED_KB_MAX_CURRENT, |
| 130 | .pwm_channel = 2, |
| 131 | .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US, |
| 132 | }, |
| 133 | }; |
| 134 | |
| 135 | static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = { |
| 136 | .led_core = &pm8018_led_core_pdata, |
| 137 | .configs = pm8018_led_configs, |
| 138 | .num_configs = ARRAY_SIZE(pm8018_led_configs), |
| 139 | }; |
| 140 | |
Jay Chokshi | dc8028b | 2011-12-01 16:17:34 -0800 | [diff] [blame] | 141 | #ifdef CONFIG_LTC4088_CHARGER |
| 142 | static struct ltc4088_charger_platform_data ltc4088_chg_pdata = { |
| 143 | .gpio_mode_select_d0 = 7, |
| 144 | .gpio_mode_select_d1 = 6, |
| 145 | .gpio_mode_select_d2 = 4, |
| 146 | }; |
| 147 | #endif |
| 148 | |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 149 | static struct pm8018_platform_data pm8018_platform_data __devinitdata = { |
| 150 | .irq_pdata = &pm8xxx_irq_pdata, |
| 151 | .gpio_pdata = &pm8xxx_gpio_pdata, |
| 152 | .mpp_pdata = &pm8xxx_mpp_pdata, |
| 153 | .rtc_pdata = &pm8xxx_rtc_pdata, |
| 154 | .pwrkey_pdata = &pm8xxx_pwrkey_pdata, |
| 155 | .misc_pdata = &pm8xxx_misc_pdata, |
David Collins | 00b31e6 | 2011-08-31 20:00:10 -0700 | [diff] [blame] | 156 | .regulator_pdatas = msm_pm8018_regulator_pdata, |
Siddartha Mohanadoss | 5f60b45 | 2011-10-05 11:49:00 -0700 | [diff] [blame] | 157 | .adc_pdata = &pm8018_adc_pdata, |
Jay Chokshi | eb5d0d5 | 2011-09-28 17:16:20 -0700 | [diff] [blame] | 158 | .leds_pdata = &pm8xxx_leds_pdata, |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 159 | }; |
| 160 | |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 161 | static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = { |
| 162 | .controller_type = MSM_SBI_CTRL_PMIC_ARBITER, |
| 163 | .slave = { |
David Collins | fb88c43 | 2011-08-25 15:12:47 -0700 | [diff] [blame] | 164 | .name = PM8018_CORE_DEV_NAME, |
| 165 | .platform_data = &pm8018_platform_data, |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 166 | }, |
| 167 | }; |
| 168 | |
David Collins | bea297a | 2011-09-28 13:11:14 -0700 | [diff] [blame] | 169 | static struct platform_device msm9615_device_rpm_regulator __devinitdata = { |
| 170 | .name = "rpm-regulator", |
| 171 | .id = -1, |
| 172 | .dev = { |
| 173 | .platform_data = &msm_rpm_regulator_9615_pdata, |
| 174 | }, |
| 175 | }; |
| 176 | |
David Collins | 0f9942a | 2011-10-31 09:47:34 -0700 | [diff] [blame] | 177 | static struct platform_device msm9615_device_ext_2p95v_vreg = { |
| 178 | .name = GPIO_REGULATOR_DEV_NAME, |
| 179 | .id = 18, |
| 180 | .dev = { |
| 181 | .platform_data = |
| 182 | &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V], |
| 183 | }, |
| 184 | }; |
| 185 | |
Maheshkumar Sivasubramanian | 4923db2 | 2011-09-15 09:28:15 -0600 | [diff] [blame] | 186 | static struct msm_cpuidle_state msm_cstates[] __initdata = { |
| 187 | {0, 0, "C0", "WFI", |
| 188 | MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT}, |
| 189 | |
| 190 | {0, 1, "C1", "STANDALONE_POWER_COLLAPSE", |
| 191 | MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE}, |
| 192 | |
| 193 | {0, 2, "C2", "POWER_COLLAPSE", |
| 194 | MSM_PM_SLEEP_MODE_POWER_COLLAPSE}, |
| 195 | }; |
| 196 | static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = { |
| 197 | [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = { |
| 198 | .idle_supported = 1, |
| 199 | .suspend_supported = 1, |
| 200 | .idle_enabled = 0, |
| 201 | .suspend_enabled = 0, |
| 202 | }, |
| 203 | [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = { |
| 204 | .idle_supported = 1, |
| 205 | .suspend_supported = 1, |
| 206 | .idle_enabled = 0, |
| 207 | .suspend_enabled = 0, |
| 208 | }, |
| 209 | [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = { |
| 210 | .idle_supported = 1, |
| 211 | .suspend_supported = 1, |
| 212 | .idle_enabled = 1, |
| 213 | .suspend_enabled = 1, |
| 214 | }, |
| 215 | }; |
Krishna Konda | dd79446 | 2011-10-01 00:19:29 -0700 | [diff] [blame] | 216 | |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 217 | static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = { |
| 218 | .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR, |
| 219 | .v_addr = MSM_APCS_GLB_BASE + 0x24, |
| 220 | }; |
| 221 | |
Gagan Mac | 7a82764 | 2011-09-22 19:42:21 -0600 | [diff] [blame] | 222 | static void __init msm9615_init_buses(void) |
| 223 | { |
| 224 | #ifdef CONFIG_MSM_BUS_SCALING |
| 225 | msm_bus_rpm_set_mt_mask(); |
| 226 | msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1; |
| 227 | msm_bus_9615_sys_fabric.dev.platform_data = |
| 228 | &msm_bus_9615_sys_fabric_pdata; |
| 229 | msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata; |
| 230 | #endif |
| 231 | } |
| 232 | |
Sagar Dharia | 2a5378d | 2011-12-01 20:00:11 -0700 | [diff] [blame] | 233 | static struct slim_boardinfo msm_slim_devices[] = { |
| 234 | /* add slimbus slaves as needed */ |
| 235 | }; |
| 236 | |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 237 | static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = { |
| 238 | .max_clock_speed = 24000000, |
| 239 | }; |
| 240 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 241 | static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = { |
| 242 | .clk_freq = 100000, |
| 243 | .src_clk_rate = 24000000, |
| 244 | }; |
| 245 | |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 246 | #define USB_5V_EN 3 |
| 247 | #define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN) |
| 248 | |
Mayank Rana | 8549e63 | 2012-01-23 12:49:54 +0530 | [diff] [blame] | 249 | static int msm_hsusb_vbus_power(bool on) |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 250 | { |
Amit Blay | a4416f9 | 2012-01-24 21:03:52 +0200 | [diff] [blame] | 251 | int rc; |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 252 | struct pm_gpio usb_vbus = { |
| 253 | .direction = PM_GPIO_DIR_OUT, |
| 254 | .pull = PM_GPIO_PULL_NO, |
| 255 | .output_buffer = PM_GPIO_OUT_BUF_CMOS, |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 256 | .vin_sel = 2, |
| 257 | .out_strength = PM_GPIO_STRENGTH_HIGH, |
| 258 | .function = PM_GPIO_FUNC_NORMAL, |
| 259 | .inv_int_pol = 0, |
| 260 | }; |
| 261 | |
Amit Blay | a4416f9 | 2012-01-24 21:03:52 +0200 | [diff] [blame] | 262 | usb_vbus.output_value = on; |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 263 | |
Amit Blay | a4416f9 | 2012-01-24 21:03:52 +0200 | [diff] [blame] | 264 | rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus); |
| 265 | if (rc) |
| 266 | pr_err("failed to config usb_5v_en gpio\n"); |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 267 | |
Mayank Rana | 8549e63 | 2012-01-23 12:49:54 +0530 | [diff] [blame] | 268 | return rc; |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 269 | } |
| 270 | |
Anji jonnala | a8b8d73 | 2011-12-06 10:03:24 +0530 | [diff] [blame] | 271 | static int shelby_phy_init_seq[] = { |
| 272 | 0x44, 0x80,/* set VBUS valid threshold and |
| 273 | disconnect valid threshold */ |
| 274 | 0x38, 0x81, /* update DC voltage level */ |
| 275 | 0x14, 0x82,/* set preemphasis and rise/fall time */ |
| 276 | 0x13, 0x83,/* set source impedance adjustment */ |
| 277 | -1}; |
| 278 | |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 279 | #define USB_BAM_PHY_BASE 0x12502000 |
Ofir Cohen | 43473c8 | 2012-01-25 16:28:13 +0200 | [diff] [blame] | 280 | #define HSIC_BAM_PHY_BASE 0x12542000 |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 281 | #define A2_BAM_PHY_BASE 0x124C2000 |
| 282 | static struct usb_bam_pipe_connect msm_usb_bam_connections[4][2] = { |
Ofir Cohen | 43473c8 | 2012-01-25 16:28:13 +0200 | [diff] [blame] | 283 | #ifndef CONFIG_USB_GADGET_CI13XXX_MSM_HSIC |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 284 | [0][USB_TO_PEER_PERIPHERAL] = { |
| 285 | .src_phy_addr = USB_BAM_PHY_BASE, |
| 286 | .src_pipe_index = 11, |
| 287 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 288 | .dst_pipe_index = 0, |
Ofir Cohen | 29cd575 | 2011-12-14 17:20:30 +0200 | [diff] [blame] | 289 | .data_fifo_base_offset = 0x1100, |
| 290 | .data_fifo_size = 0x600, |
| 291 | .desc_fifo_base_offset = 0x1700, |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 292 | .desc_fifo_size = 0x300, |
| 293 | }, |
| 294 | [0][PEER_PERIPHERAL_TO_USB] = { |
| 295 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 296 | .src_pipe_index = 1, |
| 297 | .dst_phy_addr = USB_BAM_PHY_BASE, |
| 298 | .dst_pipe_index = 10, |
| 299 | .data_fifo_base_offset = 0xa00, |
Ofir Cohen | 29cd575 | 2011-12-14 17:20:30 +0200 | [diff] [blame] | 300 | .data_fifo_size = 0x600, |
| 301 | .desc_fifo_base_offset = 0x1000, |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 302 | .desc_fifo_size = 0x100, |
| 303 | }, |
Anna Perel | 2151516 | 2012-02-02 20:50:02 +0200 | [diff] [blame] | 304 | [1][USB_TO_PEER_PERIPHERAL] = { |
| 305 | .src_phy_addr = USB_BAM_PHY_BASE, |
| 306 | .src_pipe_index = 13, |
| 307 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 308 | .dst_pipe_index = 2, |
| 309 | .data_fifo_base_offset = 0x2100, |
| 310 | .data_fifo_size = 0x600, |
| 311 | .desc_fifo_base_offset = 0x2700, |
| 312 | .desc_fifo_size = 0x300, |
| 313 | }, |
| 314 | [1][PEER_PERIPHERAL_TO_USB] = { |
| 315 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 316 | .src_pipe_index = 3, |
| 317 | .dst_phy_addr = USB_BAM_PHY_BASE, |
| 318 | .dst_pipe_index = 12, |
| 319 | .data_fifo_base_offset = 0x1a00, |
| 320 | .data_fifo_size = 0x600, |
| 321 | .desc_fifo_base_offset = 0x2000, |
| 322 | .desc_fifo_size = 0x100, |
| 323 | }, |
| 324 | [2][USB_TO_PEER_PERIPHERAL] = { |
| 325 | .src_phy_addr = USB_BAM_PHY_BASE, |
| 326 | .src_pipe_index = 15, |
| 327 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 328 | .dst_pipe_index = 4, |
| 329 | .data_fifo_base_offset = 0x3100, |
| 330 | .data_fifo_size = 0x600, |
| 331 | .desc_fifo_base_offset = 0x3700, |
| 332 | .desc_fifo_size = 0x300, |
| 333 | }, |
| 334 | [2][PEER_PERIPHERAL_TO_USB] = { |
| 335 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 336 | .src_pipe_index = 5, |
| 337 | .dst_phy_addr = USB_BAM_PHY_BASE, |
| 338 | .dst_pipe_index = 14, |
| 339 | .data_fifo_base_offset = 0x2a00, |
| 340 | .data_fifo_size = 0x600, |
| 341 | .desc_fifo_base_offset = 0x3000, |
| 342 | .desc_fifo_size = 0x100, |
| 343 | } |
Ofir Cohen | 057fb3e | 2012-02-05 15:25:47 +0200 | [diff] [blame] | 344 | #else |
| 345 | [0][USB_TO_PEER_PERIPHERAL] = { |
| 346 | .src_phy_addr = HSIC_BAM_PHY_BASE, |
| 347 | .src_pipe_index = 1, |
| 348 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 349 | .dst_pipe_index = 0, |
| 350 | .data_fifo_base_offset = 0x1100, |
| 351 | .data_fifo_size = 0x600, |
| 352 | .desc_fifo_base_offset = 0x1700, |
| 353 | .desc_fifo_size = 0x300, |
| 354 | }, |
| 355 | [0][PEER_PERIPHERAL_TO_USB] = { |
| 356 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 357 | .src_pipe_index = 1, |
| 358 | .dst_phy_addr = HSIC_BAM_PHY_BASE, |
| 359 | .dst_pipe_index = 0, |
| 360 | .data_fifo_base_offset = 0xa00, |
| 361 | .data_fifo_size = 0x600, |
| 362 | .desc_fifo_base_offset = 0x1000, |
| 363 | .desc_fifo_size = 0x100, |
| 364 | }, |
| 365 | [1][USB_TO_PEER_PERIPHERAL] = { |
| 366 | .src_phy_addr = HSIC_BAM_PHY_BASE, |
| 367 | .src_pipe_index = 3, |
| 368 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 369 | .dst_pipe_index = 2, |
| 370 | .data_fifo_base_offset = 0x2100, |
| 371 | .data_fifo_size = 0x600, |
| 372 | .desc_fifo_base_offset = 0x2700, |
| 373 | .desc_fifo_size = 0x300, |
| 374 | }, |
| 375 | [1][PEER_PERIPHERAL_TO_USB] = { |
| 376 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 377 | .src_pipe_index = 3, |
| 378 | .dst_phy_addr = HSIC_BAM_PHY_BASE, |
| 379 | .dst_pipe_index = 2, |
| 380 | .data_fifo_base_offset = 0x1a00, |
| 381 | .data_fifo_size = 0x600, |
| 382 | .desc_fifo_base_offset = 0x2000, |
| 383 | .desc_fifo_size = 0x100, |
| 384 | }, |
| 385 | [2][USB_TO_PEER_PERIPHERAL] = { |
| 386 | .src_phy_addr = HSIC_BAM_PHY_BASE, |
| 387 | .src_pipe_index = 5, |
| 388 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 389 | .dst_pipe_index = 4, |
| 390 | .data_fifo_base_offset = 0x3100, |
| 391 | .data_fifo_size = 0x600, |
| 392 | .desc_fifo_base_offset = 0x3700, |
| 393 | .desc_fifo_size = 0x300, |
| 394 | }, |
| 395 | [2][PEER_PERIPHERAL_TO_USB] = { |
| 396 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 397 | .src_pipe_index = 5, |
| 398 | .dst_phy_addr = HSIC_BAM_PHY_BASE, |
| 399 | .dst_pipe_index = 4, |
| 400 | .data_fifo_base_offset = 0x2a00, |
| 401 | .data_fifo_size = 0x600, |
| 402 | .desc_fifo_base_offset = 0x3000, |
| 403 | .desc_fifo_size = 0x100, |
| 404 | } |
| 405 | #endif |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 406 | }; |
| 407 | |
| 408 | static struct msm_usb_bam_platform_data msm_usb_bam_pdata = { |
| 409 | .connections = &msm_usb_bam_connections[0][0], |
Ofir Cohen | 43473c8 | 2012-01-25 16:28:13 +0200 | [diff] [blame] | 410 | #ifndef CONFIG_USB_GADGET_CI13XXX_MSM_HSIC |
| 411 | .usb_active_bam = HSUSB_BAM, |
| 412 | .usb_bam_num_pipes = 16, |
| 413 | #else |
| 414 | .usb_active_bam = HSIC_BAM, |
| 415 | .usb_bam_num_pipes = 16, |
| 416 | #endif |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 417 | }; |
| 418 | |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 419 | static struct msm_otg_platform_data msm_otg_pdata = { |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 420 | .mode = USB_OTG, |
| 421 | .otg_control = OTG_PHY_CONTROL, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 422 | .phy_type = SNPS_28NM_INTEGRATED_PHY, |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 423 | .vbus_power = msm_hsusb_vbus_power, |
Ofir Cohen | 4da266f | 2012-01-03 10:19:29 +0200 | [diff] [blame] | 424 | .disable_reset_on_disconnect = true, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 425 | }; |
| 426 | |
Amit Blay | 5f968cf | 2012-01-22 12:04:01 +0200 | [diff] [blame] | 427 | #define PID_MAGIC_ID 0x71432909 |
| 428 | #define SERIAL_NUM_MAGIC_ID 0x61945374 |
| 429 | #define SERIAL_NUMBER_LENGTH 127 |
| 430 | #define DLOAD_USB_BASE_ADD 0x2B0000C8 |
| 431 | |
| 432 | struct magic_num_struct { |
| 433 | uint32_t pid; |
| 434 | uint32_t serial_num; |
| 435 | }; |
| 436 | |
| 437 | struct dload_struct { |
| 438 | uint32_t reserved1; |
| 439 | uint32_t reserved2; |
| 440 | uint32_t reserved3; |
| 441 | uint16_t reserved4; |
| 442 | uint16_t pid; |
| 443 | char serial_number[SERIAL_NUMBER_LENGTH]; |
| 444 | uint16_t reserved5; |
| 445 | struct magic_num_struct magic_struct; |
| 446 | }; |
| 447 | |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 448 | static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum) |
| 449 | { |
Amit Blay | 5f968cf | 2012-01-22 12:04:01 +0200 | [diff] [blame] | 450 | struct dload_struct __iomem *dload = 0; |
| 451 | |
| 452 | dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload)); |
| 453 | if (!dload) { |
| 454 | pr_err("%s: cannot remap I/O memory region: %08x\n", |
| 455 | __func__, DLOAD_USB_BASE_ADD); |
| 456 | return -ENXIO; |
| 457 | } |
| 458 | |
| 459 | pr_debug("%s: dload:%p pid:%x serial_num:%s\n", |
| 460 | __func__, dload, pid, snum); |
| 461 | /* update pid */ |
| 462 | dload->magic_struct.pid = PID_MAGIC_ID; |
| 463 | dload->pid = pid; |
| 464 | |
| 465 | /* update serial number */ |
| 466 | dload->magic_struct.serial_num = 0; |
| 467 | if (!snum) { |
| 468 | memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH); |
| 469 | goto out; |
| 470 | } |
| 471 | |
| 472 | dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID; |
| 473 | strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH); |
| 474 | out: |
| 475 | iounmap(dload); |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 476 | return 0; |
| 477 | } |
| 478 | |
| 479 | static struct android_usb_platform_data android_usb_pdata = { |
| 480 | .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num, |
| 481 | }; |
| 482 | |
| 483 | static struct platform_device android_usb_device = { |
| 484 | .name = "android_usb", |
| 485 | .id = -1, |
| 486 | .dev = { |
| 487 | .platform_data = &android_usb_pdata, |
| 488 | }, |
| 489 | }; |
| 490 | |
Rohit Vaswani | 149f0a7 | 2011-11-09 15:21:28 -0800 | [diff] [blame] | 491 | static struct platform_device msm_wlan_ar6000_pm_device = { |
| 492 | .name = "wlan_ar6000_pm_dev", |
| 493 | .id = -1, |
| 494 | }; |
| 495 | |
| 496 | static int __init msm9615_init_ar6000pm(void) |
| 497 | { |
| 498 | return platform_device_register(&msm_wlan_ar6000_pm_device); |
| 499 | } |
| 500 | |
Jay Chokshi | dc8028b | 2011-12-01 16:17:34 -0800 | [diff] [blame] | 501 | #ifdef CONFIG_LTC4088_CHARGER |
| 502 | static struct platform_device msm_device_charger = { |
| 503 | .name = LTC4088_CHARGER_DEV_NAME, |
| 504 | .id = -1, |
| 505 | .dev = { |
| 506 | .platform_data = <c4088_chg_pdata, |
| 507 | }, |
| 508 | }; |
| 509 | #endif |
| 510 | |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 511 | static struct platform_device *common_devices[] = { |
| 512 | &msm9615_device_dmov, |
| 513 | &msm_device_smd, |
Jay Chokshi | dc8028b | 2011-12-01 16:17:34 -0800 | [diff] [blame] | 514 | #ifdef CONFIG_LTC4088_CHARGER |
| 515 | &msm_device_charger, |
| 516 | #endif |
Ofir Cohen | dca06cb | 2012-03-08 16:37:45 +0200 | [diff] [blame^] | 517 | #ifndef CONFIG_USB_GADGET_CI13XXX_MSM_HSIC |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 518 | &msm_device_otg, |
Ofir Cohen | dca06cb | 2012-03-08 16:37:45 +0200 | [diff] [blame^] | 519 | #endif |
Ofir Cohen | 73c99e8 | 2012-01-15 13:38:14 +0200 | [diff] [blame] | 520 | &msm_device_hsic_peripheral, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 521 | &msm_device_gadget_peripheral, |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 522 | &msm_device_hsusb_host, |
Lena Salman | 65bcf37 | 2012-02-14 15:33:32 +0200 | [diff] [blame] | 523 | &msm_device_hsic_host, |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 524 | &msm_device_usb_bam, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 525 | &android_usb_device, |
| 526 | &msm9615_device_uart_gsbi4, |
David Collins | 0f9942a | 2011-10-31 09:47:34 -0700 | [diff] [blame] | 527 | &msm9615_device_ext_2p95v_vreg, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 528 | &msm9615_device_ssbi_pmic1, |
| 529 | &msm9615_device_qup_i2c_gsbi5, |
| 530 | &msm9615_device_qup_spi_gsbi3, |
| 531 | &msm_device_sps, |
Sagar Dharia | 2a5378d | 2011-12-01 20:00:11 -0700 | [diff] [blame] | 532 | &msm9615_slim_ctrl, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 533 | &msm9615_device_tsens, |
| 534 | &msm_device_nand, |
Eric Holmberg | 0c96e70 | 2011-11-08 18:04:31 -0700 | [diff] [blame] | 535 | &msm_device_bam_dmux, |
Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 536 | &msm9615_rpm_device, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 537 | #ifdef CONFIG_HW_RANDOM_MSM |
| 538 | &msm_device_rng, |
| 539 | #endif |
| 540 | |
| 541 | #if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \ |
| 542 | defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) |
Ramesh Masavarapu | aa28b5b | 2011-10-21 10:26:03 -0700 | [diff] [blame] | 543 | &msm9615_qcrypto_device, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 544 | #endif |
| 545 | |
| 546 | #if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \ |
| 547 | defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE) |
Ramesh Masavarapu | aa28b5b | 2011-10-21 10:26:03 -0700 | [diff] [blame] | 548 | &msm9615_qcedev_device, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 549 | #endif |
Jeff Ohlstein | 7e66855 | 2011-10-06 16:17:25 -0700 | [diff] [blame] | 550 | &msm9615_device_watchdog, |
Gagan Mac | 7a82764 | 2011-09-22 19:42:21 -0600 | [diff] [blame] | 551 | &msm_bus_9615_sys_fabric, |
| 552 | &msm_bus_def_fab, |
Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 553 | &msm9615_rpm_log_device, |
| 554 | &msm9615_rpm_stat_device, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 555 | }; |
| 556 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 557 | static void __init msm9615_i2c_init(void) |
| 558 | { |
| 559 | msm9615_device_qup_i2c_gsbi5.dev.platform_data = |
| 560 | &msm9615_i2c_qup_gsbi5_pdata; |
| 561 | } |
| 562 | |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 563 | static void __init msm9615_reserve(void) |
| 564 | { |
| 565 | msm_pm_boot_pdata.p_addr = memblock_alloc(SZ_8, SZ_64K); |
| 566 | } |
| 567 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 568 | static void __init msm9615_common_init(void) |
| 569 | { |
| 570 | msm9615_device_init(); |
Rohit Vaswani | a681589 | 2011-12-15 20:20:39 -0800 | [diff] [blame] | 571 | msm9615_init_gpiomux(); |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 572 | msm9615_i2c_init(); |
David Collins | 00b31e6 | 2011-08-31 20:00:10 -0700 | [diff] [blame] | 573 | regulator_suppress_info_printing(); |
David Collins | bea297a | 2011-09-28 13:11:14 -0700 | [diff] [blame] | 574 | platform_device_register(&msm9615_device_rpm_regulator); |
Vikram Mulukutla | 2021c00 | 2011-12-16 12:32:59 -0800 | [diff] [blame] | 575 | msm_xo_init(); |
Gagan Mac | 7a82764 | 2011-09-22 19:42:21 -0600 | [diff] [blame] | 576 | msm_clock_init(&msm9615_clock_init_data); |
| 577 | msm9615_init_buses(); |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 578 | msm9615_device_qup_spi_gsbi3.dev.platform_data = |
| 579 | &msm9615_qup_spi_gsbi3_pdata; |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 580 | msm9615_device_ssbi_pmic1.dev.platform_data = |
| 581 | &msm9615_ssbi_pm8018_pdata; |
David Collins | 00b31e6 | 2011-08-31 20:00:10 -0700 | [diff] [blame] | 582 | pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len; |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 583 | |
| 584 | msm_device_otg.dev.platform_data = &msm_otg_pdata; |
Anji jonnala | a8b8d73 | 2011-12-06 10:03:24 +0530 | [diff] [blame] | 585 | msm_otg_pdata.phy_init_seq = shelby_phy_init_seq; |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 586 | msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata; |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 587 | platform_add_devices(common_devices, ARRAY_SIZE(common_devices)); |
Krishna Konda | dd79446 | 2011-10-01 00:19:29 -0700 | [diff] [blame] | 588 | |
Vikram Mulukutla | b5e1cda | 2011-10-04 16:17:22 -0700 | [diff] [blame] | 589 | acpuclk_init(&acpuclk_9615_soc_data); |
| 590 | |
Rohit Vaswani | 149f0a7 | 2011-11-09 15:21:28 -0800 | [diff] [blame] | 591 | /* Ensure ar6000pm device is registered before MMC/SDC */ |
| 592 | msm9615_init_ar6000pm(); |
| 593 | |
Krishna Konda | dd79446 | 2011-10-01 00:19:29 -0700 | [diff] [blame] | 594 | msm9615_init_mmc(); |
Sagar Dharia | 2a5378d | 2011-12-01 20:00:11 -0700 | [diff] [blame] | 595 | slim_register_board_info(msm_slim_devices, |
| 596 | ARRAY_SIZE(msm_slim_devices)); |
Maheshkumar Sivasubramanian | 4923db2 | 2011-09-15 09:28:15 -0600 | [diff] [blame] | 597 | msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data)); |
| 598 | msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ); |
| 599 | msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates), |
| 600 | msm_pm_data); |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 601 | BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata)); |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | static void __init msm9615_cdp_init(void) |
| 605 | { |
| 606 | msm9615_common_init(); |
| 607 | } |
| 608 | |
| 609 | static void __init msm9615_mtp_init(void) |
| 610 | { |
| 611 | msm9615_common_init(); |
| 612 | } |
| 613 | |
| 614 | MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP") |
| 615 | .map_io = msm9615_map_io, |
| 616 | .init_irq = msm9615_init_irq, |
Marc Zyngier | 89bdafd1 | 2011-12-22 11:39:20 +0530 | [diff] [blame] | 617 | .handle_irq = gic_handle_irq, |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 618 | .timer = &msm_timer, |
| 619 | .init_machine = msm9615_cdp_init, |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 620 | .reserve = msm9615_reserve, |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 621 | MACHINE_END |
| 622 | |
| 623 | MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP") |
| 624 | .map_io = msm9615_map_io, |
| 625 | .init_irq = msm9615_init_irq, |
Marc Zyngier | 89bdafd1 | 2011-12-22 11:39:20 +0530 | [diff] [blame] | 626 | .handle_irq = gic_handle_irq, |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 627 | .timer = &msm_timer, |
| 628 | .init_machine = msm9615_mtp_init, |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 629 | .reserve = msm9615_reserve, |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 630 | MACHINE_END |