blob: b12822394746ea5b4af9262d8d8cab69da9d6b9e [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
Stephen Boyd668d7652012-04-25 11:31:01 -0700110static void __init reserve_ion_memory(void)
Olav Haugane6a0acd2012-04-05 09:29:12 -0700111{
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},
Siddartha Mohanadossf9383d52012-04-19 09:42:49 -0700135 /* AMUX8 is used to read either Batt_id/Batt_therm.
136 * Current configuration is to support Batt_id. If clients
137 * want to read the Batt_therm, the scaling function needs to be
138 * updated to use ADC_SCALE_BATT_THERM instead of ADC_SCALE_DEFAULT.
139 * E.g.
140 * {"batt_therm", CHANNEL_BATT_ID_THERM, CHAN_PATH_SCALING1,
141 * AMUX_RSV2, ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
142 */
143 {"batt_id", CHANNEL_BATT_ID_THERM, CHAN_PATH_SCALING1,
144 AMUX_RSV2, ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700145 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
146 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
147 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
148 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
149 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
150 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
151 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
152 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
153};
154
155static struct pm8xxx_adc_properties pm8018_adc_data = {
156 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
157 .bitresolution = 15,
158 .bipolar = 0,
159};
160
161static struct pm8xxx_adc_platform_data pm8018_adc_pdata = {
162 .adc_channel = pm8018_adc_channels_data,
163 .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data),
164 .adc_prop = &pm8018_adc_data,
165};
166
David Collinsfb88c432011-08-25 15:12:47 -0700167static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
168 .irq_base = PM8018_IRQ_BASE,
169 .devirq = MSM_GPIO_TO_INT(87),
170 .irq_trigger_flag = IRQF_TRIGGER_LOW,
171};
172
173static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
174 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
175};
176
177static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
178 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
179};
180
181static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
182 .rtc_write_enable = false,
Ashay Jaiswaldb5e6dc2011-10-12 11:02:47 +0530183 .rtc_alarm_powerup = false,
David Collinsfb88c432011-08-25 15:12:47 -0700184};
185
186static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
187 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -0800188 .kpd_trigger_delay_us = 15625,
David Collinsfb88c432011-08-25 15:12:47 -0700189 .wakeup = 1,
190};
191
192static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
193 .priority = 0,
194};
195
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700196#define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */
197#define PM8XXX_LED_PWM_PERIOD_US 1000
198
199/**
200 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
201 * driven using PWM feature.
202 */
203#define PM8XXX_PWM_CHANNEL_NONE -1
204
205static struct led_info pm8018_led_info[] = {
206 [0] = {
207 .name = "led:kb",
208 },
209};
210
211static struct led_platform_data pm8018_led_core_pdata = {
212 .num_leds = ARRAY_SIZE(pm8018_led_info),
213 .leds = pm8018_led_info,
214};
215
216static struct pm8xxx_led_config pm8018_led_configs[] = {
217 [0] = {
218 .id = PM8XXX_ID_LED_KB_LIGHT,
219 .mode = PM8XXX_LED_MODE_PWM3,
220 .max_current = PM8018_LED_KB_MAX_CURRENT,
221 .pwm_channel = 2,
222 .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US,
223 },
224};
225
226static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
227 .led_core = &pm8018_led_core_pdata,
228 .configs = pm8018_led_configs,
229 .num_configs = ARRAY_SIZE(pm8018_led_configs),
230};
231
Jay Chokshidc8028b2011-12-01 16:17:34 -0800232#ifdef CONFIG_LTC4088_CHARGER
233static struct ltc4088_charger_platform_data ltc4088_chg_pdata = {
234 .gpio_mode_select_d0 = 7,
235 .gpio_mode_select_d1 = 6,
236 .gpio_mode_select_d2 = 4,
237};
238#endif
239
David Collinsfb88c432011-08-25 15:12:47 -0700240static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
241 .irq_pdata = &pm8xxx_irq_pdata,
242 .gpio_pdata = &pm8xxx_gpio_pdata,
243 .mpp_pdata = &pm8xxx_mpp_pdata,
244 .rtc_pdata = &pm8xxx_rtc_pdata,
245 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
246 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -0700247 .regulator_pdatas = msm_pm8018_regulator_pdata,
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700248 .adc_pdata = &pm8018_adc_pdata,
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700249 .leds_pdata = &pm8xxx_leds_pdata,
David Collinsfb88c432011-08-25 15:12:47 -0700250};
251
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700252static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
253 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
254 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -0700255 .name = PM8018_CORE_DEV_NAME,
256 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700257 },
258};
259
David Collinsbea297a2011-09-28 13:11:14 -0700260static struct platform_device msm9615_device_rpm_regulator __devinitdata = {
261 .name = "rpm-regulator",
262 .id = -1,
263 .dev = {
264 .platform_data = &msm_rpm_regulator_9615_pdata,
265 },
266};
267
David Collins0f9942a2011-10-31 09:47:34 -0700268static struct platform_device msm9615_device_ext_2p95v_vreg = {
269 .name = GPIO_REGULATOR_DEV_NAME,
270 .id = 18,
271 .dev = {
272 .platform_data =
273 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V],
274 },
275};
276
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600277static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
278 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
279 .v_addr = MSM_APCS_GLB_BASE + 0x24,
280};
281
Gagan Mac7a827642011-09-22 19:42:21 -0600282static void __init msm9615_init_buses(void)
283{
284#ifdef CONFIG_MSM_BUS_SCALING
285 msm_bus_rpm_set_mt_mask();
286 msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
287 msm_bus_9615_sys_fabric.dev.platform_data =
288 &msm_bus_9615_sys_fabric_pdata;
289 msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
290#endif
291}
292
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800293#ifdef CONFIG_WCD9310_CODEC
294
295#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS)
296
297/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
298 * 4 micbiases are used to power various analog and digital
299 * microphones operating at 1800 mV. Technically, all micbiases
300 * can source from single cfilter since all microphones operate
301 * at the same voltage level. The arrangement below is to make
302 * sure all cfilters are exercised. LDO_H regulator ouput level
303 * does not need to be as high as 2.85V. It is choosen for
304 * microphone sensitivity purpose.
305 */
306
307static struct wcd9xxx_pdata tabla20_platform_data = {
308 .slimbus_slave_device = {
309 .name = "tabla-slave",
310 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
311 },
312 .irq = 85,
313 .irq_base = TABLA_INTERRUPT_BASE,
314 .num_irqs = NR_WCD9XXX_IRQS,
315 .reset_gpio = 84,
316 .micbias = {
317 .ldoh_v = TABLA_LDOH_2P85_V,
318 .cfilt1_mv = 1800,
319 .cfilt2_mv = 1800,
320 .cfilt3_mv = 1800,
321 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
322 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
323 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
324 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
325 },
326 .regulator = {
327 {
328 .name = "CDC_VDD_CP",
329 .min_uV = 1800000,
330 .max_uV = 1800000,
331 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
332 },
333 {
334 .name = "CDC_VDDA_RX",
335 .min_uV = 1800000,
336 .max_uV = 1800000,
337 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
338 },
339 {
340 .name = "CDC_VDDA_TX",
341 .min_uV = 1800000,
342 .max_uV = 1800000,
343 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
344 },
345 {
346 .name = "VDDIO_CDC",
347 .min_uV = 1800000,
348 .max_uV = 1800000,
349 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
350 },
351 {
352 .name = "VDDD_CDC_D",
353 .min_uV = 1225000,
354 .max_uV = 1225000,
355 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
356 },
357 {
358 .name = "CDC_VDDA_A_1P2V",
359 .min_uV = 1225000,
360 .max_uV = 1225000,
361 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
362 },
363 },
364};
365
366static struct slim_device msm_slim_tabla20 = {
367 .name = "tabla2x-slim",
368 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
369 .dev = {
370 .platform_data = &tabla20_platform_data,
371 },
372};
373#endif
374
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700375static struct slim_boardinfo msm_slim_devices[] = {
376 /* add slimbus slaves as needed */
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800377#ifdef CONFIG_WCD9310_CODEC
378 {
379 .bus_num = 1,
380 .slim_slave = &msm_slim_tabla20,
381 },
382#endif
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700383};
384
Harini Jayaraman738c9312011-09-08 15:22:38 -0600385static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
386 .max_clock_speed = 24000000,
387};
388
Harini Jayaramaneba52672011-09-08 15:13:00 -0600389static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
390 .clk_freq = 100000,
391 .src_clk_rate = 24000000,
392};
393
Amit Blay6a8d4f32011-11-21 10:36:25 +0200394#define USB_5V_EN 3
395#define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN)
396
Mayank Rana8549e632012-01-23 12:49:54 +0530397static int msm_hsusb_vbus_power(bool on)
Amit Blay6a8d4f32011-11-21 10:36:25 +0200398{
Amit Blaya4416f92012-01-24 21:03:52 +0200399 int rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200400 struct pm_gpio usb_vbus = {
401 .direction = PM_GPIO_DIR_OUT,
402 .pull = PM_GPIO_PULL_NO,
403 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200404 .vin_sel = 2,
405 .out_strength = PM_GPIO_STRENGTH_HIGH,
406 .function = PM_GPIO_FUNC_NORMAL,
407 .inv_int_pol = 0,
408 };
409
Amit Blaya4416f92012-01-24 21:03:52 +0200410 usb_vbus.output_value = on;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200411
Amit Blaya4416f92012-01-24 21:03:52 +0200412 rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus);
413 if (rc)
414 pr_err("failed to config usb_5v_en gpio\n");
Amit Blay6a8d4f32011-11-21 10:36:25 +0200415
Mayank Rana8549e632012-01-23 12:49:54 +0530416 return rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200417}
418
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530419static int shelby_phy_init_seq[] = {
420 0x44, 0x80,/* set VBUS valid threshold and
421 disconnect valid threshold */
422 0x38, 0x81, /* update DC voltage level */
Amit Blaydbaeff82012-04-02 22:13:36 +0300423 0x24, 0x82,/* set preemphasis and rise/fall time */
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530424 0x13, 0x83,/* set source impedance adjustment */
425 -1};
426
Ofir Cohen40a4e862011-12-08 15:17:52 +0200427#define USB_BAM_PHY_BASE 0x12502000
Ofir Cohen43473c82012-01-25 16:28:13 +0200428#define HSIC_BAM_PHY_BASE 0x12542000
Ofir Cohen40a4e862011-12-08 15:17:52 +0200429#define A2_BAM_PHY_BASE 0x124C2000
Lena Salmana66eddf2012-03-26 13:03:43 +0200430static struct usb_bam_pipe_connect msm_usb_bam_connections[2][4][2] = {
431 [0][0][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen40a4e862011-12-08 15:17:52 +0200432 .src_phy_addr = USB_BAM_PHY_BASE,
433 .src_pipe_index = 11,
434 .dst_phy_addr = A2_BAM_PHY_BASE,
435 .dst_pipe_index = 0,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200436 .data_fifo_base_offset = 0x1100,
437 .data_fifo_size = 0x600,
438 .desc_fifo_base_offset = 0x1700,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200439 .desc_fifo_size = 0x300,
440 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200441 [0][0][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen40a4e862011-12-08 15:17:52 +0200442 .src_phy_addr = A2_BAM_PHY_BASE,
443 .src_pipe_index = 1,
444 .dst_phy_addr = USB_BAM_PHY_BASE,
445 .dst_pipe_index = 10,
446 .data_fifo_base_offset = 0xa00,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200447 .data_fifo_size = 0x600,
448 .desc_fifo_base_offset = 0x1000,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200449 .desc_fifo_size = 0x100,
450 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200451 [0][1][USB_TO_PEER_PERIPHERAL] = {
Anna Perel21515162012-02-02 20:50:02 +0200452 .src_phy_addr = USB_BAM_PHY_BASE,
453 .src_pipe_index = 13,
454 .dst_phy_addr = A2_BAM_PHY_BASE,
455 .dst_pipe_index = 2,
456 .data_fifo_base_offset = 0x2100,
457 .data_fifo_size = 0x600,
458 .desc_fifo_base_offset = 0x2700,
459 .desc_fifo_size = 0x300,
460 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200461 [0][1][PEER_PERIPHERAL_TO_USB] = {
Anna Perel21515162012-02-02 20:50:02 +0200462 .src_phy_addr = A2_BAM_PHY_BASE,
463 .src_pipe_index = 3,
464 .dst_phy_addr = USB_BAM_PHY_BASE,
465 .dst_pipe_index = 12,
466 .data_fifo_base_offset = 0x1a00,
467 .data_fifo_size = 0x600,
468 .desc_fifo_base_offset = 0x2000,
469 .desc_fifo_size = 0x100,
470 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200471 [0][2][USB_TO_PEER_PERIPHERAL] = {
Anna Perel21515162012-02-02 20:50:02 +0200472 .src_phy_addr = USB_BAM_PHY_BASE,
473 .src_pipe_index = 15,
474 .dst_phy_addr = A2_BAM_PHY_BASE,
475 .dst_pipe_index = 4,
476 .data_fifo_base_offset = 0x3100,
477 .data_fifo_size = 0x600,
478 .desc_fifo_base_offset = 0x3700,
479 .desc_fifo_size = 0x300,
480 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200481 [0][2][PEER_PERIPHERAL_TO_USB] = {
Anna Perel21515162012-02-02 20:50:02 +0200482 .src_phy_addr = A2_BAM_PHY_BASE,
483 .src_pipe_index = 5,
484 .dst_phy_addr = USB_BAM_PHY_BASE,
485 .dst_pipe_index = 14,
486 .data_fifo_base_offset = 0x2a00,
487 .data_fifo_size = 0x600,
488 .desc_fifo_base_offset = 0x3000,
489 .desc_fifo_size = 0x100,
Lena Salmana66eddf2012-03-26 13:03:43 +0200490 },
491 [1][0][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200492 .src_phy_addr = HSIC_BAM_PHY_BASE,
493 .src_pipe_index = 1,
494 .dst_phy_addr = A2_BAM_PHY_BASE,
495 .dst_pipe_index = 0,
496 .data_fifo_base_offset = 0x1100,
497 .data_fifo_size = 0x600,
498 .desc_fifo_base_offset = 0x1700,
499 .desc_fifo_size = 0x300,
500 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200501 [1][0][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200502 .src_phy_addr = A2_BAM_PHY_BASE,
503 .src_pipe_index = 1,
504 .dst_phy_addr = HSIC_BAM_PHY_BASE,
505 .dst_pipe_index = 0,
506 .data_fifo_base_offset = 0xa00,
507 .data_fifo_size = 0x600,
508 .desc_fifo_base_offset = 0x1000,
509 .desc_fifo_size = 0x100,
510 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200511 [1][1][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200512 .src_phy_addr = HSIC_BAM_PHY_BASE,
513 .src_pipe_index = 3,
514 .dst_phy_addr = A2_BAM_PHY_BASE,
515 .dst_pipe_index = 2,
516 .data_fifo_base_offset = 0x2100,
517 .data_fifo_size = 0x600,
518 .desc_fifo_base_offset = 0x2700,
519 .desc_fifo_size = 0x300,
520 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200521 [1][1][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200522 .src_phy_addr = A2_BAM_PHY_BASE,
523 .src_pipe_index = 3,
524 .dst_phy_addr = HSIC_BAM_PHY_BASE,
525 .dst_pipe_index = 2,
526 .data_fifo_base_offset = 0x1a00,
527 .data_fifo_size = 0x600,
528 .desc_fifo_base_offset = 0x2000,
529 .desc_fifo_size = 0x100,
530 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200531 [1][2][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200532 .src_phy_addr = HSIC_BAM_PHY_BASE,
533 .src_pipe_index = 5,
534 .dst_phy_addr = A2_BAM_PHY_BASE,
535 .dst_pipe_index = 4,
536 .data_fifo_base_offset = 0x3100,
537 .data_fifo_size = 0x600,
538 .desc_fifo_base_offset = 0x3700,
539 .desc_fifo_size = 0x300,
540 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200541 [1][2][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200542 .src_phy_addr = A2_BAM_PHY_BASE,
543 .src_pipe_index = 5,
544 .dst_phy_addr = HSIC_BAM_PHY_BASE,
545 .dst_pipe_index = 4,
546 .data_fifo_base_offset = 0x2a00,
547 .data_fifo_size = 0x600,
548 .desc_fifo_base_offset = 0x3000,
549 .desc_fifo_size = 0x100,
550 }
Ofir Cohen40a4e862011-12-08 15:17:52 +0200551};
552
553static struct msm_usb_bam_platform_data msm_usb_bam_pdata = {
Lena Salmana66eddf2012-03-26 13:03:43 +0200554 .connections = &msm_usb_bam_connections[0][0][0],
Lena Salman57d167e2012-03-21 19:46:38 +0200555#ifndef CONFIG_USB_CI13XXX_MSM_HSIC
Ofir Cohen43473c82012-01-25 16:28:13 +0200556 .usb_active_bam = HSUSB_BAM,
Ofir Cohen43473c82012-01-25 16:28:13 +0200557#else
558 .usb_active_bam = HSIC_BAM,
Ofir Cohen43473c82012-01-25 16:28:13 +0200559#endif
Lena Salmana66eddf2012-03-26 13:03:43 +0200560 .usb_bam_num_pipes = 16,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200561};
562
Amit Blay5e4ec192011-10-20 09:16:54 +0200563static struct msm_otg_platform_data msm_otg_pdata = {
Amit Blay6a8d4f32011-11-21 10:36:25 +0200564 .mode = USB_OTG,
565 .otg_control = OTG_PHY_CONTROL,
Amit Blay5e4ec192011-10-20 09:16:54 +0200566 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200567 .vbus_power = msm_hsusb_vbus_power,
Ofir Cohen4da266f2012-01-03 10:19:29 +0200568 .disable_reset_on_disconnect = true,
Amit Blay5e4ec192011-10-20 09:16:54 +0200569};
570
Amit Blay5f968cf2012-01-22 12:04:01 +0200571#define PID_MAGIC_ID 0x71432909
572#define SERIAL_NUM_MAGIC_ID 0x61945374
573#define SERIAL_NUMBER_LENGTH 127
574#define DLOAD_USB_BASE_ADD 0x2B0000C8
575
576struct magic_num_struct {
577 uint32_t pid;
578 uint32_t serial_num;
579};
580
581struct dload_struct {
582 uint32_t reserved1;
583 uint32_t reserved2;
584 uint32_t reserved3;
585 uint16_t reserved4;
586 uint16_t pid;
587 char serial_number[SERIAL_NUMBER_LENGTH];
588 uint16_t reserved5;
589 struct magic_num_struct magic_struct;
590};
591
Amit Blay5e4ec192011-10-20 09:16:54 +0200592static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
593{
Amit Blay5f968cf2012-01-22 12:04:01 +0200594 struct dload_struct __iomem *dload = 0;
595
596 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
597 if (!dload) {
598 pr_err("%s: cannot remap I/O memory region: %08x\n",
599 __func__, DLOAD_USB_BASE_ADD);
600 return -ENXIO;
601 }
602
603 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
604 __func__, dload, pid, snum);
605 /* update pid */
606 dload->magic_struct.pid = PID_MAGIC_ID;
607 dload->pid = pid;
608
609 /* update serial number */
610 dload->magic_struct.serial_num = 0;
611 if (!snum) {
612 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
613 goto out;
614 }
615
616 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
617 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
618out:
619 iounmap(dload);
Amit Blay5e4ec192011-10-20 09:16:54 +0200620 return 0;
621}
622
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800623static struct platform_device msm_wlan_ar6000_pm_device = {
624 .name = "wlan_ar6000_pm_dev",
625 .id = -1,
626};
627
628static int __init msm9615_init_ar6000pm(void)
629{
630 return platform_device_register(&msm_wlan_ar6000_pm_device);
631}
632
Jay Chokshidc8028b2011-12-01 16:17:34 -0800633#ifdef CONFIG_LTC4088_CHARGER
634static struct platform_device msm_device_charger = {
635 .name = LTC4088_CHARGER_DEV_NAME,
636 .id = -1,
637 .dev = {
638 .platform_data = &ltc4088_chg_pdata,
639 },
640};
641#endif
642
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700643static struct tsens_platform_data msm_tsens_pdata = {
644 .tsens_factor = 1000,
645 .hw_type = MDM_9615,
646 .tsens_num_sensor = 5,
Siddartha Mohanadoss892ee472012-05-03 10:35:20 -0700647 .slope = {1176, 1162, 1162, 1149, 1176},
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700648};
649
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -0700650static struct platform_device msm_tsens_device = {
651 .name = "tsens8960-tm",
652 .id = -1,
653};
654
Amit Blay5e4ec192011-10-20 09:16:54 +0200655static struct platform_device *common_devices[] = {
656 &msm9615_device_dmov,
657 &msm_device_smd,
Jay Chokshidc8028b2011-12-01 16:17:34 -0800658#ifdef CONFIG_LTC4088_CHARGER
659 &msm_device_charger,
660#endif
Lena Salman57d167e2012-03-21 19:46:38 +0200661#ifndef CONFIG_USB_CI13XXX_MSM_HSIC
Amit Blay5e4ec192011-10-20 09:16:54 +0200662 &msm_device_otg,
Ofir Cohendca06cb2012-03-08 16:37:45 +0200663#endif
Ofir Cohen73c99e82012-01-15 13:38:14 +0200664 &msm_device_hsic_peripheral,
Amit Blay5e4ec192011-10-20 09:16:54 +0200665 &msm_device_gadget_peripheral,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200666 &msm_device_hsusb_host,
Lena Salman65bcf372012-02-14 15:33:32 +0200667 &msm_device_hsic_host,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200668 &msm_device_usb_bam,
Ofir Cohen94213a72012-05-03 14:26:32 +0300669 &msm_android_usb_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200670 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700671 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200672 &msm9615_device_ssbi_pmic1,
673 &msm9615_device_qup_i2c_gsbi5,
674 &msm9615_device_qup_spi_gsbi3,
675 &msm_device_sps,
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700676 &msm9615_slim_ctrl,
Amit Blay5e4ec192011-10-20 09:16:54 +0200677 &msm_device_nand,
Eric Holmberg0c96e702011-11-08 18:04:31 -0700678 &msm_device_bam_dmux,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600679 &msm9615_rpm_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200680#ifdef CONFIG_HW_RANDOM_MSM
681 &msm_device_rng,
682#endif
Olav Haugane6a0acd2012-04-05 09:29:12 -0700683#ifdef CONFIG_ION_MSM
684 &ion_dev,
685#endif
Amit Blay5e4ec192011-10-20 09:16:54 +0200686
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800687 &msm_pcm,
688 &msm_multi_ch_pcm,
689 &msm_pcm_routing,
690 &msm_cpudai0,
691 &msm_cpudai1,
692 &msm_cpudai_bt_rx,
693 &msm_cpudai_bt_tx,
694 &msm_cpu_fe,
695 &msm_stub_codec,
696 &msm_voice,
697 &msm_voip,
698 &msm_pcm_hostless,
699 &msm_cpudai_afe_01_rx,
700 &msm_cpudai_afe_01_tx,
701 &msm_cpudai_afe_02_rx,
702 &msm_cpudai_afe_02_tx,
703 &msm_pcm_afe,
704 &msm_cpudai_auxpcm_rx,
705 &msm_cpudai_auxpcm_tx,
706
Amit Blay5e4ec192011-10-20 09:16:54 +0200707#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
708 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700709 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200710#endif
711
712#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
713 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700714 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200715#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700716 &msm9615_device_watchdog,
Gagan Mac7a827642011-09-22 19:42:21 -0600717 &msm_bus_9615_sys_fabric,
718 &msm_bus_def_fab,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600719 &msm9615_rpm_log_device,
720 &msm9615_rpm_stat_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -0700721 &msm_tsens_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{
Ofir Cohen94213a72012-05-03 14:26:32 +0300740 struct android_usb_platform_data *android_pdata =
741 msm_android_usb_device.dev.platform_data;
742
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700743 msm9615_device_init();
Rohit Vaswania6815892011-12-15 20:20:39 -0800744 msm9615_init_gpiomux();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600745 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700746 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700747 platform_device_register(&msm9615_device_rpm_regulator);
Vikram Mulukutla2021c002011-12-16 12:32:59 -0800748 msm_xo_init();
Gagan Mac7a827642011-09-22 19:42:21 -0600749 msm_clock_init(&msm9615_clock_init_data);
750 msm9615_init_buses();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600751 msm9615_device_qup_spi_gsbi3.dev.platform_data =
752 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700753 msm9615_device_ssbi_pmic1.dev.platform_data =
754 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700755 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200756
757 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530758 msm_otg_pdata.phy_init_seq = shelby_phy_init_seq;
Ofir Cohen40a4e862011-12-08 15:17:52 +0200759 msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700760 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700761
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700762 acpuclk_init(&acpuclk_9615_soc_data);
763
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800764 /* Ensure ar6000pm device is registered before MMC/SDC */
765 msm9615_init_ar6000pm();
766
Krishna Kondadd794462011-10-01 00:19:29 -0700767 msm9615_init_mmc();
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700768 slim_register_board_info(msm_slim_devices,
769 ARRAY_SIZE(msm_slim_devices));
Ofir Cohen94213a72012-05-03 14:26:32 +0300770 android_pdata->update_pid_and_serial_num =
771 usb_diag_update_pid_and_serial_num;
Olav Haugane6a0acd2012-04-05 09:29:12 -0700772 msm_pm_boot_pdata.p_addr = allocate_contiguous_ebi_nomap(SZ_8, SZ_64K);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600773 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700774 msm_tsens_early_init(&msm_tsens_pdata);
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700775}
776
777static void __init msm9615_cdp_init(void)
778{
779 msm9615_common_init();
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400780#ifdef CONFIG_FB_MSM
781 mdm9615_init_fb();
782#endif
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700783}
784
785static void __init msm9615_mtp_init(void)
786{
787 msm9615_common_init();
788}
789
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400790#ifdef CONFIG_FB_MSM
791static void __init mdm9615_allocate_memory_regions(void)
792{
793 mdm9615_allocate_fb_region();
794}
795#endif
796
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700797MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
798 .map_io = msm9615_map_io,
799 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530800 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700801 .timer = &msm_timer,
802 .init_machine = msm9615_cdp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600803 .reserve = msm9615_reserve,
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400804#ifdef CONFIG_FB_MSM
805 .init_early = mdm9615_allocate_memory_regions,
806#endif
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700807MACHINE_END
808
809MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
810 .map_io = msm9615_map_io,
811 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530812 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700813 .timer = &msm_timer,
814 .init_machine = msm9615_mtp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600815 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700816MACHINE_END