blob: a1a0dc73be5b58a0bac9cafb533cc005ff382ae4 [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>
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -070018#include <linux/msm_ssbi.h>
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060019#include <linux/memblock.h>
Rohit Vaswania6815892011-12-15 20:20:39 -080020#include <linux/usb/android.h>
21#include <linux/usb/msm_hsusb.h>
22#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
23#include <linux/leds.h>
24#include <linux/leds-pm8xxx.h>
25#include <linux/power/ltc4088-charger.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070026#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
Marc Zyngier89bdafd12011-12-22 11:39:20 +053028#include <asm/hardware/gic.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070029#include <mach/board.h>
30#include <mach/msm_iomap.h>
31#include <mach/gpio.h>
Harini Jayaraman738c9312011-09-08 15:22:38 -060032#include <mach/msm_spi.h>
Gagan Mac7a827642011-09-22 19:42:21 -060033#include <mach/msm_bus_board.h>
Vikram Mulukutla2021c002011-12-16 12:32:59 -080034#include <mach/msm_xo.h>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070035#include "timer.h"
36#include "devices.h"
David Collinsfb88c432011-08-25 15:12:47 -070037#include "board-9615.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080038#include <mach/cpuidle.h>
Matt Wagantall7cca4642012-02-01 16:43:24 -080039#include "pm.h"
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -070040#include "acpuclock.h"
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060041#include "pm-boot.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070042
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -070043static struct pm8xxx_adc_amux pm8018_adc_channels_data[] = {
44 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
45 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
46 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
47 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
48 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
49 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
50 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
51 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
52 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2,
53 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
54 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
55 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
56 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
57 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
58 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
59 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
60 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
61 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
62};
63
64static struct pm8xxx_adc_properties pm8018_adc_data = {
65 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
66 .bitresolution = 15,
67 .bipolar = 0,
68};
69
70static struct pm8xxx_adc_platform_data pm8018_adc_pdata = {
71 .adc_channel = pm8018_adc_channels_data,
72 .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data),
73 .adc_prop = &pm8018_adc_data,
74};
75
David Collinsfb88c432011-08-25 15:12:47 -070076static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
77 .irq_base = PM8018_IRQ_BASE,
78 .devirq = MSM_GPIO_TO_INT(87),
79 .irq_trigger_flag = IRQF_TRIGGER_LOW,
80};
81
82static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
83 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
84};
85
86static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
87 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
88};
89
90static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
91 .rtc_write_enable = false,
Ashay Jaiswaldb5e6dc2011-10-12 11:02:47 +053092 .rtc_alarm_powerup = false,
David Collinsfb88c432011-08-25 15:12:47 -070093};
94
95static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
96 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -080097 .kpd_trigger_delay_us = 15625,
David Collinsfb88c432011-08-25 15:12:47 -070098 .wakeup = 1,
99};
100
101static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
102 .priority = 0,
103};
104
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700105#define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */
106#define PM8XXX_LED_PWM_PERIOD_US 1000
107
108/**
109 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
110 * driven using PWM feature.
111 */
112#define PM8XXX_PWM_CHANNEL_NONE -1
113
114static struct led_info pm8018_led_info[] = {
115 [0] = {
116 .name = "led:kb",
117 },
118};
119
120static struct led_platform_data pm8018_led_core_pdata = {
121 .num_leds = ARRAY_SIZE(pm8018_led_info),
122 .leds = pm8018_led_info,
123};
124
125static struct pm8xxx_led_config pm8018_led_configs[] = {
126 [0] = {
127 .id = PM8XXX_ID_LED_KB_LIGHT,
128 .mode = PM8XXX_LED_MODE_PWM3,
129 .max_current = PM8018_LED_KB_MAX_CURRENT,
130 .pwm_channel = 2,
131 .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US,
132 },
133};
134
135static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
136 .led_core = &pm8018_led_core_pdata,
137 .configs = pm8018_led_configs,
138 .num_configs = ARRAY_SIZE(pm8018_led_configs),
139};
140
Jay Chokshidc8028b2011-12-01 16:17:34 -0800141#ifdef CONFIG_LTC4088_CHARGER
142static struct ltc4088_charger_platform_data ltc4088_chg_pdata = {
143 .gpio_mode_select_d0 = 7,
144 .gpio_mode_select_d1 = 6,
145 .gpio_mode_select_d2 = 4,
146};
147#endif
148
David Collinsfb88c432011-08-25 15:12:47 -0700149static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
150 .irq_pdata = &pm8xxx_irq_pdata,
151 .gpio_pdata = &pm8xxx_gpio_pdata,
152 .mpp_pdata = &pm8xxx_mpp_pdata,
153 .rtc_pdata = &pm8xxx_rtc_pdata,
154 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
155 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -0700156 .regulator_pdatas = msm_pm8018_regulator_pdata,
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700157 .adc_pdata = &pm8018_adc_pdata,
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700158 .leds_pdata = &pm8xxx_leds_pdata,
David Collinsfb88c432011-08-25 15:12:47 -0700159};
160
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700161static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
162 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
163 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -0700164 .name = PM8018_CORE_DEV_NAME,
165 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700166 },
167};
168
David Collinsbea297a2011-09-28 13:11:14 -0700169static struct platform_device msm9615_device_rpm_regulator __devinitdata = {
170 .name = "rpm-regulator",
171 .id = -1,
172 .dev = {
173 .platform_data = &msm_rpm_regulator_9615_pdata,
174 },
175};
176
David Collins0f9942a2011-10-31 09:47:34 -0700177static struct platform_device msm9615_device_ext_2p95v_vreg = {
178 .name = GPIO_REGULATOR_DEV_NAME,
179 .id = 18,
180 .dev = {
181 .platform_data =
182 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V],
183 },
184};
185
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600186static struct msm_cpuidle_state msm_cstates[] __initdata = {
187 {0, 0, "C0", "WFI",
188 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
189
190 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
191 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
192
193 {0, 2, "C2", "POWER_COLLAPSE",
194 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
195};
196static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
197 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
198 .idle_supported = 1,
199 .suspend_supported = 1,
200 .idle_enabled = 0,
201 .suspend_enabled = 0,
202 },
203 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
204 .idle_supported = 1,
205 .suspend_supported = 1,
206 .idle_enabled = 0,
207 .suspend_enabled = 0,
208 },
209 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
210 .idle_supported = 1,
211 .suspend_supported = 1,
212 .idle_enabled = 1,
213 .suspend_enabled = 1,
214 },
215};
Krishna Kondadd794462011-10-01 00:19:29 -0700216
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600217static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
218 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
219 .v_addr = MSM_APCS_GLB_BASE + 0x24,
220};
221
Gagan Mac7a827642011-09-22 19:42:21 -0600222static void __init msm9615_init_buses(void)
223{
224#ifdef CONFIG_MSM_BUS_SCALING
225 msm_bus_rpm_set_mt_mask();
226 msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
227 msm_bus_9615_sys_fabric.dev.platform_data =
228 &msm_bus_9615_sys_fabric_pdata;
229 msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
230#endif
231}
232
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700233static struct slim_boardinfo msm_slim_devices[] = {
234 /* add slimbus slaves as needed */
235};
236
Harini Jayaraman738c9312011-09-08 15:22:38 -0600237static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
238 .max_clock_speed = 24000000,
239};
240
Harini Jayaramaneba52672011-09-08 15:13:00 -0600241static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
242 .clk_freq = 100000,
243 .src_clk_rate = 24000000,
244};
245
Amit Blay6a8d4f32011-11-21 10:36:25 +0200246#define USB_5V_EN 3
247#define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN)
248
Mayank Rana8549e632012-01-23 12:49:54 +0530249static int msm_hsusb_vbus_power(bool on)
Amit Blay6a8d4f32011-11-21 10:36:25 +0200250{
Amit Blaya4416f92012-01-24 21:03:52 +0200251 int rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200252 struct pm_gpio usb_vbus = {
253 .direction = PM_GPIO_DIR_OUT,
254 .pull = PM_GPIO_PULL_NO,
255 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200256 .vin_sel = 2,
257 .out_strength = PM_GPIO_STRENGTH_HIGH,
258 .function = PM_GPIO_FUNC_NORMAL,
259 .inv_int_pol = 0,
260 };
261
Amit Blaya4416f92012-01-24 21:03:52 +0200262 usb_vbus.output_value = on;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200263
Amit Blaya4416f92012-01-24 21:03:52 +0200264 rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus);
265 if (rc)
266 pr_err("failed to config usb_5v_en gpio\n");
Amit Blay6a8d4f32011-11-21 10:36:25 +0200267
Mayank Rana8549e632012-01-23 12:49:54 +0530268 return rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200269}
270
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530271static int shelby_phy_init_seq[] = {
272 0x44, 0x80,/* set VBUS valid threshold and
273 disconnect valid threshold */
274 0x38, 0x81, /* update DC voltage level */
275 0x14, 0x82,/* set preemphasis and rise/fall time */
276 0x13, 0x83,/* set source impedance adjustment */
277 -1};
278
Ofir Cohen40a4e862011-12-08 15:17:52 +0200279#define USB_BAM_PHY_BASE 0x12502000
Ofir Cohen43473c82012-01-25 16:28:13 +0200280#define HSIC_BAM_PHY_BASE 0x12542000
Ofir Cohen40a4e862011-12-08 15:17:52 +0200281#define A2_BAM_PHY_BASE 0x124C2000
282static struct usb_bam_pipe_connect msm_usb_bam_connections[4][2] = {
Ofir Cohen43473c82012-01-25 16:28:13 +0200283#ifndef CONFIG_USB_GADGET_CI13XXX_MSM_HSIC
Ofir Cohen40a4e862011-12-08 15:17:52 +0200284 [0][USB_TO_PEER_PERIPHERAL] = {
285 .src_phy_addr = USB_BAM_PHY_BASE,
286 .src_pipe_index = 11,
287 .dst_phy_addr = A2_BAM_PHY_BASE,
288 .dst_pipe_index = 0,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200289 .data_fifo_base_offset = 0x1100,
290 .data_fifo_size = 0x600,
291 .desc_fifo_base_offset = 0x1700,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200292 .desc_fifo_size = 0x300,
293 },
294 [0][PEER_PERIPHERAL_TO_USB] = {
295 .src_phy_addr = A2_BAM_PHY_BASE,
296 .src_pipe_index = 1,
297 .dst_phy_addr = USB_BAM_PHY_BASE,
298 .dst_pipe_index = 10,
299 .data_fifo_base_offset = 0xa00,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200300 .data_fifo_size = 0x600,
301 .desc_fifo_base_offset = 0x1000,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200302 .desc_fifo_size = 0x100,
303 },
Anna Perel21515162012-02-02 20:50:02 +0200304 [1][USB_TO_PEER_PERIPHERAL] = {
305 .src_phy_addr = USB_BAM_PHY_BASE,
306 .src_pipe_index = 13,
307 .dst_phy_addr = A2_BAM_PHY_BASE,
308 .dst_pipe_index = 2,
309 .data_fifo_base_offset = 0x2100,
310 .data_fifo_size = 0x600,
311 .desc_fifo_base_offset = 0x2700,
312 .desc_fifo_size = 0x300,
313 },
314 [1][PEER_PERIPHERAL_TO_USB] = {
315 .src_phy_addr = A2_BAM_PHY_BASE,
316 .src_pipe_index = 3,
317 .dst_phy_addr = USB_BAM_PHY_BASE,
318 .dst_pipe_index = 12,
319 .data_fifo_base_offset = 0x1a00,
320 .data_fifo_size = 0x600,
321 .desc_fifo_base_offset = 0x2000,
322 .desc_fifo_size = 0x100,
323 },
324 [2][USB_TO_PEER_PERIPHERAL] = {
325 .src_phy_addr = USB_BAM_PHY_BASE,
326 .src_pipe_index = 15,
327 .dst_phy_addr = A2_BAM_PHY_BASE,
328 .dst_pipe_index = 4,
329 .data_fifo_base_offset = 0x3100,
330 .data_fifo_size = 0x600,
331 .desc_fifo_base_offset = 0x3700,
332 .desc_fifo_size = 0x300,
333 },
334 [2][PEER_PERIPHERAL_TO_USB] = {
335 .src_phy_addr = A2_BAM_PHY_BASE,
336 .src_pipe_index = 5,
337 .dst_phy_addr = USB_BAM_PHY_BASE,
338 .dst_pipe_index = 14,
339 .data_fifo_base_offset = 0x2a00,
340 .data_fifo_size = 0x600,
341 .desc_fifo_base_offset = 0x3000,
342 .desc_fifo_size = 0x100,
343 }
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200344#else
345 [0][USB_TO_PEER_PERIPHERAL] = {
346 .src_phy_addr = HSIC_BAM_PHY_BASE,
347 .src_pipe_index = 1,
348 .dst_phy_addr = A2_BAM_PHY_BASE,
349 .dst_pipe_index = 0,
350 .data_fifo_base_offset = 0x1100,
351 .data_fifo_size = 0x600,
352 .desc_fifo_base_offset = 0x1700,
353 .desc_fifo_size = 0x300,
354 },
355 [0][PEER_PERIPHERAL_TO_USB] = {
356 .src_phy_addr = A2_BAM_PHY_BASE,
357 .src_pipe_index = 1,
358 .dst_phy_addr = HSIC_BAM_PHY_BASE,
359 .dst_pipe_index = 0,
360 .data_fifo_base_offset = 0xa00,
361 .data_fifo_size = 0x600,
362 .desc_fifo_base_offset = 0x1000,
363 .desc_fifo_size = 0x100,
364 },
365 [1][USB_TO_PEER_PERIPHERAL] = {
366 .src_phy_addr = HSIC_BAM_PHY_BASE,
367 .src_pipe_index = 3,
368 .dst_phy_addr = A2_BAM_PHY_BASE,
369 .dst_pipe_index = 2,
370 .data_fifo_base_offset = 0x2100,
371 .data_fifo_size = 0x600,
372 .desc_fifo_base_offset = 0x2700,
373 .desc_fifo_size = 0x300,
374 },
375 [1][PEER_PERIPHERAL_TO_USB] = {
376 .src_phy_addr = A2_BAM_PHY_BASE,
377 .src_pipe_index = 3,
378 .dst_phy_addr = HSIC_BAM_PHY_BASE,
379 .dst_pipe_index = 2,
380 .data_fifo_base_offset = 0x1a00,
381 .data_fifo_size = 0x600,
382 .desc_fifo_base_offset = 0x2000,
383 .desc_fifo_size = 0x100,
384 },
385 [2][USB_TO_PEER_PERIPHERAL] = {
386 .src_phy_addr = HSIC_BAM_PHY_BASE,
387 .src_pipe_index = 5,
388 .dst_phy_addr = A2_BAM_PHY_BASE,
389 .dst_pipe_index = 4,
390 .data_fifo_base_offset = 0x3100,
391 .data_fifo_size = 0x600,
392 .desc_fifo_base_offset = 0x3700,
393 .desc_fifo_size = 0x300,
394 },
395 [2][PEER_PERIPHERAL_TO_USB] = {
396 .src_phy_addr = A2_BAM_PHY_BASE,
397 .src_pipe_index = 5,
398 .dst_phy_addr = HSIC_BAM_PHY_BASE,
399 .dst_pipe_index = 4,
400 .data_fifo_base_offset = 0x2a00,
401 .data_fifo_size = 0x600,
402 .desc_fifo_base_offset = 0x3000,
403 .desc_fifo_size = 0x100,
404 }
405#endif
Ofir Cohen40a4e862011-12-08 15:17:52 +0200406};
407
408static struct msm_usb_bam_platform_data msm_usb_bam_pdata = {
409 .connections = &msm_usb_bam_connections[0][0],
Ofir Cohen43473c82012-01-25 16:28:13 +0200410#ifndef CONFIG_USB_GADGET_CI13XXX_MSM_HSIC
411 .usb_active_bam = HSUSB_BAM,
412 .usb_bam_num_pipes = 16,
413#else
414 .usb_active_bam = HSIC_BAM,
415 .usb_bam_num_pipes = 16,
416#endif
Ofir Cohen40a4e862011-12-08 15:17:52 +0200417};
418
Amit Blay5e4ec192011-10-20 09:16:54 +0200419static struct msm_otg_platform_data msm_otg_pdata = {
Amit Blay6a8d4f32011-11-21 10:36:25 +0200420 .mode = USB_OTG,
421 .otg_control = OTG_PHY_CONTROL,
Amit Blay5e4ec192011-10-20 09:16:54 +0200422 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200423 .vbus_power = msm_hsusb_vbus_power,
Ofir Cohen4da266f2012-01-03 10:19:29 +0200424 .disable_reset_on_disconnect = true,
Amit Blay5e4ec192011-10-20 09:16:54 +0200425};
426
Amit Blay5f968cf2012-01-22 12:04:01 +0200427#define PID_MAGIC_ID 0x71432909
428#define SERIAL_NUM_MAGIC_ID 0x61945374
429#define SERIAL_NUMBER_LENGTH 127
430#define DLOAD_USB_BASE_ADD 0x2B0000C8
431
432struct magic_num_struct {
433 uint32_t pid;
434 uint32_t serial_num;
435};
436
437struct dload_struct {
438 uint32_t reserved1;
439 uint32_t reserved2;
440 uint32_t reserved3;
441 uint16_t reserved4;
442 uint16_t pid;
443 char serial_number[SERIAL_NUMBER_LENGTH];
444 uint16_t reserved5;
445 struct magic_num_struct magic_struct;
446};
447
Amit Blay5e4ec192011-10-20 09:16:54 +0200448static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
449{
Amit Blay5f968cf2012-01-22 12:04:01 +0200450 struct dload_struct __iomem *dload = 0;
451
452 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
453 if (!dload) {
454 pr_err("%s: cannot remap I/O memory region: %08x\n",
455 __func__, DLOAD_USB_BASE_ADD);
456 return -ENXIO;
457 }
458
459 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
460 __func__, dload, pid, snum);
461 /* update pid */
462 dload->magic_struct.pid = PID_MAGIC_ID;
463 dload->pid = pid;
464
465 /* update serial number */
466 dload->magic_struct.serial_num = 0;
467 if (!snum) {
468 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
469 goto out;
470 }
471
472 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
473 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
474out:
475 iounmap(dload);
Amit Blay5e4ec192011-10-20 09:16:54 +0200476 return 0;
477}
478
479static struct android_usb_platform_data android_usb_pdata = {
480 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
481};
482
483static struct platform_device android_usb_device = {
484 .name = "android_usb",
485 .id = -1,
486 .dev = {
487 .platform_data = &android_usb_pdata,
488 },
489};
490
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800491static struct platform_device msm_wlan_ar6000_pm_device = {
492 .name = "wlan_ar6000_pm_dev",
493 .id = -1,
494};
495
496static int __init msm9615_init_ar6000pm(void)
497{
498 return platform_device_register(&msm_wlan_ar6000_pm_device);
499}
500
Jay Chokshidc8028b2011-12-01 16:17:34 -0800501#ifdef CONFIG_LTC4088_CHARGER
502static struct platform_device msm_device_charger = {
503 .name = LTC4088_CHARGER_DEV_NAME,
504 .id = -1,
505 .dev = {
506 .platform_data = &ltc4088_chg_pdata,
507 },
508};
509#endif
510
Amit Blay5e4ec192011-10-20 09:16:54 +0200511static struct platform_device *common_devices[] = {
512 &msm9615_device_dmov,
513 &msm_device_smd,
Jay Chokshidc8028b2011-12-01 16:17:34 -0800514#ifdef CONFIG_LTC4088_CHARGER
515 &msm_device_charger,
516#endif
Ofir Cohendca06cb2012-03-08 16:37:45 +0200517#ifndef CONFIG_USB_GADGET_CI13XXX_MSM_HSIC
Amit Blay5e4ec192011-10-20 09:16:54 +0200518 &msm_device_otg,
Ofir Cohendca06cb2012-03-08 16:37:45 +0200519#endif
Ofir Cohen73c99e82012-01-15 13:38:14 +0200520 &msm_device_hsic_peripheral,
Amit Blay5e4ec192011-10-20 09:16:54 +0200521 &msm_device_gadget_peripheral,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200522 &msm_device_hsusb_host,
Lena Salman65bcf372012-02-14 15:33:32 +0200523 &msm_device_hsic_host,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200524 &msm_device_usb_bam,
Amit Blay5e4ec192011-10-20 09:16:54 +0200525 &android_usb_device,
526 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700527 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200528 &msm9615_device_ssbi_pmic1,
529 &msm9615_device_qup_i2c_gsbi5,
530 &msm9615_device_qup_spi_gsbi3,
531 &msm_device_sps,
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700532 &msm9615_slim_ctrl,
Amit Blay5e4ec192011-10-20 09:16:54 +0200533 &msm9615_device_tsens,
534 &msm_device_nand,
Eric Holmberg0c96e702011-11-08 18:04:31 -0700535 &msm_device_bam_dmux,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600536 &msm9615_rpm_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200537#ifdef CONFIG_HW_RANDOM_MSM
538 &msm_device_rng,
539#endif
540
541#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
542 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700543 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200544#endif
545
546#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
547 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700548 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200549#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700550 &msm9615_device_watchdog,
Gagan Mac7a827642011-09-22 19:42:21 -0600551 &msm_bus_9615_sys_fabric,
552 &msm_bus_def_fab,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600553 &msm9615_rpm_log_device,
554 &msm9615_rpm_stat_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200555};
556
Harini Jayaramaneba52672011-09-08 15:13:00 -0600557static void __init msm9615_i2c_init(void)
558{
559 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
560 &msm9615_i2c_qup_gsbi5_pdata;
561}
562
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600563static void __init msm9615_reserve(void)
564{
565 msm_pm_boot_pdata.p_addr = memblock_alloc(SZ_8, SZ_64K);
566}
567
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700568static void __init msm9615_common_init(void)
569{
570 msm9615_device_init();
Rohit Vaswania6815892011-12-15 20:20:39 -0800571 msm9615_init_gpiomux();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600572 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700573 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700574 platform_device_register(&msm9615_device_rpm_regulator);
Vikram Mulukutla2021c002011-12-16 12:32:59 -0800575 msm_xo_init();
Gagan Mac7a827642011-09-22 19:42:21 -0600576 msm_clock_init(&msm9615_clock_init_data);
577 msm9615_init_buses();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600578 msm9615_device_qup_spi_gsbi3.dev.platform_data =
579 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700580 msm9615_device_ssbi_pmic1.dev.platform_data =
581 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700582 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200583
584 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530585 msm_otg_pdata.phy_init_seq = shelby_phy_init_seq;
Ofir Cohen40a4e862011-12-08 15:17:52 +0200586 msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700587 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700588
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700589 acpuclk_init(&acpuclk_9615_soc_data);
590
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800591 /* Ensure ar6000pm device is registered before MMC/SDC */
592 msm9615_init_ar6000pm();
593
Krishna Kondadd794462011-10-01 00:19:29 -0700594 msm9615_init_mmc();
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700595 slim_register_board_info(msm_slim_devices,
596 ARRAY_SIZE(msm_slim_devices));
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600597 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
598 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
599 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
600 msm_pm_data);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600601 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700602}
603
604static void __init msm9615_cdp_init(void)
605{
606 msm9615_common_init();
607}
608
609static void __init msm9615_mtp_init(void)
610{
611 msm9615_common_init();
612}
613
614MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
615 .map_io = msm9615_map_io,
616 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530617 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700618 .timer = &msm_timer,
619 .init_machine = msm9615_cdp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600620 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700621MACHINE_END
622
623MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
624 .map_io = msm9615_map_io,
625 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530626 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700627 .timer = &msm_timer,
628 .init_machine = msm9615_mtp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600629 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700630MACHINE_END