blob: 9c0a80e7de317bd82650ba173563d75e675bd780 [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>
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070034#include "timer.h"
35#include "devices.h"
David Collinsfb88c432011-08-25 15:12:47 -070036#include "board-9615.h"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080037#include <mach/cpuidle.h>
38#include <mach/pm.h>
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -070039#include "acpuclock.h"
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -060040#include "pm-boot.h"
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -070041
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -070042static struct pm8xxx_adc_amux pm8018_adc_channels_data[] = {
43 {"vcoin", CHANNEL_VCOIN, CHAN_PATH_SCALING2, AMUX_RSV1,
44 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
45 {"vbat", CHANNEL_VBAT, CHAN_PATH_SCALING2, AMUX_RSV1,
46 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
47 {"vph_pwr", CHANNEL_VPH_PWR, CHAN_PATH_SCALING2, AMUX_RSV1,
48 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
49 {"batt_therm", CHANNEL_BATT_THERM, CHAN_PATH_SCALING1, AMUX_RSV2,
50 ADC_DECIMATION_TYPE2, ADC_SCALE_BATT_THERM},
51 {"batt_id", CHANNEL_BATT_ID, CHAN_PATH_SCALING1, AMUX_RSV2,
52 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
53 {"pmic_therm", CHANNEL_DIE_TEMP, CHAN_PATH_SCALING1, AMUX_RSV1,
54 ADC_DECIMATION_TYPE2, ADC_SCALE_PMIC_THERM},
55 {"625mv", CHANNEL_625MV, CHAN_PATH_SCALING1, AMUX_RSV1,
56 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
57 {"125v", CHANNEL_125V, CHAN_PATH_SCALING1, AMUX_RSV1,
58 ADC_DECIMATION_TYPE2, ADC_SCALE_DEFAULT},
59 {"pa_therm0", ADC_MPP_1_AMUX3, CHAN_PATH_SCALING1, AMUX_RSV1,
60 ADC_DECIMATION_TYPE2, ADC_SCALE_PA_THERM},
61};
62
63static struct pm8xxx_adc_properties pm8018_adc_data = {
64 .adc_vdd_reference = 1800, /* milli-voltage for this adc */
65 .bitresolution = 15,
66 .bipolar = 0,
67};
68
69static struct pm8xxx_adc_platform_data pm8018_adc_pdata = {
70 .adc_channel = pm8018_adc_channels_data,
71 .adc_num_board_channel = ARRAY_SIZE(pm8018_adc_channels_data),
72 .adc_prop = &pm8018_adc_data,
73};
74
David Collinsfb88c432011-08-25 15:12:47 -070075static struct pm8xxx_irq_platform_data pm8xxx_irq_pdata __devinitdata = {
76 .irq_base = PM8018_IRQ_BASE,
77 .devirq = MSM_GPIO_TO_INT(87),
78 .irq_trigger_flag = IRQF_TRIGGER_LOW,
79};
80
81static struct pm8xxx_gpio_platform_data pm8xxx_gpio_pdata __devinitdata = {
82 .gpio_base = PM8018_GPIO_PM_TO_SYS(1),
83};
84
85static struct pm8xxx_mpp_platform_data pm8xxx_mpp_pdata __devinitdata = {
86 .mpp_base = PM8018_MPP_PM_TO_SYS(1),
87};
88
89static struct pm8xxx_rtc_platform_data pm8xxx_rtc_pdata __devinitdata = {
90 .rtc_write_enable = false,
Ashay Jaiswaldb5e6dc2011-10-12 11:02:47 +053091 .rtc_alarm_powerup = false,
David Collinsfb88c432011-08-25 15:12:47 -070092};
93
94static struct pm8xxx_pwrkey_platform_data pm8xxx_pwrkey_pdata = {
95 .pull_up = 1,
Jing Lineecdc062011-11-17 09:47:09 -080096 .kpd_trigger_delay_us = 15625,
David Collinsfb88c432011-08-25 15:12:47 -070097 .wakeup = 1,
98};
99
100static struct pm8xxx_misc_platform_data pm8xxx_misc_pdata = {
101 .priority = 0,
102};
103
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700104#define PM8018_LED_KB_MAX_CURRENT 20 /* I = 20mA */
105#define PM8XXX_LED_PWM_PERIOD_US 1000
106
107/**
108 * PM8XXX_PWM_CHANNEL_NONE shall be used when LED shall not be
109 * driven using PWM feature.
110 */
111#define PM8XXX_PWM_CHANNEL_NONE -1
112
113static struct led_info pm8018_led_info[] = {
114 [0] = {
115 .name = "led:kb",
116 },
117};
118
119static struct led_platform_data pm8018_led_core_pdata = {
120 .num_leds = ARRAY_SIZE(pm8018_led_info),
121 .leds = pm8018_led_info,
122};
123
124static struct pm8xxx_led_config pm8018_led_configs[] = {
125 [0] = {
126 .id = PM8XXX_ID_LED_KB_LIGHT,
127 .mode = PM8XXX_LED_MODE_PWM3,
128 .max_current = PM8018_LED_KB_MAX_CURRENT,
129 .pwm_channel = 2,
130 .pwm_period_us = PM8XXX_LED_PWM_PERIOD_US,
131 },
132};
133
134static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
135 .led_core = &pm8018_led_core_pdata,
136 .configs = pm8018_led_configs,
137 .num_configs = ARRAY_SIZE(pm8018_led_configs),
138};
139
Jay Chokshidc8028b2011-12-01 16:17:34 -0800140#ifdef CONFIG_LTC4088_CHARGER
141static struct ltc4088_charger_platform_data ltc4088_chg_pdata = {
142 .gpio_mode_select_d0 = 7,
143 .gpio_mode_select_d1 = 6,
144 .gpio_mode_select_d2 = 4,
145};
146#endif
147
David Collinsfb88c432011-08-25 15:12:47 -0700148static struct pm8018_platform_data pm8018_platform_data __devinitdata = {
149 .irq_pdata = &pm8xxx_irq_pdata,
150 .gpio_pdata = &pm8xxx_gpio_pdata,
151 .mpp_pdata = &pm8xxx_mpp_pdata,
152 .rtc_pdata = &pm8xxx_rtc_pdata,
153 .pwrkey_pdata = &pm8xxx_pwrkey_pdata,
154 .misc_pdata = &pm8xxx_misc_pdata,
David Collins00b31e62011-08-31 20:00:10 -0700155 .regulator_pdatas = msm_pm8018_regulator_pdata,
Siddartha Mohanadoss5f60b452011-10-05 11:49:00 -0700156 .adc_pdata = &pm8018_adc_pdata,
Jay Chokshieb5d0d52011-09-28 17:16:20 -0700157 .leds_pdata = &pm8xxx_leds_pdata,
David Collinsfb88c432011-08-25 15:12:47 -0700158};
159
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700160static struct msm_ssbi_platform_data msm9615_ssbi_pm8018_pdata __devinitdata = {
161 .controller_type = MSM_SBI_CTRL_PMIC_ARBITER,
162 .slave = {
David Collinsfb88c432011-08-25 15:12:47 -0700163 .name = PM8018_CORE_DEV_NAME,
164 .platform_data = &pm8018_platform_data,
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700165 },
166};
167
David Collinsbea297a2011-09-28 13:11:14 -0700168static struct platform_device msm9615_device_rpm_regulator __devinitdata = {
169 .name = "rpm-regulator",
170 .id = -1,
171 .dev = {
172 .platform_data = &msm_rpm_regulator_9615_pdata,
173 },
174};
175
David Collins0f9942a2011-10-31 09:47:34 -0700176static struct platform_device msm9615_device_ext_2p95v_vreg = {
177 .name = GPIO_REGULATOR_DEV_NAME,
178 .id = 18,
179 .dev = {
180 .platform_data =
181 &msm_gpio_regulator_pdata[GPIO_VREG_ID_EXT_2P95V],
182 },
183};
184
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600185static struct msm_cpuidle_state msm_cstates[] __initdata = {
186 {0, 0, "C0", "WFI",
187 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT},
188
189 {0, 1, "C1", "STANDALONE_POWER_COLLAPSE",
190 MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE},
191
192 {0, 2, "C2", "POWER_COLLAPSE",
193 MSM_PM_SLEEP_MODE_POWER_COLLAPSE},
194};
195static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
196 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
197 .idle_supported = 1,
198 .suspend_supported = 1,
199 .idle_enabled = 0,
200 .suspend_enabled = 0,
201 },
202 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
203 .idle_supported = 1,
204 .suspend_supported = 1,
205 .idle_enabled = 0,
206 .suspend_enabled = 0,
207 },
208 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
209 .idle_supported = 1,
210 .suspend_supported = 1,
211 .idle_enabled = 1,
212 .suspend_enabled = 1,
213 },
214};
Krishna Kondadd794462011-10-01 00:19:29 -0700215
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600216static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
217 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
218 .v_addr = MSM_APCS_GLB_BASE + 0x24,
219};
220
Gagan Mac7a827642011-09-22 19:42:21 -0600221static void __init msm9615_init_buses(void)
222{
223#ifdef CONFIG_MSM_BUS_SCALING
224 msm_bus_rpm_set_mt_mask();
225 msm_bus_9615_sys_fabric_pdata.rpm_enabled = 1;
226 msm_bus_9615_sys_fabric.dev.platform_data =
227 &msm_bus_9615_sys_fabric_pdata;
228 msm_bus_def_fab.dev.platform_data = &msm_bus_9615_def_fab_pdata;
229#endif
230}
231
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700232static struct slim_boardinfo msm_slim_devices[] = {
233 /* add slimbus slaves as needed */
234};
235
Harini Jayaraman738c9312011-09-08 15:22:38 -0600236static struct msm_spi_platform_data msm9615_qup_spi_gsbi3_pdata = {
237 .max_clock_speed = 24000000,
238};
239
Harini Jayaramaneba52672011-09-08 15:13:00 -0600240static struct msm_i2c_platform_data msm9615_i2c_qup_gsbi5_pdata = {
241 .clk_freq = 100000,
242 .src_clk_rate = 24000000,
243};
244
Amit Blay6a8d4f32011-11-21 10:36:25 +0200245#define USB_5V_EN 3
246#define PM_USB_5V_EN PM8018_GPIO_PM_TO_SYS(USB_5V_EN)
247
Mayank Rana8549e632012-01-23 12:49:54 +0530248static int msm_hsusb_vbus_power(bool on)
Amit Blay6a8d4f32011-11-21 10:36:25 +0200249{
Amit Blaya4416f92012-01-24 21:03:52 +0200250 int rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200251 struct pm_gpio usb_vbus = {
252 .direction = PM_GPIO_DIR_OUT,
253 .pull = PM_GPIO_PULL_NO,
254 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200255 .vin_sel = 2,
256 .out_strength = PM_GPIO_STRENGTH_HIGH,
257 .function = PM_GPIO_FUNC_NORMAL,
258 .inv_int_pol = 0,
259 };
260
Amit Blaya4416f92012-01-24 21:03:52 +0200261 usb_vbus.output_value = on;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200262
Amit Blaya4416f92012-01-24 21:03:52 +0200263 rc = pm8xxx_gpio_config(PM_USB_5V_EN, &usb_vbus);
264 if (rc)
265 pr_err("failed to config usb_5v_en gpio\n");
Amit Blay6a8d4f32011-11-21 10:36:25 +0200266
Mayank Rana8549e632012-01-23 12:49:54 +0530267 return rc;
Amit Blay6a8d4f32011-11-21 10:36:25 +0200268}
269
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530270static int shelby_phy_init_seq[] = {
271 0x44, 0x80,/* set VBUS valid threshold and
272 disconnect valid threshold */
273 0x38, 0x81, /* update DC voltage level */
274 0x14, 0x82,/* set preemphasis and rise/fall time */
275 0x13, 0x83,/* set source impedance adjustment */
276 -1};
277
Ofir Cohen40a4e862011-12-08 15:17:52 +0200278#define USB_BAM_PHY_BASE 0x12502000
Ofir Cohen43473c82012-01-25 16:28:13 +0200279#define HSIC_BAM_PHY_BASE 0x12542000
Ofir Cohen40a4e862011-12-08 15:17:52 +0200280#define A2_BAM_PHY_BASE 0x124C2000
281static struct usb_bam_pipe_connect msm_usb_bam_connections[4][2] = {
Ofir Cohen43473c82012-01-25 16:28:13 +0200282#ifndef CONFIG_USB_GADGET_CI13XXX_MSM_HSIC
Ofir Cohen40a4e862011-12-08 15:17:52 +0200283 [0][USB_TO_PEER_PERIPHERAL] = {
284 .src_phy_addr = USB_BAM_PHY_BASE,
285 .src_pipe_index = 11,
286 .dst_phy_addr = A2_BAM_PHY_BASE,
287 .dst_pipe_index = 0,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200288 .data_fifo_base_offset = 0x1100,
289 .data_fifo_size = 0x600,
290 .desc_fifo_base_offset = 0x1700,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200291 .desc_fifo_size = 0x300,
292 },
293 [0][PEER_PERIPHERAL_TO_USB] = {
294 .src_phy_addr = A2_BAM_PHY_BASE,
295 .src_pipe_index = 1,
296 .dst_phy_addr = USB_BAM_PHY_BASE,
297 .dst_pipe_index = 10,
298 .data_fifo_base_offset = 0xa00,
Ofir Cohen29cd5752011-12-14 17:20:30 +0200299 .data_fifo_size = 0x600,
300 .desc_fifo_base_offset = 0x1000,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200301 .desc_fifo_size = 0x100,
302 },
Anna Perel21515162012-02-02 20:50:02 +0200303 [1][USB_TO_PEER_PERIPHERAL] = {
304 .src_phy_addr = USB_BAM_PHY_BASE,
305 .src_pipe_index = 13,
306 .dst_phy_addr = A2_BAM_PHY_BASE,
307 .dst_pipe_index = 2,
308 .data_fifo_base_offset = 0x2100,
309 .data_fifo_size = 0x600,
310 .desc_fifo_base_offset = 0x2700,
311 .desc_fifo_size = 0x300,
312 },
313 [1][PEER_PERIPHERAL_TO_USB] = {
314 .src_phy_addr = A2_BAM_PHY_BASE,
315 .src_pipe_index = 3,
316 .dst_phy_addr = USB_BAM_PHY_BASE,
317 .dst_pipe_index = 12,
318 .data_fifo_base_offset = 0x1a00,
319 .data_fifo_size = 0x600,
320 .desc_fifo_base_offset = 0x2000,
321 .desc_fifo_size = 0x100,
322 },
323 [2][USB_TO_PEER_PERIPHERAL] = {
324 .src_phy_addr = USB_BAM_PHY_BASE,
325 .src_pipe_index = 15,
326 .dst_phy_addr = A2_BAM_PHY_BASE,
327 .dst_pipe_index = 4,
328 .data_fifo_base_offset = 0x3100,
329 .data_fifo_size = 0x600,
330 .desc_fifo_base_offset = 0x3700,
331 .desc_fifo_size = 0x300,
332 },
333 [2][PEER_PERIPHERAL_TO_USB] = {
334 .src_phy_addr = A2_BAM_PHY_BASE,
335 .src_pipe_index = 5,
336 .dst_phy_addr = USB_BAM_PHY_BASE,
337 .dst_pipe_index = 14,
338 .data_fifo_base_offset = 0x2a00,
339 .data_fifo_size = 0x600,
340 .desc_fifo_base_offset = 0x3000,
341 .desc_fifo_size = 0x100,
342 }
Ofir Cohen057fb3e2012-02-05 15:25:47 +0200343#else
344 [0][USB_TO_PEER_PERIPHERAL] = {
345 .src_phy_addr = HSIC_BAM_PHY_BASE,
346 .src_pipe_index = 1,
347 .dst_phy_addr = A2_BAM_PHY_BASE,
348 .dst_pipe_index = 0,
349 .data_fifo_base_offset = 0x1100,
350 .data_fifo_size = 0x600,
351 .desc_fifo_base_offset = 0x1700,
352 .desc_fifo_size = 0x300,
353 },
354 [0][PEER_PERIPHERAL_TO_USB] = {
355 .src_phy_addr = A2_BAM_PHY_BASE,
356 .src_pipe_index = 1,
357 .dst_phy_addr = HSIC_BAM_PHY_BASE,
358 .dst_pipe_index = 0,
359 .data_fifo_base_offset = 0xa00,
360 .data_fifo_size = 0x600,
361 .desc_fifo_base_offset = 0x1000,
362 .desc_fifo_size = 0x100,
363 },
364 [1][USB_TO_PEER_PERIPHERAL] = {
365 .src_phy_addr = HSIC_BAM_PHY_BASE,
366 .src_pipe_index = 3,
367 .dst_phy_addr = A2_BAM_PHY_BASE,
368 .dst_pipe_index = 2,
369 .data_fifo_base_offset = 0x2100,
370 .data_fifo_size = 0x600,
371 .desc_fifo_base_offset = 0x2700,
372 .desc_fifo_size = 0x300,
373 },
374 [1][PEER_PERIPHERAL_TO_USB] = {
375 .src_phy_addr = A2_BAM_PHY_BASE,
376 .src_pipe_index = 3,
377 .dst_phy_addr = HSIC_BAM_PHY_BASE,
378 .dst_pipe_index = 2,
379 .data_fifo_base_offset = 0x1a00,
380 .data_fifo_size = 0x600,
381 .desc_fifo_base_offset = 0x2000,
382 .desc_fifo_size = 0x100,
383 },
384 [2][USB_TO_PEER_PERIPHERAL] = {
385 .src_phy_addr = HSIC_BAM_PHY_BASE,
386 .src_pipe_index = 5,
387 .dst_phy_addr = A2_BAM_PHY_BASE,
388 .dst_pipe_index = 4,
389 .data_fifo_base_offset = 0x3100,
390 .data_fifo_size = 0x600,
391 .desc_fifo_base_offset = 0x3700,
392 .desc_fifo_size = 0x300,
393 },
394 [2][PEER_PERIPHERAL_TO_USB] = {
395 .src_phy_addr = A2_BAM_PHY_BASE,
396 .src_pipe_index = 5,
397 .dst_phy_addr = HSIC_BAM_PHY_BASE,
398 .dst_pipe_index = 4,
399 .data_fifo_base_offset = 0x2a00,
400 .data_fifo_size = 0x600,
401 .desc_fifo_base_offset = 0x3000,
402 .desc_fifo_size = 0x100,
403 }
404#endif
Ofir Cohen40a4e862011-12-08 15:17:52 +0200405};
406
407static struct msm_usb_bam_platform_data msm_usb_bam_pdata = {
408 .connections = &msm_usb_bam_connections[0][0],
Ofir Cohen43473c82012-01-25 16:28:13 +0200409#ifndef CONFIG_USB_GADGET_CI13XXX_MSM_HSIC
410 .usb_active_bam = HSUSB_BAM,
411 .usb_bam_num_pipes = 16,
412#else
413 .usb_active_bam = HSIC_BAM,
414 .usb_bam_num_pipes = 16,
415#endif
Ofir Cohen40a4e862011-12-08 15:17:52 +0200416};
417
Amit Blay5e4ec192011-10-20 09:16:54 +0200418static struct msm_otg_platform_data msm_otg_pdata = {
Amit Blay6a8d4f32011-11-21 10:36:25 +0200419 .mode = USB_OTG,
420 .otg_control = OTG_PHY_CONTROL,
Amit Blay5e4ec192011-10-20 09:16:54 +0200421 .phy_type = SNPS_28NM_INTEGRATED_PHY,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200422 .vbus_power = msm_hsusb_vbus_power,
Ofir Cohen4da266f2012-01-03 10:19:29 +0200423 .disable_reset_on_disconnect = true,
Amit Blay5e4ec192011-10-20 09:16:54 +0200424};
425
Amit Blay5f968cf2012-01-22 12:04:01 +0200426#define PID_MAGIC_ID 0x71432909
427#define SERIAL_NUM_MAGIC_ID 0x61945374
428#define SERIAL_NUMBER_LENGTH 127
429#define DLOAD_USB_BASE_ADD 0x2B0000C8
430
431struct magic_num_struct {
432 uint32_t pid;
433 uint32_t serial_num;
434};
435
436struct dload_struct {
437 uint32_t reserved1;
438 uint32_t reserved2;
439 uint32_t reserved3;
440 uint16_t reserved4;
441 uint16_t pid;
442 char serial_number[SERIAL_NUMBER_LENGTH];
443 uint16_t reserved5;
444 struct magic_num_struct magic_struct;
445};
446
Amit Blay5e4ec192011-10-20 09:16:54 +0200447static int usb_diag_update_pid_and_serial_num(uint32_t pid, const char *snum)
448{
Amit Blay5f968cf2012-01-22 12:04:01 +0200449 struct dload_struct __iomem *dload = 0;
450
451 dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
452 if (!dload) {
453 pr_err("%s: cannot remap I/O memory region: %08x\n",
454 __func__, DLOAD_USB_BASE_ADD);
455 return -ENXIO;
456 }
457
458 pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
459 __func__, dload, pid, snum);
460 /* update pid */
461 dload->magic_struct.pid = PID_MAGIC_ID;
462 dload->pid = pid;
463
464 /* update serial number */
465 dload->magic_struct.serial_num = 0;
466 if (!snum) {
467 memset(dload->serial_number, 0, SERIAL_NUMBER_LENGTH);
468 goto out;
469 }
470
471 dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
472 strlcpy(dload->serial_number, snum, SERIAL_NUMBER_LENGTH);
473out:
474 iounmap(dload);
Amit Blay5e4ec192011-10-20 09:16:54 +0200475 return 0;
476}
477
478static struct android_usb_platform_data android_usb_pdata = {
479 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
480};
481
482static struct platform_device android_usb_device = {
483 .name = "android_usb",
484 .id = -1,
485 .dev = {
486 .platform_data = &android_usb_pdata,
487 },
488};
489
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800490static struct platform_device msm_wlan_ar6000_pm_device = {
491 .name = "wlan_ar6000_pm_dev",
492 .id = -1,
493};
494
495static int __init msm9615_init_ar6000pm(void)
496{
497 return platform_device_register(&msm_wlan_ar6000_pm_device);
498}
499
Jay Chokshidc8028b2011-12-01 16:17:34 -0800500#ifdef CONFIG_LTC4088_CHARGER
501static struct platform_device msm_device_charger = {
502 .name = LTC4088_CHARGER_DEV_NAME,
503 .id = -1,
504 .dev = {
505 .platform_data = &ltc4088_chg_pdata,
506 },
507};
508#endif
509
Amit Blay5e4ec192011-10-20 09:16:54 +0200510static struct platform_device *common_devices[] = {
511 &msm9615_device_dmov,
512 &msm_device_smd,
Jay Chokshidc8028b2011-12-01 16:17:34 -0800513#ifdef CONFIG_LTC4088_CHARGER
514 &msm_device_charger,
515#endif
Amit Blay5e4ec192011-10-20 09:16:54 +0200516 &msm_device_otg,
Ofir Cohen73c99e82012-01-15 13:38:14 +0200517 &msm_device_hsic_peripheral,
Amit Blay5e4ec192011-10-20 09:16:54 +0200518 &msm_device_gadget_peripheral,
Amit Blay6a8d4f32011-11-21 10:36:25 +0200519 &msm_device_hsusb_host,
Ofir Cohen40a4e862011-12-08 15:17:52 +0200520 &msm_device_usb_bam,
Amit Blay5e4ec192011-10-20 09:16:54 +0200521 &android_usb_device,
522 &msm9615_device_uart_gsbi4,
David Collins0f9942a2011-10-31 09:47:34 -0700523 &msm9615_device_ext_2p95v_vreg,
Amit Blay5e4ec192011-10-20 09:16:54 +0200524 &msm9615_device_ssbi_pmic1,
525 &msm9615_device_qup_i2c_gsbi5,
526 &msm9615_device_qup_spi_gsbi3,
527 &msm_device_sps,
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700528 &msm9615_slim_ctrl,
Amit Blay5e4ec192011-10-20 09:16:54 +0200529 &msm9615_device_tsens,
530 &msm_device_nand,
Eric Holmberg0c96e702011-11-08 18:04:31 -0700531 &msm_device_bam_dmux,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600532 &msm9615_rpm_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200533#ifdef CONFIG_HW_RANDOM_MSM
534 &msm_device_rng,
535#endif
536
537#if defined(CONFIG_CRYPTO_DEV_QCRYPTO) || \
538 defined(CONFIG_CRYPTO_DEV_QCRYPTO_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700539 &msm9615_qcrypto_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200540#endif
541
542#if defined(CONFIG_CRYPTO_DEV_QCEDEV) || \
543 defined(CONFIG_CRYPTO_DEV_QCEDEV_MODULE)
Ramesh Masavarapuaa28b5b2011-10-21 10:26:03 -0700544 &msm9615_qcedev_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200545#endif
Jeff Ohlstein7e668552011-10-06 16:17:25 -0700546 &msm9615_device_watchdog,
Gagan Mac7a827642011-09-22 19:42:21 -0600547 &msm_bus_9615_sys_fabric,
548 &msm_bus_def_fab,
Praveen Chidambaram78499012011-11-01 17:15:17 -0600549 &msm9615_rpm_log_device,
550 &msm9615_rpm_stat_device,
Amit Blay5e4ec192011-10-20 09:16:54 +0200551};
552
Harini Jayaramaneba52672011-09-08 15:13:00 -0600553static void __init msm9615_i2c_init(void)
554{
555 msm9615_device_qup_i2c_gsbi5.dev.platform_data =
556 &msm9615_i2c_qup_gsbi5_pdata;
557}
558
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600559static void __init msm9615_reserve(void)
560{
561 msm_pm_boot_pdata.p_addr = memblock_alloc(SZ_8, SZ_64K);
562}
563
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700564static void __init msm9615_common_init(void)
565{
566 msm9615_device_init();
Rohit Vaswania6815892011-12-15 20:20:39 -0800567 msm9615_init_gpiomux();
Harini Jayaramaneba52672011-09-08 15:13:00 -0600568 msm9615_i2c_init();
David Collins00b31e62011-08-31 20:00:10 -0700569 regulator_suppress_info_printing();
David Collinsbea297a2011-09-28 13:11:14 -0700570 platform_device_register(&msm9615_device_rpm_regulator);
Gagan Mac7a827642011-09-22 19:42:21 -0600571 msm_clock_init(&msm9615_clock_init_data);
572 msm9615_init_buses();
Harini Jayaraman738c9312011-09-08 15:22:38 -0600573 msm9615_device_qup_spi_gsbi3.dev.platform_data =
574 &msm9615_qup_spi_gsbi3_pdata;
Kenneth Heitkeaf3d3cf2011-09-08 11:45:31 -0700575 msm9615_device_ssbi_pmic1.dev.platform_data =
576 &msm9615_ssbi_pm8018_pdata;
David Collins00b31e62011-08-31 20:00:10 -0700577 pm8018_platform_data.num_regulators = msm_pm8018_regulator_pdata_len;
Amit Blay5e4ec192011-10-20 09:16:54 +0200578
579 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Anji jonnalaa8b8d732011-12-06 10:03:24 +0530580 msm_otg_pdata.phy_init_seq = shelby_phy_init_seq;
Ofir Cohen40a4e862011-12-08 15:17:52 +0200581 msm_device_usb_bam.dev.platform_data = &msm_usb_bam_pdata;
Rohit Vaswani09666872011-08-23 17:41:54 -0700582 platform_add_devices(common_devices, ARRAY_SIZE(common_devices));
Krishna Kondadd794462011-10-01 00:19:29 -0700583
Vikram Mulukutlab5e1cda2011-10-04 16:17:22 -0700584 acpuclk_init(&acpuclk_9615_soc_data);
585
Rohit Vaswani149f0a72011-11-09 15:21:28 -0800586 /* Ensure ar6000pm device is registered before MMC/SDC */
587 msm9615_init_ar6000pm();
588
Krishna Kondadd794462011-10-01 00:19:29 -0700589 msm9615_init_mmc();
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700590 slim_register_board_info(msm_slim_devices,
591 ARRAY_SIZE(msm_slim_devices));
Maheshkumar Sivasubramanian4923db22011-09-15 09:28:15 -0600592 msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
593 msm_pm_set_rpm_wakeup_irq(RPM_APCC_CPU0_WAKE_UP_IRQ);
594 msm_cpuidle_set_states(msm_cstates, ARRAY_SIZE(msm_cstates),
595 msm_pm_data);
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600596 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700597}
598
599static void __init msm9615_cdp_init(void)
600{
601 msm9615_common_init();
602}
603
604static void __init msm9615_mtp_init(void)
605{
606 msm9615_common_init();
607}
608
609MACHINE_START(MSM9615_CDP, "QCT MSM9615 CDP")
610 .map_io = msm9615_map_io,
611 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530612 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700613 .timer = &msm_timer,
614 .init_machine = msm9615_cdp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600615 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700616MACHINE_END
617
618MACHINE_START(MSM9615_MTP, "QCT MSM9615 MTP")
619 .map_io = msm9615_map_io,
620 .init_irq = msm9615_init_irq,
Marc Zyngier89bdafd12011-12-22 11:39:20 +0530621 .handle_irq = gic_handle_irq,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700622 .timer = &msm_timer,
623 .init_machine = msm9615_mtp_init,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600624 .reserve = msm9615_reserve,
Rohit Vaswaniced9b3b2011-08-23 17:21:49 -0700625MACHINE_END