blob: 77ee09f87da74d2e9c869ef524f42f5472860dbf [file] [log] [blame]
Manu Gautam5143b252012-01-05 19:25:23 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -07002 *
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 Blay5f968cf2012-01-22 12:04:01 +020015#include <linux/io.h>
Harini Jayaramaneba52672011-09-08 15:13:00 -060016#include <linux/i2c.h>
Sagar Dharia2a5378d2011-12-01 20:00:11 -070017#include <linux/slimbus/slimbus.h>
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -080018#ifdef CONFIG_WCD9310_CODEC
19#include <linux/mfd/wcd9xxx/core.h>
20#include <linux/mfd/wcd9xxx/pdata.h>
21#endif
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070022#include <linux/msm_ssbi.h>
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060023#include <linux/memblock.h>
Rohit Vaswania6815892011-12-15 20:20:39 -080024#include <linux/usb/android.h>
25#include <linux/usb/msm_hsusb.h>
26#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
27#include <linux/leds.h>
28#include <linux/leds-pm8xxx.h>
29#include <linux/power/ltc4088-charger.h>
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -070030#include <linux/msm_tsens.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070031#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
Marc Zyngier89bdafd12011-12-22 11:39:20 +053033#include <asm/hardware/gic.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070034#include <mach/board.h>
35#include <mach/msm_iomap.h>
36#include <mach/gpio.h>
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -080037#include <mach/socinfo.h>
Harini Jayaraman738c9312011-09-08 15:22:38 -060038#include <mach/msm_spi.h>
Gagan Mac7a827642011-09-22 19:42:21 -060039#include <mach/msm_bus_board.h>
Vikram Mulukutla2021c002011-12-16 12:32:59 -080040#include <mach/msm_xo.h>
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -080041#include <mach/dma.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070042#include "timer.h"
43#include "devices.h"
David Collinsfb88c432011-08-25 15:12:47 -070044#include "board-9615.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080045#include <mach/cpuidle.h>
Matt Wagantall7cca4642012-02-01 16:43:24 -080046#include "pm.h"
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -070047#include "acpuclock.h"
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060048#include "pm-boot.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070049
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -070050static struct pm8xxx_adc_amux pm8018_adc_channels_data[] = {
51 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
52 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
53 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
54 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
55 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
56 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
57 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
58 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
59 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2,
60 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
61 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
62 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
63 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
64 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
65 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
66 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
67 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
68 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
69};
70
71static struct pm8xxx_adc_properties pm8018_adc_data = {
72 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
73 .bitresolution = 15,
74 .bipolar = 0,
75};
76
77static struct pm8xxx_adc_platform_data pm8018_adc_pdata = {
78 .adc_channel = pm8018_adc_channels_data,
79 .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data),
80 .adc_prop = &pm8018_adc_data,
81};
82
David Collinsfb88c432011-08-25 15:12:47 -070083static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
84 .irq_base = PM8018_IRQ_BASE,
85 .devirq = MSM_GPIO_TO_INT(87),
86 .irq_trigger_flag = IRQF_TRIGGER_LOW,
87};
88
89static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
90 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
91};
92
93static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
94 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
95};
96
97static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
98 .rtc_write_enable = false,
Ashay Jaiswaldb5e6dc2011-10-12 11:02:47 +053099 .rtc_alarm_powerup = false,
David Collinsfb88c432011-08-25 15:12:47 -0700100};
101
102static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
103 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -0800104 .kpd_trigger_delay_us = 15625,
David Collinsfb88c432011-08-25 15:12:47 -0700105 .wakeup = 1,
106};
107
108static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
109 .priority = 0,
110};
111
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700112#define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */
113#define PM8XXX_LED_PWM_PERIOD_US 1000
114
115/**
116 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
117 * driven using PWM feature.
118 */
119#define PM8XXX_PWM_CHANNEL_NONE -1
120
121static struct led_info pm8018_led_info[] = {
122 [0] = {
123 .name = "led:kb",
124 },
125};
126
127static struct led_platform_data pm8018_led_core_pdata = {
128 .num_leds = ARRAY_SIZE(pm8018_led_info),
129 .leds = pm8018_led_info,
130};
131
132static struct pm8xxx_led_config pm8018_led_configs[] = {
133 [0] = {
134 .id = PM8XXX_ID_LED_KB_LIGHT,
135 .mode = PM8XXX_LED_MODE_PWM3,
136 .max_current = PM8018_LED_KB_MAX_CURRENT,
137 .pwm_channel = 2,
138 .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US,
139 },
140};
141
142static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
143 .led_core = &pm8018_led_core_pdata,
144 .configs = pm8018_led_configs,
145 .num_configs = ARRAY_SIZE(pm8018_led_configs),
146};
147
Jay Chokshidc8028b2011-12-01 16:17:34 -0800148#ifdef CONFIG_LTC4088_CHARGER
149static struct ltc4088_charger_platform_data ltc4088_chg_pdata = {
150 .gpio_mode_select_d0 = 7,
151 .gpio_mode_select_d1 = 6,
152 .gpio_mode_select_d2 = 4,
153};
154#endif
155
David Collinsfb88c432011-08-25 15:12:47 -0700156static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
157 .irq_pdata = &pm8xxx_irq_pdata,
158 .gpio_pdata = &pm8xxx_gpio_pdata,
159 .mpp_pdata = &pm8xxx_mpp_pdata,
160 .rtc_pdata = &pm8xxx_rtc_pdata,
161 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
162 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -0700163 .regulator_pdatas = msm_pm8018_regulator_pdata,
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700164 .adc_pdata = &pm8018_adc_pdata,
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700165 .leds_pdata = &pm8xxx_leds_pdata,
David Collinsfb88c432011-08-25 15:12:47 -0700166};
167
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700168static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
169 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
170 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -0700171 .name = PM8018_CORE_DEV_NAME,
172 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700173 },
174};
175
David Collinsbea297a2011-09-28 13:11:14 -0700176static struct platform_device msm9615_device_rpm_regulator __devinitdata = {
177 .name = "rpm-regulator",
178 .id = -1,
179 .dev = {
180 .platform_data = &msm_rpm_regulator_9615_pdata,
181 },
182};
183
David Collins0f9942a2011-10-31 09:47:34 -0700184static struct platform_device msm9615_device_ext_2p95v_vreg = {
185 .name = GPIO_REGULATOR_DEV_NAME,
186 .id = 18,
187 .dev = {
188 .platform_data =
189 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V],
190 },
191};
192
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600193static struct msm_cpuidle_state msm_cstates[] __initdata = {
194 {0, 0, "C0", "WFI",
195 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
196
197 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
198 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
199
200 {0, 2, "C2", "POWER_COLLAPSE",
201 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
202};
203static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
204 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
205 .idle_supported = 1,
206 .suspend_supported = 1,
207 .idle_enabled = 0,
208 .suspend_enabled = 0,
209 },
210 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
211 .idle_supported = 1,
212 .suspend_supported = 1,
213 .idle_enabled = 0,
214 .suspend_enabled = 0,
215 },
216 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
217 .idle_supported = 1,
218 .suspend_supported = 1,
219 .idle_enabled = 1,
220 .suspend_enabled = 1,
221 },
222};
Krishna Kondadd794462011-10-01 00:19:29 -0700223
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600224static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
225 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
226 .v_addr = MSM_APCS_GLB_BASE + 0x24,
227};
228
Gagan Mac7a827642011-09-22 19:42:21 -0600229static void __init msm9615_init_buses(void)
230{
231#ifdef CONFIG_MSM_BUS_SCALING
232 msm_bus_rpm_set_mt_mask();
233 msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
234 msm_bus_9615_sys_fabric.dev.platform_data =
235 &msm_bus_9615_sys_fabric_pdata;
236 msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
237#endif
238}
239
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800240#ifdef CONFIG_WCD9310_CODEC
241
242#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS)
243
244/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
245 * 4 micbiases are used to power various analog and digital
246 * microphones operating at 1800 mV. Technically, all micbiases
247 * can source from single cfilter since all microphones operate
248 * at the same voltage level. The arrangement below is to make
249 * sure all cfilters are exercised. LDO_H regulator ouput level
250 * does not need to be as high as 2.85V. It is choosen for
251 * microphone sensitivity purpose.
252 */
253
254static struct wcd9xxx_pdata tabla20_platform_data = {
255 .slimbus_slave_device = {
256 .name = "tabla-slave",
257 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
258 },
259 .irq = 85,
260 .irq_base = TABLA_INTERRUPT_BASE,
261 .num_irqs = NR_WCD9XXX_IRQS,
262 .reset_gpio = 84,
263 .micbias = {
264 .ldoh_v = TABLA_LDOH_2P85_V,
265 .cfilt1_mv = 1800,
266 .cfilt2_mv = 1800,
267 .cfilt3_mv = 1800,
268 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
269 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
270 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
271 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
272 },
273 .regulator = {
274 {
275 .name = "CDC_VDD_CP",
276 .min_uV = 1800000,
277 .max_uV = 1800000,
278 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
279 },
280 {
281 .name = "CDC_VDDA_RX",
282 .min_uV = 1800000,
283 .max_uV = 1800000,
284 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
285 },
286 {
287 .name = "CDC_VDDA_TX",
288 .min_uV = 1800000,
289 .max_uV = 1800000,
290 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
291 },
292 {
293 .name = "VDDIO_CDC",
294 .min_uV = 1800000,
295 .max_uV = 1800000,
296 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
297 },
298 {
299 .name = "VDDD_CDC_D",
300 .min_uV = 1225000,
301 .max_uV = 1225000,
302 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
303 },
304 {
305 .name = "CDC_VDDA_A_1P2V",
306 .min_uV = 1225000,
307 .max_uV = 1225000,
308 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
309 },
310 },
311};
312
313static struct slim_device msm_slim_tabla20 = {
314 .name = "tabla2x-slim",
315 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
316 .dev = {
317 .platform_data = &tabla20_platform_data,
318 },
319};
320#endif
321
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700322static struct slim_boardinfo msm_slim_devices[] = {
323 /* add slimbus slaves as needed */
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800324#ifdef CONFIG_WCD9310_CODEC
325 {
326 .bus_num = 1,
327 .slim_slave = &msm_slim_tabla20,
328 },
329#endif
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700330};
331
Harini Jayaraman738c9312011-09-08 15:22:38 -0600332static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
333 .max_clock_speed = 24000000,
334};
335
Harini Jayaramaneba52672011-09-08 15:13:00 -0600336static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
337 .clk_freq = 100000,
338 .src_clk_rate = 24000000,
339};
340
Amit Blay6a8d4f32011-11-21 10:36:25 +0200341#define USB_5V_EN 3
342#define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN)
343
Mayank Rana8549e632012-01-23 12:49:54 +0530344static int msm_hsusb_vbus_power(bool on)
Amit Blay6a8d4f32011-11-21 10:36:25 +0200345{
Amit Blaya4416f92012-01-24 21:03:52 +0200346 int rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200347 struct pm_gpio usb_vbus = {
348 .direction = PM_GPIO_DIR_OUT,
349 .pull = PM_GPIO_PULL_NO,
350 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200351 .vin_sel = 2,
352 .out_strength = PM_GPIO_STRENGTH_HIGH,
353 .function = PM_GPIO_FUNC_NORMAL,
354 .inv_int_pol = 0,
355 };
356
Amit Blaya4416f92012-01-24 21:03:52 +0200357 usb_vbus.output_value = on;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200358
Amit Blaya4416f92012-01-24 21:03:52 +0200359 rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus);
360 if (rc)
361 pr_err("failed to config usb_5v_en gpio\n");
Amit Blay6a8d4f32011-11-21 10:36:25 +0200362
Mayank Rana8549e632012-01-23 12:49:54 +0530363 return rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200364}
365
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530366static int shelby_phy_init_seq[] = {
367 0x44, 0x80,/* set VBUS valid threshold and
368 disconnect valid threshold */
369 0x38, 0x81, /* update DC voltage level */
Amit Blaydbaeff82012-04-02 22:13:36 +0300370 0x24, 0x82,/* set preemphasis and rise/fall time */
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530371 0x13, 0x83,/* set source impedance adjustment */
372 -1};
373
Ofir Cohen40a4e862011-12-08 15:17:52 +0200374#define USB_BAM_PHY_BASE 0x12502000
Ofir Cohen43473c82012-01-25 16:28:13 +0200375#define HSIC_BAM_PHY_BASE 0x12542000
Ofir Cohen40a4e862011-12-08 15:17:52 +0200376#define A2_BAM_PHY_BASE 0x124C2000
Lena Salmana66eddf2012-03-26 13:03:43 +0200377static struct usb_bam_pipe_connect msm_usb_bam_connections[2][4][2] = {
378 [0][0][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen40a4e862011-12-08 15:17:52 +0200379 .src_phy_addr = USB_BAM_PHY_BASE,
380 .src_pipe_index = 11,
381 .dst_phy_addr = A2_BAM_PHY_BASE,
382 .dst_pipe_index = 0,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200383 .data_fifo_base_offset = 0x1100,
384 .data_fifo_size = 0x600,
385 .desc_fifo_base_offset = 0x1700,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200386 .desc_fifo_size = 0x300,
387 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200388 [0][0][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen40a4e862011-12-08 15:17:52 +0200389 .src_phy_addr = A2_BAM_PHY_BASE,
390 .src_pipe_index = 1,
391 .dst_phy_addr = USB_BAM_PHY_BASE,
392 .dst_pipe_index = 10,
393 .data_fifo_base_offset = 0xa00,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200394 .data_fifo_size = 0x600,
395 .desc_fifo_base_offset = 0x1000,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200396 .desc_fifo_size = 0x100,
397 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200398 [0][1][USB_TO_PEER_PERIPHERAL] = {
Anna Perel21515162012-02-02 20:50:02 +0200399 .src_phy_addr = USB_BAM_PHY_BASE,
400 .src_pipe_index = 13,
401 .dst_phy_addr = A2_BAM_PHY_BASE,
402 .dst_pipe_index = 2,
403 .data_fifo_base_offset = 0x2100,
404 .data_fifo_size = 0x600,
405 .desc_fifo_base_offset = 0x2700,
406 .desc_fifo_size = 0x300,
407 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200408 [0][1][PEER_PERIPHERAL_TO_USB] = {
Anna Perel21515162012-02-02 20:50:02 +0200409 .src_phy_addr = A2_BAM_PHY_BASE,
410 .src_pipe_index = 3,
411 .dst_phy_addr = USB_BAM_PHY_BASE,
412 .dst_pipe_index = 12,
413 .data_fifo_base_offset = 0x1a00,
414 .data_fifo_size = 0x600,
415 .desc_fifo_base_offset = 0x2000,
416 .desc_fifo_size = 0x100,
417 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200418 [0][2][USB_TO_PEER_PERIPHERAL] = {
Anna Perel21515162012-02-02 20:50:02 +0200419 .src_phy_addr = USB_BAM_PHY_BASE,
420 .src_pipe_index = 15,
421 .dst_phy_addr = A2_BAM_PHY_BASE,
422 .dst_pipe_index = 4,
423 .data_fifo_base_offset = 0x3100,
424 .data_fifo_size = 0x600,
425 .desc_fifo_base_offset = 0x3700,
426 .desc_fifo_size = 0x300,
427 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200428 [0][2][PEER_PERIPHERAL_TO_USB] = {
Anna Perel21515162012-02-02 20:50:02 +0200429 .src_phy_addr = A2_BAM_PHY_BASE,
430 .src_pipe_index = 5,
431 .dst_phy_addr = USB_BAM_PHY_BASE,
432 .dst_pipe_index = 14,
433 .data_fifo_base_offset = 0x2a00,
434 .data_fifo_size = 0x600,
435 .desc_fifo_base_offset = 0x3000,
436 .desc_fifo_size = 0x100,
Lena Salmana66eddf2012-03-26 13:03:43 +0200437 },
438 [1][0][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200439 .src_phy_addr = HSIC_BAM_PHY_BASE,
440 .src_pipe_index = 1,
441 .dst_phy_addr = A2_BAM_PHY_BASE,
442 .dst_pipe_index = 0,
443 .data_fifo_base_offset = 0x1100,
444 .data_fifo_size = 0x600,
445 .desc_fifo_base_offset = 0x1700,
446 .desc_fifo_size = 0x300,
447 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200448 [1][0][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200449 .src_phy_addr = A2_BAM_PHY_BASE,
450 .src_pipe_index = 1,
451 .dst_phy_addr = HSIC_BAM_PHY_BASE,
452 .dst_pipe_index = 0,
453 .data_fifo_base_offset = 0xa00,
454 .data_fifo_size = 0x600,
455 .desc_fifo_base_offset = 0x1000,
456 .desc_fifo_size = 0x100,
457 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200458 [1][1][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200459 .src_phy_addr = HSIC_BAM_PHY_BASE,
460 .src_pipe_index = 3,
461 .dst_phy_addr = A2_BAM_PHY_BASE,
462 .dst_pipe_index = 2,
463 .data_fifo_base_offset = 0x2100,
464 .data_fifo_size = 0x600,
465 .desc_fifo_base_offset = 0x2700,
466 .desc_fifo_size = 0x300,
467 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200468 [1][1][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200469 .src_phy_addr = A2_BAM_PHY_BASE,
470 .src_pipe_index = 3,
471 .dst_phy_addr = HSIC_BAM_PHY_BASE,
472 .dst_pipe_index = 2,
473 .data_fifo_base_offset = 0x1a00,
474 .data_fifo_size = 0x600,
475 .desc_fifo_base_offset = 0x2000,
476 .desc_fifo_size = 0x100,
477 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200478 [1][2][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200479 .src_phy_addr = HSIC_BAM_PHY_BASE,
480 .src_pipe_index = 5,
481 .dst_phy_addr = A2_BAM_PHY_BASE,
482 .dst_pipe_index = 4,
483 .data_fifo_base_offset = 0x3100,
484 .data_fifo_size = 0x600,
485 .desc_fifo_base_offset = 0x3700,
486 .desc_fifo_size = 0x300,
487 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200488 [1][2][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200489 .src_phy_addr = A2_BAM_PHY_BASE,
490 .src_pipe_index = 5,
491 .dst_phy_addr = HSIC_BAM_PHY_BASE,
492 .dst_pipe_index = 4,
493 .data_fifo_base_offset = 0x2a00,
494 .data_fifo_size = 0x600,
495 .desc_fifo_base_offset = 0x3000,
496 .desc_fifo_size = 0x100,
497 }
Ofir Cohen40a4e862011-12-08 15:17:52 +0200498};
499
500static struct msm_usb_bam_platform_data msm_usb_bam_pdata = {
Lena Salmana66eddf2012-03-26 13:03:43 +0200501 .connections = &msm_usb_bam_connections[0][0][0],
Lena Salman57d167e2012-03-21 19:46:38 +0200502#ifndef CONFIG_USB_CI13XXX_MSM_HSIC
Ofir Cohen43473c82012-01-25 16:28:13 +0200503 .usb_active_bam = HSUSB_BAM,
Ofir Cohen43473c82012-01-25 16:28:13 +0200504#else
505 .usb_active_bam = HSIC_BAM,
Ofir Cohen43473c82012-01-25 16:28:13 +0200506#endif
Lena Salmana66eddf2012-03-26 13:03:43 +0200507 .usb_bam_num_pipes = 16,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200508};
509
Amit Blay5e4ec192011-10-20 09:16:54 +0200510static struct msm_otg_platform_data msm_otg_pdata = {
Amit Blay6a8d4f32011-11-21 10:36:25 +0200511 .mode = USB_OTG,
512 .otg_control = OTG_PHY_CONTROL,
Amit Blay5e4ec192011-10-20 09:16:54 +0200513 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200514 .vbus_power = msm_hsusb_vbus_power,
Ofir Cohen4da266f2012-01-03 10:19:29 +0200515 .disable_reset_on_disconnect = true,
Amit Blay5e4ec192011-10-20 09:16:54 +0200516};
517
Amit Blay5f968cf2012-01-22 12:04:01 +0200518#define PID_MAGIC_ID 0x71432909
519#define SERIAL_NUM_MAGIC_ID 0x61945374
520#define SERIAL_NUMBER_LENGTH 127
521#define DLOAD_USB_BASE_ADD 0x2B0000C8
522
523struct magic_num_struct {
524 uint32_t pid;
525 uint32_t serial_num;
526};
527
528struct dload_struct {
529 uint32_t reserved1;
530 uint32_t reserved2;
531 uint32_t reserved3;
532 uint16_t reserved4;
533 uint16_t pid;
534 char serial_number[SERIAL_NUMBER_LENGTH];
535 uint16_t reserved5;
536 struct magic_num_struct magic_struct;
537};
538
Amit Blay5e4ec192011-10-20 09:16:54 +0200539static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
540{
Amit Blay5f968cf2012-01-22 12:04:01 +0200541 struct dload_struct __iomem *dload = 0;
542
543 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
544 if (!dload) {
545 pr_err("%s: cannot remap I/O memory region: %08x\n",
546 __func__, DLOAD_USB_BASE_ADD);
547 return -ENXIO;
548 }
549
550 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
551 __func__, dload, pid, snum);
552 /* update pid */
553 dload->magic_struct.pid = PID_MAGIC_ID;
554 dload->pid = pid;
555
556 /* update serial number */
557 dload->magic_struct.serial_num = 0;
558 if (!snum) {
559 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
560 goto out;
561 }
562
563 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
564 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
565out:
566 iounmap(dload);
Amit Blay5e4ec192011-10-20 09:16:54 +0200567 return 0;
568}
569
570static struct android_usb_platform_data android_usb_pdata = {
571 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
572};
573
574static struct platform_device android_usb_device = {
575 .name = "android_usb",
576 .id = -1,
577 .dev = {
578 .platform_data = &android_usb_pdata,
579 },
580};
581
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800582static struct platform_device msm_wlan_ar6000_pm_device = {
583 .name = "wlan_ar6000_pm_dev",
584 .id = -1,
585};
586
587static int __init msm9615_init_ar6000pm(void)
588{
589 return platform_device_register(&msm_wlan_ar6000_pm_device);
590}
591
Jay Chokshidc8028b2011-12-01 16:17:34 -0800592#ifdef CONFIG_LTC4088_CHARGER
593static struct platform_device msm_device_charger = {
594 .name = LTC4088_CHARGER_DEV_NAME,
595 .id = -1,
596 .dev = {
597 .platform_data = &ltc4088_chg_pdata,
598 },
599};
600#endif
601
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700602static struct tsens_platform_data msm_tsens_pdata = {
603 .tsens_factor = 1000,
604 .hw_type = MDM_9615,
605 .tsens_num_sensor = 5,
606 .slope = {1176, 1176, 1154, 1176, 1111},
607};
608
Amit Blay5e4ec192011-10-20 09:16:54 +0200609static struct platform_device *common_devices[] = {
610 &msm9615_device_dmov,
611 &msm_device_smd,
Jay Chokshidc8028b2011-12-01 16:17:34 -0800612#ifdef CONFIG_LTC4088_CHARGER
613 &msm_device_charger,
614#endif
Lena Salman57d167e2012-03-21 19:46:38 +0200615#ifndef CONFIG_USB_CI13XXX_MSM_HSIC
Amit Blay5e4ec192011-10-20 09:16:54 +0200616 &msm_device_otg,
Ofir Cohendca06cb2012-03-08 16:37:45 +0200617#endif
Ofir Cohen73c99e82012-01-15 13:38:14 +0200618 &msm_device_hsic_peripheral,
Amit Blay5e4ec192011-10-20 09:16:54 +0200619 &msm_device_gadget_peripheral,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200620 &msm_device_hsusb_host,
Lena Salman65bcf372012-02-14 15:33:32 +0200621 &msm_device_hsic_host,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200622 &msm_device_usb_bam,
Amit Blay5e4ec192011-10-20 09:16:54 +0200623 &android_usb_device,
624 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700625 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200626 &msm9615_device_ssbi_pmic1,
627 &msm9615_device_qup_i2c_gsbi5,
628 &msm9615_device_qup_spi_gsbi3,
629 &msm_device_sps,
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700630 &msm9615_slim_ctrl,
Amit Blay5e4ec192011-10-20 09:16:54 +0200631 &msm_device_nand,
Eric Holmberg0c96e702011-11-08 18:04:31 -0700632 &msm_device_bam_dmux,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600633 &msm9615_rpm_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200634#ifdef CONFIG_HW_RANDOM_MSM
635 &msm_device_rng,
636#endif
637
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800638 &msm_pcm,
639 &msm_multi_ch_pcm,
640 &msm_pcm_routing,
641 &msm_cpudai0,
642 &msm_cpudai1,
643 &msm_cpudai_bt_rx,
644 &msm_cpudai_bt_tx,
645 &msm_cpu_fe,
646 &msm_stub_codec,
647 &msm_voice,
648 &msm_voip,
649 &msm_pcm_hostless,
650 &msm_cpudai_afe_01_rx,
651 &msm_cpudai_afe_01_tx,
652 &msm_cpudai_afe_02_rx,
653 &msm_cpudai_afe_02_tx,
654 &msm_pcm_afe,
655 &msm_cpudai_auxpcm_rx,
656 &msm_cpudai_auxpcm_tx,
657
Amit Blay5e4ec192011-10-20 09:16:54 +0200658#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
659 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700660 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200661#endif
662
663#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
664 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700665 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200666#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700667 &msm9615_device_watchdog,
Gagan Mac7a827642011-09-22 19:42:21 -0600668 &msm_bus_9615_sys_fabric,
669 &msm_bus_def_fab,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600670 &msm9615_rpm_log_device,
671 &msm9615_rpm_stat_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200672};
673
Harini Jayaramaneba52672011-09-08 15:13:00 -0600674static void __init msm9615_i2c_init(void)
675{
676 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
677 &msm9615_i2c_qup_gsbi5_pdata;
678}
679
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600680static void __init msm9615_reserve(void)
681{
682 msm_pm_boot_pdata.p_addr = memblock_alloc(SZ_8, SZ_64K);
683}
684
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700685static void __init msm9615_common_init(void)
686{
687 msm9615_device_init();
Rohit Vaswania6815892011-12-15 20:20:39 -0800688 msm9615_init_gpiomux();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600689 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700690 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700691 platform_device_register(&msm9615_device_rpm_regulator);
Vikram Mulukutla2021c002011-12-16 12:32:59 -0800692 msm_xo_init();
Gagan Mac7a827642011-09-22 19:42:21 -0600693 msm_clock_init(&msm9615_clock_init_data);
694 msm9615_init_buses();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600695 msm9615_device_qup_spi_gsbi3.dev.platform_data =
696 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700697 msm9615_device_ssbi_pmic1.dev.platform_data =
698 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700699 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200700
701 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530702 msm_otg_pdata.phy_init_seq = shelby_phy_init_seq;
Ofir Cohen40a4e862011-12-08 15:17:52 +0200703 msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700704 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700705
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700706 acpuclk_init(&acpuclk_9615_soc_data);
707
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800708 /* Ensure ar6000pm device is registered before MMC/SDC */
709 msm9615_init_ar6000pm();
710
Krishna Kondadd794462011-10-01 00:19:29 -0700711 msm9615_init_mmc();
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700712 slim_register_board_info(msm_slim_devices,
713 ARRAY_SIZE(msm_slim_devices));
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600714 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
715 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
716 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
717 msm_pm_data);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600718 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700719 msm_tsens_early_init(&msm_tsens_pdata);
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700720}
721
722static void __init msm9615_cdp_init(void)
723{
724 msm9615_common_init();
725}
726
727static void __init msm9615_mtp_init(void)
728{
729 msm9615_common_init();
730}
731
732MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
733 .map_io = msm9615_map_io,
734 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530735 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700736 .timer = &msm_timer,
737 .init_machine = msm9615_cdp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600738 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700739MACHINE_END
740
741MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
742 .map_io = msm9615_map_io,
743 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530744 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700745 .timer = &msm_timer,
746 .init_machine = msm9615_mtp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600747 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700748MACHINE_END