blob: 44138a5e819c4edfaf207222a677b8c24aeb9faa [file] [log] [blame]
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +05301/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -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#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/gpio_event.h>
Taniya Das2b16d1d2011-12-02 14:44:19 +053015#include <linux/memblock.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070016#include <asm/mach-types.h>
Murali Nalajala41786ab2012-03-06 10:47:32 +053017#include <linux/memblock.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070018#include <asm/mach/arch.h>
Taniya Das43bcdd62011-12-02 17:33:27 +053019#include <asm/hardware/gic.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020#include <mach/board.h>
21#include <mach/msm_iomap.h>
22#include <mach/msm_hsusb.h>
23#include <mach/rpc_hsusb.h>
24#include <mach/rpc_pmapp.h>
25#include <mach/usbdiag.h>
26#include <mach/msm_memtypes.h>
27#include <mach/msm_serial_hs.h>
28#include <linux/usb/android.h>
29#include <linux/platform_device.h>
30#include <linux/io.h>
31#include <linux/gpio.h>
32#include <mach/vreg.h>
33#include <mach/pmic.h>
34#include <mach/socinfo.h>
35#include <linux/mtd/nand.h>
36#include <linux/mtd/partitions.h>
37#include <asm/mach/mmc.h>
38#include <linux/i2c.h>
39#include <linux/i2c/sx150x.h>
40#include <linux/gpio.h>
41#include <linux/android_pmem.h>
42#include <linux/bootmem.h>
43#include <linux/mfd/marimba.h>
44#include <mach/vreg.h>
45#include <linux/power_supply.h>
Justin Paupored98328e2011-08-19 13:48:31 -070046#include <linux/regulator/consumer.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070047#include <mach/rpc_pmapp.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070048#include <mach/msm_battery.h>
49#include <linux/smsc911x.h>
50#include <linux/atmel_maxtouch.h>
Laura Abbott8f3d58b2011-12-18 10:47:03 -080051#include <linux/fmem.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052#include "devices.h"
53#include "timer.h"
Justin Pauporeb3a33b72011-08-23 15:30:32 -070054#include "board-msm7x27a-regulator.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055#include "devices-msm7x2xa.h"
Matt Wagantall7cca4642012-02-01 16:43:24 -080056#include "pm.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057#include <mach/rpc_server_handset.h>
58#include <mach/socinfo.h>
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060059#include "pm-boot.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053060#include "board-msm7627a.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062#if defined(CONFIG_GPIO_SX150X)
63enum {
64 SX150X_CORE,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070065};
66
67static struct sx150x_platform_data sx150x_data[] __initdata = {
68 [SX150X_CORE] = {
69 .gpio_base = GPIO_CORE_EXPANDER_BASE,
70 .oscio_is_gpo = false,
71 .io_pullup_ena = 0,
pankaj kumarc5c01392011-08-12 13:44:05 +053072 .io_pulldn_ena = 0x02,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073 .io_open_drain_ena = 0xfef8,
74 .irq_summary = -1,
75 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076};
77#endif
78
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070079
Santosh Sajjan6822c682011-07-26 10:49:36 +053080static struct platform_device msm_wlan_ar6000_pm_device = {
81 .name = "wlan_ar6000_pm_dev",
82 .id = -1,
83};
84
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070085#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
86static struct i2c_board_info core_exp_i2c_info[] __initdata = {
87 {
88 I2C_BOARD_INFO("sx1509q", 0x3e),
89 },
90};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092static void __init register_i2c_devices(void)
93{
Taniya Dase3027e22012-02-27 16:32:27 +053094 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
95 machine_is_msm8625_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070096 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
97
98 core_exp_i2c_info[0].platform_data =
99 &sx150x_data[SX150X_CORE];
100
101 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
102 core_exp_i2c_info,
103 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700104}
105#endif
106
107static struct msm_gpio qup_i2c_gpios_io[] = {
108 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
109 "qup_scl" },
110 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
111 "qup_sda" },
112 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
113 "qup_scl" },
114 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
115 "qup_sda" },
116};
117
118static struct msm_gpio qup_i2c_gpios_hw[] = {
119 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
120 "qup_scl" },
121 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
122 "qup_sda" },
123 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
124 "qup_scl" },
125 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
126 "qup_sda" },
127};
128
129static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
130{
131 int rc;
132
133 if (adap_id < 0 || adap_id > 1)
134 return;
135
136 /* Each adapter gets 2 lines from the table */
137 if (config_type)
138 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
139 else
140 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
141 if (rc < 0)
142 pr_err("QUP GPIO request/enable failed: %d\n", rc);
143}
144
145static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
146 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700147 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
148};
149
150static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
151 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700152 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
153};
154
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700155static struct android_usb_platform_data android_usb_pdata = {
156 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
157};
158
159static struct platform_device android_usb_device = {
160 .name = "android_usb",
161 .id = -1,
162 .dev = {
163 .platform_data = &android_usb_pdata,
164 },
165};
166
167#ifdef CONFIG_USB_EHCI_MSM_72K
168static void msm_hsusb_vbus_power(unsigned phy_info, int on)
169{
170 int rc = 0;
171 unsigned gpio;
172
173 gpio = GPIO_HOST_VBUS_EN;
174
175 rc = gpio_request(gpio, "i2c_host_vbus_en");
176 if (rc < 0) {
177 pr_err("failed to request %d GPIO\n", gpio);
178 return;
179 }
180 gpio_direction_output(gpio, !!on);
181 gpio_set_value_cansleep(gpio, !!on);
182 gpio_free(gpio);
183}
184
185static struct msm_usb_host_platform_data msm_usb_host_pdata = {
186 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
187};
188
189static void __init msm7x2x_init_host(void)
190{
191 msm_add_host(0, &msm_usb_host_pdata);
192}
193#endif
194
195#ifdef CONFIG_USB_MSM_OTG_72K
196static int hsusb_rpc_connect(int connect)
197{
198 if (connect)
199 return msm_hsusb_rpc_connect();
200 else
201 return msm_hsusb_rpc_close();
202}
203
Justin Paupored98328e2011-08-19 13:48:31 -0700204static struct regulator *reg_hsusb;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700205static int msm_hsusb_ldo_init(int init)
206{
Justin Paupored98328e2011-08-19 13:48:31 -0700207 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700208
Justin Paupored98328e2011-08-19 13:48:31 -0700209 if (init) {
210 reg_hsusb = regulator_get(NULL, "usb");
211 if (IS_ERR(reg_hsusb)) {
212 rc = PTR_ERR(reg_hsusb);
213 pr_err("%s: could not get regulator: %d\n",
214 __func__, rc);
215 goto out;
216 }
217
218 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
219 if (rc) {
220 pr_err("%s: could not set voltage: %d\n",
221 __func__, rc);
222 goto reg_free;
223 }
224
225 return 0;
226 }
227 /* else fall through */
228reg_free:
229 regulator_put(reg_hsusb);
230out:
231 reg_hsusb = NULL;
232 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700233}
234
235static int msm_hsusb_ldo_enable(int enable)
236{
237 static int ldo_status;
238
Justin Paupored98328e2011-08-19 13:48:31 -0700239 if (IS_ERR_OR_NULL(reg_hsusb))
240 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700241
242 if (ldo_status == enable)
243 return 0;
244
245 ldo_status = enable;
246
Justin Paupored98328e2011-08-19 13:48:31 -0700247 return enable ?
248 regulator_enable(reg_hsusb) :
249 regulator_disable(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700250}
251
252#ifndef CONFIG_USB_EHCI_MSM_72K
253static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
254{
255 int ret = 0;
256
257 if (init)
258 ret = msm_pm_app_rpc_init(callback);
259 else
260 msm_pm_app_rpc_deinit(callback);
261
262 return ret;
263}
264#endif
265
266static struct msm_otg_platform_data msm_otg_pdata = {
267#ifndef CONFIG_USB_EHCI_MSM_72K
268 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
269#else
270 .vbus_power = msm_hsusb_vbus_power,
271#endif
272 .rpc_connect = hsusb_rpc_connect,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700273 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
274 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
275 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
276 .se1_gating = SE1_GATING_DISABLE,
277 .ldo_init = msm_hsusb_ldo_init,
278 .ldo_enable = msm_hsusb_ldo_enable,
279 .chg_init = hsusb_chg_init,
280 .chg_connected = hsusb_chg_connected,
281 .chg_vbus_draw = hsusb_chg_vbus_draw,
282};
283#endif
284
285static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
286 .is_phy_status_timer_on = 1,
287};
288
289static struct resource smc91x_resources[] = {
290 [0] = {
291 .start = 0x90000300,
292 .end = 0x900003ff,
293 .flags = IORESOURCE_MEM,
294 },
295 [1] = {
296 .start = MSM_GPIO_TO_INT(4),
297 .end = MSM_GPIO_TO_INT(4),
298 .flags = IORESOURCE_IRQ,
299 },
300};
301
302static struct platform_device smc91x_device = {
303 .name = "smc91x",
304 .id = 0,
305 .num_resources = ARRAY_SIZE(smc91x_resources),
306 .resource = smc91x_resources,
307};
308
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700309#ifdef CONFIG_SERIAL_MSM_HS
310static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
311 .inject_rx_on_wakeup = 1,
312 .rx_to_inject = 0xFD,
313};
314#endif
315static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
Murali Nalajalab10363d2012-01-12 16:29:01 +0530316 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700317 .idle_supported = 1,
318 .suspend_supported = 1,
319 .idle_enabled = 1,
320 .suspend_enabled = 1,
321 .latency = 16000,
322 .residency = 20000,
323 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530324 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700325 .idle_supported = 1,
326 .suspend_supported = 1,
327 .idle_enabled = 1,
328 .suspend_enabled = 1,
329 .latency = 12000,
330 .residency = 20000,
331 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530332 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700333 .idle_supported = 1,
334 .suspend_supported = 1,
335 .idle_enabled = 0,
336 .suspend_enabled = 1,
337 .latency = 2000,
338 .residency = 0,
339 },
Murali Nalajalab10363d2012-01-12 16:29:01 +0530340 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700341 .idle_supported = 1,
342 .suspend_supported = 1,
343 .idle_enabled = 1,
344 .suspend_enabled = 1,
345 .latency = 2,
346 .residency = 0,
347 },
348};
349
Sujit Reddy Thummaca0c1062012-02-24 14:47:05 +0530350u32 msm7627a_power_collapse_latency(enum msm_pm_sleep_mode mode)
351{
352 switch (mode) {
353 case MSM_PM_SLEEP_MODE_POWER_COLLAPSE:
354 return msm7x27a_pm_data
355 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency;
356 case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN:
357 return msm7x27a_pm_data
358 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency;
359 case MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT:
360 return msm7x27a_pm_data
361 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
362 case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT:
363 return msm7x27a_pm_data
364 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency;
365 default:
366 return 0;
367 }
368}
369
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600370static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530371 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
372 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600373};
374
Murali Nalajalad1f67b02012-02-10 00:23:49 +0530375/* 8625 PM platform data */
376static struct msm_pm_platform_data msm8625_pm_data[MSM_PM_SLEEP_MODE_NR * 2] = {
377 /* CORE0 entries */
378 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE)] = {
379 .idle_supported = 1,
380 .suspend_supported = 1,
381 .idle_enabled = 0,
382 .suspend_enabled = 0,
383 .latency = 16000,
384 .residency = 20000,
385 },
386
387 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN)] = {
388 .idle_supported = 1,
389 .suspend_supported = 1,
390 .idle_enabled = 0,
391 .suspend_enabled = 0,
392 .latency = 12000,
393 .residency = 20000,
394 },
395
396 /* picked latency & redisdency values from 7x30 */
397 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
398 .idle_supported = 1,
399 .suspend_supported = 1,
400 .idle_enabled = 0,
401 .suspend_enabled = 0,
402 .latency = 500,
403 .residency = 6000,
404 },
405
406 [MSM_PM_MODE(0, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
407 .idle_supported = 1,
408 .suspend_supported = 1,
409 .idle_enabled = 1,
410 .suspend_enabled = 1,
411 .latency = 2,
412 .residency = 10,
413 },
414
415 /* picked latency & redisdency values from 7x30 */
416 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE)] = {
417 .idle_supported = 1,
418 .suspend_supported = 1,
419 .idle_enabled = 0,
420 .suspend_enabled = 0,
421 .latency = 500,
422 .residency = 6000,
423 },
424
425 [MSM_PM_MODE(1, MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT)] = {
426 .idle_supported = 1,
427 .suspend_supported = 1,
428 .idle_enabled = 1,
429 .suspend_enabled = 1,
430 .latency = 2,
431 .residency = 10,
432 },
433
434};
435
Murali Nalajala41786ab2012-03-06 10:47:32 +0530436static struct msm_pm_boot_platform_data msm_pm_8625_boot_pdata __initdata = {
437 .mode = MSM_PM_BOOT_CONFIG_REMAP_BOOT_ADDR,
438 .v_addr = MSM_CFG_CTL_BASE,
439};
440
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700441static u32 msm_calculate_batt_capacity(u32 current_voltage);
442
443static struct msm_psy_batt_pdata msm_psy_batt_data = {
444 .voltage_min_design = 2800,
445 .voltage_max_design = 4300,
446 .avail_chg_sources = AC_CHG | USB_CHG ,
447 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
448 .calculate_capacity = &msm_calculate_batt_capacity,
449};
450
451static u32 msm_calculate_batt_capacity(u32 current_voltage)
452{
453 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
454 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
455
456 return (current_voltage - low_voltage) * 100
457 / (high_voltage - low_voltage);
458}
459
460static struct platform_device msm_batt_device = {
461 .name = "msm-battery",
462 .id = -1,
463 .dev.platform_data = &msm_psy_batt_data,
464};
465
466static struct smsc911x_platform_config smsc911x_config = {
467 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
468 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
469 .flags = SMSC911X_USE_16BIT,
470};
471
472static struct resource smsc911x_resources[] = {
473 [0] = {
474 .start = 0x90000000,
475 .end = 0x90007fff,
476 .flags = IORESOURCE_MEM,
477 },
478 [1] = {
479 .start = MSM_GPIO_TO_INT(48),
480 .end = MSM_GPIO_TO_INT(48),
481 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
482 },
483};
484
485static struct platform_device smsc911x_device = {
486 .name = "smsc911x",
487 .id = 0,
488 .num_resources = ARRAY_SIZE(smsc911x_resources),
489 .resource = smsc911x_resources,
490 .dev = {
491 .platform_data = &smsc911x_config,
492 },
493};
494
495static struct msm_gpio smsc911x_gpios[] = {
496 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
497 "smsc911x_irq" },
498 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
499 "eth_fifo_sel" },
500};
501
502#define ETH_FIFO_SEL_GPIO 49
503static void msm7x27a_cfg_smsc911x(void)
504{
505 int res;
506
507 res = msm_gpios_request_enable(smsc911x_gpios,
508 ARRAY_SIZE(smsc911x_gpios));
509 if (res) {
510 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
511 return;
512 }
513
514 /* ETH_FIFO_SEL */
515 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
516 if (res) {
517 pr_err("%s: unable to get direction for gpio %d\n", __func__,
518 ETH_FIFO_SEL_GPIO);
519 msm_gpios_disable_free(smsc911x_gpios,
520 ARRAY_SIZE(smsc911x_gpios));
521 return;
522 }
523 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
524}
525
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700526#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
527 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
528static struct msm_gpio uart2dm_gpios[] = {
529 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
530 "uart2dm_rfr_n" },
531 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
532 "uart2dm_cts_n" },
533 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
534 "uart2dm_rx" },
535 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
536 "uart2dm_tx" },
537};
538
539static void msm7x27a_cfg_uart2dm_serial(void)
540{
541 int ret;
542 ret = msm_gpios_request_enable(uart2dm_gpios,
543 ARRAY_SIZE(uart2dm_gpios));
544 if (ret)
545 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
546}
547#else
548static void msm7x27a_cfg_uart2dm_serial(void) { }
549#endif
550
Laura Abbott8f3d58b2011-12-18 10:47:03 -0800551struct fmem_platform_data fmem_pdata;
552
553struct platform_device fmem_device = {
554 .name = "fmem",
555 .id = -1,
556 .dev = { .platform_data = &fmem_pdata },
557};
558
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700559static struct platform_device *rumi_sim_devices[] __initdata = {
560 &msm_device_dmov,
561 &msm_device_smd,
562 &smc91x_device,
563 &msm_device_uart1,
564 &msm_device_nand,
565 &msm_device_uart_dm1,
566 &msm_gsbi0_qup_i2c_device,
567 &msm_gsbi1_qup_i2c_device,
568};
569
Taniya Das43bcdd62011-12-02 17:33:27 +0530570static struct platform_device *msm8625_rumi3_devices[] __initdata = {
571 &msm8625_device_dmov,
Angshuman Sarkarfb1cce92012-02-21 15:20:43 +0530572 &msm8625_device_smd,
Taniya Das43bcdd62011-12-02 17:33:27 +0530573 &msm8625_device_uart1,
Taniya Dase3027e22012-02-27 16:32:27 +0530574 &msm8625_gsbi0_qup_i2c_device,
Taniya Das43bcdd62011-12-02 17:33:27 +0530575};
576
Taniya Dase3027e22012-02-27 16:32:27 +0530577static struct platform_device *msm7627a_surf_ffa_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700578 &msm_device_dmov,
579 &msm_device_smd,
580 &msm_device_uart1,
581 &msm_device_uart_dm1,
582 &msm_device_uart_dm2,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700583 &msm_gsbi0_qup_i2c_device,
584 &msm_gsbi1_qup_i2c_device,
585 &msm_device_otg,
586 &msm_device_gadget_peripheral,
Taniya Dase3027e22012-02-27 16:32:27 +0530587 &smsc911x_device,
588 &msm_kgsl_3d0,
589};
590
591static struct platform_device *common_devices[] __initdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700592 &android_usb_device,
Taniya Dase3027e22012-02-27 16:32:27 +0530593 &fmem_device,
594 &msm_device_nand,
Manish Dewangan3a260992011-06-24 18:01:34 +0530595 &asoc_msm_pcm,
596 &asoc_msm_dai0,
597 &asoc_msm_dai1,
Taniya Dase3027e22012-02-27 16:32:27 +0530598 &msm_batt_device,
599};
600
601static struct platform_device *msm8625_surf_devices[] __initdata = {
602 &msm8625_device_dmov,
603 &msm8625_device_uart1,
604 &msm8625_device_uart_dm1,
605 &msm8625_device_uart_dm2,
606 &msm8625_gsbi0_qup_i2c_device,
607 &msm8625_gsbi1_qup_i2c_device,
Taniya Dasf2665302012-02-28 16:54:54 +0530608 &msm8625_device_smd,
Taniya Dase3027e22012-02-27 16:32:27 +0530609 &msm8625_device_otg,
610 &msm8625_device_gadget_peripheral,
Ranjhith Kalisamy4ec2e102012-03-06 12:27:50 +0530611 &msm8625_kgsl_3d0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700612};
613
Taniya Das2b16d1d2011-12-02 14:44:19 +0530614static void __init msm8625_reserve(void)
615{
Chintan Pandya12ec56a2012-03-13 15:47:12 +0530616 msm7627a_reserve();
Taniya Dasfe04d4f2012-03-14 11:13:21 +0530617 memblock_remove(MSM8625_SECONDARY_PHYS, SZ_8);
Murali Nalajalafeedeae2012-03-28 16:15:32 +0530618 memblock_remove(MSM8625_WARM_BOOT_PHYS, SZ_32);
Taniya Das2b16d1d2011-12-02 14:44:19 +0530619}
620
Taniya Dase3027e22012-02-27 16:32:27 +0530621static void __init msm7x27a_device_i2c_init(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700622{
623 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
624 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
625}
626
Taniya Dase3027e22012-02-27 16:32:27 +0530627static void __init msm8625_device_i2c_init(void)
628{
629 msm8625_gsbi0_qup_i2c_device.dev.platform_data =
630 &msm_gsbi0_qup_i2c_pdata;
631 msm8625_gsbi1_qup_i2c_device.dev.platform_data =
632 &msm_gsbi1_qup_i2c_pdata;
633}
634
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700635#define MSM_EBI2_PHYS 0xa0d00000
636#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
637
638static void __init msm7x27a_init_ebi2(void)
639{
640 uint32_t ebi2_cfg;
641 void __iomem *ebi2_cfg_ptr;
642
643 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
644 if (!ebi2_cfg_ptr)
645 return;
646
647 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530648 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
Taniya Dase3027e22012-02-27 16:32:27 +0530649 machine_is_msm7625a_surf() || machine_is_msm8625_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700650 ebi2_cfg |= (1 << 4); /* CS2 */
651
652 writel(ebi2_cfg, ebi2_cfg_ptr);
653 iounmap(ebi2_cfg_ptr);
654
655 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
656 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
657 sizeof(uint32_t));
658 if (!ebi2_cfg_ptr)
659 return;
660
661 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530662 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700663 ebi2_cfg |= (1 << 31);
664
665 writel(ebi2_cfg, ebi2_cfg_ptr);
666 iounmap(ebi2_cfg_ptr);
667}
668
Justin Pauporeb3a33b72011-08-23 15:30:32 -0700669static struct platform_device msm_proccomm_regulator_dev = {
670 .name = PROCCOMM_REGULATOR_DEV_NAME,
671 .id = -1,
672 .dev = {
673 .platform_data = &msm7x27a_proccomm_regulator_data
674 }
675};
676
Trilok Soni16f61af2011-07-26 16:06:58 +0530677static void __init msm7627a_rumi3_init(void)
678{
679 msm7x27a_init_ebi2();
680 platform_add_devices(rumi_sim_devices,
681 ARRAY_SIZE(rumi_sim_devices));
682}
683
Taniya Das43bcdd62011-12-02 17:33:27 +0530684static void __init msm8625_rumi3_init(void)
685{
686 msm7x2x_misc_init();
Taniya Dase3027e22012-02-27 16:32:27 +0530687 msm_adsp_add_pdev();
688 msm8625_device_i2c_init();
Taniya Das43bcdd62011-12-02 17:33:27 +0530689 platform_add_devices(msm8625_rumi3_devices,
690 ARRAY_SIZE(msm8625_rumi3_devices));
Murali Nalajala41786ab2012-03-06 10:47:32 +0530691
Murali Nalajalad1f67b02012-02-10 00:23:49 +0530692 msm_pm_set_platform_data(msm8625_pm_data,
693 ARRAY_SIZE(msm8625_pm_data));
Murali Nalajala41786ab2012-03-06 10:47:32 +0530694 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
695 msm8x25_spm_device_init();
Taniya Das43bcdd62011-12-02 17:33:27 +0530696}
697
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700698#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +0530699
700#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
701static int __init msm7x27a_init_ar6000pm(void)
702{
Santosh Sajjan374d6592012-01-19 23:16:46 +0530703 msm_wlan_ar6000_pm_device.dev.platform_data = &ar600x_wlan_power;
Santosh Sajjanb479f0f2011-08-18 21:00:44 +0530704 return platform_device_register(&msm_wlan_ar6000_pm_device);
705}
706#else
707static int __init msm7x27a_init_ar6000pm(void) { return 0; }
708#endif
709
Justin Pauporeb3a33b72011-08-23 15:30:32 -0700710static void __init msm7x27a_init_regulators(void)
711{
712 int rc = platform_device_register(&msm_proccomm_regulator_dev);
713 if (rc)
714 pr_err("%s: could not register regulator device: %d\n",
715 __func__, rc);
716}
717
Taniya Dase3027e22012-02-27 16:32:27 +0530718static void __init msm7x27a_add_footswitch_devices(void)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700719{
Trilok Soni16f61af2011-07-26 16:06:58 +0530720 platform_add_devices(msm_footswitch_devices,
721 msm_num_footswitch_devices);
Taniya Dase3027e22012-02-27 16:32:27 +0530722}
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700723
Taniya Dase3027e22012-02-27 16:32:27 +0530724static void __init msm7x27a_add_platform_devices(void)
725{
726 if (machine_is_msm8625_surf()) {
727 platform_add_devices(msm8625_surf_devices,
728 ARRAY_SIZE(msm8625_surf_devices));
729 } else {
730 platform_add_devices(msm7627a_surf_ffa_devices,
731 ARRAY_SIZE(msm7627a_surf_ffa_devices));
732 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700733
Taniya Dase3027e22012-02-27 16:32:27 +0530734 platform_add_devices(common_devices,
735 ARRAY_SIZE(common_devices));
736}
737
738static void __init msm7x27a_uartdm_config(void)
739{
740 msm7x27a_cfg_uart2dm_serial();
741 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
742 if (cpu_is_msm8625())
743 msm8625_device_uart_dm1.dev.platform_data =
744 &msm_uart_dm1_pdata;
745 else
746 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
747}
748
749static void __init msm7x27a_otg_gadget(void)
750{
751 msm_otg_pdata.swfi_latency =
752 msm7x27a_pm_data[
753 MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
754 if (cpu_is_msm8625()) {
755 msm8625_device_otg.dev.platform_data = &msm_otg_pdata;
756 msm8625_device_gadget_peripheral.dev.platform_data =
757 &msm_gadget_pdata;
758 } else {
759 msm_device_otg.dev.platform_data = &msm_otg_pdata;
760 msm_device_gadget_peripheral.dev.platform_data =
761 &msm_gadget_pdata;
762 }
763}
764
Taniya Dase3027e22012-02-27 16:32:27 +0530765static void __init msm7x27a_pm_init(void)
766{
Murali Nalajala8ee084e2012-03-07 00:09:38 +0530767 if (machine_is_msm8625_surf()) {
768 msm_pm_set_platform_data(msm8625_pm_data,
769 ARRAY_SIZE(msm8625_pm_data));
770 BUG_ON(msm_pm_boot_init(&msm_pm_8625_boot_pdata));
771 msm8x25_spm_device_init();
772 } else {
773 msm_pm_set_platform_data(msm7x27a_pm_data,
774 ARRAY_SIZE(msm7x27a_pm_data));
775 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
776 }
Murali Nalajala2a0bbda2012-03-28 12:12:54 +0530777
778 msm_pm_register_irqs();
Taniya Dase3027e22012-02-27 16:32:27 +0530779}
780
781static void __init msm7x2x_init(void)
782{
783 msm7x2x_misc_init();
784
785 /* Initialize regulators first so that other devices can use them */
786 msm7x27a_init_regulators();
787 msm_adsp_add_pdev();
788 if (cpu_is_msm8625())
789 msm8625_device_i2c_init();
790 else
791 msm7x27a_device_i2c_init();
792 msm7x27a_init_ebi2();
793 msm7x27a_uartdm_config();
794
795 msm7x27a_otg_gadget();
796 msm7x27a_cfg_smsc911x();
797
798 msm7x27a_add_footswitch_devices();
799 msm7x27a_add_platform_devices();
800 /* Ensure ar6000pm device is registered before MMC/SDC */
801 msm7x27a_init_ar6000pm();
802 msm7627a_init_mmc();
803 msm_fb_add_devices();
804 msm7x2x_init_host();
805 msm7x27a_pm_init();
806 register_i2c_devices();
807 msm7627a_bt_power_init();
808 msm7627a_camera_init();
Chintan Pandya0d453192012-03-09 13:20:33 +0530809 msm7627a_add_io_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700810 /*7x25a kgsl initializations*/
811 msm7x25a_kgsl_3d0_init();
812}
813
814static void __init msm7x2x_init_early(void)
815{
Chintan Pandya250c2e52012-01-19 17:15:49 +0530816 msm_msm7627a_allocate_memory_regions();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700817}
818
819MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
820 .boot_params = PHYS_OFFSET + 0x100,
821 .map_io = msm_common_io_init,
Chintan Pandya12ec56a2012-03-13 15:47:12 +0530822 .reserve = msm7627a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700823 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +0530824 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700825 .timer = &msm_timer,
826 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +0530827 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700828MACHINE_END
829MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
830 .boot_params = PHYS_OFFSET + 0x100,
831 .map_io = msm_common_io_init,
Chintan Pandya12ec56a2012-03-13 15:47:12 +0530832 .reserve = msm7627a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700833 .init_irq = msm_init_irq,
834 .init_machine = msm7x2x_init,
835 .timer = &msm_timer,
836 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +0530837 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700838MACHINE_END
839MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
840 .boot_params = PHYS_OFFSET + 0x100,
841 .map_io = msm_common_io_init,
Chintan Pandya12ec56a2012-03-13 15:47:12 +0530842 .reserve = msm7627a_reserve,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700843 .init_irq = msm_init_irq,
844 .init_machine = msm7x2x_init,
845 .timer = &msm_timer,
846 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +0530847 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700848MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530849MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
850 .boot_params = PHYS_OFFSET + 0x100,
851 .map_io = msm_common_io_init,
Chintan Pandya12ec56a2012-03-13 15:47:12 +0530852 .reserve = msm7627a_reserve,
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530853 .init_irq = msm_init_irq,
854 .init_machine = msm7x2x_init,
855 .timer = &msm_timer,
856 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +0530857 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530858MACHINE_END
859MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
860 .boot_params = PHYS_OFFSET + 0x100,
861 .map_io = msm_common_io_init,
Chintan Pandya12ec56a2012-03-13 15:47:12 +0530862 .reserve = msm7627a_reserve,
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530863 .init_irq = msm_init_irq,
864 .init_machine = msm7x2x_init,
865 .timer = &msm_timer,
866 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +0530867 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530868MACHINE_END
Taniya Das43bcdd62011-12-02 17:33:27 +0530869MACHINE_START(MSM8625_RUMI3, "QCT MSM8625 RUMI3")
870 .boot_params = PHYS_OFFSET + 0x100,
871 .map_io = msm8625_map_io,
Taniya Das2b16d1d2011-12-02 14:44:19 +0530872 .reserve = msm8625_reserve,
Taniya Das43bcdd62011-12-02 17:33:27 +0530873 .init_irq = msm8625_init_irq,
874 .init_machine = msm8625_rumi3_init,
875 .timer = &msm_timer,
876 .handle_irq = gic_handle_irq,
877MACHINE_END
Taniya Dase3027e22012-02-27 16:32:27 +0530878MACHINE_START(MSM8625_SURF, "QCT MSM8625 SURF")
879 .boot_params = PHYS_OFFSET + 0x100,
880 .map_io = msm8625_map_io,
881 .reserve = msm8625_reserve,
882 .init_irq = msm8625_init_irq,
883 .init_machine = msm7x2x_init,
884 .timer = &msm_timer,
885 .init_early = msm7x2x_init_early,
886 .handle_irq = gic_handle_irq,
887MACHINE_END