blob: 6c6a5c271365e8ede0e2d440e62fd516d74ebb0f [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 Sivasubramanianc6c55032011-10-25 16:01:32 -0600271static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
272 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
273 .v_addr = MSM_APCS_GLB_BASE + 0x24,
274};
275
Gagan Mac7a827642011-09-22 19:42:21 -0600276static void __init msm9615_init_buses(void)
277{
278#ifdef CONFIG_MSM_BUS_SCALING
279 msm_bus_rpm_set_mt_mask();
280 msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
281 msm_bus_9615_sys_fabric.dev.platform_data =
282 &msm_bus_9615_sys_fabric_pdata;
283 msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
284#endif
285}
286
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800287#ifdef CONFIG_WCD9310_CODEC
288
289#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS)
290
291/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
292 * 4 micbiases are used to power various analog and digital
293 * microphones operating at 1800 mV. Technically, all micbiases
294 * can source from single cfilter since all microphones operate
295 * at the same voltage level. The arrangement below is to make
296 * sure all cfilters are exercised. LDO_H regulator ouput level
297 * does not need to be as high as 2.85V. It is choosen for
298 * microphone sensitivity purpose.
299 */
300
301static struct wcd9xxx_pdata tabla20_platform_data = {
302 .slimbus_slave_device = {
303 .name = "tabla-slave",
304 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
305 },
306 .irq = 85,
307 .irq_base = TABLA_INTERRUPT_BASE,
308 .num_irqs = NR_WCD9XXX_IRQS,
309 .reset_gpio = 84,
310 .micbias = {
311 .ldoh_v = TABLA_LDOH_2P85_V,
312 .cfilt1_mv = 1800,
313 .cfilt2_mv = 1800,
314 .cfilt3_mv = 1800,
315 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
316 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
317 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
318 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
319 },
320 .regulator = {
321 {
322 .name = "CDC_VDD_CP",
323 .min_uV = 1800000,
324 .max_uV = 1800000,
325 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
326 },
327 {
328 .name = "CDC_VDDA_RX",
329 .min_uV = 1800000,
330 .max_uV = 1800000,
331 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
332 },
333 {
334 .name = "CDC_VDDA_TX",
335 .min_uV = 1800000,
336 .max_uV = 1800000,
337 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
338 },
339 {
340 .name = "VDDIO_CDC",
341 .min_uV = 1800000,
342 .max_uV = 1800000,
343 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
344 },
345 {
346 .name = "VDDD_CDC_D",
347 .min_uV = 1225000,
348 .max_uV = 1225000,
349 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
350 },
351 {
352 .name = "CDC_VDDA_A_1P2V",
353 .min_uV = 1225000,
354 .max_uV = 1225000,
355 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
356 },
357 },
358};
359
360static struct slim_device msm_slim_tabla20 = {
361 .name = "tabla2x-slim",
362 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
363 .dev = {
364 .platform_data = &tabla20_platform_data,
365 },
366};
367#endif
368
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700369static struct slim_boardinfo msm_slim_devices[] = {
370 /* add slimbus slaves as needed */
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800371#ifdef CONFIG_WCD9310_CODEC
372 {
373 .bus_num = 1,
374 .slim_slave = &msm_slim_tabla20,
375 },
376#endif
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700377};
378
Harini Jayaraman738c9312011-09-08 15:22:38 -0600379static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
380 .max_clock_speed = 24000000,
381};
382
Harini Jayaramaneba52672011-09-08 15:13:00 -0600383static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
384 .clk_freq = 100000,
385 .src_clk_rate = 24000000,
386};
387
Amit Blay6a8d4f32011-11-21 10:36:25 +0200388#define USB_5V_EN 3
389#define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN)
390
Mayank Rana8549e632012-01-23 12:49:54 +0530391static int msm_hsusb_vbus_power(bool on)
Amit Blay6a8d4f32011-11-21 10:36:25 +0200392{
Amit Blaya4416f92012-01-24 21:03:52 +0200393 int rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200394 struct pm_gpio usb_vbus = {
395 .direction = PM_GPIO_DIR_OUT,
396 .pull = PM_GPIO_PULL_NO,
397 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200398 .vin_sel = 2,
399 .out_strength = PM_GPIO_STRENGTH_HIGH,
400 .function = PM_GPIO_FUNC_NORMAL,
401 .inv_int_pol = 0,
402 };
403
Amit Blaya4416f92012-01-24 21:03:52 +0200404 usb_vbus.output_value = on;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200405
Amit Blaya4416f92012-01-24 21:03:52 +0200406 rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus);
407 if (rc)
408 pr_err("failed to config usb_5v_en gpio\n");
Amit Blay6a8d4f32011-11-21 10:36:25 +0200409
Mayank Rana8549e632012-01-23 12:49:54 +0530410 return rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200411}
412
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530413static int shelby_phy_init_seq[] = {
414 0x44, 0x80,/* set VBUS valid threshold and
415 disconnect valid threshold */
416 0x38, 0x81, /* update DC voltage level */
Amit Blaydbaeff82012-04-02 22:13:36 +0300417 0x24, 0x82,/* set preemphasis and rise/fall time */
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530418 0x13, 0x83,/* set source impedance adjustment */
419 -1};
420
Ofir Cohen40a4e862011-12-08 15:17:52 +0200421#define USB_BAM_PHY_BASE 0x12502000
Ofir Cohen43473c82012-01-25 16:28:13 +0200422#define HSIC_BAM_PHY_BASE 0x12542000
Ofir Cohen40a4e862011-12-08 15:17:52 +0200423#define A2_BAM_PHY_BASE 0x124C2000
Lena Salmana66eddf2012-03-26 13:03:43 +0200424static struct usb_bam_pipe_connect msm_usb_bam_connections[2][4][2] = {
425 [0][0][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen40a4e862011-12-08 15:17:52 +0200426 .src_phy_addr = USB_BAM_PHY_BASE,
427 .src_pipe_index = 11,
428 .dst_phy_addr = A2_BAM_PHY_BASE,
429 .dst_pipe_index = 0,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200430 .data_fifo_base_offset = 0x1100,
431 .data_fifo_size = 0x600,
432 .desc_fifo_base_offset = 0x1700,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200433 .desc_fifo_size = 0x300,
434 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200435 [0][0][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen40a4e862011-12-08 15:17:52 +0200436 .src_phy_addr = A2_BAM_PHY_BASE,
437 .src_pipe_index = 1,
438 .dst_phy_addr = USB_BAM_PHY_BASE,
439 .dst_pipe_index = 10,
440 .data_fifo_base_offset = 0xa00,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200441 .data_fifo_size = 0x600,
442 .desc_fifo_base_offset = 0x1000,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200443 .desc_fifo_size = 0x100,
444 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200445 [0][1][USB_TO_PEER_PERIPHERAL] = {
Anna Perel21515162012-02-02 20:50:02 +0200446 .src_phy_addr = USB_BAM_PHY_BASE,
447 .src_pipe_index = 13,
448 .dst_phy_addr = A2_BAM_PHY_BASE,
449 .dst_pipe_index = 2,
450 .data_fifo_base_offset = 0x2100,
451 .data_fifo_size = 0x600,
452 .desc_fifo_base_offset = 0x2700,
453 .desc_fifo_size = 0x300,
454 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200455 [0][1][PEER_PERIPHERAL_TO_USB] = {
Anna Perel21515162012-02-02 20:50:02 +0200456 .src_phy_addr = A2_BAM_PHY_BASE,
457 .src_pipe_index = 3,
458 .dst_phy_addr = USB_BAM_PHY_BASE,
459 .dst_pipe_index = 12,
460 .data_fifo_base_offset = 0x1a00,
461 .data_fifo_size = 0x600,
462 .desc_fifo_base_offset = 0x2000,
463 .desc_fifo_size = 0x100,
464 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200465 [0][2][USB_TO_PEER_PERIPHERAL] = {
Anna Perel21515162012-02-02 20:50:02 +0200466 .src_phy_addr = USB_BAM_PHY_BASE,
467 .src_pipe_index = 15,
468 .dst_phy_addr = A2_BAM_PHY_BASE,
469 .dst_pipe_index = 4,
470 .data_fifo_base_offset = 0x3100,
471 .data_fifo_size = 0x600,
472 .desc_fifo_base_offset = 0x3700,
473 .desc_fifo_size = 0x300,
474 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200475 [0][2][PEER_PERIPHERAL_TO_USB] = {
Anna Perel21515162012-02-02 20:50:02 +0200476 .src_phy_addr = A2_BAM_PHY_BASE,
477 .src_pipe_index = 5,
478 .dst_phy_addr = USB_BAM_PHY_BASE,
479 .dst_pipe_index = 14,
480 .data_fifo_base_offset = 0x2a00,
481 .data_fifo_size = 0x600,
482 .desc_fifo_base_offset = 0x3000,
483 .desc_fifo_size = 0x100,
Lena Salmana66eddf2012-03-26 13:03:43 +0200484 },
485 [1][0][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200486 .src_phy_addr = HSIC_BAM_PHY_BASE,
487 .src_pipe_index = 1,
488 .dst_phy_addr = A2_BAM_PHY_BASE,
489 .dst_pipe_index = 0,
490 .data_fifo_base_offset = 0x1100,
491 .data_fifo_size = 0x600,
492 .desc_fifo_base_offset = 0x1700,
493 .desc_fifo_size = 0x300,
494 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200495 [1][0][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200496 .src_phy_addr = A2_BAM_PHY_BASE,
497 .src_pipe_index = 1,
498 .dst_phy_addr = HSIC_BAM_PHY_BASE,
499 .dst_pipe_index = 0,
500 .data_fifo_base_offset = 0xa00,
501 .data_fifo_size = 0x600,
502 .desc_fifo_base_offset = 0x1000,
503 .desc_fifo_size = 0x100,
504 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200505 [1][1][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200506 .src_phy_addr = HSIC_BAM_PHY_BASE,
507 .src_pipe_index = 3,
508 .dst_phy_addr = A2_BAM_PHY_BASE,
509 .dst_pipe_index = 2,
510 .data_fifo_base_offset = 0x2100,
511 .data_fifo_size = 0x600,
512 .desc_fifo_base_offset = 0x2700,
513 .desc_fifo_size = 0x300,
514 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200515 [1][1][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200516 .src_phy_addr = A2_BAM_PHY_BASE,
517 .src_pipe_index = 3,
518 .dst_phy_addr = HSIC_BAM_PHY_BASE,
519 .dst_pipe_index = 2,
520 .data_fifo_base_offset = 0x1a00,
521 .data_fifo_size = 0x600,
522 .desc_fifo_base_offset = 0x2000,
523 .desc_fifo_size = 0x100,
524 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200525 [1][2][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200526 .src_phy_addr = HSIC_BAM_PHY_BASE,
527 .src_pipe_index = 5,
528 .dst_phy_addr = A2_BAM_PHY_BASE,
529 .dst_pipe_index = 4,
530 .data_fifo_base_offset = 0x3100,
531 .data_fifo_size = 0x600,
532 .desc_fifo_base_offset = 0x3700,
533 .desc_fifo_size = 0x300,
534 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200535 [1][2][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200536 .src_phy_addr = A2_BAM_PHY_BASE,
537 .src_pipe_index = 5,
538 .dst_phy_addr = HSIC_BAM_PHY_BASE,
539 .dst_pipe_index = 4,
540 .data_fifo_base_offset = 0x2a00,
541 .data_fifo_size = 0x600,
542 .desc_fifo_base_offset = 0x3000,
543 .desc_fifo_size = 0x100,
544 }
Ofir Cohen40a4e862011-12-08 15:17:52 +0200545};
546
547static struct msm_usb_bam_platform_data msm_usb_bam_pdata = {
Lena Salmana66eddf2012-03-26 13:03:43 +0200548 .connections = &msm_usb_bam_connections[0][0][0],
Lena Salman57d167e2012-03-21 19:46:38 +0200549#ifndef CONFIG_USB_CI13XXX_MSM_HSIC
Ofir Cohen43473c82012-01-25 16:28:13 +0200550 .usb_active_bam = HSUSB_BAM,
Ofir Cohen43473c82012-01-25 16:28:13 +0200551#else
552 .usb_active_bam = HSIC_BAM,
Ofir Cohen43473c82012-01-25 16:28:13 +0200553#endif
Lena Salmana66eddf2012-03-26 13:03:43 +0200554 .usb_bam_num_pipes = 16,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200555};
556
Amit Blay5e4ec192011-10-20 09:16:54 +0200557static struct msm_otg_platform_data msm_otg_pdata = {
Amit Blay6a8d4f32011-11-21 10:36:25 +0200558 .mode = USB_OTG,
559 .otg_control = OTG_PHY_CONTROL,
Amit Blay5e4ec192011-10-20 09:16:54 +0200560 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200561 .vbus_power = msm_hsusb_vbus_power,
Ofir Cohen4da266f2012-01-03 10:19:29 +0200562 .disable_reset_on_disconnect = true,
Amit Blay5e4ec192011-10-20 09:16:54 +0200563};
564
Amit Blay5f968cf2012-01-22 12:04:01 +0200565#define PID_MAGIC_ID 0x71432909
566#define SERIAL_NUM_MAGIC_ID 0x61945374
567#define SERIAL_NUMBER_LENGTH 127
568#define DLOAD_USB_BASE_ADD 0x2B0000C8
569
570struct magic_num_struct {
571 uint32_t pid;
572 uint32_t serial_num;
573};
574
575struct dload_struct {
576 uint32_t reserved1;
577 uint32_t reserved2;
578 uint32_t reserved3;
579 uint16_t reserved4;
580 uint16_t pid;
581 char serial_number[SERIAL_NUMBER_LENGTH];
582 uint16_t reserved5;
583 struct magic_num_struct magic_struct;
584};
585
Amit Blay5e4ec192011-10-20 09:16:54 +0200586static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
587{
Amit Blay5f968cf2012-01-22 12:04:01 +0200588 struct dload_struct __iomem *dload = 0;
589
590 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
591 if (!dload) {
592 pr_err("%s: cannot remap I/O memory region: %08x\n",
593 __func__, DLOAD_USB_BASE_ADD);
594 return -ENXIO;
595 }
596
597 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
598 __func__, dload, pid, snum);
599 /* update pid */
600 dload->magic_struct.pid = PID_MAGIC_ID;
601 dload->pid = pid;
602
603 /* update serial number */
604 dload->magic_struct.serial_num = 0;
605 if (!snum) {
606 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
607 goto out;
608 }
609
610 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
611 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
612out:
613 iounmap(dload);
Amit Blay5e4ec192011-10-20 09:16:54 +0200614 return 0;
615}
616
617static struct android_usb_platform_data android_usb_pdata = {
618 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
619};
620
621static struct platform_device android_usb_device = {
622 .name = "android_usb",
623 .id = -1,
624 .dev = {
625 .platform_data = &android_usb_pdata,
626 },
627};
628
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800629static struct platform_device msm_wlan_ar6000_pm_device = {
630 .name = "wlan_ar6000_pm_dev",
631 .id = -1,
632};
633
634static int __init msm9615_init_ar6000pm(void)
635{
636 return platform_device_register(&msm_wlan_ar6000_pm_device);
637}
638
Jay Chokshidc8028b2011-12-01 16:17:34 -0800639#ifdef CONFIG_LTC4088_CHARGER
640static struct platform_device msm_device_charger = {
641 .name = LTC4088_CHARGER_DEV_NAME,
642 .id = -1,
643 .dev = {
644 .platform_data = &ltc4088_chg_pdata,
645 },
646};
647#endif
648
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700649static struct tsens_platform_data msm_tsens_pdata = {
650 .tsens_factor = 1000,
651 .hw_type = MDM_9615,
652 .tsens_num_sensor = 5,
653 .slope = {1176, 1176, 1154, 1176, 1111},
654};
655
Amit Blay5e4ec192011-10-20 09:16:54 +0200656static struct platform_device *common_devices[] = {
657 &msm9615_device_dmov,
658 &msm_device_smd,
Jay Chokshidc8028b2011-12-01 16:17:34 -0800659#ifdef CONFIG_LTC4088_CHARGER
660 &msm_device_charger,
661#endif
Lena Salman57d167e2012-03-21 19:46:38 +0200662#ifndef CONFIG_USB_CI13XXX_MSM_HSIC
Amit Blay5e4ec192011-10-20 09:16:54 +0200663 &msm_device_otg,
Ofir Cohendca06cb2012-03-08 16:37:45 +0200664#endif
Ofir Cohen73c99e82012-01-15 13:38:14 +0200665 &msm_device_hsic_peripheral,
Amit Blay5e4ec192011-10-20 09:16:54 +0200666 &msm_device_gadget_peripheral,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200667 &msm_device_hsusb_host,
Lena Salman65bcf372012-02-14 15:33:32 +0200668 &msm_device_hsic_host,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200669 &msm_device_usb_bam,
Amit Blay5e4ec192011-10-20 09:16:54 +0200670 &android_usb_device,
671 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700672 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200673 &msm9615_device_ssbi_pmic1,
674 &msm9615_device_qup_i2c_gsbi5,
675 &msm9615_device_qup_spi_gsbi3,
676 &msm_device_sps,
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700677 &msm9615_slim_ctrl,
Amit Blay5e4ec192011-10-20 09:16:54 +0200678 &msm_device_nand,
Eric Holmberg0c96e702011-11-08 18:04:31 -0700679 &msm_device_bam_dmux,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600680 &msm9615_rpm_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200681#ifdef CONFIG_HW_RANDOM_MSM
682 &msm_device_rng,
683#endif
Olav Haugane6a0acd2012-04-05 09:29:12 -0700684#ifdef CONFIG_ION_MSM
685 &ion_dev,
686#endif
Amit Blay5e4ec192011-10-20 09:16:54 +0200687
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800688 &msm_pcm,
689 &msm_multi_ch_pcm,
690 &msm_pcm_routing,
691 &msm_cpudai0,
692 &msm_cpudai1,
693 &msm_cpudai_bt_rx,
694 &msm_cpudai_bt_tx,
695 &msm_cpu_fe,
696 &msm_stub_codec,
697 &msm_voice,
698 &msm_voip,
699 &msm_pcm_hostless,
700 &msm_cpudai_afe_01_rx,
701 &msm_cpudai_afe_01_tx,
702 &msm_cpudai_afe_02_rx,
703 &msm_cpudai_afe_02_tx,
704 &msm_pcm_afe,
705 &msm_cpudai_auxpcm_rx,
706 &msm_cpudai_auxpcm_tx,
707
Amit Blay5e4ec192011-10-20 09:16:54 +0200708#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
709 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700710 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200711#endif
712
713#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
714 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700715 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200716#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700717 &msm9615_device_watchdog,
Gagan Mac7a827642011-09-22 19:42:21 -0600718 &msm_bus_9615_sys_fabric,
719 &msm_bus_def_fab,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600720 &msm9615_rpm_log_device,
721 &msm9615_rpm_stat_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200722};
723
Harini Jayaramaneba52672011-09-08 15:13:00 -0600724static void __init msm9615_i2c_init(void)
725{
726 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
727 &msm9615_i2c_qup_gsbi5_pdata;
728}
729
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600730static void __init msm9615_reserve(void)
731{
Olav Haugane6a0acd2012-04-05 09:29:12 -0700732#ifdef CONFIG_ION_MSM
733 reserve_info = &msm9615_reserve_info;
734 msm_reserve();
735#endif
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600736}
737
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700738static void __init msm9615_common_init(void)
739{
740 msm9615_device_init();
Rohit Vaswania6815892011-12-15 20:20:39 -0800741 msm9615_init_gpiomux();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600742 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700743 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700744 platform_device_register(&msm9615_device_rpm_regulator);
Vikram Mulukutla2021c002011-12-16 12:32:59 -0800745 msm_xo_init();
Gagan Mac7a827642011-09-22 19:42:21 -0600746 msm_clock_init(&msm9615_clock_init_data);
747 msm9615_init_buses();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600748 msm9615_device_qup_spi_gsbi3.dev.platform_data =
749 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700750 msm9615_device_ssbi_pmic1.dev.platform_data =
751 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700752 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200753
754 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530755 msm_otg_pdata.phy_init_seq = shelby_phy_init_seq;
Ofir Cohen40a4e862011-12-08 15:17:52 +0200756 msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700757 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700758
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700759 acpuclk_init(&acpuclk_9615_soc_data);
760
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800761 /* Ensure ar6000pm device is registered before MMC/SDC */
762 msm9615_init_ar6000pm();
763
Krishna Kondadd794462011-10-01 00:19:29 -0700764 msm9615_init_mmc();
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700765 slim_register_board_info(msm_slim_devices,
766 ARRAY_SIZE(msm_slim_devices));
Olav Haugane6a0acd2012-04-05 09:29:12 -0700767 msm_pm_boot_pdata.p_addr = allocate_contiguous_ebi_nomap(SZ_8, SZ_64K);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600768 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700769 msm_tsens_early_init(&msm_tsens_pdata);
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700770}
771
772static void __init msm9615_cdp_init(void)
773{
774 msm9615_common_init();
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400775#ifdef CONFIG_FB_MSM
776 mdm9615_init_fb();
777#endif
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700778}
779
780static void __init msm9615_mtp_init(void)
781{
782 msm9615_common_init();
783}
784
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400785#ifdef CONFIG_FB_MSM
786static void __init mdm9615_allocate_memory_regions(void)
787{
788 mdm9615_allocate_fb_region();
789}
790#endif
791
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700792MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
793 .map_io = msm9615_map_io,
794 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530795 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700796 .timer = &msm_timer,
797 .init_machine = msm9615_cdp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600798 .reserve = msm9615_reserve,
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400799#ifdef CONFIG_FB_MSM
800 .init_early = mdm9615_allocate_memory_regions,
801#endif
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700802MACHINE_END
803
804MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
805 .map_io = msm9615_map_io,
806 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530807 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700808 .timer = &msm_timer,
809 .init_machine = msm9615_mtp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600810 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700811MACHINE_END