blob: 5bcd749b77753dd990100a22bedb9b532fc49c83 [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>
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"
Abhijeet Dharmapurikarefaca4f2011-12-27 16:24:07 -080052#include <mach/pm.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070053#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,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070064};
65
66static struct sx150x_platform_data sx150x_data[] __initdata = {
67 [SX150X_CORE] = {
68 .gpio_base = GPIO_CORE_EXPANDER_BASE,
69 .oscio_is_gpo = false,
70 .io_pullup_ena = 0,
pankaj kumarc5c01392011-08-12 13:44:05 +053071 .io_pulldn_ena = 0x02,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070072 .io_open_drain_ena = 0xfef8,
73 .irq_summary = -1,
74 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070075};
76#endif
77
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070078
Santosh Sajjan6822c682011-07-26 10:49:36 +053079static struct platform_device msm_wlan_ar6000_pm_device = {
80 .name = "wlan_ar6000_pm_dev",
81 .id = -1,
82};
83
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070084#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
85static struct i2c_board_info core_exp_i2c_info[] __initdata = {
86 {
87 I2C_BOARD_INFO("sx1509q", 0x3e),
88 },
89};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070090
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091static void __init register_i2c_devices(void)
92{
Trilok Soni3d0f6c52011-07-26 16:06:58 +053093 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070094 sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0;
95
96 core_exp_i2c_info[0].platform_data =
97 &sx150x_data[SX150X_CORE];
98
99 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
100 core_exp_i2c_info,
101 ARRAY_SIZE(core_exp_i2c_info));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102}
103#endif
104
105static struct msm_gpio qup_i2c_gpios_io[] = {
106 { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
107 "qup_scl" },
108 { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
109 "qup_sda" },
110 { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
111 "qup_scl" },
112 { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
113 "qup_sda" },
114};
115
116static struct msm_gpio qup_i2c_gpios_hw[] = {
117 { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
118 "qup_scl" },
119 { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
120 "qup_sda" },
121 { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
122 "qup_scl" },
123 { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
124 "qup_sda" },
125};
126
127static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type)
128{
129 int rc;
130
131 if (adap_id < 0 || adap_id > 1)
132 return;
133
134 /* Each adapter gets 2 lines from the table */
135 if (config_type)
136 rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2);
137 else
138 rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2);
139 if (rc < 0)
140 pr_err("QUP GPIO request/enable failed: %d\n", rc);
141}
142
143static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = {
144 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700145 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
146};
147
148static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = {
149 .clk_freq = 100000,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700150 .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
151};
152
153#ifdef CONFIG_ARCH_MSM7X27A
Neti Ravi Kumar061726e2011-12-08 15:14:57 +0530154#define MSM_PMEM_MDP_SIZE 0x2300000
155#define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530156
Mahesh Lankaa2f6df12012-01-05 16:54:40 +0530157#define MSM_PMEM_ADSP_SIZE 0x1100000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530158#define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000
159
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700160
161#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530162#define MSM_FB_SIZE 0x260000
163#define MSM7x25A_MSM_FB_SIZE 0xE1000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700164#else
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530165#define MSM_FB_SIZE 0x195000
Padmanabhan Komanduru9380a2a2011-11-22 15:04:32 +0530166#define MSM7x25A_MSM_FB_SIZE 0x96000
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530167
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700168#endif
169
170#endif
171
172static struct android_usb_platform_data android_usb_pdata = {
173 .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num,
174};
175
176static struct platform_device android_usb_device = {
177 .name = "android_usb",
178 .id = -1,
179 .dev = {
180 .platform_data = &android_usb_pdata,
181 },
182};
183
184#ifdef CONFIG_USB_EHCI_MSM_72K
185static void msm_hsusb_vbus_power(unsigned phy_info, int on)
186{
187 int rc = 0;
188 unsigned gpio;
189
190 gpio = GPIO_HOST_VBUS_EN;
191
192 rc = gpio_request(gpio, "i2c_host_vbus_en");
193 if (rc < 0) {
194 pr_err("failed to request %d GPIO\n", gpio);
195 return;
196 }
197 gpio_direction_output(gpio, !!on);
198 gpio_set_value_cansleep(gpio, !!on);
199 gpio_free(gpio);
200}
201
202static struct msm_usb_host_platform_data msm_usb_host_pdata = {
203 .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
204};
205
206static void __init msm7x2x_init_host(void)
207{
208 msm_add_host(0, &msm_usb_host_pdata);
209}
210#endif
211
212#ifdef CONFIG_USB_MSM_OTG_72K
213static int hsusb_rpc_connect(int connect)
214{
215 if (connect)
216 return msm_hsusb_rpc_connect();
217 else
218 return msm_hsusb_rpc_close();
219}
220
Justin Paupored98328e2011-08-19 13:48:31 -0700221static struct regulator *reg_hsusb;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700222static int msm_hsusb_ldo_init(int init)
223{
Justin Paupored98328e2011-08-19 13:48:31 -0700224 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700225
Justin Paupored98328e2011-08-19 13:48:31 -0700226 if (init) {
227 reg_hsusb = regulator_get(NULL, "usb");
228 if (IS_ERR(reg_hsusb)) {
229 rc = PTR_ERR(reg_hsusb);
230 pr_err("%s: could not get regulator: %d\n",
231 __func__, rc);
232 goto out;
233 }
234
235 rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000);
236 if (rc) {
237 pr_err("%s: could not set voltage: %d\n",
238 __func__, rc);
239 goto reg_free;
240 }
241
242 return 0;
243 }
244 /* else fall through */
245reg_free:
246 regulator_put(reg_hsusb);
247out:
248 reg_hsusb = NULL;
249 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700250}
251
252static int msm_hsusb_ldo_enable(int enable)
253{
254 static int ldo_status;
255
Justin Paupored98328e2011-08-19 13:48:31 -0700256 if (IS_ERR_OR_NULL(reg_hsusb))
257 return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700258
259 if (ldo_status == enable)
260 return 0;
261
262 ldo_status = enable;
263
Justin Paupored98328e2011-08-19 13:48:31 -0700264 return enable ?
265 regulator_enable(reg_hsusb) :
266 regulator_disable(reg_hsusb);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700267}
268
269#ifndef CONFIG_USB_EHCI_MSM_72K
270static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
271{
272 int ret = 0;
273
274 if (init)
275 ret = msm_pm_app_rpc_init(callback);
276 else
277 msm_pm_app_rpc_deinit(callback);
278
279 return ret;
280}
281#endif
282
283static struct msm_otg_platform_data msm_otg_pdata = {
284#ifndef CONFIG_USB_EHCI_MSM_72K
285 .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init,
286#else
287 .vbus_power = msm_hsusb_vbus_power,
288#endif
289 .rpc_connect = hsusb_rpc_connect,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700290 .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT,
291 .cdr_autoreset = CDR_AUTO_RESET_DISABLE,
292 .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT,
293 .se1_gating = SE1_GATING_DISABLE,
294 .ldo_init = msm_hsusb_ldo_init,
295 .ldo_enable = msm_hsusb_ldo_enable,
296 .chg_init = hsusb_chg_init,
297 .chg_connected = hsusb_chg_connected,
298 .chg_vbus_draw = hsusb_chg_vbus_draw,
299};
300#endif
301
302static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = {
303 .is_phy_status_timer_on = 1,
304};
305
306static struct resource smc91x_resources[] = {
307 [0] = {
308 .start = 0x90000300,
309 .end = 0x900003ff,
310 .flags = IORESOURCE_MEM,
311 },
312 [1] = {
313 .start = MSM_GPIO_TO_INT(4),
314 .end = MSM_GPIO_TO_INT(4),
315 .flags = IORESOURCE_IRQ,
316 },
317};
318
319static struct platform_device smc91x_device = {
320 .name = "smc91x",
321 .id = 0,
322 .num_resources = ARRAY_SIZE(smc91x_resources),
323 .resource = smc91x_resources,
324};
325
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700326#ifdef CONFIG_SERIAL_MSM_HS
327static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
328 .inject_rx_on_wakeup = 1,
329 .rx_to_inject = 0xFD,
330};
331#endif
332static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = {
333 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = {
334 .idle_supported = 1,
335 .suspend_supported = 1,
336 .idle_enabled = 1,
337 .suspend_enabled = 1,
338 .latency = 16000,
339 .residency = 20000,
340 },
341 [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = {
342 .idle_supported = 1,
343 .suspend_supported = 1,
344 .idle_enabled = 1,
345 .suspend_enabled = 1,
346 .latency = 12000,
347 .residency = 20000,
348 },
349 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = {
350 .idle_supported = 1,
351 .suspend_supported = 1,
352 .idle_enabled = 0,
353 .suspend_enabled = 1,
354 .latency = 2000,
355 .residency = 0,
356 },
357 [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = {
358 .idle_supported = 1,
359 .suspend_supported = 1,
360 .idle_enabled = 1,
361 .suspend_enabled = 1,
362 .latency = 2,
363 .residency = 0,
364 },
365};
366
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600367static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = {
Sravan Kumar Ambapuramb22cf4d2012-01-02 21:45:04 +0530368 .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_PHYS,
369 .p_addr = 0,
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -0600370};
371
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700372static struct android_pmem_platform_data android_pmem_adsp_pdata = {
373 .name = "pmem_adsp",
374 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
Mahesh Lankac6af7eb2011-08-02 18:00:35 +0530375 .cached = 1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700376 .memory_type = MEMTYPE_EBI1,
377};
378
379static struct platform_device android_pmem_adsp_device = {
380 .name = "android_pmem",
381 .id = 1,
382 .dev = { .platform_data = &android_pmem_adsp_pdata },
383};
384
385static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
386static int __init pmem_mdp_size_setup(char *p)
387{
388 pmem_mdp_size = memparse(p, NULL);
389 return 0;
390}
391
392early_param("pmem_mdp_size", pmem_mdp_size_setup);
393
394static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
395static int __init pmem_adsp_size_setup(char *p)
396{
397 pmem_adsp_size = memparse(p, NULL);
398 return 0;
399}
400
401early_param("pmem_adsp_size", pmem_adsp_size_setup);
402
403static unsigned fb_size = MSM_FB_SIZE;
404static int __init fb_size_setup(char *p)
405{
406 fb_size = memparse(p, NULL);
407 return 0;
408}
409
410early_param("fb_size", fb_size_setup);
411
Justin Paupored98328e2011-08-19 13:48:31 -0700412static struct regulator_bulk_data regs_lcdc[] = {
413 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
414 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700415};
416
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700417static uint32_t lcdc_gpio_initialized;
418
419static void lcdc_toshiba_gpio_init(void)
420{
Justin Paupored98328e2011-08-19 13:48:31 -0700421 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700422 if (!lcdc_gpio_initialized) {
423 if (gpio_request(GPIO_SPI_CLK, "spi_clk")) {
424 pr_err("failed to request gpio spi_clk\n");
425 return;
426 }
427 if (gpio_request(GPIO_SPI_CS0_N, "spi_cs")) {
428 pr_err("failed to request gpio spi_cs0_N\n");
429 goto fail_gpio6;
430 }
431 if (gpio_request(GPIO_SPI_MOSI, "spi_mosi")) {
432 pr_err("failed to request gpio spi_mosi\n");
433 goto fail_gpio5;
434 }
435 if (gpio_request(GPIO_SPI_MISO, "spi_miso")) {
436 pr_err("failed to request gpio spi_miso\n");
437 goto fail_gpio4;
438 }
439 if (gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr")) {
440 pr_err("failed to request gpio_disp_pwr\n");
441 goto fail_gpio3;
442 }
443 if (gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en")) {
444 pr_err("failed to request gpio_bkl_en\n");
445 goto fail_gpio2;
446 }
447 pmapp_disp_backlight_init();
448
Justin Paupored98328e2011-08-19 13:48:31 -0700449 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_lcdc), regs_lcdc);
450 if (rc) {
451 pr_err("%s: could not get regulators: %d\n",
452 __func__, rc);
453 goto fail_gpio1;
454 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700455
Justin Paupored98328e2011-08-19 13:48:31 -0700456 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_lcdc),
457 regs_lcdc);
458 if (rc) {
459 pr_err("%s: could not set voltages: %d\n",
460 __func__, rc);
461 goto fail_vreg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700462 }
463 lcdc_gpio_initialized = 1;
464 }
465 return;
Justin Paupored98328e2011-08-19 13:48:31 -0700466fail_vreg:
467 regulator_bulk_free(ARRAY_SIZE(regs_lcdc), regs_lcdc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700468fail_gpio1:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700469 gpio_free(GPIO_BACKLIGHT_EN);
470fail_gpio2:
471 gpio_free(GPIO_DISPLAY_PWR_EN);
472fail_gpio3:
473 gpio_free(GPIO_SPI_MISO);
474fail_gpio4:
475 gpio_free(GPIO_SPI_MOSI);
476fail_gpio5:
477 gpio_free(GPIO_SPI_CS0_N);
478fail_gpio6:
479 gpio_free(GPIO_SPI_CLK);
480 lcdc_gpio_initialized = 0;
481}
482
483static uint32_t lcdc_gpio_table[] = {
484 GPIO_SPI_CLK,
485 GPIO_SPI_CS0_N,
486 GPIO_SPI_MOSI,
487 GPIO_DISPLAY_PWR_EN,
488 GPIO_BACKLIGHT_EN,
489 GPIO_SPI_MISO,
490};
491
492static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable)
493{
494 int n;
495
496 if (lcdc_gpio_initialized) {
497 /* All are IO Expander GPIOs */
498 for (n = 0; n < (len - 1); n++)
499 gpio_direction_output(table[n], 1);
500 }
501}
502
503static void lcdc_toshiba_config_gpios(int enable)
504{
505 config_lcdc_gpio_table(lcdc_gpio_table,
506 ARRAY_SIZE(lcdc_gpio_table), enable);
507}
508
509static int msm_fb_lcdc_power_save(int on)
510{
Justin Paupored98328e2011-08-19 13:48:31 -0700511 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700512 /* Doing the init of the LCDC GPIOs very late as they are from
513 an I2C-controlled IO Expander */
514 lcdc_toshiba_gpio_init();
515
516 if (lcdc_gpio_initialized) {
517 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
518 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
519
Justin Paupored98328e2011-08-19 13:48:31 -0700520 rc = on ? regulator_bulk_enable(
521 ARRAY_SIZE(regs_lcdc), regs_lcdc) :
522 regulator_bulk_disable(
523 ARRAY_SIZE(regs_lcdc), regs_lcdc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700524
Justin Paupored98328e2011-08-19 13:48:31 -0700525 if (rc)
526 pr_err("%s: could not %sable regulators: %d\n",
527 __func__, on ? "en" : "dis", rc);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700528 }
529
530 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700531}
532
533
534static int lcdc_toshiba_set_bl(int level)
535{
536 int ret;
537
538 ret = pmapp_disp_backlight_set_brightness(level);
539 if (ret)
540 pr_err("%s: can't set lcd backlight!\n", __func__);
541
542 return ret;
543}
544
545
546static struct lcdc_platform_data lcdc_pdata = {
Jeevan Shriram15f2a5e2011-07-13 21:45:26 +0530547 .lcdc_gpio_config = NULL,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700548 .lcdc_power_save = msm_fb_lcdc_power_save,
549};
550
551static int lcd_panel_spi_gpio_num[] = {
552 GPIO_SPI_MOSI, /* spi_sdi */
553 GPIO_SPI_MISO, /* spi_sdoi */
554 GPIO_SPI_CLK, /* spi_clk */
555 GPIO_SPI_CS0_N, /* spi_cs */
556};
557
558static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
559 .panel_config_gpio = lcdc_toshiba_config_gpios,
560 .pmic_backlight = lcdc_toshiba_set_bl,
561 .gpio_num = lcd_panel_spi_gpio_num,
562};
563
564static struct platform_device lcdc_toshiba_panel_device = {
565 .name = "lcdc_toshiba_fwvga_pt",
566 .id = 0,
567 .dev = {
568 .platform_data = &lcdc_toshiba_panel_data,
569 }
570};
571
572static struct resource msm_fb_resources[] = {
573 {
574 .flags = IORESOURCE_DMA,
575 }
576};
577
Ajay Singh Parmareede70e2011-08-24 17:36:08 +0530578#define PANEL_NAME_MAX_LEN 30
579#define LCDC_TOSHIBA_FWVGA_PANEL_NAME "lcdc_toshiba_fwvga_pt"
580#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
581
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700582static int msm_fb_detect_panel(const char *name)
583{
Taniya Das0a5303a2011-08-23 18:47:48 +0530584 int ret = -ENODEV;
585
586 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) {
587 if (!strncmp(name, "lcdc_toshiba_fwvga_pt", 21) ||
588 !strncmp(name, "mipi_cmd_renesas_fwvga", 22))
589 ret = 0;
Jeevan Shriram29c9e952011-10-27 11:22:46 +0530590 } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) {
Taniya Das0a5303a2011-08-23 18:47:48 +0530591 if (!strncmp(name, "mipi_cmd_renesas_fwvga", 22))
592 ret = 0;
593 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700594
Ajay Singh Parmareede70e2011-08-24 17:36:08 +0530595#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
596 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
597 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
598 if (machine_is_msm7x27a_surf() ||
599 machine_is_msm7625a_surf()) {
600 if (!strncmp(name, LCDC_TOSHIBA_FWVGA_PANEL_NAME,
601 strnlen(LCDC_TOSHIBA_FWVGA_PANEL_NAME,
602 PANEL_NAME_MAX_LEN)))
603 return 0;
604 }
605#endif
Taniya Das0a5303a2011-08-23 18:47:48 +0530606 return ret;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700607}
608
609static struct msm_fb_platform_data msm_fb_pdata = {
610 .detect_client = msm_fb_detect_panel,
611};
612
613static struct platform_device msm_fb_device = {
614 .name = "msm_fb",
615 .id = 0,
616 .num_resources = ARRAY_SIZE(msm_fb_resources),
617 .resource = msm_fb_resources,
618 .dev = {
619 .platform_data = &msm_fb_pdata,
620 }
621};
622
623#ifdef CONFIG_FB_MSM_MIPI_DSI
624static int mipi_renesas_set_bl(int level)
625{
626 int ret;
627
628 ret = pmapp_disp_backlight_set_brightness(level);
629
630 if (ret)
631 pr_err("%s: can't set lcd backlight!\n", __func__);
632
633 return ret;
634}
635
636static struct msm_panel_common_pdata mipi_renesas_pdata = {
637 .pmic_backlight = mipi_renesas_set_bl,
638};
639
640
641static struct platform_device mipi_dsi_renesas_panel_device = {
642 .name = "mipi_renesas",
643 .id = 0,
644 .dev = {
645 .platform_data = &mipi_renesas_pdata,
646 }
647};
648#endif
649
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700650#define SND(desc, num) { .name = #desc, .id = num }
651static struct snd_endpoint snd_endpoints_list[] = {
652 SND(HANDSET, 0),
653 SND(MONO_HEADSET, 2),
654 SND(HEADSET, 3),
655 SND(SPEAKER, 6),
656 SND(TTY_HEADSET, 8),
657 SND(TTY_VCO, 9),
658 SND(TTY_HCO, 10),
659 SND(BT, 12),
660 SND(IN_S_SADC_OUT_HANDSET, 16),
661 SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
662 SND(FM_DIGITAL_STEREO_HEADSET, 26),
663 SND(FM_DIGITAL_SPEAKER_PHONE, 27),
664 SND(FM_DIGITAL_BT_A2DP_HEADSET, 28),
Shashi Kumar64e07602011-10-11 13:18:57 +0530665 SND(STEREO_HEADSET_AND_SPEAKER, 31),
Sidipotu Ashokab34ca42011-07-22 16:34:20 +0530666 SND(CURRENT, 0x7FFFFFFE),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700667 SND(FM_ANALOG_STEREO_HEADSET, 35),
668 SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36),
669};
670#undef SND
671
672static struct msm_snd_endpoints msm_device_snd_endpoints = {
673 .endpoints = snd_endpoints_list,
674 .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
675};
676
677static struct platform_device msm_device_snd = {
678 .name = "msm_snd",
679 .id = -1,
680 .dev = {
681 .platform_data = &msm_device_snd_endpoints
682 },
683};
684
685#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
686 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
687 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
688 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
689 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
690 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
691#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
692 (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
693 (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
694 (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
695 (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
696 (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
697#define DEC2_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 DEC3_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 DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
710
711static unsigned int dec_concurrency_table[] = {
712 /* Audio LP */
713 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
714 0, 0, 0,
715
716 /* Concurrency 1 */
717 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
718 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
719 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
720 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
721 (DEC4_FORMAT),
722
723 /* Concurrency 2 */
724 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
725 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
726 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
727 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
728 (DEC4_FORMAT),
729
730 /* Concurrency 3 */
731 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
732 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
733 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
734 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
735 (DEC4_FORMAT),
736
737 /* Concurrency 4 */
738 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
739 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
740 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
741 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
742 (DEC4_FORMAT),
743
744 /* Concurrency 5 */
745 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
746 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
747 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
748 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
749 (DEC4_FORMAT),
750
751 /* Concurrency 6 */
752 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
753 0, 0, 0, 0,
754
755 /* Concurrency 7 */
756 (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
757 (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
758 (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
759 (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
760 (DEC4_FORMAT),
761};
762
763#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
764 .module_queueid = queueid, .module_decid = decid, \
765 .nr_codec_support = nr_codec}
766
767static struct msm_adspdec_info dec_info_list[] = {
768 DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
769 DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
770 DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
771 DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
772 DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
773};
774
775static struct msm_adspdec_database msm_device_adspdec_database = {
776 .num_dec = ARRAY_SIZE(dec_info_list),
777 .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
778 ARRAY_SIZE(dec_info_list)),
779 .dec_concurrency_table = dec_concurrency_table,
780 .dec_info_list = dec_info_list,
781};
782
783static struct platform_device msm_device_adspdec = {
784 .name = "msm_adspdec",
785 .id = -1,
786 .dev = {
787 .platform_data = &msm_device_adspdec_database
788 },
789};
790
791static struct android_pmem_platform_data android_pmem_audio_pdata = {
792 .name = "pmem_audio",
793 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
794 .cached = 0,
795 .memory_type = MEMTYPE_EBI1,
796};
797
798static struct platform_device android_pmem_audio_device = {
799 .name = "android_pmem",
800 .id = 2,
801 .dev = { .platform_data = &android_pmem_audio_pdata },
802};
803
804static struct android_pmem_platform_data android_pmem_pdata = {
805 .name = "pmem",
806 .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
807 .cached = 1,
808 .memory_type = MEMTYPE_EBI1,
809};
810static struct platform_device android_pmem_device = {
811 .name = "android_pmem",
812 .id = 0,
813 .dev = { .platform_data = &android_pmem_pdata },
814};
815
816static u32 msm_calculate_batt_capacity(u32 current_voltage);
817
818static struct msm_psy_batt_pdata msm_psy_batt_data = {
819 .voltage_min_design = 2800,
820 .voltage_max_design = 4300,
821 .avail_chg_sources = AC_CHG | USB_CHG ,
822 .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION,
823 .calculate_capacity = &msm_calculate_batt_capacity,
824};
825
826static u32 msm_calculate_batt_capacity(u32 current_voltage)
827{
828 u32 low_voltage = msm_psy_batt_data.voltage_min_design;
829 u32 high_voltage = msm_psy_batt_data.voltage_max_design;
830
831 return (current_voltage - low_voltage) * 100
832 / (high_voltage - low_voltage);
833}
834
835static struct platform_device msm_batt_device = {
836 .name = "msm-battery",
837 .id = -1,
838 .dev.platform_data = &msm_psy_batt_data,
839};
840
841static struct smsc911x_platform_config smsc911x_config = {
842 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
843 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
844 .flags = SMSC911X_USE_16BIT,
845};
846
847static struct resource smsc911x_resources[] = {
848 [0] = {
849 .start = 0x90000000,
850 .end = 0x90007fff,
851 .flags = IORESOURCE_MEM,
852 },
853 [1] = {
854 .start = MSM_GPIO_TO_INT(48),
855 .end = MSM_GPIO_TO_INT(48),
856 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
857 },
858};
859
860static struct platform_device smsc911x_device = {
861 .name = "smsc911x",
862 .id = 0,
863 .num_resources = ARRAY_SIZE(smsc911x_resources),
864 .resource = smsc911x_resources,
865 .dev = {
866 .platform_data = &smsc911x_config,
867 },
868};
869
870static struct msm_gpio smsc911x_gpios[] = {
871 { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
872 "smsc911x_irq" },
873 { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA),
874 "eth_fifo_sel" },
875};
876
877#define ETH_FIFO_SEL_GPIO 49
878static void msm7x27a_cfg_smsc911x(void)
879{
880 int res;
881
882 res = msm_gpios_request_enable(smsc911x_gpios,
883 ARRAY_SIZE(smsc911x_gpios));
884 if (res) {
885 pr_err("%s: unable to enable gpios for SMSC911x\n", __func__);
886 return;
887 }
888
889 /* ETH_FIFO_SEL */
890 res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0);
891 if (res) {
892 pr_err("%s: unable to get direction for gpio %d\n", __func__,
893 ETH_FIFO_SEL_GPIO);
894 msm_gpios_disable_free(smsc911x_gpios,
895 ARRAY_SIZE(smsc911x_gpios));
896 return;
897 }
898 gpio_set_value(ETH_FIFO_SEL_GPIO, 0);
899}
900
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700901#if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \
902 && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM)
903static struct msm_gpio uart2dm_gpios[] = {
904 {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
905 "uart2dm_rfr_n" },
906 {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
907 "uart2dm_cts_n" },
908 {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
909 "uart2dm_rx" },
910 {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
911 "uart2dm_tx" },
912};
913
914static void msm7x27a_cfg_uart2dm_serial(void)
915{
916 int ret;
917 ret = msm_gpios_request_enable(uart2dm_gpios,
918 ARRAY_SIZE(uart2dm_gpios));
919 if (ret)
920 pr_err("%s: unable to enable gpios for uart2dm\n", __func__);
921}
922#else
923static void msm7x27a_cfg_uart2dm_serial(void) { }
924#endif
925
926static struct platform_device *rumi_sim_devices[] __initdata = {
927 &msm_device_dmov,
928 &msm_device_smd,
929 &smc91x_device,
930 &msm_device_uart1,
931 &msm_device_nand,
932 &msm_device_uart_dm1,
933 &msm_gsbi0_qup_i2c_device,
934 &msm_gsbi1_qup_i2c_device,
935};
936
937static struct platform_device *surf_ffa_devices[] __initdata = {
938 &msm_device_dmov,
939 &msm_device_smd,
940 &msm_device_uart1,
941 &msm_device_uart_dm1,
942 &msm_device_uart_dm2,
943 &msm_device_nand,
944 &msm_gsbi0_qup_i2c_device,
945 &msm_gsbi1_qup_i2c_device,
946 &msm_device_otg,
947 &msm_device_gadget_peripheral,
948 &android_usb_device,
949 &android_pmem_device,
950 &android_pmem_adsp_device,
951 &android_pmem_audio_device,
952 &msm_device_snd,
953 &msm_device_adspdec,
954 &msm_fb_device,
955 &lcdc_toshiba_panel_device,
956 &msm_batt_device,
957 &smsc911x_device,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700958#ifdef CONFIG_FB_MSM_MIPI_DSI
959 &mipi_dsi_renesas_panel_device,
960#endif
961 &msm_kgsl_3d0,
962#ifdef CONFIG_BT
963 &msm_bt_power_device,
964#endif
Manish Dewangan3a260992011-06-24 18:01:34 +0530965 &asoc_msm_pcm,
966 &asoc_msm_dai0,
967 &asoc_msm_dai1,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700968};
969
970static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
971static int __init pmem_kernel_ebi1_size_setup(char *p)
972{
973 pmem_kernel_ebi1_size = memparse(p, NULL);
974 return 0;
975}
976early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup);
977
978static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
979static int __init pmem_audio_size_setup(char *p)
980{
981 pmem_audio_size = memparse(p, NULL);
982 return 0;
983}
984early_param("pmem_audio_size", pmem_audio_size_setup);
985
986static void __init msm_msm7x2x_allocate_memory_regions(void)
987{
988 void *addr;
989 unsigned long size;
990
Jeevan Shriramf40764e2011-10-31 23:28:26 +0530991 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa())
992 fb_size = MSM7x25A_MSM_FB_SIZE;
993 else
994 fb_size = MSM_FB_SIZE;
995
996 size = fb_size;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700997 addr = alloc_bootmem_align(size, 0x1000);
998 msm_fb_resources[0].start = __pa(addr);
999 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1000 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1001 size, addr, __pa(addr));
1002}
1003
1004static struct memtype_reserve msm7x27a_reserve_table[] __initdata = {
1005 [MEMTYPE_SMI] = {
1006 },
1007 [MEMTYPE_EBI0] = {
1008 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1009 },
1010 [MEMTYPE_EBI1] = {
1011 .flags = MEMTYPE_FLAGS_1M_ALIGN,
1012 },
1013};
1014
1015static void __init size_pmem_devices(void)
1016{
Jeevan Shriramf40764e2011-10-31 23:28:26 +05301017
1018 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
1019 pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE;
1020 pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE;
1021 } else {
1022 pmem_mdp_size = MSM_PMEM_MDP_SIZE;
1023 pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
1024 }
1025
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001026#ifdef CONFIG_ANDROID_PMEM
1027 android_pmem_adsp_pdata.size = pmem_adsp_size;
1028 android_pmem_pdata.size = pmem_mdp_size;
1029 android_pmem_audio_pdata.size = pmem_audio_size;
1030#endif
1031}
1032
1033static void __init reserve_memory_for(struct android_pmem_platform_data *p)
1034{
1035 msm7x27a_reserve_table[p->memory_type].size += p->size;
1036}
1037
1038static void __init reserve_pmem_memory(void)
1039{
1040#ifdef CONFIG_ANDROID_PMEM
1041 reserve_memory_for(&android_pmem_adsp_pdata);
1042 reserve_memory_for(&android_pmem_pdata);
1043 reserve_memory_for(&android_pmem_audio_pdata);
1044 msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size;
1045#endif
1046}
1047
1048static void __init msm7x27a_calculate_reserve_sizes(void)
1049{
1050 size_pmem_devices();
1051 reserve_pmem_memory();
1052}
1053
1054static int msm7x27a_paddr_to_memtype(unsigned int paddr)
1055{
1056 return MEMTYPE_EBI1;
1057}
1058
1059static struct reserve_info msm7x27a_reserve_info __initdata = {
1060 .memtype_reserve_table = msm7x27a_reserve_table,
1061 .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes,
1062 .paddr_to_memtype = msm7x27a_paddr_to_memtype,
1063};
1064
1065static void __init msm7x27a_reserve(void)
1066{
1067 reserve_info = &msm7x27a_reserve_info;
1068 msm_reserve();
1069}
1070
1071static void __init msm_device_i2c_init(void)
1072{
1073 msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata;
1074 msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata;
1075}
1076
1077static struct msm_panel_common_pdata mdp_pdata = {
1078 .gpio = 97,
1079 .mdp_rev = MDP_REV_303,
1080};
1081
Pankaj Kumarffdaec82011-09-26 12:24:45 +05301082
1083#ifdef CONFIG_FB_MSM
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001084#define GPIO_LCDC_BRDG_PD 128
1085#define GPIO_LCDC_BRDG_RESET_N 129
1086
1087#define LCDC_RESET_PHYS 0x90008014
Pankaj Kumarffdaec82011-09-26 12:24:45 +05301088
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001089static void __iomem *lcdc_reset_ptr;
1090
1091static unsigned mipi_dsi_gpio[] = {
1092 GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1093 GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
1094 GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1095 GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
1096};
1097
1098enum {
1099 DSI_SINGLE_LANE = 1,
1100 DSI_TWO_LANES,
1101};
1102
1103static int msm_fb_get_lane_config(void)
1104{
1105 int rc = DSI_TWO_LANES;
1106
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301107 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001108 rc = DSI_SINGLE_LANE;
1109 pr_info("DSI Single Lane\n");
1110 } else {
1111 pr_info("DSI Two Lanes\n");
1112 }
1113 return rc;
1114}
1115
1116static int msm_fb_dsi_client_reset(void)
1117{
1118 int rc = 0;
1119
1120 rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
1121 if (rc < 0) {
1122 pr_err("failed to request lcd brdg reset_n\n");
1123 return rc;
1124 }
1125
1126 rc = gpio_request(GPIO_LCDC_BRDG_PD, "lcdc_brdg_pd");
1127 if (rc < 0) {
1128 pr_err("failed to request lcd brdg pd\n");
1129 return rc;
1130 }
1131
1132 rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
1133 if (rc) {
1134 pr_err("Failed to enable LCDC Bridge reset enable\n");
1135 goto gpio_error;
1136 }
1137
1138 rc = gpio_tlmm_config(mipi_dsi_gpio[1], GPIO_CFG_ENABLE);
1139 if (rc) {
1140 pr_err("Failed to enable LCDC Bridge pd enable\n");
1141 goto gpio_error2;
1142 }
1143
1144 rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
1145 rc |= gpio_direction_output(GPIO_LCDC_BRDG_PD, 1);
1146 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);
1147
1148 if (!rc) {
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301149 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001150 lcdc_reset_ptr = ioremap_nocache(LCDC_RESET_PHYS,
1151 sizeof(uint32_t));
1152
1153 if (!lcdc_reset_ptr)
1154 return 0;
1155 }
1156 return rc;
1157 } else {
1158 goto gpio_error;
1159 }
1160
1161gpio_error2:
1162 pr_err("Failed GPIO bridge pd\n");
1163 gpio_free(GPIO_LCDC_BRDG_PD);
1164
1165gpio_error:
1166 pr_err("Failed GPIO bridge reset\n");
1167 gpio_free(GPIO_LCDC_BRDG_RESET_N);
1168 return rc;
1169}
1170
Justin Paupored98328e2011-08-19 13:48:31 -07001171static struct regulator_bulk_data regs_dsi[] = {
1172 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
1173 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001174};
1175
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001176static int dsi_gpio_initialized;
1177
1178static int mipi_dsi_panel_power(int on)
1179{
Justin Paupored98328e2011-08-19 13:48:31 -07001180 int rc = 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001181 uint32_t lcdc_reset_cfg;
1182
1183 /* I2C-controlled GPIO Expander -init of the GPIOs very late */
Justin Paupored98328e2011-08-19 13:48:31 -07001184 if (unlikely(!dsi_gpio_initialized)) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001185 pmapp_disp_backlight_init();
1186
1187 rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr");
1188 if (rc < 0) {
1189 pr_err("failed to request gpio_disp_pwr\n");
1190 return rc;
1191 }
1192
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301193 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001194 rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1);
1195 if (rc < 0) {
1196 pr_err("failed to enable display pwr\n");
1197 goto fail_gpio1;
1198 }
1199
1200 rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en");
1201 if (rc < 0) {
1202 pr_err("failed to request gpio_bkl_en\n");
1203 goto fail_gpio1;
1204 }
1205
1206 rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1);
1207 if (rc < 0) {
1208 pr_err("failed to enable backlight\n");
1209 goto fail_gpio2;
1210 }
1211 }
1212
Justin Paupored98328e2011-08-19 13:48:31 -07001213 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi);
1214 if (rc) {
1215 pr_err("%s: could not get regulators: %d\n",
1216 __func__, rc);
1217 goto fail_gpio2;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001218 }
Justin Paupored98328e2011-08-19 13:48:31 -07001219
1220 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi), regs_dsi);
1221 if (rc) {
1222 pr_err("%s: could not set voltages: %d\n",
1223 __func__, rc);
1224 goto fail_vreg;
1225 }
Jeevan Shriram9de513d2012-01-09 22:48:24 +05301226 if (pmapp_disp_backlight_set_brightness(100))
1227 pr_err("backlight set brightness failed\n");
Justin Paupored98328e2011-08-19 13:48:31 -07001228
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001229 dsi_gpio_initialized = 1;
1230 }
1231
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301232 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) {
Justin Paupored98328e2011-08-19 13:48:31 -07001233 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
1234 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301235 } else if (machine_is_msm7x27a_ffa() ||
1236 machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001237 if (on) {
Justin Paupored98328e2011-08-19 13:48:31 -07001238 /* This line drives an active low pin on FFA */
1239 rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on);
1240 if (rc < 0)
1241 pr_err("failed to set direction for "
1242 "display pwr\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001243 } else {
Justin Paupored98328e2011-08-19 13:48:31 -07001244 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on);
1245 rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN);
1246 if (rc < 0)
1247 pr_err("failed to set direction for "
1248 "display pwr\n");
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001249 }
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001250 }
1251
Justin Paupored98328e2011-08-19 13:48:31 -07001252 if (on) {
1253 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);
1254
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301255 if (machine_is_msm7x27a_surf() ||
1256 machine_is_msm7625a_surf()) {
Justin Paupored98328e2011-08-19 13:48:31 -07001257 lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr);
1258 rmb();
1259 lcdc_reset_cfg &= ~1;
1260
1261 writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
1262 msleep(20);
1263 wmb();
1264 lcdc_reset_cfg |= 1;
1265 writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
1266 } else {
1267 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
1268 msleep(20);
1269 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1270 }
Justin Paupored98328e2011-08-19 13:48:31 -07001271 } else {
1272 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1);
1273
1274 if (pmapp_disp_backlight_set_brightness(0))
1275 pr_err("backlight set brightness failed\n");
1276 }
1277
1278 rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) :
1279 regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi);
1280
1281 if (rc)
1282 pr_err("%s: could not %sable regulators: %d\n",
1283 __func__, on ? "en" : "dis", rc);
1284
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001285 return rc;
1286
Justin Paupored98328e2011-08-19 13:48:31 -07001287fail_vreg:
1288 regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001289fail_gpio2:
1290 gpio_free(GPIO_BACKLIGHT_EN);
1291fail_gpio1:
1292 gpio_free(GPIO_DISPLAY_PWR_EN);
1293 dsi_gpio_initialized = 0;
1294 return rc;
1295}
Pankaj Kumarffdaec82011-09-26 12:24:45 +05301296#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001297
1298#define MDP_303_VSYNC_GPIO 97
1299
1300#ifdef CONFIG_FB_MSM_MDP303
1301static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1302 .vsync_gpio = MDP_303_VSYNC_GPIO,
1303 .dsi_power_save = mipi_dsi_panel_power,
1304 .dsi_client_reset = msm_fb_dsi_client_reset,
1305 .get_lane_config = msm_fb_get_lane_config,
1306};
1307#endif
1308
1309static void __init msm_fb_add_devices(void)
1310{
1311 msm_fb_register_device("mdp", &mdp_pdata);
1312 msm_fb_register_device("lcdc", &lcdc_pdata);
Pankaj Kumarffdaec82011-09-26 12:24:45 +05301313#ifdef CONFIG_FB_MSM_MDP303
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001314 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
Pankaj Kumarffdaec82011-09-26 12:24:45 +05301315#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001316}
1317
1318#define MSM_EBI2_PHYS 0xa0d00000
1319#define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030
1320
1321static void __init msm7x27a_init_ebi2(void)
1322{
1323 uint32_t ebi2_cfg;
1324 void __iomem *ebi2_cfg_ptr;
1325
1326 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t));
1327 if (!ebi2_cfg_ptr)
1328 return;
1329
1330 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301331 if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() ||
1332 machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001333 ebi2_cfg |= (1 << 4); /* CS2 */
1334
1335 writel(ebi2_cfg, ebi2_cfg_ptr);
1336 iounmap(ebi2_cfg_ptr);
1337
1338 /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */
1339 ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1,
1340 sizeof(uint32_t));
1341 if (!ebi2_cfg_ptr)
1342 return;
1343
1344 ebi2_cfg = readl(ebi2_cfg_ptr);
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301345 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001346 ebi2_cfg |= (1 << 31);
1347
1348 writel(ebi2_cfg, ebi2_cfg_ptr);
1349 iounmap(ebi2_cfg_ptr);
1350}
1351
1352#define ATMEL_TS_I2C_NAME "maXTouch"
Justin Paupored98328e2011-08-19 13:48:31 -07001353
1354static struct regulator_bulk_data regs_atmel[] = {
1355 { .supply = "ldo2", .min_uV = 2850000, .max_uV = 2850000 },
1356 { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 },
1357};
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001358
1359#define ATMEL_TS_GPIO_IRQ 82
1360
1361static int atmel_ts_power_on(bool on)
1362{
Justin Paupored98328e2011-08-19 13:48:31 -07001363 int rc = on ?
1364 regulator_bulk_enable(ARRAY_SIZE(regs_atmel), regs_atmel) :
1365 regulator_bulk_disable(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001366
Justin Paupored98328e2011-08-19 13:48:31 -07001367 if (rc)
1368 pr_err("%s: could not %sable regulators: %d\n",
1369 __func__, on ? "en" : "dis", rc);
1370 else
1371 msleep(50);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001372
Justin Paupored98328e2011-08-19 13:48:31 -07001373 return rc;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001374}
1375
1376static int atmel_ts_platform_init(struct i2c_client *client)
1377{
1378 int rc;
Justin Paupored98328e2011-08-19 13:48:31 -07001379 struct device *dev = &client->dev;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001380
Justin Paupored98328e2011-08-19 13:48:31 -07001381 rc = regulator_bulk_get(dev, ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001382 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -07001383 dev_err(dev, "%s: could not get regulators: %d\n",
1384 __func__, rc);
1385 goto out;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001386 }
1387
Justin Paupored98328e2011-08-19 13:48:31 -07001388 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001389 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -07001390 dev_err(dev, "%s: could not set voltages: %d\n",
1391 __func__, rc);
1392 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001393 }
1394
1395 rc = gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
1396 GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
1397 GPIO_CFG_8MA), GPIO_CFG_ENABLE);
1398 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -07001399 dev_err(dev, "%s: gpio_tlmm_config for %d failed\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001400 __func__, ATMEL_TS_GPIO_IRQ);
Justin Paupored98328e2011-08-19 13:48:31 -07001401 goto reg_free;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001402 }
1403
1404 /* configure touchscreen interrupt gpio */
1405 rc = gpio_request(ATMEL_TS_GPIO_IRQ, "atmel_maxtouch_gpio");
1406 if (rc) {
Justin Paupored98328e2011-08-19 13:48:31 -07001407 dev_err(dev, "%s: unable to request gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001408 __func__, ATMEL_TS_GPIO_IRQ);
1409 goto ts_gpio_tlmm_unconfig;
1410 }
1411
1412 rc = gpio_direction_input(ATMEL_TS_GPIO_IRQ);
1413 if (rc < 0) {
Justin Paupored98328e2011-08-19 13:48:31 -07001414 dev_err(dev, "%s: unable to set the direction of gpio %d\n",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001415 __func__, ATMEL_TS_GPIO_IRQ);
1416 goto free_ts_gpio;
1417 }
1418 return 0;
1419
1420free_ts_gpio:
1421 gpio_free(ATMEL_TS_GPIO_IRQ);
1422ts_gpio_tlmm_unconfig:
1423 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
1424 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
1425 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -07001426reg_free:
1427 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
1428out:
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001429 return rc;
1430}
1431
1432static int atmel_ts_platform_exit(struct i2c_client *client)
1433{
1434 gpio_free(ATMEL_TS_GPIO_IRQ);
1435 gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0,
1436 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
1437 GPIO_CFG_2MA), GPIO_CFG_DISABLE);
Justin Paupored98328e2011-08-19 13:48:31 -07001438 regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001439 return 0;
1440}
1441
1442static u8 atmel_ts_read_chg(void)
1443{
1444 return gpio_get_value(ATMEL_TS_GPIO_IRQ);
1445}
1446
1447static u8 atmel_ts_valid_interrupt(void)
1448{
1449 return !atmel_ts_read_chg();
1450}
1451
1452#define ATMEL_X_OFFSET 13
1453#define ATMEL_Y_OFFSET 0
1454
Mohan Pallaka4e9a94e2011-11-23 16:34:21 +05301455static struct maxtouch_platform_data atmel_ts_pdata = {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001456 .numtouch = 4,
1457 .init_platform_hw = atmel_ts_platform_init,
1458 .exit_platform_hw = atmel_ts_platform_exit,
1459 .power_on = atmel_ts_power_on,
1460 .display_res_x = 480,
1461 .display_res_y = 864,
1462 .min_x = ATMEL_X_OFFSET,
1463 .max_x = (505 - ATMEL_X_OFFSET),
1464 .min_y = ATMEL_Y_OFFSET,
1465 .max_y = (863 - ATMEL_Y_OFFSET),
1466 .valid_interrupt = atmel_ts_valid_interrupt,
1467 .read_chg = atmel_ts_read_chg,
1468};
1469
1470static struct i2c_board_info atmel_ts_i2c_info[] __initdata = {
1471 {
1472 I2C_BOARD_INFO(ATMEL_TS_I2C_NAME, 0x4a),
1473 .platform_data = &atmel_ts_pdata,
1474 .irq = MSM_GPIO_TO_INT(ATMEL_TS_GPIO_IRQ),
1475 },
1476};
1477
1478#define KP_INDEX(row, col) ((row)*ARRAY_SIZE(kp_col_gpios) + (col))
1479
1480static unsigned int kp_row_gpios[] = {31, 32, 33, 34, 35};
1481static unsigned int kp_col_gpios[] = {36, 37, 38, 39, 40};
1482
1483static const unsigned short keymap[ARRAY_SIZE(kp_col_gpios) *
1484 ARRAY_SIZE(kp_row_gpios)] = {
1485 [KP_INDEX(0, 0)] = KEY_7,
1486 [KP_INDEX(0, 1)] = KEY_DOWN,
1487 [KP_INDEX(0, 2)] = KEY_UP,
1488 [KP_INDEX(0, 3)] = KEY_RIGHT,
1489 [KP_INDEX(0, 4)] = KEY_ENTER,
1490
1491 [KP_INDEX(1, 0)] = KEY_LEFT,
1492 [KP_INDEX(1, 1)] = KEY_SEND,
1493 [KP_INDEX(1, 2)] = KEY_1,
1494 [KP_INDEX(1, 3)] = KEY_4,
1495 [KP_INDEX(1, 4)] = KEY_CLEAR,
1496
1497 [KP_INDEX(2, 0)] = KEY_6,
1498 [KP_INDEX(2, 1)] = KEY_5,
1499 [KP_INDEX(2, 2)] = KEY_8,
1500 [KP_INDEX(2, 3)] = KEY_3,
1501 [KP_INDEX(2, 4)] = KEY_NUMERIC_STAR,
1502
1503 [KP_INDEX(3, 0)] = KEY_9,
1504 [KP_INDEX(3, 1)] = KEY_NUMERIC_POUND,
1505 [KP_INDEX(3, 2)] = KEY_0,
1506 [KP_INDEX(3, 3)] = KEY_2,
1507 [KP_INDEX(3, 4)] = KEY_SLEEP,
1508
1509 [KP_INDEX(4, 0)] = KEY_BACK,
1510 [KP_INDEX(4, 1)] = KEY_HOME,
1511 [KP_INDEX(4, 2)] = KEY_MENU,
1512 [KP_INDEX(4, 3)] = KEY_VOLUMEUP,
1513 [KP_INDEX(4, 4)] = KEY_VOLUMEDOWN,
1514};
1515
1516/* SURF keypad platform device information */
1517static struct gpio_event_matrix_info kp_matrix_info = {
1518 .info.func = gpio_event_matrix_func,
1519 .keymap = keymap,
1520 .output_gpios = kp_row_gpios,
1521 .input_gpios = kp_col_gpios,
1522 .noutputs = ARRAY_SIZE(kp_row_gpios),
1523 .ninputs = ARRAY_SIZE(kp_col_gpios),
1524 .settle_time.tv_nsec = 40 * NSEC_PER_USEC,
1525 .poll_time.tv_nsec = 20 * NSEC_PER_MSEC,
1526 .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE |
1527 GPIOKPF_PRINT_UNMAPPED_KEYS,
1528};
1529
1530static struct gpio_event_info *kp_info[] = {
1531 &kp_matrix_info.info
1532};
1533
1534static struct gpio_event_platform_data kp_pdata = {
1535 .name = "7x27a_kp",
1536 .info = kp_info,
1537 .info_count = ARRAY_SIZE(kp_info)
1538};
1539
1540static struct platform_device kp_pdev = {
1541 .name = GPIO_EVENT_DEV_NAME,
1542 .id = -1,
1543 .dev = {
1544 .platform_data = &kp_pdata,
1545 },
1546};
1547
1548static struct msm_handset_platform_data hs_platform_data = {
1549 .hs_name = "7k_handset",
1550 .pwr_key_delay_ms = 500, /* 0 will disable end key */
1551};
1552
1553static struct platform_device hs_pdev = {
1554 .name = "msm-handset",
1555 .id = -1,
1556 .dev = {
1557 .platform_data = &hs_platform_data,
1558 },
1559};
1560
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001561static struct platform_device msm_proccomm_regulator_dev = {
1562 .name = PROCCOMM_REGULATOR_DEV_NAME,
1563 .id = -1,
1564 .dev = {
1565 .platform_data = &msm7x27a_proccomm_regulator_data
1566 }
1567};
1568
Trilok Soni16f61af2011-07-26 16:06:58 +05301569static void __init msm7627a_rumi3_init(void)
1570{
1571 msm7x27a_init_ebi2();
1572 platform_add_devices(rumi_sim_devices,
1573 ARRAY_SIZE(rumi_sim_devices));
1574}
1575
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001576#define LED_GPIO_PDM 96
1577#define UART1DM_RX_GPIO 45
Santosh Sajjanb479f0f2011-08-18 21:00:44 +05301578
1579#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
1580static int __init msm7x27a_init_ar6000pm(void)
1581{
1582 return platform_device_register(&msm_wlan_ar6000_pm_device);
1583}
1584#else
1585static int __init msm7x27a_init_ar6000pm(void) { return 0; }
1586#endif
1587
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001588static void __init msm7x27a_init_regulators(void)
1589{
1590 int rc = platform_device_register(&msm_proccomm_regulator_dev);
1591 if (rc)
1592 pr_err("%s: could not register regulator device: %d\n",
1593 __func__, rc);
1594}
1595
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001596static void __init msm7x2x_init(void)
1597{
Trilok Sonia416c492011-07-22 20:20:23 +05301598 msm7x2x_misc_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001599
Justin Pauporeb3a33b72011-08-23 15:30:32 -07001600 /* Initialize regulators first so that other devices can use them */
1601 msm7x27a_init_regulators();
1602
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001603 /* Common functions for SURF/FFA/RUMI3 */
1604 msm_device_i2c_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001605 msm7x27a_init_ebi2();
1606 msm7x27a_cfg_uart2dm_serial();
1607#ifdef CONFIG_SERIAL_MSM_HS
1608 msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO);
1609 msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
1610#endif
1611
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001612#ifdef CONFIG_USB_MSM_OTG_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301613 msm_otg_pdata.swfi_latency =
1614 msm7x27a_pm_data
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001615 [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
Trilok Soni16f61af2011-07-26 16:06:58 +05301616 msm_device_otg.dev.platform_data = &msm_otg_pdata;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001617#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301618 msm_device_gadget_peripheral.dev.platform_data =
1619 &msm_gadget_pdata;
1620 msm7x27a_cfg_smsc911x();
1621 platform_add_devices(msm_footswitch_devices,
1622 msm_num_footswitch_devices);
1623 platform_add_devices(surf_ffa_devices,
1624 ARRAY_SIZE(surf_ffa_devices));
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301625 /* Ensure ar6000pm device is registered before MMC/SDC */
1626 msm7x27a_init_ar6000pm();
1627#ifdef CONFIG_MMC_MSM
Chintan Pandyacf467fc2011-12-01 17:11:11 +05301628 msm7627a_init_mmc();
Sujith Reddy Thummaad7c9a82011-09-30 20:54:38 +05301629#endif
Trilok Soni16f61af2011-07-26 16:06:58 +05301630 msm_fb_add_devices();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001631#ifdef CONFIG_USB_EHCI_MSM_72K
Trilok Soni16f61af2011-07-26 16:06:58 +05301632 msm7x2x_init_host();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001633#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001634
1635 msm_pm_set_platform_data(msm7x27a_pm_data,
1636 ARRAY_SIZE(msm7x27a_pm_data));
Maheshkumar Sivasubramanianc6c55032011-10-25 16:01:32 -06001637 BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001638
1639#if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X)
1640 register_i2c_devices();
1641#endif
1642#if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE)
Chintan Pandya13490c02011-12-20 13:03:36 +05301643 msm7627a_bt_power_init();
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001644#endif
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301645 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001646 atmel_ts_pdata.min_x = 0;
1647 atmel_ts_pdata.max_x = 480;
1648 atmel_ts_pdata.min_y = 0;
1649 atmel_ts_pdata.max_y = 320;
1650 }
1651
1652 i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
1653 atmel_ts_i2c_info,
1654 ARRAY_SIZE(atmel_ts_i2c_info));
1655
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301656#if defined(CONFIG_MSM_CAMERA)
Chintan Pandya40762702011-12-06 13:47:06 +05301657 msm7627a_camera_init();
Pankaj Kumar5be2a3e2011-09-26 11:45:02 +05301658#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001659 platform_device_register(&kp_pdev);
1660 platform_device_register(&hs_pdev);
1661
1662 /* configure it as a pdm function*/
1663 if (gpio_tlmm_config(GPIO_CFG(LED_GPIO_PDM, 3,
1664 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
1665 GPIO_CFG_8MA), GPIO_CFG_ENABLE))
1666 pr_err("%s: gpio_tlmm_config for %d failed\n",
1667 __func__, LED_GPIO_PDM);
1668 else
1669 platform_device_register(&led_pdev);
1670
1671#ifdef CONFIG_MSM_RPC_VIBRATOR
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301672 if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa())
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001673 msm_init_pmic_vibrator();
1674#endif
1675 /*7x25a kgsl initializations*/
1676 msm7x25a_kgsl_3d0_init();
1677}
1678
1679static void __init msm7x2x_init_early(void)
1680{
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001681 msm_msm7x2x_allocate_memory_regions();
1682}
1683
1684MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3")
1685 .boot_params = PHYS_OFFSET + 0x100,
1686 .map_io = msm_common_io_init,
1687 .reserve = msm7x27a_reserve,
1688 .init_irq = msm_init_irq,
Trilok Soni16f61af2011-07-26 16:06:58 +05301689 .init_machine = msm7627a_rumi3_init,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001690 .timer = &msm_timer,
1691 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301692 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001693MACHINE_END
1694MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF")
1695 .boot_params = PHYS_OFFSET + 0x100,
1696 .map_io = msm_common_io_init,
1697 .reserve = msm7x27a_reserve,
1698 .init_irq = msm_init_irq,
1699 .init_machine = msm7x2x_init,
1700 .timer = &msm_timer,
1701 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301702 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001703MACHINE_END
1704MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA")
1705 .boot_params = PHYS_OFFSET + 0x100,
1706 .map_io = msm_common_io_init,
1707 .reserve = msm7x27a_reserve,
1708 .init_irq = msm_init_irq,
1709 .init_machine = msm7x2x_init,
1710 .timer = &msm_timer,
1711 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301712 .handle_irq = vic_handle_irq,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001713MACHINE_END
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301714MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF")
1715 .boot_params = PHYS_OFFSET + 0x100,
1716 .map_io = msm_common_io_init,
1717 .reserve = msm7x27a_reserve,
1718 .init_irq = msm_init_irq,
1719 .init_machine = msm7x2x_init,
1720 .timer = &msm_timer,
1721 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301722 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301723MACHINE_END
1724MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA")
1725 .boot_params = PHYS_OFFSET + 0x100,
1726 .map_io = msm_common_io_init,
1727 .reserve = msm7x27a_reserve,
1728 .init_irq = msm_init_irq,
1729 .init_machine = msm7x2x_init,
1730 .timer = &msm_timer,
1731 .init_early = msm7x2x_init_early,
Taniya Das86e0e132011-10-19 11:32:00 +05301732 .handle_irq = vic_handle_irq,
Trilok Soni3d0f6c52011-07-26 16:06:58 +05301733MACHINE_END