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 | { |
Amit Blay | a4416f9 | 2012-01-24 21:03:52 +0200 | [diff] [blame] | 250 | int rc; |
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, |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 255 | .vin_sel = 2, |
| 256 | .out_strength = PM_GPIO_STRENGTH_HIGH, |
| 257 | .function = PM_GPIO_FUNC_NORMAL, |
| 258 | .inv_int_pol = 0, |
| 259 | }; |
| 260 | |
Amit Blay | a4416f9 | 2012-01-24 21:03:52 +0200 | [diff] [blame] | 261 | usb_vbus.output_value = on; |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 262 | |
Amit Blay | a4416f9 | 2012-01-24 21:03:52 +0200 | [diff] [blame] | 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"); |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 266 | |
Mayank Rana | 8549e63 | 2012-01-23 12:49:54 +0530 | [diff] [blame] | 267 | return rc; |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 268 | } |
| 269 | |
Anji jonnala | a8b8d73 | 2011-12-06 10:03:24 +0530 | [diff] [blame] | 270 | static int shelby_phy_init_seq[] = { |
| 271 | 0x44, 0x80,/* set VBUS valid threshold and |
| 272 | disconnect valid threshold */ |
| 273 | 0x38, 0x81, /* update DC voltage level */ |
| 274 | 0x14, 0x82,/* set preemphasis and rise/fall time */ |
| 275 | 0x13, 0x83,/* set source impedance adjustment */ |
| 276 | -1}; |
| 277 | |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 278 | #define USB_BAM_PHY_BASE 0x12502000 |
Ofir Cohen | 43473c8 | 2012-01-25 16:28:13 +0200 | [diff] [blame] | 279 | #define HSIC_BAM_PHY_BASE 0x12542000 |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 280 | #define A2_BAM_PHY_BASE 0x124C2000 |
| 281 | static struct usb_bam_pipe_connect msm_usb_bam_connections[4][2] = { |
Ofir Cohen | 43473c8 | 2012-01-25 16:28:13 +0200 | [diff] [blame] | 282 | #ifndef CONFIG_USB_GADGET_CI13XXX_MSM_HSIC |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 283 | [0][USB_TO_PEER_PERIPHERAL] = { |
| 284 | .src_phy_addr = USB_BAM_PHY_BASE, |
| 285 | .src_pipe_index = 11, |
| 286 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 287 | .dst_pipe_index = 0, |
Ofir Cohen | 29cd575 | 2011-12-14 17:20:30 +0200 | [diff] [blame] | 288 | .data_fifo_base_offset = 0x1100, |
| 289 | .data_fifo_size = 0x600, |
| 290 | .desc_fifo_base_offset = 0x1700, |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 291 | .desc_fifo_size = 0x300, |
| 292 | }, |
| 293 | [0][PEER_PERIPHERAL_TO_USB] = { |
| 294 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 295 | .src_pipe_index = 1, |
| 296 | .dst_phy_addr = USB_BAM_PHY_BASE, |
| 297 | .dst_pipe_index = 10, |
| 298 | .data_fifo_base_offset = 0xa00, |
Ofir Cohen | 29cd575 | 2011-12-14 17:20:30 +0200 | [diff] [blame] | 299 | .data_fifo_size = 0x600, |
| 300 | .desc_fifo_base_offset = 0x1000, |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 301 | .desc_fifo_size = 0x100, |
| 302 | }, |
Anna Perel | 2151516 | 2012-02-02 20:50:02 +0200 | [diff] [blame] | 303 | [1][USB_TO_PEER_PERIPHERAL] = { |
| 304 | .src_phy_addr = USB_BAM_PHY_BASE, |
| 305 | .src_pipe_index = 13, |
| 306 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 307 | .dst_pipe_index = 2, |
| 308 | .data_fifo_base_offset = 0x2100, |
| 309 | .data_fifo_size = 0x600, |
| 310 | .desc_fifo_base_offset = 0x2700, |
| 311 | .desc_fifo_size = 0x300, |
| 312 | }, |
| 313 | [1][PEER_PERIPHERAL_TO_USB] = { |
| 314 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 315 | .src_pipe_index = 3, |
| 316 | .dst_phy_addr = USB_BAM_PHY_BASE, |
| 317 | .dst_pipe_index = 12, |
| 318 | .data_fifo_base_offset = 0x1a00, |
| 319 | .data_fifo_size = 0x600, |
| 320 | .desc_fifo_base_offset = 0x2000, |
| 321 | .desc_fifo_size = 0x100, |
| 322 | }, |
| 323 | [2][USB_TO_PEER_PERIPHERAL] = { |
| 324 | .src_phy_addr = USB_BAM_PHY_BASE, |
| 325 | .src_pipe_index = 15, |
| 326 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 327 | .dst_pipe_index = 4, |
| 328 | .data_fifo_base_offset = 0x3100, |
| 329 | .data_fifo_size = 0x600, |
| 330 | .desc_fifo_base_offset = 0x3700, |
| 331 | .desc_fifo_size = 0x300, |
| 332 | }, |
| 333 | [2][PEER_PERIPHERAL_TO_USB] = { |
| 334 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 335 | .src_pipe_index = 5, |
| 336 | .dst_phy_addr = USB_BAM_PHY_BASE, |
| 337 | .dst_pipe_index = 14, |
| 338 | .data_fifo_base_offset = 0x2a00, |
| 339 | .data_fifo_size = 0x600, |
| 340 | .desc_fifo_base_offset = 0x3000, |
| 341 | .desc_fifo_size = 0x100, |
| 342 | } |
Ofir Cohen | 057fb3e | 2012-02-05 15:25:47 +0200 | [diff] [blame^] | 343 | #else |
| 344 | [0][USB_TO_PEER_PERIPHERAL] = { |
| 345 | .src_phy_addr = HSIC_BAM_PHY_BASE, |
| 346 | .src_pipe_index = 1, |
| 347 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 348 | .dst_pipe_index = 0, |
| 349 | .data_fifo_base_offset = 0x1100, |
| 350 | .data_fifo_size = 0x600, |
| 351 | .desc_fifo_base_offset = 0x1700, |
| 352 | .desc_fifo_size = 0x300, |
| 353 | }, |
| 354 | [0][PEER_PERIPHERAL_TO_USB] = { |
| 355 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 356 | .src_pipe_index = 1, |
| 357 | .dst_phy_addr = HSIC_BAM_PHY_BASE, |
| 358 | .dst_pipe_index = 0, |
| 359 | .data_fifo_base_offset = 0xa00, |
| 360 | .data_fifo_size = 0x600, |
| 361 | .desc_fifo_base_offset = 0x1000, |
| 362 | .desc_fifo_size = 0x100, |
| 363 | }, |
| 364 | [1][USB_TO_PEER_PERIPHERAL] = { |
| 365 | .src_phy_addr = HSIC_BAM_PHY_BASE, |
| 366 | .src_pipe_index = 3, |
| 367 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 368 | .dst_pipe_index = 2, |
| 369 | .data_fifo_base_offset = 0x2100, |
| 370 | .data_fifo_size = 0x600, |
| 371 | .desc_fifo_base_offset = 0x2700, |
| 372 | .desc_fifo_size = 0x300, |
| 373 | }, |
| 374 | [1][PEER_PERIPHERAL_TO_USB] = { |
| 375 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 376 | .src_pipe_index = 3, |
| 377 | .dst_phy_addr = HSIC_BAM_PHY_BASE, |
| 378 | .dst_pipe_index = 2, |
| 379 | .data_fifo_base_offset = 0x1a00, |
| 380 | .data_fifo_size = 0x600, |
| 381 | .desc_fifo_base_offset = 0x2000, |
| 382 | .desc_fifo_size = 0x100, |
| 383 | }, |
| 384 | [2][USB_TO_PEER_PERIPHERAL] = { |
| 385 | .src_phy_addr = HSIC_BAM_PHY_BASE, |
| 386 | .src_pipe_index = 5, |
| 387 | .dst_phy_addr = A2_BAM_PHY_BASE, |
| 388 | .dst_pipe_index = 4, |
| 389 | .data_fifo_base_offset = 0x3100, |
| 390 | .data_fifo_size = 0x600, |
| 391 | .desc_fifo_base_offset = 0x3700, |
| 392 | .desc_fifo_size = 0x300, |
| 393 | }, |
| 394 | [2][PEER_PERIPHERAL_TO_USB] = { |
| 395 | .src_phy_addr = A2_BAM_PHY_BASE, |
| 396 | .src_pipe_index = 5, |
| 397 | .dst_phy_addr = HSIC_BAM_PHY_BASE, |
| 398 | .dst_pipe_index = 4, |
| 399 | .data_fifo_base_offset = 0x2a00, |
| 400 | .data_fifo_size = 0x600, |
| 401 | .desc_fifo_base_offset = 0x3000, |
| 402 | .desc_fifo_size = 0x100, |
| 403 | } |
| 404 | #endif |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 405 | }; |
| 406 | |
| 407 | static struct msm_usb_bam_platform_data msm_usb_bam_pdata = { |
| 408 | .connections = &msm_usb_bam_connections[0][0], |
Ofir Cohen | 43473c8 | 2012-01-25 16:28:13 +0200 | [diff] [blame] | 409 | #ifndef CONFIG_USB_GADGET_CI13XXX_MSM_HSIC |
| 410 | .usb_active_bam = HSUSB_BAM, |
| 411 | .usb_bam_num_pipes = 16, |
| 412 | #else |
| 413 | .usb_active_bam = HSIC_BAM, |
| 414 | .usb_bam_num_pipes = 16, |
| 415 | #endif |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 416 | }; |
| 417 | |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 418 | static struct msm_otg_platform_data msm_otg_pdata = { |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 419 | .mode = USB_OTG, |
| 420 | .otg_control = OTG_PHY_CONTROL, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 421 | .phy_type = SNPS_28NM_INTEGRATED_PHY, |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 422 | .vbus_power = msm_hsusb_vbus_power, |
Ofir Cohen | 4da266f | 2012-01-03 10:19:29 +0200 | [diff] [blame] | 423 | .disable_reset_on_disconnect = true, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 424 | }; |
| 425 | |
Amit Blay | 5f968cf | 2012-01-22 12:04:01 +0200 | [diff] [blame] | 426 | #define PID_MAGIC_ID 0x71432909 |
| 427 | #define SERIAL_NUM_MAGIC_ID 0x61945374 |
| 428 | #define SERIAL_NUMBER_LENGTH 127 |
| 429 | #define DLOAD_USB_BASE_ADD 0x2B0000C8 |
| 430 | |
| 431 | struct magic_num_struct { |
| 432 | uint32_t pid; |
| 433 | uint32_t serial_num; |
| 434 | }; |
| 435 | |
| 436 | struct dload_struct { |
| 437 | uint32_t reserved1; |
| 438 | uint32_t reserved2; |
| 439 | uint32_t reserved3; |
| 440 | uint16_t reserved4; |
| 441 | uint16_t pid; |
| 442 | char serial_number[SERIAL_NUMBER_LENGTH]; |
| 443 | uint16_t reserved5; |
| 444 | struct magic_num_struct magic_struct; |
| 445 | }; |
| 446 | |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 447 | static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum) |
| 448 | { |
Amit Blay | 5f968cf | 2012-01-22 12:04:01 +0200 | [diff] [blame] | 449 | struct dload_struct __iomem *dload = 0; |
| 450 | |
| 451 | dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload)); |
| 452 | if (!dload) { |
| 453 | pr_err("%s: cannot remap I/O memory region: %08x\n", |
| 454 | __func__, DLOAD_USB_BASE_ADD); |
| 455 | return -ENXIO; |
| 456 | } |
| 457 | |
| 458 | pr_debug("%s: dload:%p pid:%x serial_num:%s\n", |
| 459 | __func__, dload, pid, snum); |
| 460 | /* update pid */ |
| 461 | dload->magic_struct.pid = PID_MAGIC_ID; |
| 462 | dload->pid = pid; |
| 463 | |
| 464 | /* update serial number */ |
| 465 | dload->magic_struct.serial_num = 0; |
| 466 | if (!snum) { |
| 467 | memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH); |
| 468 | goto out; |
| 469 | } |
| 470 | |
| 471 | dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID; |
| 472 | strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH); |
| 473 | out: |
| 474 | iounmap(dload); |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | static struct android_usb_platform_data android_usb_pdata = { |
| 479 | .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num, |
| 480 | }; |
| 481 | |
| 482 | static struct platform_device android_usb_device = { |
| 483 | .name = "android_usb", |
| 484 | .id = -1, |
| 485 | .dev = { |
| 486 | .platform_data = &android_usb_pdata, |
| 487 | }, |
| 488 | }; |
| 489 | |
Rohit Vaswani | 149f0a7 | 2011-11-09 15:21:28 -0800 | [diff] [blame] | 490 | static struct platform_device msm_wlan_ar6000_pm_device = { |
| 491 | .name = "wlan_ar6000_pm_dev", |
| 492 | .id = -1, |
| 493 | }; |
| 494 | |
| 495 | static int __init msm9615_init_ar6000pm(void) |
| 496 | { |
| 497 | return platform_device_register(&msm_wlan_ar6000_pm_device); |
| 498 | } |
| 499 | |
Jay Chokshi | dc8028b | 2011-12-01 16:17:34 -0800 | [diff] [blame] | 500 | #ifdef CONFIG_LTC4088_CHARGER |
| 501 | static struct platform_device msm_device_charger = { |
| 502 | .name = LTC4088_CHARGER_DEV_NAME, |
| 503 | .id = -1, |
| 504 | .dev = { |
| 505 | .platform_data = <c4088_chg_pdata, |
| 506 | }, |
| 507 | }; |
| 508 | #endif |
| 509 | |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 510 | static struct platform_device *common_devices[] = { |
| 511 | &msm9615_device_dmov, |
| 512 | &msm_device_smd, |
Jay Chokshi | dc8028b | 2011-12-01 16:17:34 -0800 | [diff] [blame] | 513 | #ifdef CONFIG_LTC4088_CHARGER |
| 514 | &msm_device_charger, |
| 515 | #endif |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 516 | &msm_device_otg, |
Ofir Cohen | 73c99e8 | 2012-01-15 13:38:14 +0200 | [diff] [blame] | 517 | &msm_device_hsic_peripheral, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 518 | &msm_device_gadget_peripheral, |
Amit Blay | 6a8d4f3 | 2011-11-21 10:36:25 +0200 | [diff] [blame] | 519 | &msm_device_hsusb_host, |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 520 | &msm_device_usb_bam, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 521 | &android_usb_device, |
| 522 | &msm9615_device_uart_gsbi4, |
David Collins | 0f9942a | 2011-10-31 09:47:34 -0700 | [diff] [blame] | 523 | &msm9615_device_ext_2p95v_vreg, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 524 | &msm9615_device_ssbi_pmic1, |
| 525 | &msm9615_device_qup_i2c_gsbi5, |
| 526 | &msm9615_device_qup_spi_gsbi3, |
| 527 | &msm_device_sps, |
Sagar Dharia | 2a5378d | 2011-12-01 20:00:11 -0700 | [diff] [blame] | 528 | &msm9615_slim_ctrl, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 529 | &msm9615_device_tsens, |
| 530 | &msm_device_nand, |
Eric Holmberg | 0c96e70 | 2011-11-08 18:04:31 -0700 | [diff] [blame] | 531 | &msm_device_bam_dmux, |
Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 532 | &msm9615_rpm_device, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 533 | #ifdef CONFIG_HW_RANDOM_MSM |
| 534 | &msm_device_rng, |
| 535 | #endif |
| 536 | |
| 537 | #if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \ |
| 538 | defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE) |
Ramesh Masavarapu | aa28b5b | 2011-10-21 10:26:03 -0700 | [diff] [blame] | 539 | &msm9615_qcrypto_device, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 540 | #endif |
| 541 | |
| 542 | #if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \ |
| 543 | defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE) |
Ramesh Masavarapu | aa28b5b | 2011-10-21 10:26:03 -0700 | [diff] [blame] | 544 | &msm9615_qcedev_device, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 545 | #endif |
Jeff Ohlstein | 7e66855 | 2011-10-06 16:17:25 -0700 | [diff] [blame] | 546 | &msm9615_device_watchdog, |
Gagan Mac | 7a82764 | 2011-09-22 19:42:21 -0600 | [diff] [blame] | 547 | &msm_bus_9615_sys_fabric, |
| 548 | &msm_bus_def_fab, |
Praveen Chidambaram | 7849901 | 2011-11-01 17:15:17 -0600 | [diff] [blame] | 549 | &msm9615_rpm_log_device, |
| 550 | &msm9615_rpm_stat_device, |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 551 | }; |
| 552 | |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 553 | static void __init msm9615_i2c_init(void) |
| 554 | { |
| 555 | msm9615_device_qup_i2c_gsbi5.dev.platform_data = |
| 556 | &msm9615_i2c_qup_gsbi5_pdata; |
| 557 | } |
| 558 | |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 559 | static void __init msm9615_reserve(void) |
| 560 | { |
| 561 | msm_pm_boot_pdata.p_addr = memblock_alloc(SZ_8, SZ_64K); |
| 562 | } |
| 563 | |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 564 | static void __init msm9615_common_init(void) |
| 565 | { |
| 566 | msm9615_device_init(); |
Rohit Vaswani | a681589 | 2011-12-15 20:20:39 -0800 | [diff] [blame] | 567 | msm9615_init_gpiomux(); |
Harini Jayaraman | eba5267 | 2011-09-08 15:13:00 -0600 | [diff] [blame] | 568 | msm9615_i2c_init(); |
David Collins | 00b31e6 | 2011-08-31 20:00:10 -0700 | [diff] [blame] | 569 | regulator_suppress_info_printing(); |
David Collins | bea297a | 2011-09-28 13:11:14 -0700 | [diff] [blame] | 570 | platform_device_register(&msm9615_device_rpm_regulator); |
Gagan Mac | 7a82764 | 2011-09-22 19:42:21 -0600 | [diff] [blame] | 571 | msm_clock_init(&msm9615_clock_init_data); |
| 572 | msm9615_init_buses(); |
Harini Jayaraman | 738c931 | 2011-09-08 15:22:38 -0600 | [diff] [blame] | 573 | msm9615_device_qup_spi_gsbi3.dev.platform_data = |
| 574 | &msm9615_qup_spi_gsbi3_pdata; |
Kenneth Heitke | af3d3cf | 2011-09-08 11:45:31 -0700 | [diff] [blame] | 575 | msm9615_device_ssbi_pmic1.dev.platform_data = |
| 576 | &msm9615_ssbi_pm8018_pdata; |
David Collins | 00b31e6 | 2011-08-31 20:00:10 -0700 | [diff] [blame] | 577 | pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len; |
Amit Blay | 5e4ec19 | 2011-10-20 09:16:54 +0200 | [diff] [blame] | 578 | |
| 579 | msm_device_otg.dev.platform_data = &msm_otg_pdata; |
Anji jonnala | a8b8d73 | 2011-12-06 10:03:24 +0530 | [diff] [blame] | 580 | msm_otg_pdata.phy_init_seq = shelby_phy_init_seq; |
Ofir Cohen | 40a4e86 | 2011-12-08 15:17:52 +0200 | [diff] [blame] | 581 | msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata; |
Rohit Vaswani | 0966687 | 2011-08-23 17:41:54 -0700 | [diff] [blame] | 582 | platform_add_devices(common_devices, ARRAY_SIZE(common_devices)); |
Krishna Konda | dd79446 | 2011-10-01 00:19:29 -0700 | [diff] [blame] | 583 | |
Vikram Mulukutla | b5e1cda | 2011-10-04 16:17:22 -0700 | [diff] [blame] | 584 | acpuclk_init(&acpuclk_9615_soc_data); |
| 585 | |
Rohit Vaswani | 149f0a7 | 2011-11-09 15:21:28 -0800 | [diff] [blame] | 586 | /* Ensure ar6000pm device is registered before MMC/SDC */ |
| 587 | msm9615_init_ar6000pm(); |
| 588 | |
Krishna Konda | dd79446 | 2011-10-01 00:19:29 -0700 | [diff] [blame] | 589 | msm9615_init_mmc(); |
Sagar Dharia | 2a5378d | 2011-12-01 20:00:11 -0700 | [diff] [blame] | 590 | slim_register_board_info(msm_slim_devices, |
| 591 | ARRAY_SIZE(msm_slim_devices)); |
Maheshkumar Sivasubramanian | 4923db2 | 2011-09-15 09:28:15 -0600 | [diff] [blame] | 592 | msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data)); |
| 593 | msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ); |
| 594 | msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates), |
| 595 | msm_pm_data); |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 596 | BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata)); |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | static void __init msm9615_cdp_init(void) |
| 600 | { |
| 601 | msm9615_common_init(); |
| 602 | } |
| 603 | |
| 604 | static void __init msm9615_mtp_init(void) |
| 605 | { |
| 606 | msm9615_common_init(); |
| 607 | } |
| 608 | |
| 609 | MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP") |
| 610 | .map_io = msm9615_map_io, |
| 611 | .init_irq = msm9615_init_irq, |
Marc Zyngier | 89bdafd1 | 2011-12-22 11:39:20 +0530 | [diff] [blame] | 612 | .handle_irq = gic_handle_irq, |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 613 | .timer = &msm_timer, |
| 614 | .init_machine = msm9615_cdp_init, |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 615 | .reserve = msm9615_reserve, |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 616 | MACHINE_END |
| 617 | |
| 618 | MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP") |
| 619 | .map_io = msm9615_map_io, |
| 620 | .init_irq = msm9615_init_irq, |
Marc Zyngier | 89bdafd1 | 2011-12-22 11:39:20 +0530 | [diff] [blame] | 621 | .handle_irq = gic_handle_irq, |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 622 | .timer = &msm_timer, |
| 623 | .init_machine = msm9615_mtp_init, |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 624 | .reserve = msm9615_reserve, |
Rohit Vaswani | ced9b3b | 2011-08-23 17:21:49 -0700 | [diff] [blame] | 625 | MACHINE_END |