blob: a8602d3bc7960763ae60c7847ac9add5f4d06dba [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>
Amit Blaye5bb35e2012-05-08 20:38:20 +030046#include <mach/cpuidle.h>
47#include <mach/usb_bam.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070048#include "timer.h"
49#include "devices.h"
David Collinsfb88c432011-08-25 15:12:47 -070050#include "board-9615.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080051#include "pm.h"
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -070052#include "acpuclock.h"
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060053#include "pm-boot.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070054
Olav Haugane6a0acd2012-04-05 09:29:12 -070055#ifdef CONFIG_ION_MSM
56#define MSM_ION_AUDIO_SIZE 0xAF000
57#define MSM_ION_HEAP_NUM 3
58#define MSM_KERNEL_EBI_SIZE 0x51000
59
60static struct memtype_reserve msm9615_reserve_table[] __initdata = {
61 [MEMTYPE_SMI] = {
62 },
63 [MEMTYPE_EBI0] = {
64 .flags = MEMTYPE_FLAGS_1M_ALIGN,
65 },
66 [MEMTYPE_EBI1] = {
67 .flags = MEMTYPE_FLAGS_1M_ALIGN,
68 },
69};
70
71static int msm9615_paddr_to_memtype(unsigned int paddr)
72{
73 return MEMTYPE_EBI1;
74}
75
76static struct ion_co_heap_pdata co_ion_pdata = {
77 .adjacent_mem_id = INVALID_HEAP_ID,
78 .align = PAGE_SIZE,
79};
80
81static struct ion_platform_data ion_pdata = {
82 .nr = MSM_ION_HEAP_NUM,
83 .heaps = {
84 {
85 .id = ION_SYSTEM_HEAP_ID,
86 .type = ION_HEAP_TYPE_SYSTEM,
87 .name = ION_VMALLOC_HEAP_NAME,
88 },
89 {
90 .id = ION_IOMMU_HEAP_ID,
91 .type = ION_HEAP_TYPE_IOMMU,
92 .name = ION_IOMMU_HEAP_NAME,
93 },
94 {
95 .id = ION_AUDIO_HEAP_ID,
96 .type = ION_HEAP_TYPE_CARVEOUT,
97 .name = ION_AUDIO_HEAP_NAME,
98 .size = MSM_ION_AUDIO_SIZE,
99 .memory_type = ION_EBI_TYPE,
100 .extra_data = (void *) &co_ion_pdata,
101 },
102 }
103};
104
105static struct platform_device ion_dev = {
106 .name = "ion-msm",
107 .id = 1,
108 .dev = { .platform_data = &ion_pdata },
109};
110
Stephen Boyd668d7652012-04-25 11:31:01 -0700111static void __init reserve_ion_memory(void)
Olav Haugane6a0acd2012-04-05 09:29:12 -0700112{
113 msm9615_reserve_table[MEMTYPE_EBI1].size += MSM_ION_AUDIO_SIZE;
114}
115
116static void __init msm9615_calculate_reserve_sizes(void)
117{
118 reserve_ion_memory();
119 msm9615_reserve_table[MEMTYPE_EBI1].size += MSM_KERNEL_EBI_SIZE;
120}
121
122static struct reserve_info msm9615_reserve_info __initdata = {
123 .memtype_reserve_table = msm9615_reserve_table,
124 .calculate_reserve_sizes = msm9615_calculate_reserve_sizes,
125 .paddr_to_memtype = msm9615_paddr_to_memtype,
126};
127#endif
128
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700129static struct pm8xxx_adc_amux pm8018_adc_channels_data[] = {
130 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
131 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
132 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
133 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
134 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
135 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
Siddartha Mohanadossf9383d52012-04-19 09:42:49 -0700136 /* AMUX8 is used to read either Batt_id/Batt_therm.
137 * Current configuration is to support Batt_id. If clients
138 * want to read the Batt_therm, the scaling function needs to be
139 * updated to use ADC_SCALE_BATT_THERM instead of ADC_SCALE_DEFAULT.
140 * E.g.
141 * {"batt_therm", CHANNEL_BATT_ID_THERM, CHAN_PATH_SCALING1,
142 * AMUX_RSV2, ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
143 */
144 {"batt_id", CHANNEL_BATT_ID_THERM, CHAN_PATH_SCALING1,
145 AMUX_RSV2, ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700146 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
147 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
148 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
149 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
150 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
151 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
152 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
153 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
154};
155
156static struct pm8xxx_adc_properties pm8018_adc_data = {
157 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
158 .bitresolution = 15,
159 .bipolar = 0,
160};
161
162static struct pm8xxx_adc_platform_data pm8018_adc_pdata = {
163 .adc_channel = pm8018_adc_channels_data,
164 .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data),
165 .adc_prop = &pm8018_adc_data,
166};
167
David Collinsfb88c432011-08-25 15:12:47 -0700168static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
169 .irq_base = PM8018_IRQ_BASE,
170 .devirq = MSM_GPIO_TO_INT(87),
171 .irq_trigger_flag = IRQF_TRIGGER_LOW,
172};
173
174static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
175 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
176};
177
178static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
179 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
180};
181
182static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
183 .rtc_write_enable = false,
Ashay Jaiswaldb5e6dc2011-10-12 11:02:47 +0530184 .rtc_alarm_powerup = false,
David Collinsfb88c432011-08-25 15:12:47 -0700185};
186
187static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
188 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -0800189 .kpd_trigger_delay_us = 15625,
David Collinsfb88c432011-08-25 15:12:47 -0700190 .wakeup = 1,
191};
192
193static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
194 .priority = 0,
195};
196
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700197#define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */
198#define PM8XXX_LED_PWM_PERIOD_US 1000
199
200/**
201 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
202 * driven using PWM feature.
203 */
204#define PM8XXX_PWM_CHANNEL_NONE -1
205
206static struct led_info pm8018_led_info[] = {
207 [0] = {
208 .name = "led:kb",
209 },
210};
211
212static struct led_platform_data pm8018_led_core_pdata = {
213 .num_leds = ARRAY_SIZE(pm8018_led_info),
214 .leds = pm8018_led_info,
215};
216
217static struct pm8xxx_led_config pm8018_led_configs[] = {
218 [0] = {
219 .id = PM8XXX_ID_LED_KB_LIGHT,
220 .mode = PM8XXX_LED_MODE_PWM3,
221 .max_current = PM8018_LED_KB_MAX_CURRENT,
222 .pwm_channel = 2,
223 .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US,
224 },
225};
226
227static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
228 .led_core = &pm8018_led_core_pdata,
229 .configs = pm8018_led_configs,
230 .num_configs = ARRAY_SIZE(pm8018_led_configs),
231};
232
Jay Chokshidc8028b2011-12-01 16:17:34 -0800233#ifdef CONFIG_LTC4088_CHARGER
234static struct ltc4088_charger_platform_data ltc4088_chg_pdata = {
235 .gpio_mode_select_d0 = 7,
236 .gpio_mode_select_d1 = 6,
237 .gpio_mode_select_d2 = 4,
238};
239#endif
240
David Collinsfb88c432011-08-25 15:12:47 -0700241static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
242 .irq_pdata = &pm8xxx_irq_pdata,
243 .gpio_pdata = &pm8xxx_gpio_pdata,
244 .mpp_pdata = &pm8xxx_mpp_pdata,
245 .rtc_pdata = &pm8xxx_rtc_pdata,
246 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
247 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -0700248 .regulator_pdatas = msm_pm8018_regulator_pdata,
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700249 .adc_pdata = &pm8018_adc_pdata,
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700250 .leds_pdata = &pm8xxx_leds_pdata,
David Collinsfb88c432011-08-25 15:12:47 -0700251};
252
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700253static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
254 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
255 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -0700256 .name = PM8018_CORE_DEV_NAME,
257 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700258 },
259};
260
David Collinsbea297a2011-09-28 13:11:14 -0700261static struct platform_device msm9615_device_rpm_regulator __devinitdata = {
262 .name = "rpm-regulator",
263 .id = -1,
264 .dev = {
265 .platform_data = &msm_rpm_regulator_9615_pdata,
266 },
267};
268
David Collins0f9942a2011-10-31 09:47:34 -0700269static struct platform_device msm9615_device_ext_2p95v_vreg = {
270 .name = GPIO_REGULATOR_DEV_NAME,
271 .id = 18,
272 .dev = {
273 .platform_data =
274 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V],
275 },
276};
277
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600278static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
279 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
280 .v_addr = MSM_APCS_GLB_BASE + 0x24,
281};
282
Gagan Mac7a827642011-09-22 19:42:21 -0600283static void __init msm9615_init_buses(void)
284{
285#ifdef CONFIG_MSM_BUS_SCALING
286 msm_bus_rpm_set_mt_mask();
287 msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
288 msm_bus_9615_sys_fabric.dev.platform_data =
289 &msm_bus_9615_sys_fabric_pdata;
290 msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
291#endif
292}
293
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800294#ifdef CONFIG_WCD9310_CODEC
295
296#define TABLA_INTERRUPT_BASE (NR_MSM_IRQS + NR_GPIO_IRQS)
297
298/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
299 * 4 micbiases are used to power various analog and digital
300 * microphones operating at 1800 mV. Technically, all micbiases
301 * can source from single cfilter since all microphones operate
302 * at the same voltage level. The arrangement below is to make
303 * sure all cfilters are exercised. LDO_H regulator ouput level
304 * does not need to be as high as 2.85V. It is choosen for
305 * microphone sensitivity purpose.
306 */
307
308static struct wcd9xxx_pdata tabla20_platform_data = {
309 .slimbus_slave_device = {
310 .name = "tabla-slave",
311 .e_addr = {0, 0, 0x60, 0, 0x17, 2},
312 },
313 .irq = 85,
314 .irq_base = TABLA_INTERRUPT_BASE,
315 .num_irqs = NR_WCD9XXX_IRQS,
316 .reset_gpio = 84,
317 .micbias = {
318 .ldoh_v = TABLA_LDOH_2P85_V,
319 .cfilt1_mv = 1800,
320 .cfilt2_mv = 1800,
321 .cfilt3_mv = 1800,
322 .bias1_cfilt_sel = TABLA_CFILT1_SEL,
323 .bias2_cfilt_sel = TABLA_CFILT2_SEL,
324 .bias3_cfilt_sel = TABLA_CFILT3_SEL,
325 .bias4_cfilt_sel = TABLA_CFILT3_SEL,
326 },
327 .regulator = {
328 {
329 .name = "CDC_VDD_CP",
330 .min_uV = 1800000,
331 .max_uV = 1800000,
332 .optimum_uA = WCD9XXX_CDC_VDDA_CP_CUR_MAX,
333 },
334 {
335 .name = "CDC_VDDA_RX",
336 .min_uV = 1800000,
337 .max_uV = 1800000,
338 .optimum_uA = WCD9XXX_CDC_VDDA_RX_CUR_MAX,
339 },
340 {
341 .name = "CDC_VDDA_TX",
342 .min_uV = 1800000,
343 .max_uV = 1800000,
344 .optimum_uA = WCD9XXX_CDC_VDDA_TX_CUR_MAX,
345 },
346 {
347 .name = "VDDIO_CDC",
348 .min_uV = 1800000,
349 .max_uV = 1800000,
350 .optimum_uA = WCD9XXX_VDDIO_CDC_CUR_MAX,
351 },
352 {
353 .name = "VDDD_CDC_D",
354 .min_uV = 1225000,
355 .max_uV = 1225000,
356 .optimum_uA = WCD9XXX_VDDD_CDC_D_CUR_MAX,
357 },
358 {
359 .name = "CDC_VDDA_A_1P2V",
360 .min_uV = 1225000,
361 .max_uV = 1225000,
362 .optimum_uA = WCD9XXX_VDDD_CDC_A_CUR_MAX,
363 },
364 },
365};
366
367static struct slim_device msm_slim_tabla20 = {
368 .name = "tabla2x-slim",
369 .e_addr = {0, 1, 0x60, 0, 0x17, 2},
370 .dev = {
371 .platform_data = &tabla20_platform_data,
372 },
373};
374#endif
375
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700376static struct slim_boardinfo msm_slim_devices[] = {
377 /* add slimbus slaves as needed */
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800378#ifdef CONFIG_WCD9310_CODEC
379 {
380 .bus_num = 1,
381 .slim_slave = &msm_slim_tabla20,
382 },
383#endif
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700384};
385
Harini Jayaraman738c9312011-09-08 15:22:38 -0600386static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
387 .max_clock_speed = 24000000,
388};
389
Harini Jayaramaneba52672011-09-08 15:13:00 -0600390static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
391 .clk_freq = 100000,
392 .src_clk_rate = 24000000,
393};
394
Amit Blay6a8d4f32011-11-21 10:36:25 +0200395#define USB_5V_EN 3
396#define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN)
397
Mayank Rana8549e632012-01-23 12:49:54 +0530398static int msm_hsusb_vbus_power(bool on)
Amit Blay6a8d4f32011-11-21 10:36:25 +0200399{
Amit Blaya4416f92012-01-24 21:03:52 +0200400 int rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200401 struct pm_gpio usb_vbus = {
402 .direction = PM_GPIO_DIR_OUT,
403 .pull = PM_GPIO_PULL_NO,
404 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200405 .vin_sel = 2,
406 .out_strength = PM_GPIO_STRENGTH_HIGH,
407 .function = PM_GPIO_FUNC_NORMAL,
408 .inv_int_pol = 0,
409 };
410
Amit Blaya4416f92012-01-24 21:03:52 +0200411 usb_vbus.output_value = on;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200412
Amit Blaya4416f92012-01-24 21:03:52 +0200413 rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus);
414 if (rc)
415 pr_err("failed to config usb_5v_en gpio\n");
Amit Blay6a8d4f32011-11-21 10:36:25 +0200416
Mayank Rana8549e632012-01-23 12:49:54 +0530417 return rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200418}
419
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530420static int shelby_phy_init_seq[] = {
421 0x44, 0x80,/* set VBUS valid threshold and
422 disconnect valid threshold */
423 0x38, 0x81, /* update DC voltage level */
Amit Blaydbaeff82012-04-02 22:13:36 +0300424 0x24, 0x82,/* set preemphasis and rise/fall time */
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530425 0x13, 0x83,/* set source impedance adjustment */
426 -1};
427
Ofir Cohen40a4e862011-12-08 15:17:52 +0200428#define USB_BAM_PHY_BASE 0x12502000
Ofir Cohen43473c82012-01-25 16:28:13 +0200429#define HSIC_BAM_PHY_BASE 0x12542000
Ofir Cohen40a4e862011-12-08 15:17:52 +0200430#define A2_BAM_PHY_BASE 0x124C2000
Lena Salmana66eddf2012-03-26 13:03:43 +0200431static struct usb_bam_pipe_connect msm_usb_bam_connections[2][4][2] = {
432 [0][0][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen40a4e862011-12-08 15:17:52 +0200433 .src_phy_addr = USB_BAM_PHY_BASE,
434 .src_pipe_index = 11,
435 .dst_phy_addr = A2_BAM_PHY_BASE,
436 .dst_pipe_index = 0,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200437 .data_fifo_base_offset = 0x1100,
438 .data_fifo_size = 0x600,
439 .desc_fifo_base_offset = 0x1700,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200440 .desc_fifo_size = 0x300,
441 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200442 [0][0][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen40a4e862011-12-08 15:17:52 +0200443 .src_phy_addr = A2_BAM_PHY_BASE,
444 .src_pipe_index = 1,
445 .dst_phy_addr = USB_BAM_PHY_BASE,
446 .dst_pipe_index = 10,
447 .data_fifo_base_offset = 0xa00,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200448 .data_fifo_size = 0x600,
449 .desc_fifo_base_offset = 0x1000,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200450 .desc_fifo_size = 0x100,
451 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200452 [0][1][USB_TO_PEER_PERIPHERAL] = {
Anna Perel21515162012-02-02 20:50:02 +0200453 .src_phy_addr = USB_BAM_PHY_BASE,
454 .src_pipe_index = 13,
455 .dst_phy_addr = A2_BAM_PHY_BASE,
456 .dst_pipe_index = 2,
457 .data_fifo_base_offset = 0x2100,
458 .data_fifo_size = 0x600,
459 .desc_fifo_base_offset = 0x2700,
460 .desc_fifo_size = 0x300,
461 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200462 [0][1][PEER_PERIPHERAL_TO_USB] = {
Anna Perel21515162012-02-02 20:50:02 +0200463 .src_phy_addr = A2_BAM_PHY_BASE,
464 .src_pipe_index = 3,
465 .dst_phy_addr = USB_BAM_PHY_BASE,
466 .dst_pipe_index = 12,
467 .data_fifo_base_offset = 0x1a00,
468 .data_fifo_size = 0x600,
469 .desc_fifo_base_offset = 0x2000,
470 .desc_fifo_size = 0x100,
471 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200472 [0][2][USB_TO_PEER_PERIPHERAL] = {
Anna Perel21515162012-02-02 20:50:02 +0200473 .src_phy_addr = USB_BAM_PHY_BASE,
474 .src_pipe_index = 15,
475 .dst_phy_addr = A2_BAM_PHY_BASE,
476 .dst_pipe_index = 4,
477 .data_fifo_base_offset = 0x3100,
478 .data_fifo_size = 0x600,
479 .desc_fifo_base_offset = 0x3700,
480 .desc_fifo_size = 0x300,
481 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200482 [0][2][PEER_PERIPHERAL_TO_USB] = {
Anna Perel21515162012-02-02 20:50:02 +0200483 .src_phy_addr = A2_BAM_PHY_BASE,
484 .src_pipe_index = 5,
485 .dst_phy_addr = USB_BAM_PHY_BASE,
486 .dst_pipe_index = 14,
487 .data_fifo_base_offset = 0x2a00,
488 .data_fifo_size = 0x600,
489 .desc_fifo_base_offset = 0x3000,
490 .desc_fifo_size = 0x100,
Lena Salmana66eddf2012-03-26 13:03:43 +0200491 },
492 [1][0][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200493 .src_phy_addr = HSIC_BAM_PHY_BASE,
494 .src_pipe_index = 1,
495 .dst_phy_addr = A2_BAM_PHY_BASE,
496 .dst_pipe_index = 0,
497 .data_fifo_base_offset = 0x1100,
498 .data_fifo_size = 0x600,
499 .desc_fifo_base_offset = 0x1700,
500 .desc_fifo_size = 0x300,
501 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200502 [1][0][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200503 .src_phy_addr = A2_BAM_PHY_BASE,
504 .src_pipe_index = 1,
505 .dst_phy_addr = HSIC_BAM_PHY_BASE,
506 .dst_pipe_index = 0,
507 .data_fifo_base_offset = 0xa00,
508 .data_fifo_size = 0x600,
509 .desc_fifo_base_offset = 0x1000,
510 .desc_fifo_size = 0x100,
511 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200512 [1][1][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200513 .src_phy_addr = HSIC_BAM_PHY_BASE,
514 .src_pipe_index = 3,
515 .dst_phy_addr = A2_BAM_PHY_BASE,
516 .dst_pipe_index = 2,
517 .data_fifo_base_offset = 0x2100,
518 .data_fifo_size = 0x600,
519 .desc_fifo_base_offset = 0x2700,
520 .desc_fifo_size = 0x300,
521 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200522 [1][1][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200523 .src_phy_addr = A2_BAM_PHY_BASE,
524 .src_pipe_index = 3,
525 .dst_phy_addr = HSIC_BAM_PHY_BASE,
526 .dst_pipe_index = 2,
527 .data_fifo_base_offset = 0x1a00,
528 .data_fifo_size = 0x600,
529 .desc_fifo_base_offset = 0x2000,
530 .desc_fifo_size = 0x100,
531 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200532 [1][2][USB_TO_PEER_PERIPHERAL] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200533 .src_phy_addr = HSIC_BAM_PHY_BASE,
534 .src_pipe_index = 5,
535 .dst_phy_addr = A2_BAM_PHY_BASE,
536 .dst_pipe_index = 4,
537 .data_fifo_base_offset = 0x3100,
538 .data_fifo_size = 0x600,
539 .desc_fifo_base_offset = 0x3700,
540 .desc_fifo_size = 0x300,
541 },
Lena Salmana66eddf2012-03-26 13:03:43 +0200542 [1][2][PEER_PERIPHERAL_TO_USB] = {
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200543 .src_phy_addr = A2_BAM_PHY_BASE,
544 .src_pipe_index = 5,
545 .dst_phy_addr = HSIC_BAM_PHY_BASE,
546 .dst_pipe_index = 4,
547 .data_fifo_base_offset = 0x2a00,
548 .data_fifo_size = 0x600,
549 .desc_fifo_base_offset = 0x3000,
550 .desc_fifo_size = 0x100,
551 }
Ofir Cohen40a4e862011-12-08 15:17:52 +0200552};
553
554static struct msm_usb_bam_platform_data msm_usb_bam_pdata = {
Lena Salmana66eddf2012-03-26 13:03:43 +0200555 .connections = &msm_usb_bam_connections[0][0][0],
Lena Salman57d167e2012-03-21 19:46:38 +0200556#ifndef CONFIG_USB_CI13XXX_MSM_HSIC
Ofir Cohen43473c82012-01-25 16:28:13 +0200557 .usb_active_bam = HSUSB_BAM,
Ofir Cohen43473c82012-01-25 16:28:13 +0200558#else
559 .usb_active_bam = HSIC_BAM,
Ofir Cohen43473c82012-01-25 16:28:13 +0200560#endif
Lena Salmana66eddf2012-03-26 13:03:43 +0200561 .usb_bam_num_pipes = 16,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200562};
563
Amit Blay5e4ec192011-10-20 09:16:54 +0200564static struct msm_otg_platform_data msm_otg_pdata = {
Amit Blay6a8d4f32011-11-21 10:36:25 +0200565 .mode = USB_OTG,
566 .otg_control = OTG_PHY_CONTROL,
Amit Blay5e4ec192011-10-20 09:16:54 +0200567 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200568 .vbus_power = msm_hsusb_vbus_power,
Ofir Cohen4da266f2012-01-03 10:19:29 +0200569 .disable_reset_on_disconnect = true,
Amit Blay5e4ec192011-10-20 09:16:54 +0200570};
571
Amit Blay4d57d362012-04-28 11:00:21 +0300572static struct msm_hsic_peripheral_platform_data msm_hsic_peripheral_pdata = {
573 .keep_core_clk_on_suspend_workaround = true,
574};
575
Amit Blay5f968cf2012-01-22 12:04:01 +0200576#define PID_MAGIC_ID 0x71432909
577#define SERIAL_NUM_MAGIC_ID 0x61945374
578#define SERIAL_NUMBER_LENGTH 127
579#define DLOAD_USB_BASE_ADD 0x2B0000C8
580
581struct magic_num_struct {
582 uint32_t pid;
583 uint32_t serial_num;
584};
585
586struct dload_struct {
587 uint32_t reserved1;
588 uint32_t reserved2;
589 uint32_t reserved3;
590 uint16_t reserved4;
591 uint16_t pid;
592 char serial_number[SERIAL_NUMBER_LENGTH];
593 uint16_t reserved5;
594 struct magic_num_struct magic_struct;
595};
596
Amit Blay5e4ec192011-10-20 09:16:54 +0200597static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
598{
Amit Blay5f968cf2012-01-22 12:04:01 +0200599 struct dload_struct __iomem *dload = 0;
600
601 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
602 if (!dload) {
603 pr_err("%s: cannot remap I/O memory region: %08x\n",
604 __func__, DLOAD_USB_BASE_ADD);
605 return -ENXIO;
606 }
607
608 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
609 __func__, dload, pid, snum);
610 /* update pid */
611 dload->magic_struct.pid = PID_MAGIC_ID;
612 dload->pid = pid;
613
614 /* update serial number */
615 dload->magic_struct.serial_num = 0;
616 if (!snum) {
617 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
618 goto out;
619 }
620
621 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
622 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
623out:
624 iounmap(dload);
Amit Blay5e4ec192011-10-20 09:16:54 +0200625 return 0;
626}
627
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800628static struct platform_device msm_wlan_ar6000_pm_device = {
629 .name = "wlan_ar6000_pm_dev",
630 .id = -1,
631};
632
633static int __init msm9615_init_ar6000pm(void)
634{
635 return platform_device_register(&msm_wlan_ar6000_pm_device);
636}
637
Jay Chokshidc8028b2011-12-01 16:17:34 -0800638#ifdef CONFIG_LTC4088_CHARGER
639static struct platform_device msm_device_charger = {
640 .name = LTC4088_CHARGER_DEV_NAME,
641 .id = -1,
642 .dev = {
643 .platform_data = &ltc4088_chg_pdata,
644 },
645};
646#endif
647
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700648static struct tsens_platform_data msm_tsens_pdata = {
649 .tsens_factor = 1000,
650 .hw_type = MDM_9615,
651 .tsens_num_sensor = 5,
Siddartha Mohanadoss892ee472012-05-03 10:35:20 -0700652 .slope = {1176, 1162, 1162, 1149, 1176},
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700653};
654
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -0700655static struct platform_device msm_tsens_device = {
656 .name = "tsens8960-tm",
657 .id = -1,
658};
659
Amit Blay5e4ec192011-10-20 09:16:54 +0200660static struct platform_device *common_devices[] = {
661 &msm9615_device_dmov,
662 &msm_device_smd,
Jay Chokshidc8028b2011-12-01 16:17:34 -0800663#ifdef CONFIG_LTC4088_CHARGER
664 &msm_device_charger,
665#endif
Lena Salman57d167e2012-03-21 19:46:38 +0200666#ifndef CONFIG_USB_CI13XXX_MSM_HSIC
Amit Blay5e4ec192011-10-20 09:16:54 +0200667 &msm_device_otg,
Ofir Cohendca06cb2012-03-08 16:37:45 +0200668#endif
Ofir Cohen73c99e82012-01-15 13:38:14 +0200669 &msm_device_hsic_peripheral,
Amit Blay5e4ec192011-10-20 09:16:54 +0200670 &msm_device_gadget_peripheral,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200671 &msm_device_hsusb_host,
Lena Salman65bcf372012-02-14 15:33:32 +0200672 &msm_device_hsic_host,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200673 &msm_device_usb_bam,
Ofir Cohen94213a72012-05-03 14:26:32 +0300674 &msm_android_usb_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200675 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700676 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200677 &msm9615_device_ssbi_pmic1,
678 &msm9615_device_qup_i2c_gsbi5,
679 &msm9615_device_qup_spi_gsbi3,
680 &msm_device_sps,
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700681 &msm9615_slim_ctrl,
Amit Blay5e4ec192011-10-20 09:16:54 +0200682 &msm_device_nand,
Eric Holmberg0c96e702011-11-08 18:04:31 -0700683 &msm_device_bam_dmux,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600684 &msm9615_rpm_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200685#ifdef CONFIG_HW_RANDOM_MSM
686 &msm_device_rng,
687#endif
Olav Haugane6a0acd2012-04-05 09:29:12 -0700688#ifdef CONFIG_ION_MSM
689 &ion_dev,
690#endif
Amit Blay5e4ec192011-10-20 09:16:54 +0200691
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800692 &msm_pcm,
693 &msm_multi_ch_pcm,
694 &msm_pcm_routing,
695 &msm_cpudai0,
696 &msm_cpudai1,
697 &msm_cpudai_bt_rx,
698 &msm_cpudai_bt_tx,
699 &msm_cpu_fe,
700 &msm_stub_codec,
701 &msm_voice,
702 &msm_voip,
703 &msm_pcm_hostless,
704 &msm_cpudai_afe_01_rx,
705 &msm_cpudai_afe_01_tx,
706 &msm_cpudai_afe_02_rx,
707 &msm_cpudai_afe_02_tx,
708 &msm_pcm_afe,
709 &msm_cpudai_auxpcm_rx,
710 &msm_cpudai_auxpcm_tx,
711
Amit Blay5e4ec192011-10-20 09:16:54 +0200712#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
713 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700714 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200715#endif
716
717#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
718 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700719 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200720#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700721 &msm9615_device_watchdog,
Gagan Mac7a827642011-09-22 19:42:21 -0600722 &msm_bus_9615_sys_fabric,
723 &msm_bus_def_fab,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600724 &msm9615_rpm_log_device,
725 &msm9615_rpm_stat_device,
Siddartha Mohanadoss48cad912012-04-05 21:29:54 -0700726 &msm_tsens_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200727};
728
Harini Jayaramaneba52672011-09-08 15:13:00 -0600729static void __init msm9615_i2c_init(void)
730{
731 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
732 &msm9615_i2c_qup_gsbi5_pdata;
733}
734
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600735static void __init msm9615_reserve(void)
736{
Olav Haugane6a0acd2012-04-05 09:29:12 -0700737#ifdef CONFIG_ION_MSM
738 reserve_info = &msm9615_reserve_info;
739 msm_reserve();
740#endif
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600741}
742
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700743static void __init msm9615_common_init(void)
744{
Ofir Cohen94213a72012-05-03 14:26:32 +0300745 struct android_usb_platform_data *android_pdata =
746 msm_android_usb_device.dev.platform_data;
747
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700748 msm9615_device_init();
Rohit Vaswania6815892011-12-15 20:20:39 -0800749 msm9615_init_gpiomux();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600750 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700751 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700752 platform_device_register(&msm9615_device_rpm_regulator);
Vikram Mulukutla2021c002011-12-16 12:32:59 -0800753 msm_xo_init();
Gagan Mac7a827642011-09-22 19:42:21 -0600754 msm_clock_init(&msm9615_clock_init_data);
755 msm9615_init_buses();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600756 msm9615_device_qup_spi_gsbi3.dev.platform_data =
757 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700758 msm9615_device_ssbi_pmic1.dev.platform_data =
759 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700760 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200761
762 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530763 msm_otg_pdata.phy_init_seq = shelby_phy_init_seq;
Amit Blay4d57d362012-04-28 11:00:21 +0300764 msm_device_hsic_peripheral.dev.platform_data =
765 &msm_hsic_peripheral_pdata;
Ofir Cohen40a4e862011-12-08 15:17:52 +0200766 msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700767 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700768
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700769 acpuclk_init(&acpuclk_9615_soc_data);
770
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800771 /* Ensure ar6000pm device is registered before MMC/SDC */
772 msm9615_init_ar6000pm();
773
Krishna Kondadd794462011-10-01 00:19:29 -0700774 msm9615_init_mmc();
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700775 slim_register_board_info(msm_slim_devices,
776 ARRAY_SIZE(msm_slim_devices));
Ofir Cohen94213a72012-05-03 14:26:32 +0300777 android_pdata->update_pid_and_serial_num =
778 usb_diag_update_pid_and_serial_num;
Olav Haugane6a0acd2012-04-05 09:29:12 -0700779 msm_pm_boot_pdata.p_addr = allocate_contiguous_ebi_nomap(SZ_8, SZ_64K);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600780 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Siddartha Mohanadoss7e25dc12012-03-19 11:19:27 -0700781 msm_tsens_early_init(&msm_tsens_pdata);
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700782}
783
784static void __init msm9615_cdp_init(void)
785{
786 msm9615_common_init();
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400787#ifdef CONFIG_FB_MSM
788 mdm9615_init_fb();
789#endif
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700790}
791
792static void __init msm9615_mtp_init(void)
793{
794 msm9615_common_init();
795}
796
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400797#ifdef CONFIG_FB_MSM
798static void __init mdm9615_allocate_memory_regions(void)
799{
800 mdm9615_allocate_fb_region();
801}
802#endif
803
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700804MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
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_cdp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600810 .reserve = msm9615_reserve,
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400811#ifdef CONFIG_FB_MSM
812 .init_early = mdm9615_allocate_memory_regions,
813#endif
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700814MACHINE_END
815
816MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
817 .map_io = msm9615_map_io,
818 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530819 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700820 .timer = &msm_timer,
821 .init_machine = msm9615_mtp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600822 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700823MACHINE_END