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