blob: 8a8e5757c3635835dc9cd3ea30b1bcd9afc8932c [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>
Olav Haugane6a0acd2012-04-05 09:29:12 -070031#include <linux/ion.h>
32#include <linux/memory.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070033#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
Marc Zyngier89bdafd12011-12-22 11:39:20 +053035#include <asm/hardware/gic.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070036#include <mach/board.h>
37#include <mach/msm_iomap.h>
38#include <mach/gpio.h>
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -080039#include <mach/socinfo.h>
Harini Jayaraman738c9312011-09-08 15:22:38 -060040#include <mach/msm_spi.h>
Gagan Mac7a827642011-09-22 19:42:21 -060041#include <mach/msm_bus_board.h>
Vikram Mulukutla2021c002011-12-16 12:32:59 -080042#include <mach/msm_xo.h>
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -080043#include <mach/dma.h>
Olav Haugane6a0acd2012-04-05 09:29:12 -070044#include <mach/ion.h>
45#include <mach/msm_memtypes.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070046#include "timer.h"
47#include "devices.h"
David Collinsfb88c432011-08-25 15:12:47 -070048#include "board-9615.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080049#include <mach/cpuidle.h>
Matt Wagantall7cca4642012-02-01 16:43:24 -080050#include "pm.h"
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -070051#include "acpuclock.h"
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060052#include "pm-boot.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070053
Olav Haugane6a0acd2012-04-05 09:29:12 -070054#ifdef CONFIG_ION_MSM
55#define MSM_ION_AUDIO_SIZE 0xAF000
56#define MSM_ION_HEAP_NUM 3
57#define MSM_KERNEL_EBI_SIZE 0x51000
58
59static struct memtype_reserve msm9615_reserve_table[] __initdata = {
60 [MEMTYPE_SMI] = {
61 },
62 [MEMTYPE_EBI0] = {
63 .flags = MEMTYPE_FLAGS_1M_ALIGN,
64 },
65 [MEMTYPE_EBI1] = {
66 .flags = MEMTYPE_FLAGS_1M_ALIGN,
67 },
68};
69
70static int msm9615_paddr_to_memtype(unsigned int paddr)
71{
72 return MEMTYPE_EBI1;
73}
74
75static struct ion_co_heap_pdata co_ion_pdata = {
76 .adjacent_mem_id = INVALID_HEAP_ID,
77 .align = PAGE_SIZE,
78};
79
80static struct ion_platform_data ion_pdata = {
81 .nr = MSM_ION_HEAP_NUM,
82 .heaps = {
83 {
84 .id = ION_SYSTEM_HEAP_ID,
85 .type = ION_HEAP_TYPE_SYSTEM,
86 .name = ION_VMALLOC_HEAP_NAME,
87 },
88 {
89 .id = ION_IOMMU_HEAP_ID,
90 .type = ION_HEAP_TYPE_IOMMU,
91 .name = ION_IOMMU_HEAP_NAME,
92 },
93 {
94 .id = ION_AUDIO_HEAP_ID,
95 .type = ION_HEAP_TYPE_CARVEOUT,
96 .name = ION_AUDIO_HEAP_NAME,
97 .size = MSM_ION_AUDIO_SIZE,
98 .memory_type = ION_EBI_TYPE,
99 .extra_data = (void *) &co_ion_pdata,
100 },
101 }
102};
103
104static struct platform_device ion_dev = {
105 .name = "ion-msm",
106 .id = 1,
107 .dev = { .platform_data = &ion_pdata },
108};
109
110static void reserve_ion_memory(void)
111{
112 msm9615_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
113}
114
115static void __init msm9615_calculate_reserve_sizes(void)
116{
117 reserve_ion_memory();
118 msm9615_reserve_table[MEMTYPE_EBI1].size += MSM_KERNEL_EBI_SIZE;
119}
120
121static struct reserve_info msm9615_reserve_info __initdata = {
122 .memtype_reserve_table = msm9615_reserve_table,
123 .calculate_reserve_sizes = msm9615_calculate_reserve_sizes,
124 .paddr_to_memtype = msm9615_paddr_to_memtype,
125};
126#endif
127
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700128static struct pm8xxx_adc_amux pm8018_adc_channels_data[] = {
129 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
130 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
131 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
132 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
133 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
134 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
135 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
136 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
137 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2,
138 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
139 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
140 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
141 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
142 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
143 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
144 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
145 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
146 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
147};
148
149static struct pm8xxx_adc_properties pm8018_adc_data = {
150 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
151 .bitresolution = 15,
152 .bipolar = 0,
153};
154
155static struct pm8xxx_adc_platform_data pm8018_adc_pdata = {
156 .adc_channel = pm8018_adc_channels_data,
157 .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data),
158 .adc_prop = &pm8018_adc_data,
159};
160
David Collinsfb88c432011-08-25 15:12:47 -0700161static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
162 .irq_base = PM8018_IRQ_BASE,
163 .devirq = MSM_GPIO_TO_INT(87),
164 .irq_trigger_flag = IRQF_TRIGGER_LOW,
165};
166
167static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
168 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
169};
170
171static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
172 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
173};
174
175static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
176 .rtc_write_enable = false,
Ashay Jaiswaldb5e6dc2011-10-12 11:02:47 +0530177 .rtc_alarm_powerup = false,
David Collinsfb88c432011-08-25 15:12:47 -0700178};
179
180static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
181 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -0800182 .kpd_trigger_delay_us = 15625,
David Collinsfb88c432011-08-25 15:12:47 -0700183 .wakeup = 1,
184};
185
186static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
187 .priority = 0,
188};
189
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700190#define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */
191#define PM8XXX_LED_PWM_PERIOD_US 1000
192
193/**
194 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
195 * driven using PWM feature.
196 */
197#define PM8XXX_PWM_CHANNEL_NONE -1
198
199static struct led_info pm8018_led_info[] = {
200 [0] = {
201 .name = "led:kb",
202 },
203};
204
205static struct led_platform_data pm8018_led_core_pdata = {
206 .num_leds = ARRAY_SIZE(pm8018_led_info),
207 .leds = pm8018_led_info,
208};
209
210static struct pm8xxx_led_config pm8018_led_configs[] = {
211 [0] = {
212 .id = PM8XXX_ID_LED_KB_LIGHT,
213 .mode = PM8XXX_LED_MODE_PWM3,
214 .max_current = PM8018_LED_KB_MAX_CURRENT,
215 .pwm_channel = 2,
216 .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US,
217 },
218};
219
220static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
221 .led_core = &pm8018_led_core_pdata,
222 .configs = pm8018_led_configs,
223 .num_configs = ARRAY_SIZE(pm8018_led_configs),
224};
225
Jay Chokshidc8028b2011-12-01 16:17:34 -0800226#ifdef CONFIG_LTC4088_CHARGER
227static struct ltc4088_charger_platform_data ltc4088_chg_pdata = {
228 .gpio_mode_select_d0 = 7,
229 .gpio_mode_select_d1 = 6,
230 .gpio_mode_select_d2 = 4,
231};
232#endif
233
David Collinsfb88c432011-08-25 15:12:47 -0700234static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
235 .irq_pdata = &pm8xxx_irq_pdata,
236 .gpio_pdata = &pm8xxx_gpio_pdata,
237 .mpp_pdata = &pm8xxx_mpp_pdata,
238 .rtc_pdata = &pm8xxx_rtc_pdata,
239 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
240 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -0700241 .regulator_pdatas = msm_pm8018_regulator_pdata,
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700242 .adc_pdata = &pm8018_adc_pdata,
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700243 .leds_pdata = &pm8xxx_leds_pdata,
David Collinsfb88c432011-08-25 15:12:47 -0700244};
245
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700246static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
247 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
248 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -0700249 .name = PM8018_CORE_DEV_NAME,
250 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700251 },
252};
253
David Collinsbea297a2011-09-28 13:11:14 -0700254static struct platform_device msm9615_device_rpm_regulator __devinitdata = {
255 .name = "rpm-regulator",
256 .id = -1,
257 .dev = {
258 .platform_data = &msm_rpm_regulator_9615_pdata,
259 },
260};
261
David Collins0f9942a2011-10-31 09:47:34 -0700262static struct platform_device msm9615_device_ext_2p95v_vreg = {
263 .name = GPIO_REGULATOR_DEV_NAME,
264 .id = 18,
265 .dev = {
266 .platform_data =
267 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V],
268 },
269};
270
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600271static struct msm_cpuidle_state msm_cstates[] __initdata = {
272 {0, 0, "C0", "WFI",
273 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
274
275 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
276 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
277
278 {0, 2, "C2", "POWER_COLLAPSE",
279 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
280};
281static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
282 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
283 .idle_supported = 1,
284 .suspend_supported = 1,
285 .idle_enabled = 0,
286 .suspend_enabled = 0,
287 },
288 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
289 .idle_supported = 1,
290 .suspend_supported = 1,
291 .idle_enabled = 0,
292 .suspend_enabled = 0,
293 },
294 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
295 .idle_supported = 1,
296 .suspend_supported = 1,
297 .idle_enabled = 1,
298 .suspend_enabled = 1,
299 },
300};
Krishna Kondadd794462011-10-01 00:19:29 -0700301
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600302static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
303 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
304 .v_addr = MSM_APCS_GLB_BASE + 0x24,
305};
306
Gagan Mac7a827642011-09-22 19:42:21 -0600307static void __init msm9615_init_buses(void)
308{
309#ifdef CONFIG_MSM_BUS_SCALING
310 msm_bus_rpm_set_mt_mask();
311 msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
312 msm_bus_9615_sys_fabric.dev.platform_data =
313 &msm_bus_9615_sys_fabric_pdata;
314 msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
315#endif
316}
317
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800318#ifdef CONFIG_WCD9310_CODEC
319
320#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS)
321
322/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
323 * 4 micbiases are used to power various analog and digital
324 * microphones operating at 1800 mV. Technically, all micbiases
325 * can source from single cfilter since all microphones operate
326 * at the same voltage level. The arrangement below is to make
327 * sure all cfilters are exercised. LDO_H regulator ouput level
328 * does not need to be as high as 2.85V. It is choosen for
329 * microphone sensitivity purpose.
330 */
331
332static struct wcd9xxx_pdata tabla20_platform_data = {
333 .slimbus_slave_device = {
334 .name = "tabla-slave",
335 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
336 },
337 .irq = 85,
338 .irq_base = TABLA_INTERRUPT_BASE,
339 .num_irqs = NR_WCD9XXX_IRQS,
340 .reset_gpio = 84,
341 .micbias = {
342 .ldoh_v = TABLA_LDOH_2P85_V,
343 .cfilt1_mv = 1800,
344 .cfilt2_mv = 1800,
345 .cfilt3_mv = 1800,
346 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
347 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
348 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
349 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
350 },
351 .regulator = {
352 {
353 .name = "CDC_VDD_CP",
354 .min_uV = 1800000,
355 .max_uV = 1800000,
356 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
357 },
358 {
359 .name = "CDC_VDDA_RX",
360 .min_uV = 1800000,
361 .max_uV = 1800000,
362 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
363 },
364 {
365 .name = "CDC_VDDA_TX",
366 .min_uV = 1800000,
367 .max_uV = 1800000,
368 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
369 },
370 {
371 .name = "VDDIO_CDC",
372 .min_uV = 1800000,
373 .max_uV = 1800000,
374 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
375 },
376 {
377 .name = "VDDD_CDC_D",
378 .min_uV = 1225000,
379 .max_uV = 1225000,
380 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
381 },
382 {
383 .name = "CDC_VDDA_A_1P2V",
384 .min_uV = 1225000,
385 .max_uV = 1225000,
386 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
387 },
388 },
389};
390
391static struct slim_device msm_slim_tabla20 = {
392 .name = "tabla2x-slim",
393 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
394 .dev = {
395 .platform_data = &tabla20_platform_data,
396 },
397};
398#endif
399
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700400static struct slim_boardinfo msm_slim_devices[] = {
401 /* add slimbus slaves as needed */
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800402#ifdef CONFIG_WCD9310_CODEC
403 {
404 .bus_num = 1,
405 .slim_slave = &msm_slim_tabla20,
406 },
407#endif
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700408};
409
Harini Jayaraman738c9312011-09-08 15:22:38 -0600410static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
411 .max_clock_speed = 24000000,
412};
413
Harini Jayaramaneba52672011-09-08 15:13:00 -0600414static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
415 .clk_freq = 100000,
416 .src_clk_rate = 24000000,
417};
418
Amit Blay6a8d4f32011-11-21 10:36:25 +0200419#define USB_5V_EN 3
420#define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN)
421
Mayank Rana8549e632012-01-23 12:49:54 +0530422static int msm_hsusb_vbus_power(bool on)
Amit Blay6a8d4f32011-11-21 10:36:25 +0200423{
Amit Blaya4416f92012-01-24 21:03:52 +0200424 int rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200425 struct pm_gpio usb_vbus = {
426 .direction = PM_GPIO_DIR_OUT,
427 .pull = PM_GPIO_PULL_NO,
428 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200429 .vin_sel = 2,
430 .out_strength = PM_GPIO_STRENGTH_HIGH,
431 .function = PM_GPIO_FUNC_NORMAL,
432 .inv_int_pol = 0,
433 };
434
Amit Blaya4416f92012-01-24 21:03:52 +0200435 usb_vbus.output_value = on;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200436
Amit Blaya4416f92012-01-24 21:03:52 +0200437 rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus);
438 if (rc)
439 pr_err("failed to config usb_5v_en gpio\n");
Amit Blay6a8d4f32011-11-21 10:36:25 +0200440
Mayank Rana8549e632012-01-23 12:49:54 +0530441 return rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200442}
443
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530444static int shelby_phy_init_seq[] = {
445 0x44, 0x80,/* set VBUS valid threshold and
446 disconnect valid threshold */
447 0x38, 0x81, /* update DC voltage level */
Amit Blaydbaeff82012-04-02 22:13:36 +0300448 0x24, 0x82,/* set preemphasis and rise/fall time */
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530449 0x13, 0x83,/* set source impedance adjustment */
450 -1};
451
Ofir Cohen40a4e862011-12-08 15:17:52 +0200452#define USB_BAM_PHY_BASE 0x12502000
Ofir Cohen43473c82012-01-25 16:28:13 +0200453#define HSIC_BAM_PHY_BASE 0x12542000
Ofir Cohen40a4e862011-12-08 15:17:52 +0200454#define A2_BAM_PHY_BASE 0x124C2000
Lena Salmana66eddf2012-03-26 13:03:43 +0200455static struct usb_bam_pipe_connect msm_usb_bam_connections[2][4][2] = {
456 [0][0][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen40a4e862011-12-08 15:17:52 +0200457 .src_phy_addr = USB_BAM_PHY_BASE,
458 .src_pipe_index = 11,
459 .dst_phy_addr = A2_BAM_PHY_BASE,
460 .dst_pipe_index = 0,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200461 .data_fifo_base_offset = 0x1100,
462 .data_fifo_size = 0x600,
463 .desc_fifo_base_offset = 0x1700,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200464 .desc_fifo_size = 0x300,
465 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200466 [0][0][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen40a4e862011-12-08 15:17:52 +0200467 .src_phy_addr = A2_BAM_PHY_BASE,
468 .src_pipe_index = 1,
469 .dst_phy_addr = USB_BAM_PHY_BASE,
470 .dst_pipe_index = 10,
471 .data_fifo_base_offset = 0xa00,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200472 .data_fifo_size = 0x600,
473 .desc_fifo_base_offset = 0x1000,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200474 .desc_fifo_size = 0x100,
475 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200476 [0][1][USB_TO_PEER_PERIPHERAL] = {
Anna Perel21515162012-02-02 20:50:02 +0200477 .src_phy_addr = USB_BAM_PHY_BASE,
478 .src_pipe_index = 13,
479 .dst_phy_addr = A2_BAM_PHY_BASE,
480 .dst_pipe_index = 2,
481 .data_fifo_base_offset = 0x2100,
482 .data_fifo_size = 0x600,
483 .desc_fifo_base_offset = 0x2700,
484 .desc_fifo_size = 0x300,
485 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200486 [0][1][PEER_PERIPHERAL_TO_USB] = {
Anna Perel21515162012-02-02 20:50:02 +0200487 .src_phy_addr = A2_BAM_PHY_BASE,
488 .src_pipe_index = 3,
489 .dst_phy_addr = USB_BAM_PHY_BASE,
490 .dst_pipe_index = 12,
491 .data_fifo_base_offset = 0x1a00,
492 .data_fifo_size = 0x600,
493 .desc_fifo_base_offset = 0x2000,
494 .desc_fifo_size = 0x100,
495 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200496 [0][2][USB_TO_PEER_PERIPHERAL] = {
Anna Perel21515162012-02-02 20:50:02 +0200497 .src_phy_addr = USB_BAM_PHY_BASE,
498 .src_pipe_index = 15,
499 .dst_phy_addr = A2_BAM_PHY_BASE,
500 .dst_pipe_index = 4,
501 .data_fifo_base_offset = 0x3100,
502 .data_fifo_size = 0x600,
503 .desc_fifo_base_offset = 0x3700,
504 .desc_fifo_size = 0x300,
505 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200506 [0][2][PEER_PERIPHERAL_TO_USB] = {
Anna Perel21515162012-02-02 20:50:02 +0200507 .src_phy_addr = A2_BAM_PHY_BASE,
508 .src_pipe_index = 5,
509 .dst_phy_addr = USB_BAM_PHY_BASE,
510 .dst_pipe_index = 14,
511 .data_fifo_base_offset = 0x2a00,
512 .data_fifo_size = 0x600,
513 .desc_fifo_base_offset = 0x3000,
514 .desc_fifo_size = 0x100,
Lena Salmana66eddf2012-03-26 13:03:43 +0200515 },
516 [1][0][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200517 .src_phy_addr = HSIC_BAM_PHY_BASE,
518 .src_pipe_index = 1,
519 .dst_phy_addr = A2_BAM_PHY_BASE,
520 .dst_pipe_index = 0,
521 .data_fifo_base_offset = 0x1100,
522 .data_fifo_size = 0x600,
523 .desc_fifo_base_offset = 0x1700,
524 .desc_fifo_size = 0x300,
525 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200526 [1][0][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200527 .src_phy_addr = A2_BAM_PHY_BASE,
528 .src_pipe_index = 1,
529 .dst_phy_addr = HSIC_BAM_PHY_BASE,
530 .dst_pipe_index = 0,
531 .data_fifo_base_offset = 0xa00,
532 .data_fifo_size = 0x600,
533 .desc_fifo_base_offset = 0x1000,
534 .desc_fifo_size = 0x100,
535 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200536 [1][1][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200537 .src_phy_addr = HSIC_BAM_PHY_BASE,
538 .src_pipe_index = 3,
539 .dst_phy_addr = A2_BAM_PHY_BASE,
540 .dst_pipe_index = 2,
541 .data_fifo_base_offset = 0x2100,
542 .data_fifo_size = 0x600,
543 .desc_fifo_base_offset = 0x2700,
544 .desc_fifo_size = 0x300,
545 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200546 [1][1][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200547 .src_phy_addr = A2_BAM_PHY_BASE,
548 .src_pipe_index = 3,
549 .dst_phy_addr = HSIC_BAM_PHY_BASE,
550 .dst_pipe_index = 2,
551 .data_fifo_base_offset = 0x1a00,
552 .data_fifo_size = 0x600,
553 .desc_fifo_base_offset = 0x2000,
554 .desc_fifo_size = 0x100,
555 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200556 [1][2][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200557 .src_phy_addr = HSIC_BAM_PHY_BASE,
558 .src_pipe_index = 5,
559 .dst_phy_addr = A2_BAM_PHY_BASE,
560 .dst_pipe_index = 4,
561 .data_fifo_base_offset = 0x3100,
562 .data_fifo_size = 0x600,
563 .desc_fifo_base_offset = 0x3700,
564 .desc_fifo_size = 0x300,
565 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200566 [1][2][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200567 .src_phy_addr = A2_BAM_PHY_BASE,
568 .src_pipe_index = 5,
569 .dst_phy_addr = HSIC_BAM_PHY_BASE,
570 .dst_pipe_index = 4,
571 .data_fifo_base_offset = 0x2a00,
572 .data_fifo_size = 0x600,
573 .desc_fifo_base_offset = 0x3000,
574 .desc_fifo_size = 0x100,
575 }
Ofir Cohen40a4e862011-12-08 15:17:52 +0200576};
577
578static struct msm_usb_bam_platform_data msm_usb_bam_pdata = {
Lena Salmana66eddf2012-03-26 13:03:43 +0200579 .connections = &msm_usb_bam_connections[0][0][0],
Lena Salman57d167e2012-03-21 19:46:38 +0200580#ifndef CONFIG_USB_CI13XXX_MSM_HSIC
Ofir Cohen43473c82012-01-25 16:28:13 +0200581 .usb_active_bam = HSUSB_BAM,
Ofir Cohen43473c82012-01-25 16:28:13 +0200582#else
583 .usb_active_bam = HSIC_BAM,
Ofir Cohen43473c82012-01-25 16:28:13 +0200584#endif
Lena Salmana66eddf2012-03-26 13:03:43 +0200585 .usb_bam_num_pipes = 16,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200586};
587
Amit Blay5e4ec192011-10-20 09:16:54 +0200588static struct msm_otg_platform_data msm_otg_pdata = {
Amit Blay6a8d4f32011-11-21 10:36:25 +0200589 .mode = USB_OTG,
590 .otg_control = OTG_PHY_CONTROL,
Amit Blay5e4ec192011-10-20 09:16:54 +0200591 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200592 .vbus_power = msm_hsusb_vbus_power,
Ofir Cohen4da266f2012-01-03 10:19:29 +0200593 .disable_reset_on_disconnect = true,
Amit Blay5e4ec192011-10-20 09:16:54 +0200594};
595
Amit Blay5f968cf2012-01-22 12:04:01 +0200596#define PID_MAGIC_ID 0x71432909
597#define SERIAL_NUM_MAGIC_ID 0x61945374
598#define SERIAL_NUMBER_LENGTH 127
599#define DLOAD_USB_BASE_ADD 0x2B0000C8
600
601struct magic_num_struct {
602 uint32_t pid;
603 uint32_t serial_num;
604};
605
606struct dload_struct {
607 uint32_t reserved1;
608 uint32_t reserved2;
609 uint32_t reserved3;
610 uint16_t reserved4;
611 uint16_t pid;
612 char serial_number[SERIAL_NUMBER_LENGTH];
613 uint16_t reserved5;
614 struct magic_num_struct magic_struct;
615};
616
Amit Blay5e4ec192011-10-20 09:16:54 +0200617static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
618{
Amit Blay5f968cf2012-01-22 12:04:01 +0200619 struct dload_struct __iomem *dload = 0;
620
621 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
622 if (!dload) {
623 pr_err("%s: cannot remap I/O memory region: %08x\n",
624 __func__, DLOAD_USB_BASE_ADD);
625 return -ENXIO;
626 }
627
628 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
629 __func__, dload, pid, snum);
630 /* update pid */
631 dload->magic_struct.pid = PID_MAGIC_ID;
632 dload->pid = pid;
633
634 /* update serial number */
635 dload->magic_struct.serial_num = 0;
636 if (!snum) {
637 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
638 goto out;
639 }
640
641 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
642 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
643out:
644 iounmap(dload);
Amit Blay5e4ec192011-10-20 09:16:54 +0200645 return 0;
646}
647
648static struct android_usb_platform_data android_usb_pdata = {
649 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
650};
651
652static struct platform_device android_usb_device = {
653 .name = "android_usb",
654 .id = -1,
655 .dev = {
656 .platform_data = &android_usb_pdata,
657 },
658};
659
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800660static struct platform_device msm_wlan_ar6000_pm_device = {
661 .name = "wlan_ar6000_pm_dev",
662 .id = -1,
663};
664
665static int __init msm9615_init_ar6000pm(void)
666{
667 return platform_device_register(&msm_wlan_ar6000_pm_device);
668}
669
Jay Chokshidc8028b2011-12-01 16:17:34 -0800670#ifdef CONFIG_LTC4088_CHARGER
671static struct platform_device msm_device_charger = {
672 .name = LTC4088_CHARGER_DEV_NAME,
673 .id = -1,
674 .dev = {
675 .platform_data = &ltc4088_chg_pdata,
676 },
677};
678#endif
679
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700680static struct tsens_platform_data msm_tsens_pdata = {
681 .tsens_factor = 1000,
682 .hw_type = MDM_9615,
683 .tsens_num_sensor = 5,
684 .slope = {1176, 1176, 1154, 1176, 1111},
685};
686
Amit Blay5e4ec192011-10-20 09:16:54 +0200687static struct platform_device *common_devices[] = {
688 &msm9615_device_dmov,
689 &msm_device_smd,
Jay Chokshidc8028b2011-12-01 16:17:34 -0800690#ifdef CONFIG_LTC4088_CHARGER
691 &msm_device_charger,
692#endif
Lena Salman57d167e2012-03-21 19:46:38 +0200693#ifndef CONFIG_USB_CI13XXX_MSM_HSIC
Amit Blay5e4ec192011-10-20 09:16:54 +0200694 &msm_device_otg,
Ofir Cohendca06cb2012-03-08 16:37:45 +0200695#endif
Ofir Cohen73c99e82012-01-15 13:38:14 +0200696 &msm_device_hsic_peripheral,
Amit Blay5e4ec192011-10-20 09:16:54 +0200697 &msm_device_gadget_peripheral,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200698 &msm_device_hsusb_host,
Lena Salman65bcf372012-02-14 15:33:32 +0200699 &msm_device_hsic_host,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200700 &msm_device_usb_bam,
Amit Blay5e4ec192011-10-20 09:16:54 +0200701 &android_usb_device,
702 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700703 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200704 &msm9615_device_ssbi_pmic1,
705 &msm9615_device_qup_i2c_gsbi5,
706 &msm9615_device_qup_spi_gsbi3,
707 &msm_device_sps,
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700708 &msm9615_slim_ctrl,
Amit Blay5e4ec192011-10-20 09:16:54 +0200709 &msm_device_nand,
Eric Holmberg0c96e702011-11-08 18:04:31 -0700710 &msm_device_bam_dmux,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600711 &msm9615_rpm_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200712#ifdef CONFIG_HW_RANDOM_MSM
713 &msm_device_rng,
714#endif
Olav Haugane6a0acd2012-04-05 09:29:12 -0700715#ifdef CONFIG_ION_MSM
716 &ion_dev,
717#endif
Amit Blay5e4ec192011-10-20 09:16:54 +0200718
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800719 &msm_pcm,
720 &msm_multi_ch_pcm,
721 &msm_pcm_routing,
722 &msm_cpudai0,
723 &msm_cpudai1,
724 &msm_cpudai_bt_rx,
725 &msm_cpudai_bt_tx,
726 &msm_cpu_fe,
727 &msm_stub_codec,
728 &msm_voice,
729 &msm_voip,
730 &msm_pcm_hostless,
731 &msm_cpudai_afe_01_rx,
732 &msm_cpudai_afe_01_tx,
733 &msm_cpudai_afe_02_rx,
734 &msm_cpudai_afe_02_tx,
735 &msm_pcm_afe,
736 &msm_cpudai_auxpcm_rx,
737 &msm_cpudai_auxpcm_tx,
738
Amit Blay5e4ec192011-10-20 09:16:54 +0200739#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
740 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700741 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200742#endif
743
744#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
745 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700746 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200747#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700748 &msm9615_device_watchdog,
Gagan Mac7a827642011-09-22 19:42:21 -0600749 &msm_bus_9615_sys_fabric,
750 &msm_bus_def_fab,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600751 &msm9615_rpm_log_device,
752 &msm9615_rpm_stat_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200753};
754
Harini Jayaramaneba52672011-09-08 15:13:00 -0600755static void __init msm9615_i2c_init(void)
756{
757 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
758 &msm9615_i2c_qup_gsbi5_pdata;
759}
760
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600761static void __init msm9615_reserve(void)
762{
Olav Haugane6a0acd2012-04-05 09:29:12 -0700763#ifdef CONFIG_ION_MSM
764 reserve_info = &msm9615_reserve_info;
765 msm_reserve();
766#endif
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600767}
768
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700769static void __init msm9615_common_init(void)
770{
771 msm9615_device_init();
Rohit Vaswania6815892011-12-15 20:20:39 -0800772 msm9615_init_gpiomux();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600773 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700774 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700775 platform_device_register(&msm9615_device_rpm_regulator);
Vikram Mulukutla2021c002011-12-16 12:32:59 -0800776 msm_xo_init();
Gagan Mac7a827642011-09-22 19:42:21 -0600777 msm_clock_init(&msm9615_clock_init_data);
778 msm9615_init_buses();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600779 msm9615_device_qup_spi_gsbi3.dev.platform_data =
780 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700781 msm9615_device_ssbi_pmic1.dev.platform_data =
782 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700783 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200784
785 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530786 msm_otg_pdata.phy_init_seq = shelby_phy_init_seq;
Ofir Cohen40a4e862011-12-08 15:17:52 +0200787 msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700788 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700789
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700790 acpuclk_init(&acpuclk_9615_soc_data);
791
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800792 /* Ensure ar6000pm device is registered before MMC/SDC */
793 msm9615_init_ar6000pm();
794
Krishna Kondadd794462011-10-01 00:19:29 -0700795 msm9615_init_mmc();
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700796 slim_register_board_info(msm_slim_devices,
797 ARRAY_SIZE(msm_slim_devices));
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600798 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
799 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
800 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
801 msm_pm_data);
Olav Haugane6a0acd2012-04-05 09:29:12 -0700802 msm_pm_boot_pdata.p_addr = allocate_contiguous_ebi_nomap(SZ_8, SZ_64K);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600803 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700804 msm_tsens_early_init(&msm_tsens_pdata);
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700805}
806
807static void __init msm9615_cdp_init(void)
808{
809 msm9615_common_init();
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400810#ifdef CONFIG_FB_MSM
811 mdm9615_init_fb();
812#endif
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700813}
814
815static void __init msm9615_mtp_init(void)
816{
817 msm9615_common_init();
818}
819
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400820#ifdef CONFIG_FB_MSM
821static void __init mdm9615_allocate_memory_regions(void)
822{
823 mdm9615_allocate_fb_region();
824}
825#endif
826
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700827MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
828 .map_io = msm9615_map_io,
829 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530830 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700831 .timer = &msm_timer,
832 .init_machine = msm9615_cdp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600833 .reserve = msm9615_reserve,
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400834#ifdef CONFIG_FB_MSM
835 .init_early = mdm9615_allocate_memory_regions,
836#endif
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700837MACHINE_END
838
839MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
840 .map_io = msm9615_map_io,
841 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530842 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700843 .timer = &msm_timer,
844 .init_machine = msm9615_mtp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600845 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700846MACHINE_END