blob: 7540aa98cd426d2bdaf07511879489d479d5033b [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
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>
15#include <asm/mach-types.h>
16#include <asm/mach/arch.h>
17#include <mach/board.h>
18#include <mach/msm_iomap.h>
19#include <mach/msm_hsusb.h>
20#include <mach/rpc_hsusb.h>
21#include <mach/rpc_pmapp.h>
22#include <mach/usbdiag.h>
23#include <mach/msm_memtypes.h>
24#include <mach/msm_serial_hs.h>
25#include <linux/usb/android.h>
26#include <linux/platform_device.h>
27#include <linux/io.h>
28#include <linux/gpio.h>
29#include <mach/vreg.h>
30#include <mach/pmic.h>
31#include <mach/socinfo.h>
32#include <linux/mtd/nand.h>
33#include <linux/mtd/partitions.h>
34#include <asm/mach/mmc.h>
35#include <linux/i2c.h>
36#include <linux/i2c/sx150x.h>
37#include <linux/gpio.h>
38#include <linux/android_pmem.h>
39#include <linux/bootmem.h>
40#include <linux/mfd/marimba.h>
41#include <mach/vreg.h>
42#include <linux/power_supply.h>
Justin Paupored98328e2011-08-19 13:48:31 -070043#include <linux/regulator/consumer.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070044#include <mach/rpc_pmapp.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070045#include <mach/msm_battery.h>
46#include <linux/smsc911x.h>
47#include <linux/atmel_maxtouch.h>
48#include "devices.h"
49#include "timer.h"
Justin Pauporeb3a33b72011-08-23 15:30:32 -070050#include "board-msm7x27a-regulator.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#include "devices-msm7x2xa.h"
52#include "pm.h"
53#include <mach/rpc_server_handset.h>
54#include <mach/socinfo.h>
Maheshkumar Sivasubramanian8ccc16e2011-10-25 15:59:57 -060055#include "pm-boot.h"
Chintan Pandyacf467fc2011-12-01 17:11:11 +053056#include "board-msm7627a.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057
58#define PMEM_KERNEL_EBI1_SIZE 0x3A000
59#define MSM_PMEM_AUDIO_SIZE 0x5B000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070060
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070061#if defined(CONFIG_GPIO_SX150X)
62enum {
63 SX150X_CORE,
64 SX150X_CAM,
65};
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 },
76 [SX150X_CAM] = {
77 .gpio_base = GPIO_CAM_EXPANDER_BASE,
78 .oscio_is_gpo = false,
79 .io_pullup_ena = 0,
80 .io_pulldn_ena = 0,
81 .io_open_drain_ena = 0x23,
82 .irq_summary = -1,
83 },
84};
85#endif
86
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087
Santosh Sajjan6822c682011-07-26 10:49:36 +053088static struct platform_device msm_wlan_ar6000_pm_device = {
89 .name = "wlan_ar6000_pm_dev",
90 .id = -1,
91};
92
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070093#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
94static struct i2c_board_info core_exp_i2c_info[] __initdata = {
95 {
96 I2C_BOARD_INFO("sx1509q", 0x3e),
97 },
98};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070099#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700100
101#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
102static void __init register_i2c_devices(void)
103{
Trilok Soni3d0f6c52011-07-26 16:06:58 +0530104 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700105 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
106
107 core_exp_i2c_info[0].platform_data =
108 &sx150x_data[SX150X_CORE];
109
110 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
111 core_exp_i2c_info,
112 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700113}
114#endif
115
116static struct msm_gpio qup_i2c_gpios_io[] = {
117 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
118 "qup_scl" },
119 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
120 "qup_sda" },
121 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
122 "qup_scl" },
123 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
124 "qup_sda" },
125};
126
127static struct msm_gpio qup_i2c_gpios_hw[] = {
128 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
129 "qup_scl" },
130 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
131 "qup_sda" },
132 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
133 "qup_scl" },
134 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
135 "qup_sda" },
136};
137
138static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
139{
140 int rc;
141
142 if (adap_id < 0 || adap_id > 1)
143 return;
144
145 /* Each adapter gets 2 lines from the table */
146 if (config_type)
147 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
148 else
149 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
150 if (rc < 0)
151 pr_err("QUP GPIO request/enable failed: %d\n", rc);
152}
153
154static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
155 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700156 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
157};
158
159static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
160 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700161 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
162};
163
164#ifdef CONFIG_ARCH_MSM7X27A
Neti Ravi Kumar061726e2011-12-08 15:14:57 +0530165#define MSM_PMEM_MDP_SIZE 0x2300000
166#define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530167
Roja Rani Yarubandi09986562011-12-06 18:54:47 +0530168#define MSM_PMEM_ADSP_SIZE 0x1000000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530169#define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000
170
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700171
172#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530173#define MSM_FB_SIZE 0x260000
174#define MSM7x25A_MSM_FB_SIZE 0xE1000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700175#else
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530176#define MSM_FB_SIZE 0x195000
Padmanabhan Komanduru9380a2a2011-11-22 15:04:32 +0530177#define MSM7x25A_MSM_FB_SIZE 0x96000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530178
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700179#endif
180
181#endif
182
183static struct android_usb_platform_data android_usb_pdata = {
184 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
185};
186
187static struct platform_device android_usb_device = {
188 .name = "android_usb",
189 .id = -1,
190 .dev = {
191 .platform_data = &android_usb_pdata,
192 },
193};
194
195#ifdef CONFIG_USB_EHCI_MSM_72K
196static void msm_hsusb_vbus_power(unsigned phy_info, int on)
197{
198 int rc = 0;
199 unsigned gpio;
200
201 gpio = GPIO_HOST_VBUS_EN;
202
203 rc = gpio_request(gpio, "i2c_host_vbus_en");
204 if (rc < 0) {
205 pr_err("failed to request %d GPIO\n", gpio);
206 return;
207 }
208 gpio_direction_output(gpio, !!on);
209 gpio_set_value_cansleep(gpio, !!on);
210 gpio_free(gpio);
211}
212
213static struct msm_usb_host_platform_data msm_usb_host_pdata = {
214 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
215};
216
217static void __init msm7x2x_init_host(void)
218{
219 msm_add_host(0, &msm_usb_host_pdata);
220}
221#endif
222
223#ifdef CONFIG_USB_MSM_OTG_72K
224static int hsusb_rpc_connect(int connect)
225{
226 if (connect)
227 return msm_hsusb_rpc_connect();
228 else
229 return msm_hsusb_rpc_close();
230}
231
Justin Paupored98328e2011-08-19 13:48:31 -0700232static struct regulator *reg_hsusb;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700233static int msm_hsusb_ldo_init(int init)
234{
Justin Paupored98328e2011-08-19 13:48:31 -0700235 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700236
Justin Paupored98328e2011-08-19 13:48:31 -0700237 if (init) {
238 reg_hsusb = regulator_get(NULL, "usb");
239 if (IS_ERR(reg_hsusb)) {
240 rc = PTR_ERR(reg_hsusb);
241 pr_err("%s: could not get regulator: %d\n",
242 __func__, rc);
243 goto out;
244 }
245
246 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
247 if (rc) {
248 pr_err("%s: could not set voltage: %d\n",
249 __func__, rc);
250 goto reg_free;
251 }
252
253 return 0;
254 }
255 /* else fall through */
256reg_free:
257 regulator_put(reg_hsusb);
258out:
259 reg_hsusb = NULL;
260 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700261}
262
263static int msm_hsusb_ldo_enable(int enable)
264{
265 static int ldo_status;
266
Justin Paupored98328e2011-08-19 13:48:31 -0700267 if (IS_ERR_OR_NULL(reg_hsusb))
268 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700269
270 if (ldo_status == enable)
271 return 0;
272
273 ldo_status = enable;
274
Justin Paupored98328e2011-08-19 13:48:31 -0700275 return enable ?
276 regulator_enable(reg_hsusb) :
277 regulator_disable(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700278}
279
280#ifndef CONFIG_USB_EHCI_MSM_72K
281static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
282{
283 int ret = 0;
284
285 if (init)
286 ret = msm_pm_app_rpc_init(callback);
287 else
288 msm_pm_app_rpc_deinit(callback);
289
290 return ret;
291}
292#endif
293
294static struct msm_otg_platform_data msm_otg_pdata = {
295#ifndef CONFIG_USB_EHCI_MSM_72K
296 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
297#else
298 .vbus_power = msm_hsusb_vbus_power,
299#endif
300 .rpc_connect = hsusb_rpc_connect,
301 .core_clk = 1,
302 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
303 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
304 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
305 .se1_gating = SE1_GATING_DISABLE,
306 .ldo_init = msm_hsusb_ldo_init,
307 .ldo_enable = msm_hsusb_ldo_enable,
308 .chg_init = hsusb_chg_init,
309 .chg_connected = hsusb_chg_connected,
310 .chg_vbus_draw = hsusb_chg_vbus_draw,
311};
312#endif
313
314static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
315 .is_phy_status_timer_on = 1,
316};
317
318static struct resource smc91x_resources[] = {
319 [0] = {
320 .start = 0x90000300,
321 .end = 0x900003ff,
322 .flags = IORESOURCE_MEM,
323 },
324 [1] = {
325 .start = MSM_GPIO_TO_INT(4),
326 .end = MSM_GPIO_TO_INT(4),
327 .flags = IORESOURCE_IRQ,
328 },
329};
330
331static struct platform_device smc91x_device = {
332 .name = "smc91x",
333 .id = 0,
334 .num_resources = ARRAY_SIZE(smc91x_resources),
335 .resource = smc91x_resources,
336};
337
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700338#ifdef CONFIG_SERIAL_MSM_HS
339static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
340 .inject_rx_on_wakeup = 1,
341 .rx_to_inject = 0xFD,
342};
343#endif
344static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
345 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
346 .idle_supported = 1,
347 .suspend_supported = 1,
348 .idle_enabled = 1,
349 .suspend_enabled = 1,
350 .latency = 16000,
351 .residency = 20000,
352 },
353 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
354 .idle_supported = 1,
355 .suspend_supported = 1,
356 .idle_enabled = 1,
357 .suspend_enabled = 1,
358 .latency = 12000,
359 .residency = 20000,
360 },
361 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
362 .idle_supported = 1,
363 .suspend_supported = 1,
364 .idle_enabled = 0,
365 .suspend_enabled = 1,
366 .latency = 2000,
367 .residency = 0,
368 },
369 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
370 .idle_supported = 1,
371 .suspend_supported = 1,
372 .idle_enabled = 1,
373 .suspend_enabled = 1,
374 .latency = 2,
375 .residency = 0,
376 },
377};
378
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600379static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
380 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT,
381 .v_addr = (uint32_t *)PAGE_OFFSET,
382};
383
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700384static struct android_pmem_platform_data android_pmem_adsp_pdata = {
385 .name = "pmem_adsp",
386 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
Mahesh Lankac6af7eb2011-08-02 18:00:35 +0530387 .cached = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700388 .memory_type = MEMTYPE_EBI1,
389};
390
391static struct platform_device android_pmem_adsp_device = {
392 .name = "android_pmem",
393 .id = 1,
394 .dev = { .platform_data = &android_pmem_adsp_pdata },
395};
396
397static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
398static int __init pmem_mdp_size_setup(char *p)
399{
400 pmem_mdp_size = memparse(p, NULL);
401 return 0;
402}
403
404early_param("pmem_mdp_size", pmem_mdp_size_setup);
405
406static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
407static int __init pmem_adsp_size_setup(char *p)
408{
409 pmem_adsp_size = memparse(p, NULL);
410 return 0;
411}
412
413early_param("pmem_adsp_size", pmem_adsp_size_setup);
414
415static unsigned fb_size = MSM_FB_SIZE;
416static int __init fb_size_setup(char *p)
417{
418 fb_size = memparse(p, NULL);
419 return 0;
420}
421
422early_param("fb_size", fb_size_setup);
423
Justin Paupored98328e2011-08-19 13:48:31 -0700424static struct regulator_bulk_data regs_lcdc[] = {
425 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
426 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700427};
428
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700429static uint32_t lcdc_gpio_initialized;
430
431static void lcdc_toshiba_gpio_init(void)
432{
Justin Paupored98328e2011-08-19 13:48:31 -0700433 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700434 if (!lcdc_gpio_initialized) {
435 if (gpio_request(GPIO_SPI_CLK, "spi_clk")) {
436 pr_err("failed to request gpio spi_clk\n");
437 return;
438 }
439 if (gpio_request(GPIO_SPI_CS0_N, "spi_cs")) {
440 pr_err("failed to request gpio spi_cs0_N\n");
441 goto fail_gpio6;
442 }
443 if (gpio_request(GPIO_SPI_MOSI, "spi_mosi")) {
444 pr_err("failed to request gpio spi_mosi\n");
445 goto fail_gpio5;
446 }
447 if (gpio_request(GPIO_SPI_MISO, "spi_miso")) {
448 pr_err("failed to request gpio spi_miso\n");
449 goto fail_gpio4;
450 }
451 if (gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr")) {
452 pr_err("failed to request gpio_disp_pwr\n");
453 goto fail_gpio3;
454 }
455 if (gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en")) {
456 pr_err("failed to request gpio_bkl_en\n");
457 goto fail_gpio2;
458 }
459 pmapp_disp_backlight_init();
460
Justin Paupored98328e2011-08-19 13:48:31 -0700461 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_lcdc), regs_lcdc);
462 if (rc) {
463 pr_err("%s: could not get regulators: %d\n",
464 __func__, rc);
465 goto fail_gpio1;
466 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700467
Justin Paupored98328e2011-08-19 13:48:31 -0700468 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_lcdc),
469 regs_lcdc);
470 if (rc) {
471 pr_err("%s: could not set voltages: %d\n",
472 __func__, rc);
473 goto fail_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700474 }
475 lcdc_gpio_initialized = 1;
476 }
477 return;
Justin Paupored98328e2011-08-19 13:48:31 -0700478fail_vreg:
479 regulator_bulk_free(ARRAY_SIZE(regs_lcdc), regs_lcdc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700480fail_gpio1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700481 gpio_free(GPIO_BACKLIGHT_EN);
482fail_gpio2:
483 gpio_free(GPIO_DISPLAY_PWR_EN);
484fail_gpio3:
485 gpio_free(GPIO_SPI_MISO);
486fail_gpio4:
487 gpio_free(GPIO_SPI_MOSI);
488fail_gpio5:
489 gpio_free(GPIO_SPI_CS0_N);
490fail_gpio6:
491 gpio_free(GPIO_SPI_CLK);
492 lcdc_gpio_initialized = 0;
493}
494
495static uint32_t lcdc_gpio_table[] = {
496 GPIO_SPI_CLK,
497 GPIO_SPI_CS0_N,
498 GPIO_SPI_MOSI,
499 GPIO_DISPLAY_PWR_EN,
500 GPIO_BACKLIGHT_EN,
501 GPIO_SPI_MISO,
502};
503
504static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable)
505{
506 int n;
507
508 if (lcdc_gpio_initialized) {
509 /* All are IO Expander GPIOs */
510 for (n = 0; n < (len - 1); n++)
511 gpio_direction_output(table[n], 1);
512 }
513}
514
515static void lcdc_toshiba_config_gpios(int enable)
516{
517 config_lcdc_gpio_table(lcdc_gpio_table,
518 ARRAY_SIZE(lcdc_gpio_table), enable);
519}
520
521static int msm_fb_lcdc_power_save(int on)
522{
Justin Paupored98328e2011-08-19 13:48:31 -0700523 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700524 /* Doing the init of the LCDC GPIOs very late as they are from
525 an I2C-controlled IO Expander */
526 lcdc_toshiba_gpio_init();
527
528 if (lcdc_gpio_initialized) {
529 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
530 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
531
Justin Paupored98328e2011-08-19 13:48:31 -0700532 rc = on ? regulator_bulk_enable(
533 ARRAY_SIZE(regs_lcdc), regs_lcdc) :
534 regulator_bulk_disable(
535 ARRAY_SIZE(regs_lcdc), regs_lcdc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700536
Justin Paupored98328e2011-08-19 13:48:31 -0700537 if (rc)
538 pr_err("%s: could not %sable regulators: %d\n",
539 __func__, on ? "en" : "dis", rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700540 }
541
542 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700543}
544
545
546static int lcdc_toshiba_set_bl(int level)
547{
548 int ret;
549
550 ret = pmapp_disp_backlight_set_brightness(level);
551 if (ret)
552 pr_err("%s: can't set lcd backlight!\n", __func__);
553
554 return ret;
555}
556
557
558static struct lcdc_platform_data lcdc_pdata = {
Jeevan Shriram15f2a5e2011-07-13 21:45:26 +0530559 .lcdc_gpio_config = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700560 .lcdc_power_save = msm_fb_lcdc_power_save,
561};
562
563static int lcd_panel_spi_gpio_num[] = {
564 GPIO_SPI_MOSI, /* spi_sdi */
565 GPIO_SPI_MISO, /* spi_sdoi */
566 GPIO_SPI_CLK, /* spi_clk */
567 GPIO_SPI_CS0_N, /* spi_cs */
568};
569
570static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
571 .panel_config_gpio = lcdc_toshiba_config_gpios,
572 .pmic_backlight = lcdc_toshiba_set_bl,
573 .gpio_num = lcd_panel_spi_gpio_num,
574};
575
576static struct platform_device lcdc_toshiba_panel_device = {
577 .name = "lcdc_toshiba_fwvga_pt",
578 .id = 0,
579 .dev = {
580 .platform_data = &lcdc_toshiba_panel_data,
581 }
582};
583
584static struct resource msm_fb_resources[] = {
585 {
586 .flags = IORESOURCE_DMA,
587 }
588};
589
Ajay Singh Parmareede70e2011-08-24 17:36:08 +0530590#define PANEL_NAME_MAX_LEN 30
591#define LCDC_TOSHIBA_FWVGA_PANEL_NAME "lcdc_toshiba_fwvga_pt"
592#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
593
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700594static int msm_fb_detect_panel(const char *name)
595{
Taniya Das0a5303a2011-08-23 18:47:48 +0530596 int ret = -ENODEV;
597
598 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) {
599 if (!strncmp(name, "lcdc_toshiba_fwvga_pt", 21) ||
600 !strncmp(name, "mipi_cmd_renesas_fwvga", 22))
601 ret = 0;
Jeevan Shriram29c9e952011-10-27 11:22:46 +0530602 } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) {
Taniya Das0a5303a2011-08-23 18:47:48 +0530603 if (!strncmp(name, "mipi_cmd_renesas_fwvga", 22))
604 ret = 0;
605 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700606
Ajay Singh Parmareede70e2011-08-24 17:36:08 +0530607#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
608 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
609 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
610 if (machine_is_msm7x27a_surf() ||
611 machine_is_msm7625a_surf()) {
612 if (!strncmp(name, LCDC_TOSHIBA_FWVGA_PANEL_NAME,
613 strnlen(LCDC_TOSHIBA_FWVGA_PANEL_NAME,
614 PANEL_NAME_MAX_LEN)))
615 return 0;
616 }
617#endif
Taniya Das0a5303a2011-08-23 18:47:48 +0530618 return ret;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700619}
620
621static struct msm_fb_platform_data msm_fb_pdata = {
622 .detect_client = msm_fb_detect_panel,
623};
624
625static struct platform_device msm_fb_device = {
626 .name = "msm_fb",
627 .id = 0,
628 .num_resources = ARRAY_SIZE(msm_fb_resources),
629 .resource = msm_fb_resources,
630 .dev = {
631 .platform_data = &msm_fb_pdata,
632 }
633};
634
635#ifdef CONFIG_FB_MSM_MIPI_DSI
636static int mipi_renesas_set_bl(int level)
637{
638 int ret;
639
640 ret = pmapp_disp_backlight_set_brightness(level);
641
642 if (ret)
643 pr_err("%s: can't set lcd backlight!\n", __func__);
644
645 return ret;
646}
647
648static struct msm_panel_common_pdata mipi_renesas_pdata = {
649 .pmic_backlight = mipi_renesas_set_bl,
650};
651
652
653static struct platform_device mipi_dsi_renesas_panel_device = {
654 .name = "mipi_renesas",
655 .id = 0,
656 .dev = {
657 .platform_data = &mipi_renesas_pdata,
658 }
659};
660#endif
661
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700662#define SND(desc, num) { .name = #desc, .id = num }
663static struct snd_endpoint snd_endpoints_list[] = {
664 SND(HANDSET, 0),
665 SND(MONO_HEADSET, 2),
666 SND(HEADSET, 3),
667 SND(SPEAKER, 6),
668 SND(TTY_HEADSET, 8),
669 SND(TTY_VCO, 9),
670 SND(TTY_HCO, 10),
671 SND(BT, 12),
672 SND(IN_S_SADC_OUT_HANDSET, 16),
673 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
674 SND(FM_DIGITAL_STEREO_HEADSET, 26),
675 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
676 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530677 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Sidipotu Ashokab34ca42011-07-22 16:34:20 +0530678 SND(CURRENT, 0x7FFFFFFE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700679 SND(FM_ANALOG_STEREO_HEADSET, 35),
680 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
681};
682#undef SND
683
684static struct msm_snd_endpoints msm_device_snd_endpoints = {
685 .endpoints = snd_endpoints_list,
686 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
687};
688
689static struct platform_device msm_device_snd = {
690 .name = "msm_snd",
691 .id = -1,
692 .dev = {
693 .platform_data = &msm_device_snd_endpoints
694 },
695};
696
697#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
698 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
699 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
700 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
701 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
702 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
703#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
704 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
705 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
706 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
707 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
708 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
709#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
710 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
711 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
712 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
713 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
714 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
715#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
716 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
717 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
718 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
719 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
720 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
721#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
722
723static unsigned int dec_concurrency_table[] = {
724 /* Audio LP */
725 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
726 0, 0, 0,
727
728 /* Concurrency 1 */
729 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
730 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
731 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
732 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
733 (DEC4_FORMAT),
734
735 /* Concurrency 2 */
736 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
737 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
738 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
739 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
740 (DEC4_FORMAT),
741
742 /* Concurrency 3 */
743 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
744 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
745 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
746 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
747 (DEC4_FORMAT),
748
749 /* Concurrency 4 */
750 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
751 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
752 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
753 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
754 (DEC4_FORMAT),
755
756 /* Concurrency 5 */
757 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
758 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
759 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
760 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
761 (DEC4_FORMAT),
762
763 /* Concurrency 6 */
764 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
765 0, 0, 0, 0,
766
767 /* Concurrency 7 */
768 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
769 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
770 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
771 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
772 (DEC4_FORMAT),
773};
774
775#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
776 .module_queueid = queueid, .module_decid = decid, \
777 .nr_codec_support = nr_codec}
778
779static struct msm_adspdec_info dec_info_list[] = {
780 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
781 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
782 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
783 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
784 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
785};
786
787static struct msm_adspdec_database msm_device_adspdec_database = {
788 .num_dec = ARRAY_SIZE(dec_info_list),
789 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
790 ARRAY_SIZE(dec_info_list)),
791 .dec_concurrency_table = dec_concurrency_table,
792 .dec_info_list = dec_info_list,
793};
794
795static struct platform_device msm_device_adspdec = {
796 .name = "msm_adspdec",
797 .id = -1,
798 .dev = {
799 .platform_data = &msm_device_adspdec_database
800 },
801};
802
803static struct android_pmem_platform_data android_pmem_audio_pdata = {
804 .name = "pmem_audio",
805 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
806 .cached = 0,
807 .memory_type = MEMTYPE_EBI1,
808};
809
810static struct platform_device android_pmem_audio_device = {
811 .name = "android_pmem",
812 .id = 2,
813 .dev = { .platform_data = &android_pmem_audio_pdata },
814};
815
816static struct android_pmem_platform_data android_pmem_pdata = {
817 .name = "pmem",
818 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
819 .cached = 1,
820 .memory_type = MEMTYPE_EBI1,
821};
822static struct platform_device android_pmem_device = {
823 .name = "android_pmem",
824 .id = 0,
825 .dev = { .platform_data = &android_pmem_pdata },
826};
827
828static u32 msm_calculate_batt_capacity(u32 current_voltage);
829
830static struct msm_psy_batt_pdata msm_psy_batt_data = {
831 .voltage_min_design = 2800,
832 .voltage_max_design = 4300,
833 .avail_chg_sources = AC_CHG | USB_CHG ,
834 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
835 .calculate_capacity = &msm_calculate_batt_capacity,
836};
837
838static u32 msm_calculate_batt_capacity(u32 current_voltage)
839{
840 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
841 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
842
843 return (current_voltage - low_voltage) * 100
844 / (high_voltage - low_voltage);
845}
846
847static struct platform_device msm_batt_device = {
848 .name = "msm-battery",
849 .id = -1,
850 .dev.platform_data = &msm_psy_batt_data,
851};
852
853static struct smsc911x_platform_config smsc911x_config = {
854 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
855 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
856 .flags = SMSC911X_USE_16BIT,
857};
858
859static struct resource smsc911x_resources[] = {
860 [0] = {
861 .start = 0x90000000,
862 .end = 0x90007fff,
863 .flags = IORESOURCE_MEM,
864 },
865 [1] = {
866 .start = MSM_GPIO_TO_INT(48),
867 .end = MSM_GPIO_TO_INT(48),
868 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
869 },
870};
871
872static struct platform_device smsc911x_device = {
873 .name = "smsc911x",
874 .id = 0,
875 .num_resources = ARRAY_SIZE(smsc911x_resources),
876 .resource = smsc911x_resources,
877 .dev = {
878 .platform_data = &smsc911x_config,
879 },
880};
881
882static struct msm_gpio smsc911x_gpios[] = {
883 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
884 "smsc911x_irq" },
885 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
886 "eth_fifo_sel" },
887};
888
889#define ETH_FIFO_SEL_GPIO 49
890static void msm7x27a_cfg_smsc911x(void)
891{
892 int res;
893
894 res = msm_gpios_request_enable(smsc911x_gpios,
895 ARRAY_SIZE(smsc911x_gpios));
896 if (res) {
897 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
898 return;
899 }
900
901 /* ETH_FIFO_SEL */
902 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
903 if (res) {
904 pr_err("%s: unable to get direction for gpio %d\n", __func__,
905 ETH_FIFO_SEL_GPIO);
906 msm_gpios_disable_free(smsc911x_gpios,
907 ARRAY_SIZE(smsc911x_gpios));
908 return;
909 }
910 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
911}
912
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700913#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
914 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
915static struct msm_gpio uart2dm_gpios[] = {
916 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
917 "uart2dm_rfr_n" },
918 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
919 "uart2dm_cts_n" },
920 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
921 "uart2dm_rx" },
922 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
923 "uart2dm_tx" },
924};
925
926static void msm7x27a_cfg_uart2dm_serial(void)
927{
928 int ret;
929 ret = msm_gpios_request_enable(uart2dm_gpios,
930 ARRAY_SIZE(uart2dm_gpios));
931 if (ret)
932 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
933}
934#else
935static void msm7x27a_cfg_uart2dm_serial(void) { }
936#endif
937
938static struct platform_device *rumi_sim_devices[] __initdata = {
939 &msm_device_dmov,
940 &msm_device_smd,
941 &smc91x_device,
942 &msm_device_uart1,
943 &msm_device_nand,
944 &msm_device_uart_dm1,
945 &msm_gsbi0_qup_i2c_device,
946 &msm_gsbi1_qup_i2c_device,
947};
948
949static struct platform_device *surf_ffa_devices[] __initdata = {
950 &msm_device_dmov,
951 &msm_device_smd,
952 &msm_device_uart1,
953 &msm_device_uart_dm1,
954 &msm_device_uart_dm2,
955 &msm_device_nand,
956 &msm_gsbi0_qup_i2c_device,
957 &msm_gsbi1_qup_i2c_device,
958 &msm_device_otg,
959 &msm_device_gadget_peripheral,
960 &android_usb_device,
961 &android_pmem_device,
962 &android_pmem_adsp_device,
963 &android_pmem_audio_device,
964 &msm_device_snd,
965 &msm_device_adspdec,
966 &msm_fb_device,
967 &lcdc_toshiba_panel_device,
968 &msm_batt_device,
969 &smsc911x_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700970#ifdef CONFIG_FB_MSM_MIPI_DSI
971 &mipi_dsi_renesas_panel_device,
972#endif
973 &msm_kgsl_3d0,
974#ifdef CONFIG_BT
975 &msm_bt_power_device,
976#endif
Manish Dewangan3a260992011-06-24 18:01:34 +0530977 &asoc_msm_pcm,
978 &asoc_msm_dai0,
979 &asoc_msm_dai1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700980};
981
982static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
983static int __init pmem_kernel_ebi1_size_setup(char *p)
984{
985 pmem_kernel_ebi1_size = memparse(p, NULL);
986 return 0;
987}
988early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
989
990static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
991static int __init pmem_audio_size_setup(char *p)
992{
993 pmem_audio_size = memparse(p, NULL);
994 return 0;
995}
996early_param("pmem_audio_size", pmem_audio_size_setup);
997
998static void __init msm_msm7x2x_allocate_memory_regions(void)
999{
1000 void *addr;
1001 unsigned long size;
1002
Jeevan Shriramf40764e2011-10-31 23:28:26 +05301003 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa())
1004 fb_size = MSM7x25A_MSM_FB_SIZE;
1005 else
1006 fb_size = MSM_FB_SIZE;
1007
1008 size = fb_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001009 addr = alloc_bootmem_align(size, 0x1000);
1010 msm_fb_resources[0].start = __pa(addr);
1011 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1012 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1013 size, addr, __pa(addr));
1014}
1015
1016static struct memtype_reserve msm7x27a_reserve_table[] __initdata = {
1017 [MEMTYPE_SMI] = {
1018 },
1019 [MEMTYPE_EBI0] = {
1020 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1021 },
1022 [MEMTYPE_EBI1] = {
1023 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1024 },
1025};
1026
1027static void __init size_pmem_devices(void)
1028{
Jeevan Shriramf40764e2011-10-31 23:28:26 +05301029
1030 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
1031 pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE;
1032 pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE;
1033 } else {
1034 pmem_mdp_size = MSM_PMEM_MDP_SIZE;
1035 pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
1036 }
1037
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001038#ifdef CONFIG_ANDROID_PMEM
1039 android_pmem_adsp_pdata.size = pmem_adsp_size;
1040 android_pmem_pdata.size = pmem_mdp_size;
1041 android_pmem_audio_pdata.size = pmem_audio_size;
1042#endif
1043}
1044
1045static void __init reserve_memory_for(struct android_pmem_platform_data *p)
1046{
1047 msm7x27a_reserve_table[p->memory_type].size += p->size;
1048}
1049
1050static void __init reserve_pmem_memory(void)
1051{
1052#ifdef CONFIG_ANDROID_PMEM
1053 reserve_memory_for(&android_pmem_adsp_pdata);
1054 reserve_memory_for(&android_pmem_pdata);
1055 reserve_memory_for(&android_pmem_audio_pdata);
1056 msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
1057#endif
1058}
1059
1060static void __init msm7x27a_calculate_reserve_sizes(void)
1061{
1062 size_pmem_devices();
1063 reserve_pmem_memory();
1064}
1065
1066static int msm7x27a_paddr_to_memtype(unsigned int paddr)
1067{
1068 return MEMTYPE_EBI1;
1069}
1070
1071static struct reserve_info msm7x27a_reserve_info __initdata = {
1072 .memtype_reserve_table = msm7x27a_reserve_table,
1073 .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes,
1074 .paddr_to_memtype = msm7x27a_paddr_to_memtype,
1075};
1076
1077static void __init msm7x27a_reserve(void)
1078{
1079 reserve_info = &msm7x27a_reserve_info;
1080 msm_reserve();
1081}
1082
1083static void __init msm_device_i2c_init(void)
1084{
1085 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
1086 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
1087}
1088
1089static struct msm_panel_common_pdata mdp_pdata = {
1090 .gpio = 97,
1091 .mdp_rev = MDP_REV_303,
1092};
1093
Pankaj Kumarffdaec82011-09-26 12:24:45 +05301094
1095#ifdef CONFIG_FB_MSM
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001096#define GPIO_LCDC_BRDG_PD 128
1097#define GPIO_LCDC_BRDG_RESET_N 129
1098
1099#define LCDC_RESET_PHYS 0x90008014
Pankaj Kumarffdaec82011-09-26 12:24:45 +05301100
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001101static void __iomem *lcdc_reset_ptr;
1102
1103static unsigned mipi_dsi_gpio[] = {
1104 GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1105 GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
1106 GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1107 GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
1108};
1109
1110enum {
1111 DSI_SINGLE_LANE = 1,
1112 DSI_TWO_LANES,
1113};
1114
1115static int msm_fb_get_lane_config(void)
1116{
1117 int rc = DSI_TWO_LANES;
1118
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301119 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001120 rc = DSI_SINGLE_LANE;
1121 pr_info("DSI Single Lane\n");
1122 } else {
1123 pr_info("DSI Two Lanes\n");
1124 }
1125 return rc;
1126}
1127
1128static int msm_fb_dsi_client_reset(void)
1129{
1130 int rc = 0;
1131
1132 rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
1133 if (rc < 0) {
1134 pr_err("failed to request lcd brdg reset_n\n");
1135 return rc;
1136 }
1137
1138 rc = gpio_request(GPIO_LCDC_BRDG_PD, "lcdc_brdg_pd");
1139 if (rc < 0) {
1140 pr_err("failed to request lcd brdg pd\n");
1141 return rc;
1142 }
1143
1144 rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
1145 if (rc) {
1146 pr_err("Failed to enable LCDC Bridge reset enable\n");
1147 goto gpio_error;
1148 }
1149
1150 rc = gpio_tlmm_config(mipi_dsi_gpio[1], GPIO_CFG_ENABLE);
1151 if (rc) {
1152 pr_err("Failed to enable LCDC Bridge pd enable\n");
1153 goto gpio_error2;
1154 }
1155
1156 rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
1157 rc |= gpio_direction_output(GPIO_LCDC_BRDG_PD, 1);
1158 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);
1159
1160 if (!rc) {
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301161 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001162 lcdc_reset_ptr = ioremap_nocache(LCDC_RESET_PHYS,
1163 sizeof(uint32_t));
1164
1165 if (!lcdc_reset_ptr)
1166 return 0;
1167 }
1168 return rc;
1169 } else {
1170 goto gpio_error;
1171 }
1172
1173gpio_error2:
1174 pr_err("Failed GPIO bridge pd\n");
1175 gpio_free(GPIO_LCDC_BRDG_PD);
1176
1177gpio_error:
1178 pr_err("Failed GPIO bridge reset\n");
1179 gpio_free(GPIO_LCDC_BRDG_RESET_N);
1180 return rc;
1181}
1182
Justin Paupored98328e2011-08-19 13:48:31 -07001183static struct regulator_bulk_data regs_dsi[] = {
1184 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
1185 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001186};
1187
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001188static int dsi_gpio_initialized;
1189
1190static int mipi_dsi_panel_power(int on)
1191{
Justin Paupored98328e2011-08-19 13:48:31 -07001192 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001193 uint32_t lcdc_reset_cfg;
1194
1195 /* I2C-controlled GPIO Expander -init of the GPIOs very late */
Justin Paupored98328e2011-08-19 13:48:31 -07001196 if (unlikely(!dsi_gpio_initialized)) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001197 pmapp_disp_backlight_init();
1198
1199 rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr");
1200 if (rc < 0) {
1201 pr_err("failed to request gpio_disp_pwr\n");
1202 return rc;
1203 }
1204
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301205 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001206 rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1);
1207 if (rc < 0) {
1208 pr_err("failed to enable display pwr\n");
1209 goto fail_gpio1;
1210 }
1211
1212 rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en");
1213 if (rc < 0) {
1214 pr_err("failed to request gpio_bkl_en\n");
1215 goto fail_gpio1;
1216 }
1217
1218 rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1);
1219 if (rc < 0) {
1220 pr_err("failed to enable backlight\n");
1221 goto fail_gpio2;
1222 }
1223 }
1224
Justin Paupored98328e2011-08-19 13:48:31 -07001225 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi);
1226 if (rc) {
1227 pr_err("%s: could not get regulators: %d\n",
1228 __func__, rc);
1229 goto fail_gpio2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001230 }
Justin Paupored98328e2011-08-19 13:48:31 -07001231
1232 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi), regs_dsi);
1233 if (rc) {
1234 pr_err("%s: could not set voltages: %d\n",
1235 __func__, rc);
1236 goto fail_vreg;
1237 }
1238
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001239 dsi_gpio_initialized = 1;
1240 }
1241
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301242 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) {
Justin Paupored98328e2011-08-19 13:48:31 -07001243 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
1244 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301245 } else if (machine_is_msm7x27a_ffa() ||
1246 machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001247 if (on) {
Justin Paupored98328e2011-08-19 13:48:31 -07001248 /* This line drives an active low pin on FFA */
1249 rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on);
1250 if (rc < 0)
1251 pr_err("failed to set direction for "
1252 "display pwr\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001253 } else {
Justin Paupored98328e2011-08-19 13:48:31 -07001254 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on);
1255 rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN);
1256 if (rc < 0)
1257 pr_err("failed to set direction for "
1258 "display pwr\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001259 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001260 }
1261
Justin Paupored98328e2011-08-19 13:48:31 -07001262 if (on) {
1263 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);
1264
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301265 if (machine_is_msm7x27a_surf() ||
1266 machine_is_msm7625a_surf()) {
Justin Paupored98328e2011-08-19 13:48:31 -07001267 lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr);
1268 rmb();
1269 lcdc_reset_cfg &= ~1;
1270
1271 writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
1272 msleep(20);
1273 wmb();
1274 lcdc_reset_cfg |= 1;
1275 writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
1276 } else {
1277 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
1278 msleep(20);
1279 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1280 }
1281
1282 if (pmapp_disp_backlight_set_brightness(100))
1283 pr_err("backlight set brightness failed\n");
1284 } else {
1285 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1);
1286
1287 if (pmapp_disp_backlight_set_brightness(0))
1288 pr_err("backlight set brightness failed\n");
1289 }
1290
1291 rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) :
1292 regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi);
1293
1294 if (rc)
1295 pr_err("%s: could not %sable regulators: %d\n",
1296 __func__, on ? "en" : "dis", rc);
1297
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001298 return rc;
1299
Justin Paupored98328e2011-08-19 13:48:31 -07001300fail_vreg:
1301 regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001302fail_gpio2:
1303 gpio_free(GPIO_BACKLIGHT_EN);
1304fail_gpio1:
1305 gpio_free(GPIO_DISPLAY_PWR_EN);
1306 dsi_gpio_initialized = 0;
1307 return rc;
1308}
Pankaj Kumarffdaec82011-09-26 12:24:45 +05301309#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001310
1311#define MDP_303_VSYNC_GPIO 97
1312
1313#ifdef CONFIG_FB_MSM_MDP303
1314static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1315 .vsync_gpio = MDP_303_VSYNC_GPIO,
1316 .dsi_power_save = mipi_dsi_panel_power,
1317 .dsi_client_reset = msm_fb_dsi_client_reset,
1318 .get_lane_config = msm_fb_get_lane_config,
1319};
1320#endif
1321
1322static void __init msm_fb_add_devices(void)
1323{
1324 msm_fb_register_device("mdp", &mdp_pdata);
1325 msm_fb_register_device("lcdc", &lcdc_pdata);
Pankaj Kumarffdaec82011-09-26 12:24:45 +05301326#ifdef CONFIG_FB_MSM_MDP303
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001327 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
Pankaj Kumarffdaec82011-09-26 12:24:45 +05301328#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001329}
1330
1331#define MSM_EBI2_PHYS 0xa0d00000
1332#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
1333
1334static void __init msm7x27a_init_ebi2(void)
1335{
1336 uint32_t ebi2_cfg;
1337 void __iomem *ebi2_cfg_ptr;
1338
1339 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
1340 if (!ebi2_cfg_ptr)
1341 return;
1342
1343 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301344 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
1345 machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001346 ebi2_cfg |= (1 << 4); /* CS2 */
1347
1348 writel(ebi2_cfg, ebi2_cfg_ptr);
1349 iounmap(ebi2_cfg_ptr);
1350
1351 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
1352 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
1353 sizeof(uint32_t));
1354 if (!ebi2_cfg_ptr)
1355 return;
1356
1357 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301358 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001359 ebi2_cfg |= (1 << 31);
1360
1361 writel(ebi2_cfg, ebi2_cfg_ptr);
1362 iounmap(ebi2_cfg_ptr);
1363}
1364
1365#define ATMEL_TS_I2C_NAME "maXTouch"
Justin Paupored98328e2011-08-19 13:48:31 -07001366
1367static struct regulator_bulk_data regs_atmel[] = {
1368 { .supply = "ldo2", .min_uV = 2850000, .max_uV = 2850000 },
1369 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
1370};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001371
1372#define ATMEL_TS_GPIO_IRQ 82
1373
1374static int atmel_ts_power_on(bool on)
1375{
Justin Paupored98328e2011-08-19 13:48:31 -07001376 int rc = on ?
1377 regulator_bulk_enable(ARRAY_SIZE(regs_atmel), regs_atmel) :
1378 regulator_bulk_disable(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001379
Justin Paupored98328e2011-08-19 13:48:31 -07001380 if (rc)
1381 pr_err("%s: could not %sable regulators: %d\n",
1382 __func__, on ? "en" : "dis", rc);
1383 else
1384 msleep(50);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001385
Justin Paupored98328e2011-08-19 13:48:31 -07001386 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001387}
1388
1389static int atmel_ts_platform_init(struct i2c_client *client)
1390{
1391 int rc;
Justin Paupored98328e2011-08-19 13:48:31 -07001392 struct device *dev = &client->dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001393
Justin Paupored98328e2011-08-19 13:48:31 -07001394 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001395 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -07001396 dev_err(dev, "%s: could not get regulators: %d\n",
1397 __func__, rc);
1398 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001399 }
1400
Justin Paupored98328e2011-08-19 13:48:31 -07001401 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001402 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -07001403 dev_err(dev, "%s: could not set voltages: %d\n",
1404 __func__, rc);
1405 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001406 }
1407
1408 rc = gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
1409 GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
1410 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
1411 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -07001412 dev_err(dev, "%s: gpio_tlmm_config for %d failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001413 __func__, ATMEL_TS_GPIO_IRQ);
Justin Paupored98328e2011-08-19 13:48:31 -07001414 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001415 }
1416
1417 /* configure touchscreen interrupt gpio */
1418 rc = gpio_request(ATMEL_TS_GPIO_IRQ, "atmel_maxtouch_gpio");
1419 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -07001420 dev_err(dev, "%s: unable to request gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001421 __func__, ATMEL_TS_GPIO_IRQ);
1422 goto ts_gpio_tlmm_unconfig;
1423 }
1424
1425 rc = gpio_direction_input(ATMEL_TS_GPIO_IRQ);
1426 if (rc < 0) {
Justin Paupored98328e2011-08-19 13:48:31 -07001427 dev_err(dev, "%s: unable to set the direction of gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001428 __func__, ATMEL_TS_GPIO_IRQ);
1429 goto free_ts_gpio;
1430 }
1431 return 0;
1432
1433free_ts_gpio:
1434 gpio_free(ATMEL_TS_GPIO_IRQ);
1435ts_gpio_tlmm_unconfig:
1436 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
1437 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
1438 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -07001439reg_free:
1440 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
1441out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001442 return rc;
1443}
1444
1445static int atmel_ts_platform_exit(struct i2c_client *client)
1446{
1447 gpio_free(ATMEL_TS_GPIO_IRQ);
1448 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
1449 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
1450 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -07001451 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001452 return 0;
1453}
1454
1455static u8 atmel_ts_read_chg(void)
1456{
1457 return gpio_get_value(ATMEL_TS_GPIO_IRQ);
1458}
1459
1460static u8 atmel_ts_valid_interrupt(void)
1461{
1462 return !atmel_ts_read_chg();
1463}
1464
1465#define ATMEL_X_OFFSET 13
1466#define ATMEL_Y_OFFSET 0
1467
Mohan Pallaka4e9a94e2011-11-23 16:34:21 +05301468static struct maxtouch_platform_data atmel_ts_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001469 .numtouch = 4,
1470 .init_platform_hw = atmel_ts_platform_init,
1471 .exit_platform_hw = atmel_ts_platform_exit,
1472 .power_on = atmel_ts_power_on,
1473 .display_res_x = 480,
1474 .display_res_y = 864,
1475 .min_x = ATMEL_X_OFFSET,
1476 .max_x = (505 - ATMEL_X_OFFSET),
1477 .min_y = ATMEL_Y_OFFSET,
1478 .max_y = (863 - ATMEL_Y_OFFSET),
1479 .valid_interrupt = atmel_ts_valid_interrupt,
1480 .read_chg = atmel_ts_read_chg,
1481};
1482
1483static struct i2c_board_info atmel_ts_i2c_info[] __initdata = {
1484 {
1485 I2C_BOARD_INFO(ATMEL_TS_I2C_NAME, 0x4a),
1486 .platform_data = &atmel_ts_pdata,
1487 .irq = MSM_GPIO_TO_INT(ATMEL_TS_GPIO_IRQ),
1488 },
1489};
1490
1491#define KP_INDEX(row, col) ((row)*ARRAY_SIZE(kp_col_gpios) + (col))
1492
1493static unsigned int kp_row_gpios[] = {31, 32, 33, 34, 35};
1494static unsigned int kp_col_gpios[] = {36, 37, 38, 39, 40};
1495
1496static const unsigned short keymap[ARRAY_SIZE(kp_col_gpios) *
1497 ARRAY_SIZE(kp_row_gpios)] = {
1498 [KP_INDEX(0, 0)] = KEY_7,
1499 [KP_INDEX(0, 1)] = KEY_DOWN,
1500 [KP_INDEX(0, 2)] = KEY_UP,
1501 [KP_INDEX(0, 3)] = KEY_RIGHT,
1502 [KP_INDEX(0, 4)] = KEY_ENTER,
1503
1504 [KP_INDEX(1, 0)] = KEY_LEFT,
1505 [KP_INDEX(1, 1)] = KEY_SEND,
1506 [KP_INDEX(1, 2)] = KEY_1,
1507 [KP_INDEX(1, 3)] = KEY_4,
1508 [KP_INDEX(1, 4)] = KEY_CLEAR,
1509
1510 [KP_INDEX(2, 0)] = KEY_6,
1511 [KP_INDEX(2, 1)] = KEY_5,
1512 [KP_INDEX(2, 2)] = KEY_8,
1513 [KP_INDEX(2, 3)] = KEY_3,
1514 [KP_INDEX(2, 4)] = KEY_NUMERIC_STAR,
1515
1516 [KP_INDEX(3, 0)] = KEY_9,
1517 [KP_INDEX(3, 1)] = KEY_NUMERIC_POUND,
1518 [KP_INDEX(3, 2)] = KEY_0,
1519 [KP_INDEX(3, 3)] = KEY_2,
1520 [KP_INDEX(3, 4)] = KEY_SLEEP,
1521
1522 [KP_INDEX(4, 0)] = KEY_BACK,
1523 [KP_INDEX(4, 1)] = KEY_HOME,
1524 [KP_INDEX(4, 2)] = KEY_MENU,
1525 [KP_INDEX(4, 3)] = KEY_VOLUMEUP,
1526 [KP_INDEX(4, 4)] = KEY_VOLUMEDOWN,
1527};
1528
1529/* SURF keypad platform device information */
1530static struct gpio_event_matrix_info kp_matrix_info = {
1531 .info.func = gpio_event_matrix_func,
1532 .keymap = keymap,
1533 .output_gpios = kp_row_gpios,
1534 .input_gpios = kp_col_gpios,
1535 .noutputs = ARRAY_SIZE(kp_row_gpios),
1536 .ninputs = ARRAY_SIZE(kp_col_gpios),
1537 .settle_time.tv_nsec = 40 * NSEC_PER_USEC,
1538 .poll_time.tv_nsec = 20 * NSEC_PER_MSEC,
1539 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
1540 GPIOKPF_PRINT_UNMAPPED_KEYS,
1541};
1542
1543static struct gpio_event_info *kp_info[] = {
1544 &kp_matrix_info.info
1545};
1546
1547static struct gpio_event_platform_data kp_pdata = {
1548 .name = "7x27a_kp",
1549 .info = kp_info,
1550 .info_count = ARRAY_SIZE(kp_info)
1551};
1552
1553static struct platform_device kp_pdev = {
1554 .name = GPIO_EVENT_DEV_NAME,
1555 .id = -1,
1556 .dev = {
1557 .platform_data = &kp_pdata,
1558 },
1559};
1560
1561static struct msm_handset_platform_data hs_platform_data = {
1562 .hs_name = "7k_handset",
1563 .pwr_key_delay_ms = 500, /* 0 will disable end key */
1564};
1565
1566static struct platform_device hs_pdev = {
1567 .name = "msm-handset",
1568 .id = -1,
1569 .dev = {
1570 .platform_data = &hs_platform_data,
1571 },
1572};
1573
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001574static struct platform_device msm_proccomm_regulator_dev = {
1575 .name = PROCCOMM_REGULATOR_DEV_NAME,
1576 .id = -1,
1577 .dev = {
1578 .platform_data = &msm7x27a_proccomm_regulator_data
1579 }
1580};
1581
Trilok Soni16f61af2011-07-26 16:06:58 +05301582static void __init msm7627a_rumi3_init(void)
1583{
1584 msm7x27a_init_ebi2();
1585 platform_add_devices(rumi_sim_devices,
1586 ARRAY_SIZE(rumi_sim_devices));
1587}
1588
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001589#define LED_GPIO_PDM 96
1590#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301591
1592#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
1593static int __init msm7x27a_init_ar6000pm(void)
1594{
1595 return platform_device_register(&msm_wlan_ar6000_pm_device);
1596}
1597#else
1598static int __init msm7x27a_init_ar6000pm(void) { return 0; }
1599#endif
1600
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001601static void __init msm7x27a_init_regulators(void)
1602{
1603 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1604 if (rc)
1605 pr_err("%s: could not register regulator device: %d\n",
1606 __func__, rc);
1607}
1608
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001609static void __init msm7x2x_init(void)
1610{
Trilok Sonia416c492011-07-22 20:20:23 +05301611 msm7x2x_misc_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001612
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001613 /* Initialize regulators first so that other devices can use them */
1614 msm7x27a_init_regulators();
1615
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001616 /* Common functions for SURF/FFA/RUMI3 */
1617 msm_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001618 msm7x27a_init_ebi2();
1619 msm7x27a_cfg_uart2dm_serial();
1620#ifdef CONFIG_SERIAL_MSM_HS
1621 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1622 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1623#endif
1624
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001625#ifdef CONFIG_USB_MSM_OTG_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301626 msm_otg_pdata.swfi_latency =
1627 msm7x27a_pm_data
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001628 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Trilok Soni16f61af2011-07-26 16:06:58 +05301629 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001630#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301631 msm_device_gadget_peripheral.dev.platform_data =
1632 &msm_gadget_pdata;
1633 msm7x27a_cfg_smsc911x();
1634 platform_add_devices(msm_footswitch_devices,
1635 msm_num_footswitch_devices);
1636 platform_add_devices(surf_ffa_devices,
1637 ARRAY_SIZE(surf_ffa_devices));
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301638 /* Ensure ar6000pm device is registered before MMC/SDC */
1639 msm7x27a_init_ar6000pm();
1640#ifdef CONFIG_MMC_MSM
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301641 msm7627a_init_mmc();
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301642#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301643 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001644#ifdef CONFIG_USB_EHCI_MSM_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301645 msm7x2x_init_host();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001646#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001647
1648 msm_pm_set_platform_data(msm7x27a_pm_data,
1649 ARRAY_SIZE(msm7x27a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001650 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001651
1652#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
1653 register_i2c_devices();
1654#endif
1655#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301656 msm7627a_bt_power_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001657#endif
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301658 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001659 atmel_ts_pdata.min_x = 0;
1660 atmel_ts_pdata.max_x = 480;
1661 atmel_ts_pdata.min_y = 0;
1662 atmel_ts_pdata.max_y = 320;
1663 }
1664
1665 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1666 atmel_ts_i2c_info,
1667 ARRAY_SIZE(atmel_ts_i2c_info));
1668
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301669#if defined(CONFIG_MSM_CAMERA)
Justin Paupored98328e2011-08-19 13:48:31 -07001670 msm_camera_vreg_init();
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301671#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001672 platform_device_register(&kp_pdev);
1673 platform_device_register(&hs_pdev);
1674
1675 /* configure it as a pdm function*/
1676 if (gpio_tlmm_config(GPIO_CFG(LED_GPIO_PDM, 3,
1677 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1678 GPIO_CFG_8MA), GPIO_CFG_ENABLE))
1679 pr_err("%s: gpio_tlmm_config for %d failed\n",
1680 __func__, LED_GPIO_PDM);
1681 else
1682 platform_device_register(&led_pdev);
1683
1684#ifdef CONFIG_MSM_RPC_VIBRATOR
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301685 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001686 msm_init_pmic_vibrator();
1687#endif
1688 /*7x25a kgsl initializations*/
1689 msm7x25a_kgsl_3d0_init();
1690}
1691
1692static void __init msm7x2x_init_early(void)
1693{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001694 msm_msm7x2x_allocate_memory_regions();
1695}
1696
1697MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
1698 .boot_params = PHYS_OFFSET + 0x100,
1699 .map_io = msm_common_io_init,
1700 .reserve = msm7x27a_reserve,
1701 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +05301702 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001703 .timer = &msm_timer,
1704 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301705 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001706MACHINE_END
1707MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
1708 .boot_params = PHYS_OFFSET + 0x100,
1709 .map_io = msm_common_io_init,
1710 .reserve = msm7x27a_reserve,
1711 .init_irq = msm_init_irq,
1712 .init_machine = msm7x2x_init,
1713 .timer = &msm_timer,
1714 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301715 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001716MACHINE_END
1717MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
1718 .boot_params = PHYS_OFFSET + 0x100,
1719 .map_io = msm_common_io_init,
1720 .reserve = msm7x27a_reserve,
1721 .init_irq = msm_init_irq,
1722 .init_machine = msm7x2x_init,
1723 .timer = &msm_timer,
1724 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301725 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001726MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301727MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
1728 .boot_params = PHYS_OFFSET + 0x100,
1729 .map_io = msm_common_io_init,
1730 .reserve = msm7x27a_reserve,
1731 .init_irq = msm_init_irq,
1732 .init_machine = msm7x2x_init,
1733 .timer = &msm_timer,
1734 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301735 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301736MACHINE_END
1737MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
1738 .boot_params = PHYS_OFFSET + 0x100,
1739 .map_io = msm_common_io_init,
1740 .reserve = msm7x27a_reserve,
1741 .init_irq = msm_init_irq,
1742 .init_machine = msm7x2x_init,
1743 .timer = &msm_timer,
1744 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301745 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301746MACHINE_END