jznomoney

Untitled

Mar 23rd, 2011
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 72.60 KB | None | 0 0
  1. /* linux/arch/arm/mach-msm/board-vivo.c
  2. *
  3. * Copyright (C) 2009 Google, Inc.
  4. * Copyright (C) 2010 HTC Corporation.
  5. * Author: Andy Liu <[email protected]>
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17.  
  18. #include <linux/delay.h>
  19. #include <linux/gpio.h>
  20. #include <linux/init.h>
  21. #include <linux/io.h>
  22. #include <linux/kernel.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/input.h>
  25. #include <linux/android_pmem.h>
  26. #include <linux/mfd/pmic8058.h>
  27. #include <linux/mfd/marimba.h>
  28. #include <linux/i2c.h>
  29. #include <linux/i2c-msm.h>
  30. #include <linux/spi/spi.h>
  31. #include <mach/qdsp5v2/msm_lpa.h>
  32. #include <linux/akm8975.h>
  33. #include <linux/bma150.h>
  34. #include <linux/capella_cm3602.h>
  35. #include <linux/cm3628.h>
  36. #include <linux/lightsensor.h>
  37. #include <linux/atmel_qt602240.h>
  38. #include <linux/cy8c_tma_ts.h>
  39. #include <linux/pmic8058-pwm.h>
  40. #include <linux/leds-pm8058.h>
  41. #include <linux/input/pmic8058-keypad.h>
  42. #include <linux/proc_fs.h>
  43. #include <asm/mach-types.h>
  44. #include <asm/mach/arch.h>
  45. #include <asm/mach/map.h>
  46. #include <asm/setup.h>
  47. #include <asm/mach/flash.h>
  48. #include <mach/msm_flashlight.h>
  49.  
  50. #include <mach/system.h>
  51. #include <mach/gpio.h>
  52. #include <mach/board.h>
  53. #include <mach/board_htc.h>
  54. #include <mach/msm_serial_hs.h>
  55.  
  56. #include <mach/htc_usb.h>
  57. #include <mach/hardware.h>
  58. #include <mach/msm_hsusb.h>
  59. #include <mach/rpc_hsusb.h>
  60. #include <mach/msm_spi.h>
  61. #include <mach/dma.h>
  62. #include <mach/msm_iomap.h>
  63. #include <mach/perflock.h>
  64. #include <mach/msm_serial_debugger.h>
  65. #include <mach/remote_spinlock.h>
  66. #include <mach/msm_panel.h>
  67. #include <mach/vreg.h>
  68. #include <mach/htc_battery.h>
  69. #include <mach/tpa2051d3.h>
  70. #include <mach/rpc_pmapp.h>
  71. #include <mach/htc_headset_mgr.h>
  72. #include <mach/htc_headset_gpio.h>
  73. #include <mach/htc_headset_pmic.h>
  74.  
  75. #include "pmic.h"
  76. #include "board-vivo.h"
  77. #include "devices.h"
  78. #include "proc_comm.h"
  79. #include "smd_private.h"
  80. #include "spm.h"
  81. #include "pm.h"
  82. #include "socinfo.h"
  83. #ifdef CONFIG_MSM_SSBI
  84. #include <mach/msm_ssbi.h>
  85. #endif
  86.  
  87. #define PMIC_GPIO_INT 27
  88.  
  89.  
  90. static uint opt_disable_uart2;
  91. module_param_named(disable_uart2, opt_disable_uart2, uint, 0);
  92.  
  93. static uint32_t usb_ID_PIN_input_table[] = {
  94. PCOM_GPIO_CFG(VIVO_GPIO_USB_ID_PIN, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_4MA),
  95. PCOM_GPIO_CFG(VIVO_GPIO_USB_ID1_PIN, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_4MA),
  96. };
  97.  
  98. static uint32_t usb_ID_PIN_ouput_table[] = {
  99. PCOM_GPIO_CFG(VIVO_GPIO_USB_ID_PIN, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA),
  100. };
  101.  
  102.  
  103. void config_vivo_usb_id_gpios(bool output)
  104. {
  105. if (output) {
  106. config_gpio_table(usb_ID_PIN_ouput_table, ARRAY_SIZE(usb_ID_PIN_ouput_table));
  107. gpio_set_value(VIVO_GPIO_USB_ID_PIN, 1);
  108. printk(KERN_INFO "%s %d output high\n", __func__, VIVO_GPIO_USB_ID_PIN);
  109. } else {
  110. config_gpio_table(usb_ID_PIN_input_table, ARRAY_SIZE(usb_ID_PIN_input_table));
  111. printk(KERN_INFO "%s %d input none pull\n", __func__, VIVO_GPIO_USB_ID_PIN);
  112. }
  113. }
  114.  
  115. void vivo_change_phy_voltage(int cable_in)
  116. {
  117. struct vreg *vreg = vreg_get(0, "usb");
  118. if (!vreg) {
  119. printk(KERN_INFO "%s: vreg_get error\n", __func__);
  120. return;
  121. }
  122. printk(KERN_INFO "%s %d\n", __func__, cable_in);
  123. if (cable_in) {
  124. vreg_disable(vreg);
  125. vreg_set_level(vreg, 3450);
  126. vreg_enable(vreg);
  127. } else {
  128. vreg_disable(vreg);
  129. vreg_set_level(vreg, 3300);
  130. vreg_enable(vreg);
  131. }
  132. }
  133.  
  134. #ifdef CONFIG_USB_ANDROID
  135. static void vivo_disable_usb_charger(void)
  136. {
  137. printk(KERN_INFO "%s\n", __func__);
  138. htc_battery_charger_disable();
  139. }
  140.  
  141. static int phy_init_seq[] = { 0x06, 0x36, 0x0C, 0x31, 0x31, 0x32, 0x1, 0x0D, 0x1, 0x10, -1 };
  142. static struct msm_hsusb_platform_data msm_hsusb_pdata = {
  143. .phy_init_seq = phy_init_seq,
  144. .phy_reset = msm_hsusb_phy_reset,
  145. .usb_id_pin_gpio = VIVO_GPIO_USB_ID_PIN,
  146. .accessory_detect = 1, /* detect by USB ID pin */
  147. .change_phy_voltage = vivo_change_phy_voltage,
  148. .disable_usb_charger = vivo_disable_usb_charger,
  149. };
  150.  
  151. static struct usb_mass_storage_platform_data mass_storage_pdata = {
  152. .nluns = 1,
  153. .vendor = "HTC",
  154. .product = "Android Phone",
  155. .release = 0x0100,
  156. };
  157.  
  158. static struct platform_device usb_mass_storage_device = {
  159. .name = "usb_mass_storage",
  160. .id = -1,
  161. .dev = {
  162. .platform_data = &mass_storage_pdata,
  163. },
  164. };
  165.  
  166. static struct android_usb_platform_data android_usb_pdata = {
  167. .vendor_id = 0x0bb4,
  168. .product_id = 0x0cac,
  169. .version = 0x0100,
  170. .product_name = "Android Phone",
  171. .manufacturer_name = "HTC",
  172. .num_products = ARRAY_SIZE(usb_products),
  173. .products = usb_products,
  174. .num_functions = ARRAY_SIZE(usb_functions_all),
  175. .functions = usb_functions_all,
  176. };
  177.  
  178. static struct platform_device android_usb_device = {
  179. .name = "android_usb",
  180. .id = -1,
  181. .dev = {
  182. .platform_data = &android_usb_pdata,
  183. },
  184. };
  185.  
  186. void vivo_add_usb_devices(void)
  187. {
  188. android_usb_pdata.products[0].product_id =
  189. android_usb_pdata.product_id;
  190. msm_hsusb_pdata.serial_number = board_serialno();
  191. android_usb_pdata.serial_number = board_serialno();
  192. msm_device_hsusb.dev.platform_data = &msm_hsusb_pdata;
  193. config_vivo_usb_id_gpios(0);
  194. platform_device_register(&msm_device_hsusb);
  195. platform_device_register(&usb_mass_storage_device);
  196. platform_device_register(&android_usb_device);
  197. }
  198. #endif
  199.  
  200. static int flashlight_control(int mode)
  201. {
  202. return aat1271_flashlight_control(mode);
  203. }
  204.  
  205. static void config_vivo_flashlight_gpios(void)
  206. {
  207. uint32_t flashlight_gpio_table[] = {
  208. PCOM_GPIO_CFG(VIVO_GPIO_TORCH_EN, 0, GPIO_OUTPUT,
  209. GPIO_NO_PULL, GPIO_2MA),
  210. };
  211. config_gpio_table(flashlight_gpio_table,
  212. ARRAY_SIZE(flashlight_gpio_table));
  213.  
  214. pm8058_gpio_cfg(VIVO_GPIO_FLASH_EN, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, 0, PM_GPIO_PULL_NO, PM_GPIO_VIN_L5, PM_GPIO_STRENGTH_HIGH, PM_GPIO_FUNC_NORMAL, 0);
  215. }
  216.  
  217. static void config_vivo_emmc_gpios(void)
  218. {
  219. uint32_t emmc_gpio_table[] = {
  220. PCOM_GPIO_CFG(VIVO_GPIO_EMMC_RST, 0, GPIO_OUTPUT,
  221. GPIO_NO_PULL, GPIO_8MA),
  222. };
  223. config_gpio_table(emmc_gpio_table,
  224. ARRAY_SIZE(emmc_gpio_table));
  225. }
  226.  
  227. static struct flashlight_platform_data vivo_flashlight_data = {
  228. .gpio_init = config_vivo_flashlight_gpios,
  229. .torch = VIVO_GPIO_TORCH_EN,
  230. .flash = PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_FLASH_EN),
  231. .flash_duration_ms = 600,
  232. .led_count = 1,
  233. };
  234.  
  235. static struct platform_device vivo_flashlight_device = {
  236. .name = FLASHLIGHT_NAME,
  237. .dev = {
  238. .platform_data = &vivo_flashlight_data,
  239. },
  240. };
  241.  
  242. static int pm8058_gpios_init(struct pm8058_chip *pm_chip)
  243. {
  244. /* touch panel */
  245. pm8058_gpio_cfg(VIVO_GPIO_TP_INT_N, PM_GPIO_DIR_IN, 0, 0, PM_GPIO_PULL_UP_31P5,
  246. PM_GPIO_VIN_L5, 0, PM_GPIO_FUNC_NORMAL, 0);
  247. pm8058_gpio_cfg(VIVO_TP_RSTz, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, 1, PM_GPIO_PULL_NO,
  248. PM_GPIO_VIN_L5, PM_GPIO_STRENGTH_HIGH, PM_GPIO_FUNC_NORMAL, 0);
  249.  
  250. /* led */
  251. pm8058_gpio_cfg(VIVO_GREEN_LED, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, 1, PM_GPIO_PULL_NO,
  252. PM_GPIO_VIN_L5, PM_GPIO_STRENGTH_HIGH, PM_GPIO_FUNC_2, 0);
  253. pm8058_gpio_cfg(VIVO_AMBER_LED, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, 1, PM_GPIO_PULL_NO,
  254. PM_GPIO_VIN_L5, PM_GPIO_STRENGTH_HIGH, PM_GPIO_FUNC_2, 0);
  255. //pm8058_gpio_cfg(VIVO_KEYPAD_LED, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, 0, PM_GPIO_PULL_NO,
  256. // PM_GPIO_VIN_S3, PM_GPIO_STRENGTH_HIGH, PM_GPIO_FUNC_2, 0);
  257.  
  258. /* direct key */
  259. pm8058_gpio_cfg(VIVO_VOL_UP, PM_GPIO_DIR_IN, 0, 0, PM_GPIO_PULL_UP_31P5, PM_GPIO_VIN_S3, 0, PM_GPIO_FUNC_NORMAL, 0);
  260. pm8058_gpio_cfg(VIVO_VOL_DN, PM_GPIO_DIR_IN, 0, 0, PM_GPIO_PULL_UP_31P5, PM_GPIO_VIN_S3, 0, PM_GPIO_FUNC_NORMAL, 0);
  261.  
  262. /* sd detect */
  263. pm8058_gpio_cfg(VIVO_GPIO_SDMC_CD_N, PM_GPIO_DIR_IN, 0, 0, PM_GPIO_PULL_UP_31P5, PM_GPIO_VIN_L5, 0, PM_GPIO_FUNC_NORMAL, 0);
  264.  
  265.  
  266. /* audio */
  267. //pm8058_gpio_cfg(VIVO_AUD_SPK_ENO, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, 0, PM_GPIO_PULL_NO,
  268. // PM_GPIO_VIN_L5, PM_GPIO_STRENGTH_HIGH, PM_GPIO_FUNC_NORMAL, 0);
  269. //pm8058_gpio_cfg(VIVO_AUD_HANDSET_ENO, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, 0, PM_GPIO_PULL_NO,
  270. // PM_GPIO_VIN_L5, PM_GPIO_STRENGTH_HIGH, PM_GPIO_FUNC_NORMAL, 0);
  271.  
  272. /* P-sensor and light sensor */
  273. pm8058_gpio_cfg(VIVO_GPIO_PS_EN, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, 0, PM_GPIO_PULL_NO,
  274. PM_GPIO_VIN_L5, PM_GPIO_STRENGTH_HIGH, PM_GPIO_FUNC_NORMAL, 0);
  275. pm8058_gpio_cfg(VIVO_GPIO_LS_EN, PM_GPIO_DIR_OUT, PM_GPIO_OUT_BUF_CMOS, 0, PM_GPIO_PULL_NO,
  276. PM_GPIO_VIN_L5, PM_GPIO_STRENGTH_HIGH, PM_GPIO_FUNC_NORMAL, 0);
  277. if (system_rev == 0)
  278. pm8058_gpio_cfg(VIVO_GPIO_PS_INT_N, PM_GPIO_DIR_IN, 0, 0, PM_GPIO_PULL_DN, PM_GPIO_VIN_L5, 0, PM_GPIO_FUNC_NORMAL, 0);
  279. else
  280. pm8058_gpio_cfg(VIVO_GPIO_PS_INT_N, PM_GPIO_DIR_IN, 0, 0, PM_GPIO_PULL_UP_31P5, PM_GPIO_VIN_L5, 0, PM_GPIO_FUNC_NORMAL, 0);
  281.  
  282. if (system_rev >= 1) {
  283. /* G Sensor INT*/
  284. pm8058_gpio_cfg(VIVO_GPIO_GSENSOR_INT, PM_GPIO_DIR_IN, 0, 0, PM_GPIO_PULL_NO, PM_GPIO_VIN_L5, 0, PM_GPIO_FUNC_NORMAL, 0);
  285. /* E-Compass INT */
  286. pm8058_gpio_cfg(VIVO_GPIO_COMPASS_INT_N, PM_GPIO_DIR_IN, 0, 0, PM_GPIO_PULL_NO, PM_GPIO_VIN_L5, 0, PM_GPIO_FUNC_NORMAL, 0);
  287. }
  288. return 0;
  289. }
  290.  
  291. /* HTC_HEADSET_GPIO Driver */
  292. static struct htc_headset_gpio_platform_data htc_headset_gpio_data = {
  293. .hpin_gpio = VIVO_GPIO_35MM_HEADSET_DET,
  294. .key_enable_gpio = 0,
  295. .mic_select_gpio = 0,
  296. };
  297.  
  298. static struct platform_device htc_headset_gpio = {
  299. .name = "HTC_HEADSET_GPIO",
  300. .id = -1,
  301. .dev = {
  302. .platform_data = &htc_headset_gpio_data,
  303. },
  304. };
  305.  
  306. /* HTC_HEADSET_PMIC Driver */
  307. static struct htc_headset_pmic_platform_data htc_headset_pmic_data = {
  308. .driver_flag = DRIVER_HS_PMIC_RPC_KEY |
  309. DRIVER_HS_PMIC_DYNAMIC_THRESHOLD,
  310. .hpin_gpio = 0,
  311. .hpin_irq = 0,
  312. .adc_mic = 14894,
  313. .adc_remote = {0, 2502, 2860, 6822, 9086, 13614},
  314. .hs_controller = HS_PMIC_CONTROLLER_2,
  315. .hs_switch = HS_PMIC_SC_SWITCH_TYPE,
  316. };
  317.  
  318. static struct platform_device htc_headset_pmic = {
  319. .name = "HTC_HEADSET_PMIC",
  320. .id = -1,
  321. .dev = {
  322. .platform_data = &htc_headset_pmic_data,
  323. },
  324. };
  325.  
  326. /* HTC_HEADSET_MGR Driver */
  327. static struct platform_device *headset_devices[] = {
  328. &htc_headset_pmic,
  329. &htc_headset_gpio,
  330. /* Please put the headset detection driver on the last */
  331. };
  332.  
  333. static struct htc_headset_mgr_platform_data htc_headset_mgr_data = {
  334. .driver_flag = DRIVER_HS_MGR_RPC_SERVER,
  335. .headset_devices_num = ARRAY_SIZE(headset_devices),
  336. .headset_devices = headset_devices,
  337. };
  338.  
  339. static struct platform_device htc_headset_mgr = {
  340. .name = "HTC_HEADSET_MGR",
  341. .id = -1,
  342. .dev = {
  343. .platform_data = &htc_headset_mgr_data,
  344. },
  345. };
  346.  
  347. static struct htc_battery_platform_data htc_battery_pdev_data = {
  348. .guage_driver = GUAGE_MODEM,
  349. .charger = SWITCH_CHARGER,
  350. .m2a_cable_detect = 1,
  351. .int_data.chg_int = MSM_GPIO_TO_INT(VIVO_GPIO_CHG_INT),
  352. };
  353.  
  354. static struct platform_device htc_battery_pdev = {
  355. .name = "htc_battery",
  356. .id = -1,
  357. .dev = {
  358. .platform_data = &htc_battery_pdev_data,
  359. },
  360. };
  361.  
  362. static int capella_cm3602_power(int pwr_device, uint8_t enable);
  363.  
  364. /*static struct microp_led_config led_config[] = {
  365. {
  366. .name = "amber",
  367. .type = LED_RGB,
  368. },
  369. {
  370. .name = "green",
  371. .type = LED_RGB,
  372. },
  373. {
  374. .name = "button-backlight",
  375. .type = LED_PWM,
  376. .led_pin = 1 << 0,
  377. .init_value = 0xFF,
  378. .fade_time = 5,
  379. },
  380.  
  381. };
  382.  
  383. static struct microp_led_platform_data microp_leds_data = {
  384. .num_leds = ARRAY_SIZE(led_config),
  385. .led_config = led_config,
  386. };*/
  387.  
  388.  
  389. static struct pm8058_led_config pm_led_config[] = {
  390. {
  391. .name = "green",
  392. .type = PM8058_LED_RGB,
  393. .bank = 0,
  394. .pwm_size = 9,
  395. .clk = PM_PWM_CLK_32KHZ,
  396. .pre_div = PM_PWM_PREDIVIDE_2,
  397. .pre_div_exp = 1,
  398. .pwm_value = 511,
  399. },
  400. {
  401. .name = "amber",
  402. .type = PM8058_LED_RGB,
  403. .bank = 1,
  404. .pwm_size = 9,
  405. .clk = PM_PWM_CLK_32KHZ,
  406. .pre_div = PM_PWM_PREDIVIDE_2,
  407. .pre_div_exp = 1,
  408. .pwm_value = 511,
  409. },
  410. {
  411. .name = "button-backlight-portrait",
  412. .type = PM8058_LED_DRVX,
  413. .bank = 4,
  414. .flags = PM8058_LED_DYNAMIC_BRIGHTNESS_EN,
  415. .out_current = 20,
  416. },
  417. {
  418. .name = "button-backlight-landscape",
  419. .type = PM8058_LED_DRVX,
  420. .bank = 5,
  421. .flags = PM8058_LED_DYNAMIC_BRIGHTNESS_EN,
  422. .out_current = 20,
  423. },
  424. };
  425.  
  426. static struct pm8058_led_config pm_led_config_xb[] = {
  427. {
  428. .name = "amber",
  429. .type = PM8058_LED_CURRENT,
  430. .bank = 3,
  431. .flags = PM8058_LED_BLINK_EN,
  432. .out_current = 200,
  433. },
  434. {
  435. .name = "button-backlight-portrait",
  436. .type = PM8058_LED_DRVX,
  437. .bank = 4,
  438. .flags = PM8058_LED_DYNAMIC_BRIGHTNESS_EN,
  439. .out_current = 20,
  440. },
  441. {
  442. .name = "button-backlight-landscape",
  443. .type = PM8058_LED_DRVX,
  444. .bank = 5,
  445. .flags = PM8058_LED_DYNAMIC_BRIGHTNESS_EN,
  446. .out_current = 20,
  447. },
  448. {
  449. .name = "green",
  450. .type = PM8058_LED_DRVX,
  451. .bank = 6,
  452. .flags = PM8058_LED_BLINK_EN,
  453. .out_current = 4,
  454. },
  455. };
  456.  
  457. static struct pm8058_led_platform_data pm8058_leds_data = {
  458. .led_config = pm_led_config_xb,
  459. .num_leds = ARRAY_SIZE(pm_led_config_xb),
  460. .duties = {0, 5, 10, 15, 20, 25, 30, 30,
  461. 30, 25, 20, 15, 10, 5, 5, 0,
  462. 90, 0, 90, 0, 90, 0, 90, 0,
  463. 90, 0, 90, 0, 90, 0, 90, 0,
  464. 90, 0, 0, 0, 0, 0, 0, 0,
  465. 0, 0, 0, 0, 0, 0, 0, 0,
  466. 0, 0, 0, 0, 0, 0, 0, 0,
  467. 0, 0, 0, 0, 0, 0, 0, 0},
  468. };
  469.  
  470. static struct platform_device pm8058_leds = {
  471. .name = "leds-pm8058",
  472. .id = -1,
  473. .dev = {
  474. .platform_data = &pm8058_leds_data,
  475. },
  476. };
  477.  
  478. static struct akm8975_platform_data compass_platform_data = {
  479. .layouts = VIVO_LAYOUTS,
  480. };
  481.  
  482. static struct bma150_platform_data gsensor_platform_data = {
  483. .intr = VIVO_GPIO_GSENSOR_INT,
  484. .chip_layout = 1,
  485. };
  486.  
  487. static struct tpa2051d3_platform_data tpa2051d3_platform_data = {
  488. //.gpio_tpa2051_spk_en = VIVO_AUD_SPK_ENO,
  489. };
  490.  
  491. static int config_vivo_proximity_gpios(int on)
  492. {
  493. int ret, pull_state;
  494.  
  495. if (on)
  496. pull_state = PM_GPIO_PULL_NO;
  497. else
  498. pull_state = PM_GPIO_PULL_DN;
  499.  
  500. ret = pm8058_gpio_cfg(VIVO_GPIO_PS_INT_N, PM_GPIO_DIR_IN, 0, 0, pull_state,
  501. PM_GPIO_VIN_L5, 0, PM_GPIO_FUNC_NORMAL, 0);
  502. if (ret)
  503. pr_err("%s PMIC GPIO P-sensor interrupt write failed\n", __func__);
  504. return ret;
  505. }
  506.  
  507. static int __capella_cm3602_power(int on)
  508. {
  509. int rc;
  510. struct vreg *vreg = vreg_get(0, "gp7");
  511.  
  512. if (!vreg) {
  513. printk(KERN_ERR "%s: vreg error\n", __func__);
  514. return -EIO;
  515. }
  516. rc = vreg_set_level(vreg, 2850);
  517.  
  518. printk(KERN_DEBUG "%s: Turn the capella_cm3602 power %s\n",
  519. __func__, (on) ? "on" : "off");
  520.  
  521. if (on) {
  522. config_vivo_proximity_gpios(1);
  523.  
  524. rc = gpio_direction_output(
  525. PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_PS_EN), 1);
  526. if (rc < 0)
  527. printk(KERN_ERR "%s: gpio_direction_output failed\n",
  528. __func__);
  529.  
  530. rc = vreg_enable(vreg);
  531. if (rc < 0)
  532. printk(KERN_ERR "%s: vreg enable failed\n", __func__);
  533. } else {
  534. rc = vreg_disable(vreg);
  535. if (rc < 0)
  536. printk(KERN_ERR "%s: vreg disable failed\n", __func__);
  537.  
  538. /* For proximity enable PMIC GPIO */
  539. rc = pm8058_gpio_cfg(VIVO_GPIO_PS_EN, PM_GPIO_DIR_IN, 0, 0,
  540. PM_GPIO_PULL_DN, PM_GPIO_VIN_L5, 0, PM_GPIO_FUNC_NORMAL, 0);
  541. if (rc) {
  542. pr_err("%s PMIC GPIO P-sensor enable PMIC GPIO write"
  543. " failed\n", __func__);
  544. return rc;
  545. }
  546. config_vivo_proximity_gpios(0);
  547. }
  548.  
  549. return rc;
  550. }
  551.  
  552. static DEFINE_MUTEX(capella_cm3602_lock);
  553. static int als_power_control;
  554.  
  555. static int capella_cm3602_power(int pwr_device, uint8_t enable)
  556. {
  557. unsigned int old_status = 0;
  558. int ret = 0, on = 0;
  559. mutex_lock(&capella_cm3602_lock);
  560.  
  561. old_status = als_power_control;
  562. if (enable)
  563. als_power_control |= pwr_device;
  564. else
  565. als_power_control &= ~pwr_device;
  566.  
  567. on = als_power_control ? 1 : 0;
  568. if (old_status == 0 && on)
  569. ret = __capella_cm3602_power(1);
  570. else if (!on)
  571. ret = __capella_cm3602_power(0);
  572.  
  573. mutex_unlock(&capella_cm3602_lock);
  574. return ret;
  575. }
  576.  
  577. static struct capella_cm3602_platform_data capella_cm3602_pdata = {
  578. .power = capella_cm3602_power,
  579. .p_en = PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_PS_EN),
  580. .p_out = PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_PS_INT_N),
  581. .irq = MSM_GPIO_TO_INT(PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_PS_INT_N)),
  582. };
  583.  
  584. static struct platform_device capella_cm3602 = {
  585. .name = CAPELLA_CM3602,
  586. .id = -1,
  587. .dev = {
  588. .platform_data = &capella_cm3602_pdata
  589. }
  590. };
  591.  
  592. static struct lightsensor_smd_platform_data lightsensor_data = {
  593. .levels = { 0x0, 0x0, 0x0, 0x3A3, 0x97B, 0x1873, 0x2B21, 0x3CC8,
  594. 0x4E70, 0xFFFF },
  595. .golden_adc = 0x1D98,
  596. .ls_power = capella_cm3602_power,
  597. };
  598.  
  599. static struct platform_device lightsensor_pdev = {
  600. .name = "lightsensor_smd",
  601. .id = -1,
  602. .dev = {
  603. .platform_data = &lightsensor_data
  604. }
  605. };
  606.  
  607. #ifdef CONFIG_INPUT_CAPELLA_CM3628
  608. static DEFINE_MUTEX(capella_cm3628_lock);
  609. static int als_power_control;
  610. static int __capella_cm3628_power(int on)
  611. {
  612. int rc;
  613. struct vreg *vreg = vreg_get(0, "gp7");
  614.  
  615. if (!vreg) {
  616. printk(KERN_ERR "%s: vreg error\n", __func__);
  617. return -EIO;
  618. }
  619. rc = vreg_set_level(vreg, 2850);
  620.  
  621. printk(KERN_DEBUG "%s: Turn the capella_cm3628 power %s\n",
  622. __func__, (on) ? "on" : "off");
  623.  
  624. if (on) {
  625. rc = vreg_enable(vreg);
  626. if (rc < 0)
  627. printk(KERN_ERR "%s: vreg enable failed\n", __func__);
  628. } else {
  629. rc = vreg_disable(vreg);
  630. if (rc < 0)
  631. printk(KERN_ERR "%s: vreg disable failed\n", __func__);
  632. }
  633.  
  634. return rc;
  635. }
  636.  
  637. static int capella_cm3628_power(int pwr_device, uint8_t enable)
  638. {
  639. unsigned int old_status = 0;
  640. int ret = 0, on = 0;
  641. mutex_lock(&capella_cm3628_lock);
  642.  
  643. old_status = als_power_control;
  644. if (enable)
  645. als_power_control |= pwr_device;
  646. else
  647. als_power_control &= ~pwr_device;
  648.  
  649. on = als_power_control ? 1 : 0;
  650. if (old_status == 0 && on)
  651. ret = __capella_cm3628_power(1);
  652. else if (!on)
  653. ret = __capella_cm3628_power(0);
  654.  
  655. mutex_unlock(&capella_cm3628_lock);
  656. return ret;
  657. }
  658.  
  659. static struct cm3628_platform_data cm3628_pdata = {
  660. .intr = PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_PS_INT_N),
  661. .levels = { 0, 0, 0, 0x16, 0x2D, 0x2C4,
  662. 0x3CA, 0x447, 0x4C4, 0xFFFF},
  663. .golden_adc = 0x375,
  664. .power = capella_cm3628_power,
  665. .ALS_slave_address = 0x30>>1,
  666. .PS_slave_address = 0x32>>1,
  667. .check_interrupt_add = 0x18>>1,
  668. .ps_thd_set = 0x3,
  669. .ps_conf2_val = 0,
  670. .ps_conf1_val = CM3628_PS_DR_1_320 |CM3628_PS_IT_1T,
  671. };
  672.  
  673. static struct i2c_board_info i2c_CM3628_devices[] = {
  674. {
  675. I2C_BOARD_INFO(CM3628_I2C_NAME, 0x30 >> 1),
  676. .platform_data = &cm3628_pdata,
  677. .irq = MSM_GPIO_TO_INT(PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_PS_INT_N)),
  678. },
  679. };
  680. #endif
  681.  
  682. static int vivo_ts_power(int on)
  683. {
  684. pr_info("%s: power %d\n", __func__, on);
  685.  
  686. if (on == 1) {
  687. gpio_set_value(VIVO_GPIO_TP_EN, 1);
  688. msleep(5);
  689. gpio_set_value(PM8058_GPIO_PM_TO_SYS(VIVO_TP_RSTz), 1);
  690. } else if (on == 2) {
  691. gpio_set_value(PM8058_GPIO_PM_TO_SYS(VIVO_TP_RSTz), 0);
  692. msleep(5);
  693. gpio_set_value(PM8058_GPIO_PM_TO_SYS(VIVO_TP_RSTz), 1);
  694. msleep(40);
  695. }
  696.  
  697. return 0;
  698. }
  699.  
  700. struct atmel_i2c_platform_data vivo_ts_atmel_data[] = {
  701. {
  702. .version = 0x0020,
  703. .source = 1,
  704. .abs_x_min = 0,
  705. .abs_x_max = 1023,
  706. .abs_y_min = 0,
  707. .abs_y_max = 946,
  708. .abs_pressure_min = 0,
  709. .abs_pressure_max = 255,
  710. .abs_width_min = 0,
  711. .abs_width_max = 20,
  712. .gpio_irq = PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_TP_INT_N),
  713. .power = vivo_ts_power,
  714. .config_T6 = {0, 0, 0, 0, 0, 0},
  715. .config_T7 = {16, 15, 50},
  716. .config_T8 = {10, 0, 2, 2, 0, 0, 5, 15, 4, 170},
  717. .config_T9 = {139, 0, 0, 19, 11, 0, 16, 35, 3, 1, 0, 5, 2, 0, 4, 20, 10, 10, 0, 0, 0, 0, 248, 3, 25, 25, 140, 65, 136, 75, 15, 10},
  718. .config_T15 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  719. .config_T19 = {3, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0},
  720. .config_T20 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  721. .config_T22 = {15, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, 7, 38, 255, 255, 0},
  722. .config_T23 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  723. .config_T24 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  724. .config_T25 = {3, 0, 4, 41, 88, 27, 0, 0, 0, 0, 0, 0, 0, 0},
  725. .config_T27 = {0, 0, 0, 0, 0, 0, 0},
  726. .config_T28 = {0, 0, 3, 4, 8, 60},
  727. .object_crc = {0xFF, 0xA9, 0x45},
  728. .cable_config = {35, 25, 8, 16},
  729. .GCAF_level = {20, 24, 28, 40, 63},
  730. },
  731. {
  732. .version = 0x0020,
  733. .source = 0,
  734. .abs_x_min = 0,
  735. .abs_x_max = 1023,
  736. .abs_y_min = 0,
  737. .abs_y_max = 946,
  738. .abs_pressure_min = 0,
  739. .abs_pressure_max = 255,
  740. .abs_width_min = 0,
  741. .abs_width_max = 20,
  742. .gpio_irq = PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_TP_INT_N),
  743. .power = vivo_ts_power,
  744. .config_T6 = {0, 0, 0, 0, 0, 0},
  745. .config_T7 = {16, 15, 50},
  746. .config_T8 = {10, 0, 2, 2, 0, 0, 5, 15, 4, 170},
  747. .config_T9 = {139, 0, 0, 19, 11, 0, 16, 35, 3, 1, 0, 5, 2, 0, 4, 20, 10, 10, 0, 0, 0, 0, 248, 0, 35, 25, 140, 65, 140, 75, 15, 10},
  748. .config_T15 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  749. .config_T19 = {3, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0},
  750. .config_T20 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  751. .config_T22 = {15, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, 7, 38, 255, 255, 0},
  752. .config_T23 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  753. .config_T24 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  754. .config_T25 = {3, 0, 4, 41, 88, 27, 0, 0, 0, 0, 0, 0, 0, 0},
  755. .config_T27 = {0, 0, 0, 0, 0, 0, 0},
  756. .config_T28 = {0, 0, 3, 4, 8, 60},
  757. .object_crc = {0x6A, 0x55, 0x35},
  758. .cable_config = {35, 25, 8, 16},
  759. .GCAF_level = {20, 24, 28, 40, 63},
  760. },
  761. {
  762. .version = 0x0016,
  763. .source = 1,
  764. .abs_x_min = 0,
  765. .abs_x_max = 1023,
  766. .abs_y_min = 0,
  767. .abs_y_max = 946,
  768. .abs_pressure_min = 0,
  769. .abs_pressure_max = 255,
  770. .abs_width_min = 0,
  771. .abs_width_max = 20,
  772. .gpio_irq = PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_TP_INT_N),
  773. .power = vivo_ts_power,
  774. .config_T6 = {0, 0, 0, 0, 0, 0},
  775. .config_T7 = {16, 15, 50},
  776. .config_T8 = {10, 0, 2, 2, 0, 0, 5, 15},
  777. .config_T9 = {139, 0, 0, 19, 11, 0, 16, 35, 3, 1, 0, 5, 2, 0, 4, 20, 10, 10, 0, 0, 0, 0, 248, 3, 25, 25, 140, 65, 136, 75, 15},
  778. .config_T15 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  779. .config_T19 = {3, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0},
  780. .config_T20 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  781. .config_T22 = {15, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, 7, 38, 255, 255, 0},
  782. .config_T23 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  783. .config_T24 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  784. .config_T25 = {3, 0, 4, 41, 88, 27, 0, 0, 0, 0, 0, 0, 0, 0},
  785. .config_T27 = {0, 0, 0, 0, 0, 0, 0},
  786. .config_T28 = {0, 0, 3, 4, 8, 60},
  787. .object_crc = {0x07, 0xA4, 0xE8},
  788. .cable_config = {35, 25, 8, 16},
  789. },
  790. {
  791. .version = 0x0016,
  792. .source = 0,
  793. .abs_x_min = 0,
  794. .abs_x_max = 1023,
  795. .abs_y_min = 0,
  796. .abs_y_max = 946,
  797. .abs_pressure_min = 0,
  798. .abs_pressure_max = 255,
  799. .abs_width_min = 0,
  800. .abs_width_max = 20,
  801. .gpio_irq = PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_TP_INT_N),
  802. .power = vivo_ts_power,
  803. .config_T6 = {0, 0, 0, 0, 0, 0},
  804. .config_T7 = {16, 15, 50},
  805. .config_T8 = {10, 0, 2, 2, 0, 0, 5, 15},
  806. .config_T9 = {139, 0, 0, 19, 11, 0, 16, 35, 3, 1, 0, 5, 2, 0, 4, 20, 10, 10, 0, 0, 0, 0, 248, 0, 35, 25, 140, 65, 140, 75, 15},
  807. .config_T15 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  808. .config_T19 = {3, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0},
  809. .config_T20 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  810. .config_T22 = {15, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, 7, 38, 255, 255, 0},
  811. .config_T23 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  812. .config_T24 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  813. .config_T25 = {3, 0, 4, 41, 88, 27, 0, 0, 0, 0, 0, 0, 0, 0},
  814. .config_T27 = {0, 0, 0, 0, 0, 0, 0},
  815. .config_T28 = {0, 0, 3, 4, 8, 60},
  816. .object_crc = {0x99, 0x40, 0x6F},
  817. .cable_config = {35, 25, 8, 16},
  818. },
  819. };
  820.  
  821. static int vivo_ts_cy8c_power(int on)
  822. {
  823. printk(KERN_INFO "%s():\n", __func__);
  824. if (on) {
  825. gpio_set_value(VIVO_GPIO_TP_EN, 1);
  826. msleep(5);
  827. gpio_set_value(PM8058_GPIO_PM_TO_SYS(VIVO_TP_RSTz), 1);
  828. }
  829. return 0;
  830. }
  831.  
  832. struct cy8c_i2c_platform_data vivo_ts_cy8c_data[] = {
  833. {
  834. .version = 0x03,
  835. .abs_x_min = 0,
  836. .abs_x_max = 1023,
  837. .abs_y_min = 0,
  838. .abs_y_max = 932,
  839. .abs_pressure_min = 0,
  840. .abs_pressure_max = 255,
  841. .abs_width_min = 0,
  842. .abs_width_max = 255,
  843. .power = vivo_ts_cy8c_power,
  844. .gpio_irq = PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_TP_INT_N),
  845. },
  846. {
  847. .version = 0x00,
  848. .abs_x_min = 0,
  849. .abs_x_max = 1023,
  850. .abs_y_min = 0,
  851. .abs_y_max = 932,
  852. .abs_pressure_min = 0,
  853. .abs_pressure_max = 255,
  854. .abs_width_min = 0,
  855. .abs_width_max = 255,
  856. .power = vivo_ts_cy8c_power,
  857. .gpio_irq = PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_TP_INT_N),
  858. .orient = 1,
  859. },
  860. };
  861.  
  862. static struct i2c_board_info i2c_devices[] = {
  863. {
  864. I2C_BOARD_INFO(ATMEL_QT602240_NAME, 0x94 >> 1),
  865. .platform_data = &vivo_ts_atmel_data,
  866. .irq = MSM_GPIO_TO_INT(PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_TP_INT_N))
  867. },
  868. {
  869. I2C_BOARD_INFO(CYPRESS_TMA_NAME, 0x67),
  870. .platform_data = &vivo_ts_cy8c_data,
  871. .irq = MSM_GPIO_TO_INT(PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_TP_INT_N))
  872. },
  873. {
  874. I2C_BOARD_INFO(TPA2051D3_I2C_NAME, 0xE0 >> 1),
  875. .platform_data = &tpa2051d3_platform_data,
  876. },
  877. {
  878. I2C_BOARD_INFO("tps65200", 0xD4 >> 1),
  879. },
  880. };
  881.  
  882.  
  883. static struct i2c_board_info i2c_Sensors_devices[] = {
  884. {
  885. I2C_BOARD_INFO(AKM8975_I2C_NAME, 0x1A >> 1),
  886. .platform_data = &compass_platform_data,
  887. .irq = MSM_GPIO_TO_INT(PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_COMPASS_INT_N)),
  888. },
  889. {
  890. I2C_BOARD_INFO(BMA150_I2C_NAME, 0x70 >> 1),
  891. .platform_data = &gsensor_platform_data,
  892. .irq = MSM_GPIO_TO_INT(PM8058_GPIO_PM_TO_SYS(VIVO_GPIO_GSENSOR_INT)),
  893. },
  894. };
  895.  
  896. static struct i2c_board_info msm_camera_boardinfo[] __initdata = {
  897. #ifdef CONFIG_S5K3H1GX
  898. {
  899. I2C_BOARD_INFO("s5k3h1gx", 0x20 >> 1),
  900. },
  901. #endif
  902. #ifdef CONFIG_S5K6AAFX
  903. {
  904. I2C_BOARD_INFO("s5k6aafx", 0x78 >> 1),
  905. },
  906. #endif
  907. };
  908.  
  909. static uint32_t camera_off_gpio_table[] = {
  910. PCOM_GPIO_CFG(CAM2_RST, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  911. PCOM_GPIO_CFG(CAM1_PWD, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  912. PCOM_GPIO_CFG(CAM2_PWD, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  913. PCOM_GPIO_CFG(4, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* DAT2 */
  914. PCOM_GPIO_CFG(5, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* DAT3 */
  915. PCOM_GPIO_CFG(6, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* DAT4 */
  916. PCOM_GPIO_CFG(7, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* DAT5 */
  917. PCOM_GPIO_CFG(8, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* DAT6 */
  918. PCOM_GPIO_CFG(9, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* DAT7 */
  919. PCOM_GPIO_CFG(10, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* DAT8 */
  920. PCOM_GPIO_CFG(11, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* DAT9 */
  921. PCOM_GPIO_CFG(12, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* PCLK */
  922. PCOM_GPIO_CFG(13, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* HSYNC_IN */
  923. PCOM_GPIO_CFG(14, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_8MA), /* VSYNC_IN */
  924. PCOM_GPIO_CFG(15, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_14MA), /* MCLK */
  925. };
  926.  
  927. static uint32_t camera_on_gpio_table[] = {
  928. #if 0
  929. PCOM_GPIO_CFG(CAM2_RST, 0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA),
  930. PCOM_GPIO_CFG(CAM1_PWD, 0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA),
  931. PCOM_GPIO_CFG(CAM2_PWD, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  932. #endif
  933. PCOM_GPIO_CFG(4, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT2 */
  934. PCOM_GPIO_CFG(5, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT3 */
  935. PCOM_GPIO_CFG(6, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT4 */
  936. PCOM_GPIO_CFG(7, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT5 */
  937. PCOM_GPIO_CFG(8, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT6 */
  938. PCOM_GPIO_CFG(9, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT7 */
  939. PCOM_GPIO_CFG(10, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT8 */
  940. PCOM_GPIO_CFG(11, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT9 */
  941. PCOM_GPIO_CFG(12, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* PCLK */
  942. PCOM_GPIO_CFG(13, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* HSYNC_IN */
  943. PCOM_GPIO_CFG(14, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* VSYNC_IN */
  944. PCOM_GPIO_CFG(15, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_16MA), /* MCLK */
  945. };
  946.  
  947.  
  948. static int sensor_power_enable(char *power, unsigned volt)
  949. {
  950. struct vreg *vreg_gp;
  951. int rc;
  952.  
  953. if (power == NULL)
  954. return EIO;
  955.  
  956. vreg_gp = vreg_get(NULL, power);
  957. if (IS_ERR(vreg_gp)) {
  958. pr_err("%s: vreg_get(%s) failed (%ld)\n",
  959. __func__, power, PTR_ERR(vreg_gp));
  960. return EIO;
  961. }
  962.  
  963. rc = vreg_set_level(vreg_gp, volt);
  964. if (rc) {
  965. pr_err("%s: vreg wlan set %s level failed (%d)\n",
  966. __func__, power, rc);
  967. return EIO;
  968. }
  969.  
  970. rc = vreg_enable(vreg_gp);
  971. if (rc) {
  972. pr_err("%s: vreg enable %s failed (%d)\n",
  973. __func__, power, rc);
  974. return EIO;
  975. }
  976. return rc;
  977. }
  978.  
  979. static int sensor_power_disable(char *power)
  980. {
  981. struct vreg *vreg_gp;
  982. int rc;
  983. vreg_gp = vreg_get(NULL, power);
  984. if (IS_ERR(vreg_gp)) {
  985. pr_err("%s: vreg_get(%s) failed (%ld)\n",
  986. __func__, power, PTR_ERR(vreg_gp));
  987. return EIO;
  988. }
  989.  
  990. rc = vreg_disable(vreg_gp);
  991. if (rc) {
  992. pr_err("%s: vreg disable %s failed (%d)\n",
  993. __func__, power, rc);
  994. return EIO;
  995. }
  996. return rc;
  997. }
  998.  
  999. static int sensor_vreg_on(void)
  1000. {
  1001. int rc;
  1002. pr_info("%s camera vreg on\n", __func__);
  1003.  
  1004. /* main camera VCM power */
  1005. rc = sensor_power_enable("gp4", 2850);
  1006. pr_info("sensor_power_enable(\"gp4\", 2850) == %d\n", rc);
  1007.  
  1008. /* main / 2nd camera analog power */
  1009. rc = sensor_power_enable("gp6", 2850);
  1010. pr_info("sensor_power_enable(\"gp6\", 2850) == %d\n", rc);
  1011. msleep(5);
  1012.  
  1013. /* main / 2nd camera digital power */
  1014. rc = sensor_power_enable("lvsw1", 1800);
  1015. pr_info("sensor_power_enable(\"lvsw1\", 1800) == %d\n", rc);
  1016. msleep(5);
  1017.  
  1018. /* 2nd camera IO power */
  1019. rc = sensor_power_enable("wlan2", 1800);
  1020. pr_info("sensor_power_enable(\"wlan2\", 1800) == %d\n", rc);
  1021.  
  1022. return rc;
  1023. }
  1024.  
  1025.  
  1026.  
  1027. static int sensor_vreg_off(void)
  1028. {
  1029. int rc;
  1030. pr_info("%s camera vreg off\n", __func__);
  1031.  
  1032. /* 2nd camera IO power */
  1033. rc = sensor_power_disable("wlan2");
  1034. pr_info("sensor_power_disable(\"wlan2\") == %d\n", rc);
  1035.  
  1036. /* main / 2nd camera digital power */
  1037. rc = sensor_power_disable("lvsw1");
  1038. pr_info("sensor_power_disable(\"lvsw1\") == %d\n", rc);
  1039.  
  1040. /* main / 2nd camera analog power */
  1041. rc = sensor_power_disable("gp6");
  1042. pr_info("sensor_power_disable(\"gp6\") == %d\n", rc);
  1043.  
  1044. /* main camera VCM power */
  1045. rc = sensor_power_disable("gp4");
  1046. pr_info("sensor_power_disable(\"gp4\") == %d\n", rc);
  1047.  
  1048. return rc;
  1049. }
  1050.  
  1051.  
  1052. static void config_camera_on_gpios(void)
  1053. {
  1054. pr_info("config_camera_on_gpios\n");
  1055. config_gpio_table(camera_on_gpio_table,
  1056. ARRAY_SIZE(camera_on_gpio_table));
  1057. }
  1058.  
  1059. static void config_camera_off_gpios(void)
  1060. {
  1061. pr_info("config_camera_off_gpios\n");
  1062. config_gpio_table(camera_off_gpio_table,
  1063. ARRAY_SIZE(camera_off_gpio_table));
  1064. }
  1065.  
  1066. static struct resource msm_camera_resources[] = {
  1067. {
  1068. .start = 0xA6000000,
  1069. .end = 0xA6000000 + SZ_1M - 1,
  1070. .flags = IORESOURCE_MEM,
  1071. },
  1072. {
  1073. .start = INT_VFE,
  1074. .end = INT_VFE,
  1075. .flags = IORESOURCE_IRQ,
  1076. },
  1077. };
  1078.  
  1079. struct msm_camera_device_platform_data camera_device_data = {
  1080. .camera_gpio_on = config_camera_on_gpios,
  1081. .camera_gpio_off = config_camera_off_gpios,
  1082. .ioext.mdcphy = MSM_MDC_PHYS,
  1083. .ioext.mdcsz = MSM_MDC_SIZE,
  1084. .ioext.appphy = MSM_CLK_CTL_PHYS,
  1085. .ioext.appsz = MSM_CLK_CTL_SIZE,
  1086. .ioext.camifpadphy = 0xAB000000,
  1087. .ioext.camifpadsz = 0x00000400,
  1088. #ifdef CONFIG_S5K3H1GX
  1089. .ioext.csiphy = 0xA6100000,
  1090. .ioext.csisz = 0x00000400,
  1091. .ioext.csiirq = INT_CSI,
  1092. #endif
  1093. };
  1094.  
  1095. static void s5k3h1gx_clk_switch(void){
  1096. int rc = 0;
  1097. pr_info("Doing clk switch (s5k3h1gx)\n");
  1098. rc = gpio_request(CLK_SWITCH, "s5k3h1gx");
  1099.  
  1100. if (rc < 0)
  1101. pr_err("GPIO (%d) request fail\n", CLK_SWITCH);
  1102. else
  1103. gpio_direction_output(CLK_SWITCH, 0);
  1104.  
  1105. gpio_free(CLK_SWITCH);
  1106. return;
  1107. }
  1108.  
  1109. #ifdef CONFIG_S5K6AAFX
  1110. static void s5k6aafx_clk_switch(void){
  1111. int rc = 0;
  1112. pr_info("Doing clk switch (s5k6aafx)\n");
  1113. rc = gpio_request(CLK_SWITCH, "s5k6aafx");
  1114.  
  1115. if (rc < 0)
  1116. pr_err("GPIO (%d) request fail\n", CLK_SWITCH);
  1117. else
  1118. gpio_direction_output(CLK_SWITCH, 1);
  1119.  
  1120. gpio_free(CLK_SWITCH);
  1121. return;
  1122. }
  1123. #endif
  1124.  
  1125. static struct camera_flash_cfg msm_camera_sensor_flash_cfg = {
  1126. .camera_flash = flashlight_control,
  1127. .num_flash_levels = FLASHLIGHT_NUM,
  1128. .low_temp_limit = 5,
  1129. .low_cap_limit = 15,
  1130. };
  1131.  
  1132. #ifdef CONFIG_S5K3H1GX
  1133. static struct msm_camera_sensor_info msm_camera_sensor_s5k3h1gx_data = {
  1134. .sensor_name = "s5k3h1gx",
  1135. .sensor_pwd = CAM1_PWD,
  1136. .vcm_pwd = CAM1_VCM_PWD,
  1137. .camera_power_on = sensor_vreg_on,
  1138. .camera_power_off = sensor_vreg_off,
  1139. .camera_clk_switch = s5k3h1gx_clk_switch,
  1140. .pdata = &camera_device_data,
  1141. .flash_type = MSM_CAMERA_FLASH_LED,
  1142. .resource = msm_camera_resources,
  1143. .num_resources = ARRAY_SIZE(msm_camera_resources),
  1144. #ifdef CONFIG_ARCH_MSM_FLASHLIGHT
  1145. .flash_cfg = &msm_camera_sensor_flash_cfg,
  1146. #endif
  1147. .csi_if = 1,
  1148. };
  1149.  
  1150. static struct platform_device msm_camera_sensor_s5k3h1gx = {
  1151. .name = "msm_camera_s5k3h1gx",
  1152. .dev = {
  1153. .platform_data = &msm_camera_sensor_s5k3h1gx_data,
  1154. },
  1155. };
  1156. #endif
  1157.  
  1158. #ifdef CONFIG_S5K6AAFX
  1159. static struct msm_camera_sensor_info msm_camera_sensor_s5k6aafx_data = {
  1160. .sensor_name = "s5k6aafx",
  1161. .sensor_reset = CAM2_RST,
  1162. .sensor_pwd = CAM2_PWD,
  1163. .camera_power_on = sensor_vreg_on,
  1164. .camera_power_off = sensor_vreg_off,
  1165. .camera_clk_switch = s5k6aafx_clk_switch,
  1166. .pdata = &camera_device_data,
  1167. .flash_type = MSM_CAMERA_FLASH_LED,
  1168. .resource = msm_camera_resources,
  1169. .num_resources = ARRAY_SIZE(msm_camera_resources),
  1170. };
  1171.  
  1172. static struct platform_device msm_camera_sensor_s5k6aafx = {
  1173. .name = "msm_camera_s5k6aafx",
  1174. .dev = {
  1175. .platform_data = &msm_camera_sensor_s5k6aafx_data,
  1176. },
  1177. };
  1178. #endif
  1179.  
  1180. #ifdef CONFIG_MSM_GEMINI
  1181. static struct resource msm_gemini_resources[] = {
  1182. {
  1183. .start = 0xA3A00000,
  1184. .end = 0xA3A00000 + 0x0150 - 1,
  1185. .flags = IORESOURCE_MEM,
  1186. },
  1187. {
  1188. .start = INT_JPEG,
  1189. .end = INT_JPEG,
  1190. .flags = IORESOURCE_IRQ,
  1191. },
  1192. };
  1193.  
  1194. static struct platform_device msm_gemini_device = {
  1195. .name = "msm_gemini",
  1196. .resource = msm_gemini_resources,
  1197. .num_resources = ARRAY_SIZE(msm_gemini_resources),
  1198. };
  1199. #endif
  1200.  
  1201.  
  1202. static struct vreg *vreg_marimba_1;
  1203. static struct vreg *vreg_marimba_2;
  1204.  
  1205. static unsigned int msm_marimba_setup_power(void)
  1206. {
  1207. int rc;
  1208.  
  1209. rc = vreg_enable(vreg_marimba_1);
  1210. if (rc) {
  1211. printk(KERN_ERR "%s: vreg_enable() = %d \n",
  1212. __func__, rc);
  1213. goto out;
  1214. }
  1215. rc = vreg_enable(vreg_marimba_2);
  1216. if (rc) {
  1217. printk(KERN_ERR "%s: vreg_enable() = %d \n",
  1218. __func__, rc);
  1219. goto out;
  1220. }
  1221.  
  1222. out:
  1223. return rc;
  1224. };
  1225.  
  1226. static void msm_marimba_shutdown_power(void)
  1227. {
  1228. int rc;
  1229.  
  1230. rc = vreg_disable(vreg_marimba_1);
  1231. if (rc) {
  1232. printk(KERN_ERR "%s: return val: %d \n",
  1233. __func__, rc);
  1234. }
  1235. rc = vreg_disable(vreg_marimba_2);
  1236. if (rc) {
  1237. printk(KERN_ERR "%s: return val: %d \n",
  1238. __func__, rc);
  1239. }
  1240. };
  1241.  
  1242. /*
  1243. static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
  1244. {
  1245. int rc;
  1246. uint32_t irqcfg;
  1247. const char *id = "FMPW";
  1248.  
  1249. pdata->vreg_s2 = vreg_get(NULL, "s2");
  1250. if (IS_ERR(pdata->vreg_s2)) {
  1251. printk(KERN_ERR "%s: vreg get failed (%ld)\n",
  1252. __func__, PTR_ERR(pdata->vreg_s2));
  1253. return -1;
  1254. }
  1255.  
  1256. rc = pmapp_vreg_level_vote(id, PMAPP_VREG_S2, 1300);
  1257. if (rc < 0) {
  1258. printk(KERN_ERR "%s: voltage level vote failed (%d)\n",
  1259. __func__, rc);
  1260. return rc;
  1261. }
  1262.  
  1263. rc = vreg_enable(pdata->vreg_s2);
  1264. if (rc) {
  1265. printk(KERN_ERR "%s: vreg_enable() = %d \n",
  1266. __func__, rc);
  1267. return rc;
  1268. }
  1269.  
  1270. rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
  1271. PMAPP_CLOCK_VOTE_ON);
  1272. if (rc < 0) {
  1273. printk(KERN_ERR "%s: clock vote failed (%d)\n",
  1274. __func__, rc);
  1275. goto fm_clock_vote_fail;
  1276. }
  1277. irqcfg = PCOM_GPIO_CFG(147, 0, GPIO_INPUT, GPIO_NO_PULL,
  1278. GPIO_2MA);
  1279. rc = gpio_tlmm_config(irqcfg, GPIO_ENABLE);
  1280. if (rc) {
  1281. printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
  1282. __func__, irqcfg, rc);
  1283. rc = -EIO;
  1284. goto fm_gpio_config_fail;
  1285.  
  1286. }
  1287. return 0;
  1288. fm_gpio_config_fail:
  1289. pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
  1290. PMAPP_CLOCK_VOTE_OFF);
  1291. fm_clock_vote_fail:
  1292. vreg_disable(pdata->vreg_s2);
  1293. return rc;
  1294.  
  1295. };
  1296.  
  1297. static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata)
  1298. {
  1299. int rc;
  1300. const char *id = "FMPW";
  1301. uint32_t irqcfg = PCOM_GPIO_CFG(147, 0, GPIO_INPUT, GPIO_PULL_UP,
  1302. GPIO_2MA);
  1303. rc = gpio_tlmm_config(irqcfg, GPIO_ENABLE);
  1304. if (rc) {
  1305. printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
  1306. __func__, irqcfg, rc);
  1307. }
  1308. rc = vreg_disable(pdata->vreg_s2);
  1309. if (rc) {
  1310. printk(KERN_ERR "%s: return val: %d \n",
  1311. __func__, rc);
  1312. }
  1313. rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
  1314. PMAPP_CLOCK_VOTE_OFF);
  1315. if (rc < 0)
  1316. printk(KERN_ERR "%s: clock_vote return val: %d \n",
  1317. __func__, rc);
  1318. rc = pmapp_vreg_level_vote(id, PMAPP_VREG_S2, 0);
  1319. if (rc < 0)
  1320. printk(KERN_ERR "%s: vreg level vote return val: %d \n",
  1321. __func__, rc);
  1322. }
  1323.  
  1324. static struct marimba_fm_platform_data marimba_fm_pdata = {
  1325. .fm_setup = fm_radio_setup,
  1326. .fm_shutdown = fm_radio_shutdown,
  1327. .irq = MSM_GPIO_TO_INT(147),
  1328. .vreg_s2 = NULL,
  1329. .vreg_xo_out = NULL,
  1330. };
  1331. */
  1332.  
  1333. /* Slave id address for FM/CDC/QMEMBIST
  1334. * Values can be programmed using Marimba slave id 0
  1335. * should there be a conflict with other I2C devices
  1336. * */
  1337. /*#define MARIMBA_SLAVE_ID_FM_ADDR 0x2A*/
  1338. #define MARIMBA_SLAVE_ID_CDC_ADDR 0x77
  1339. #define MARIMBA_SLAVE_ID_QMEMBIST_ADDR 0X66
  1340.  
  1341. static const char *tsadc_id = "MADC";
  1342. static const char *vregs_tsadc_name[] = {
  1343. "gp12",
  1344. "s2",
  1345. };
  1346. static struct vreg *vregs_tsadc[ARRAY_SIZE(vregs_tsadc_name)];
  1347.  
  1348. static int marimba_tsadc_power(int vreg_on)
  1349. {
  1350. int i, rc = 0;
  1351.  
  1352. for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
  1353. if (!vregs_tsadc[i]) {
  1354. printk(KERN_ERR "%s: vreg_get %s failed (%d)\n",
  1355. __func__, vregs_tsadc_name[i], rc);
  1356. goto vreg_fail;
  1357. }
  1358.  
  1359. rc = vreg_on ? vreg_enable(vregs_tsadc[i]) :
  1360. vreg_disable(vregs_tsadc[i]);
  1361. if (rc < 0) {
  1362. printk(KERN_ERR "%s: vreg %s %s failed (%d)\n",
  1363. __func__, vregs_tsadc_name[i],
  1364. vreg_on ? "enable" : "disable", rc);
  1365. goto vreg_fail;
  1366. }
  1367. }
  1368. /* vote for D0 buffer */
  1369. rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
  1370. vreg_on ? PMAPP_CLOCK_VOTE_ON : PMAPP_CLOCK_VOTE_OFF);
  1371. if (rc) {
  1372. printk(KERN_ERR "%s: unable to %svote for d0 clk\n",
  1373. __func__, vreg_on ? "" : "de-");
  1374. goto do_vote_fail;
  1375. }
  1376.  
  1377. mdelay(5); /* ensure power is stable */
  1378.  
  1379. return 0;
  1380.  
  1381. do_vote_fail:
  1382. vreg_fail:
  1383. while (i)
  1384. vreg_disable(vregs_tsadc[--i]);
  1385. return rc;
  1386. }
  1387.  
  1388. static int marimba_tsadc_vote(int vote_on)
  1389. {
  1390. int rc, level;
  1391.  
  1392. level = vote_on ? 1300 : 0;
  1393.  
  1394. rc = pmapp_vreg_level_vote(tsadc_id, PMAPP_VREG_S2, level);
  1395. if (rc < 0)
  1396. printk(KERN_ERR "%s: vreg level %s failed (%d)\n",
  1397. __func__, vote_on ? "on" : "off", rc);
  1398.  
  1399. return rc;
  1400. }
  1401.  
  1402. static int marimba_tsadc_init(void)
  1403. {
  1404. int i, rc = 0;
  1405.  
  1406. for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
  1407. vregs_tsadc[i] = vreg_get(NULL, vregs_tsadc_name[i]);
  1408. if (IS_ERR(vregs_tsadc[i])) {
  1409. printk(KERN_ERR "%s: vreg get %s failed (%ld)\n",
  1410. __func__, vregs_tsadc_name[i],
  1411. PTR_ERR(vregs_tsadc[i]));
  1412. rc = PTR_ERR(vregs_tsadc[i]);
  1413. goto vreg_get_fail;
  1414. }
  1415. }
  1416.  
  1417. return rc;
  1418.  
  1419. vreg_get_fail:
  1420. while (i)
  1421. vreg_put(vregs_tsadc[--i]);
  1422. return rc;
  1423. }
  1424.  
  1425. static int marimba_tsadc_exit(void)
  1426. {
  1427. int i, rc;
  1428.  
  1429. for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
  1430. if (vregs_tsadc[i])
  1431. vreg_put(vregs_tsadc[i]);
  1432. }
  1433.  
  1434. rc = pmapp_vreg_level_vote(tsadc_id, PMAPP_VREG_S2, 0);
  1435. if (rc < 0)
  1436. printk(KERN_ERR "%s: vreg level off failed (%d)\n",
  1437. __func__, rc);
  1438.  
  1439. return rc;
  1440. }
  1441.  
  1442. static struct marimba_tsadc_platform_data marimba_tsadc_pdata = {
  1443. .marimba_tsadc_power = marimba_tsadc_power,
  1444. .init = marimba_tsadc_init,
  1445. .exit = marimba_tsadc_exit,
  1446. .level_vote = marimba_tsadc_vote,
  1447. .tsadc_prechg_en = true,
  1448. .setup = {
  1449. .pen_irq_en = true,
  1450. .tsadc_en = true,
  1451. },
  1452. .params2 = {
  1453. .input_clk_khz = 2400,
  1454. .sample_prd = TSADC_CLK_3,
  1455. },
  1456. .params3 = {
  1457. .prechg_time_nsecs = 6400,
  1458. .stable_time_nsecs = 6400,
  1459. .tsadc_test_mode = 0,
  1460. },
  1461. };
  1462.  
  1463. static struct vreg *vreg_codec_s4;
  1464. static int msm_marimba_codec_power(int vreg_on)
  1465. {
  1466. int rc = 0;
  1467.  
  1468. if (!vreg_codec_s4) {
  1469.  
  1470. vreg_codec_s4 = vreg_get(NULL, "s4");
  1471.  
  1472. if (IS_ERR(vreg_codec_s4)) {
  1473. printk(KERN_ERR "%s: vreg_get() failed (%ld)\n",
  1474. __func__, PTR_ERR(vreg_codec_s4));
  1475. rc = PTR_ERR(vreg_codec_s4);
  1476. goto vreg_codec_s4_fail;
  1477. }
  1478. }
  1479.  
  1480. if (vreg_on) {
  1481. rc = vreg_enable(vreg_codec_s4);
  1482. if (rc)
  1483. printk(KERN_ERR "%s: vreg_enable() = %d \n",
  1484. __func__, rc);
  1485. goto vreg_codec_s4_fail;
  1486. } else {
  1487. rc = vreg_disable(vreg_codec_s4);
  1488. if (rc)
  1489. printk(KERN_ERR "%s: vreg_disable() = %d \n",
  1490. __func__, rc);
  1491. goto vreg_codec_s4_fail;
  1492. }
  1493.  
  1494. vreg_codec_s4_fail:
  1495. return rc;
  1496. }
  1497.  
  1498. static struct marimba_codec_platform_data mariba_codec_pdata = {
  1499. .marimba_codec_power = msm_marimba_codec_power,
  1500. };
  1501.  
  1502. static struct marimba_platform_data marimba_pdata = {
  1503. /*.slave_id[MARIMBA_SLAVE_ID_FM] = MARIMBA_SLAVE_ID_FM_ADDR,*/
  1504. .slave_id[MARIMBA_SLAVE_ID_CDC] = MARIMBA_SLAVE_ID_CDC_ADDR,
  1505. .slave_id[MARIMBA_SLAVE_ID_QMEMBIST] = MARIMBA_SLAVE_ID_QMEMBIST_ADDR,
  1506. .marimba_setup = msm_marimba_setup_power,
  1507. .marimba_shutdown = msm_marimba_shutdown_power,
  1508. /*.fm = &marimba_fm_pdata,*/
  1509. .tsadc = &marimba_tsadc_pdata,
  1510. .codec = &mariba_codec_pdata,
  1511. };
  1512.  
  1513. static void __init msm7x30_init_marimba(void)
  1514. {
  1515. vreg_marimba_1 = vreg_get(NULL, "s2");
  1516. if (IS_ERR(vreg_marimba_1)) {
  1517. printk(KERN_ERR "%s: vreg get failed (%ld)\n",
  1518. __func__, PTR_ERR(vreg_marimba_1));
  1519. return;
  1520. }
  1521. vreg_marimba_2 = vreg_get(NULL, "gp16");
  1522. if (IS_ERR(vreg_marimba_2)) {
  1523. printk(KERN_ERR "%s: vreg get failed (%ld)\n",
  1524. __func__, PTR_ERR(vreg_marimba_2));
  1525. return;
  1526. }
  1527. }
  1528. #ifdef CONFIG_MSM7KV2_AUDIO
  1529. static struct resource msm_aictl_resources[] = {
  1530. {
  1531. .name = "aictl",
  1532. .start = 0xa5000100,
  1533. .end = 0xa5000100,
  1534. .flags = IORESOURCE_MEM,
  1535. }
  1536. };
  1537.  
  1538. static struct resource msm_mi2s_resources[] = {
  1539. {
  1540. .name = "hdmi",
  1541. .start = 0xac900000,
  1542. .end = 0xac900038,
  1543. .flags = IORESOURCE_MEM,
  1544. },
  1545. {
  1546. .name = "codec_rx",
  1547. .start = 0xac940040,
  1548. .end = 0xac940078,
  1549. .flags = IORESOURCE_MEM,
  1550. },
  1551. {
  1552. .name = "codec_tx",
  1553. .start = 0xac980080,
  1554. .end = 0xac9800B8,
  1555. .flags = IORESOURCE_MEM,
  1556. }
  1557.  
  1558. };
  1559.  
  1560. static struct msm_lpa_platform_data lpa_pdata = {
  1561. .obuf_hlb_size = 0x2BFF8,
  1562. .dsp_proc_id = 0,
  1563. .app_proc_id = 2,
  1564. .nosb_config = {
  1565. .llb_min_addr = 0,
  1566. .llb_max_addr = 0x3ff8,
  1567. .sb_min_addr = 0,
  1568. .sb_max_addr = 0,
  1569. },
  1570. .sb_config = {
  1571. .llb_min_addr = 0,
  1572. .llb_max_addr = 0x37f8,
  1573. .sb_min_addr = 0x3800,
  1574. .sb_max_addr = 0x3ff8,
  1575. }
  1576. };
  1577.  
  1578. static struct resource msm_lpa_resources[] = {
  1579. {
  1580. .name = "lpa",
  1581. .start = 0xa5000000,
  1582. .end = 0xa50000a0,
  1583. .flags = IORESOURCE_MEM,
  1584. }
  1585. };
  1586.  
  1587. #if 1
  1588. static struct resource msm_aux_pcm_resources[] = {
  1589.  
  1590. {
  1591. .name = "aux_codec_reg_addr",
  1592. .start = 0xac9c00c0,
  1593. .end = 0xac9c00c8,
  1594. .flags = IORESOURCE_MEM,
  1595. },
  1596. {
  1597. .name = "aux_pcm_dout",
  1598. .start = 138,
  1599. .end = 138,
  1600. .flags = IORESOURCE_IO,
  1601. },
  1602. {
  1603. .name = "aux_pcm_din",
  1604. .start = 139,
  1605. .end = 139,
  1606. .flags = IORESOURCE_IO,
  1607. },
  1608. {
  1609. .name = "aux_pcm_syncout",
  1610. .start = 140,
  1611. .end = 140,
  1612. .flags = IORESOURCE_IO,
  1613. },
  1614. {
  1615. .name = "aux_pcm_clkin_a",
  1616. .start = 141,
  1617. .end = 141,
  1618. .flags = IORESOURCE_IO,
  1619. },
  1620. };
  1621.  
  1622. static struct platform_device msm_aux_pcm_device = {
  1623. .name = "msm_aux_pcm",
  1624. .id = 0,
  1625. .num_resources = ARRAY_SIZE(msm_aux_pcm_resources),
  1626. .resource = msm_aux_pcm_resources,
  1627. };
  1628. #endif
  1629. static struct platform_device msm_aictl_device = {
  1630. .name = "audio_interct",
  1631. .id = 0,
  1632. .num_resources = ARRAY_SIZE(msm_aictl_resources),
  1633. .resource = msm_aictl_resources,
  1634. };
  1635.  
  1636. static struct platform_device msm_mi2s_device = {
  1637. .name = "mi2s",
  1638. .id = 0,
  1639. .num_resources = ARRAY_SIZE(msm_mi2s_resources),
  1640. .resource = msm_mi2s_resources,
  1641. };
  1642.  
  1643. static struct platform_device msm_lpa_device = {
  1644. .name = "lpa",
  1645. .id = 0,
  1646. .num_resources = ARRAY_SIZE(msm_lpa_resources),
  1647. .resource = msm_lpa_resources,
  1648. .dev = {
  1649. .platform_data = &lpa_pdata,
  1650. },
  1651. };
  1652.  
  1653. #define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
  1654. (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
  1655. (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
  1656. (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
  1657. (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
  1658. (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
  1659. #define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
  1660. (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
  1661. (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
  1662. (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
  1663. (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
  1664. (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
  1665. #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
  1666. (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
  1667. (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
  1668. (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
  1669. (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
  1670. (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
  1671. #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
  1672. (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
  1673. (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
  1674. (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
  1675. (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
  1676. (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
  1677. #define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
  1678.  
  1679. static unsigned int dec_concurrency_table[] = {
  1680. /* Audio LP */
  1681. 0, 0, 0, 0,
  1682. (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_MODE_LP)|
  1683. (1<<MSM_ADSP_OP_DM)),
  1684.  
  1685. /* Concurrency 1 */
  1686. (DEC4_FORMAT),
  1687. (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1688. (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1689. (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1690. (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1691.  
  1692. /* Concurrency 2 */
  1693. (DEC4_FORMAT),
  1694. (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1695. (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1696. (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1697. (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1698.  
  1699. /* Concurrency 3 */
  1700. (DEC4_FORMAT),
  1701. (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1702. (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1703. (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1704. (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1705.  
  1706. /* Concurrency 4 */
  1707. (DEC4_FORMAT),
  1708. (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1709. (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1710. (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1711. (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1712.  
  1713. /* Concurrency 5 */
  1714. (DEC4_FORMAT),
  1715. (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1716. (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1717. (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1718. (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1719.  
  1720. /* Concurrency 6 */
  1721. (DEC4_FORMAT),
  1722. (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1723. (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1724. (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1725. (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1726. };
  1727.  
  1728. #define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
  1729. .module_queueid = queueid, .module_decid = decid, \
  1730. .nr_codec_support = nr_codec}
  1731.  
  1732. #define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
  1733. .max_instances_same_dec = max_instance_same, \
  1734. .max_instances_diff_dec = max_instance_diff}
  1735.  
  1736. static struct msm_adspdec_info dec_info_list[] = {
  1737. DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */
  1738. DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */
  1739. DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */
  1740. DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */
  1741. DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
  1742. };
  1743.  
  1744. static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
  1745. /* Non Turbo Mode */
  1746. {
  1747. DEC_INSTANCE(4, 3), /* WAV */
  1748. DEC_INSTANCE(4, 3), /* ADPCM */
  1749. DEC_INSTANCE(4, 2), /* MP3 */
  1750. DEC_INSTANCE(0, 0), /* Real Audio */
  1751. DEC_INSTANCE(4, 2), /* WMA */
  1752. DEC_INSTANCE(3, 2), /* AAC */
  1753. DEC_INSTANCE(0, 0), /* Reserved */
  1754. DEC_INSTANCE(0, 0), /* MIDI */
  1755. DEC_INSTANCE(4, 3), /* YADPCM */
  1756. DEC_INSTANCE(4, 3), /* QCELP */
  1757. DEC_INSTANCE(4, 3), /* AMRNB */
  1758. DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
  1759. DEC_INSTANCE(4, 3), /* EVRC */
  1760. DEC_INSTANCE(1, 1), /* WMAPRO */
  1761. },
  1762. /* Turbo Mode */
  1763. {
  1764. DEC_INSTANCE(4, 3), /* WAV */
  1765. DEC_INSTANCE(4, 3), /* ADPCM */
  1766. DEC_INSTANCE(4, 3), /* MP3 */
  1767. DEC_INSTANCE(0, 0), /* Real Audio */
  1768. DEC_INSTANCE(4, 3), /* WMA */
  1769. DEC_INSTANCE(4, 3), /* AAC */
  1770. DEC_INSTANCE(0, 0), /* Reserved */
  1771. DEC_INSTANCE(0, 0), /* MIDI */
  1772. DEC_INSTANCE(4, 3), /* YADPCM */
  1773. DEC_INSTANCE(4, 3), /* QCELP */
  1774. DEC_INSTANCE(4, 3), /* AMRNB */
  1775. DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
  1776. DEC_INSTANCE(4, 3), /* EVRC */
  1777. DEC_INSTANCE(1, 2), /* WMAPRO */
  1778. },
  1779. };
  1780.  
  1781. static struct msm_adspdec_database msm_device_adspdec_database = {
  1782. .num_dec = ARRAY_SIZE(dec_info_list),
  1783. .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
  1784. ARRAY_SIZE(dec_info_list)),
  1785. .dec_concurrency_table = dec_concurrency_table,
  1786. .dec_info_list = dec_info_list,
  1787. .dec_instance_list = &dec_instance_list[0][0],
  1788. };
  1789.  
  1790. static struct platform_device msm_device_adspdec = {
  1791. .name = "msm_adspdec",
  1792. .id = -1,
  1793. .dev = {
  1794. .platform_data = &msm_device_adspdec_database
  1795. },
  1796. };
  1797.  
  1798. static unsigned aux_pcm_gpio_off[] = {
  1799. PCOM_GPIO_CFG(138, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* PCM_DOUT */
  1800. PCOM_GPIO_CFG(139, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* PCM_DIN */
  1801. PCOM_GPIO_CFG(140, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* PCM_SYNC */
  1802. PCOM_GPIO_CFG(141, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* PCM_CLK */
  1803. };
  1804.  
  1805. static void __init aux_pcm_gpio_init(void)
  1806. {
  1807. config_gpio_table(aux_pcm_gpio_off,
  1808. ARRAY_SIZE(aux_pcm_gpio_off));
  1809. }
  1810.  
  1811. #endif /* CONFIG_MSM7KV2_AUDIO */
  1812.  
  1813. static struct i2c_board_info msm_marimba_board_info[] = {
  1814. {
  1815. I2C_BOARD_INFO("marimba", 0xc),
  1816. .platform_data = &marimba_pdata,
  1817. }
  1818. };
  1819.  
  1820. static struct spi_board_info msm_spi_board_info[] __initdata = {
  1821. {
  1822. .modalias = "spi_qsd",
  1823. .mode = SPI_MODE_3,
  1824. // .irq = MSM_GPIO_TO_INT(51),
  1825. .bus_num = 0,
  1826. .chip_select = 2,
  1827. .max_speed_hz = 10000000,
  1828. // .platform_data = &bma_pdata,
  1829. },
  1830. {
  1831. .modalias = "spi_aic3254",
  1832. .mode = SPI_MODE_1,
  1833. .bus_num = 0,
  1834. .chip_select = 3,
  1835. .max_speed_hz = 9963243,
  1836. }
  1837. };
  1838.  
  1839.  
  1840. #ifdef CONFIG_SPI_QSD_NEW
  1841. static int msm_qsd_spi_gpio_config(void)
  1842. {
  1843. #if 0
  1844. unsigned id;
  1845. id = PCOM_GPIO_CFG(45, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_16MA);
  1846. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  1847. id = PCOM_GPIO_CFG(47, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_16MA);
  1848. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  1849. id = PCOM_GPIO_CFG(48, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_16MA);
  1850. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  1851.  
  1852. id = PCOM_GPIO_CFG(87, 1, GPIO_INPUT, GPIO_NO_PULL, GPIO_16MA);
  1853. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  1854. #endif
  1855. return 0;
  1856. }
  1857.  
  1858. static void msm_qsd_spi_gpio_release(void)
  1859. {
  1860. #if 0
  1861. unsigned id;
  1862. id = PCOM_GPIO_CFG(45, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_16MA);
  1863. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  1864. id = PCOM_GPIO_CFG(47, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_16MA);
  1865. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  1866. id = PCOM_GPIO_CFG(48, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_16MA);
  1867. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  1868.  
  1869. id = PCOM_GPIO_CFG(87, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_16MA);
  1870. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  1871. #endif
  1872. }
  1873. #endif
  1874.  
  1875. #if 0
  1876. #define AMDH0_BASE_PHYS 0xAC200000
  1877. #define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
  1878. static int msm_qsd_spi_dma_config(void)
  1879. {
  1880. void __iomem *ct_adm_base = 0;
  1881. u32 spi_mux = 0;
  1882. int ret = 0;
  1883.  
  1884. ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
  1885. if (!ct_adm_base) {
  1886. pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
  1887. return -ENOMEM;
  1888. }
  1889.  
  1890. spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
  1891.  
  1892. qsd_spi_resources[4].start = DMOV_USB_CHAN;
  1893. qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
  1894.  
  1895. switch (spi_mux) {
  1896. case (1):
  1897. qsd_spi_resources[5].start = DMOV_HSUART1_RX_CRCI;
  1898. qsd_spi_resources[5].end = DMOV_HSUART1_TX_CRCI;
  1899. break;
  1900. case (2):
  1901. qsd_spi_resources[5].start = DMOV_HSUART2_RX_CRCI;
  1902. qsd_spi_resources[5].end = DMOV_HSUART2_TX_CRCI;
  1903. break;
  1904. case (3):
  1905. qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
  1906. qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
  1907. break;
  1908. default:
  1909. ret = -ENOENT;
  1910. }
  1911.  
  1912. iounmap(ct_adm_base);
  1913.  
  1914. return ret;
  1915. }
  1916. #endif
  1917. #ifdef CONFIG_SPI_QSD_NEW
  1918. static struct msm_spi_platform_data qsd_spi_pdata = {
  1919. .max_clock_speed = 26000000,
  1920. .gpio_config = msm_qsd_spi_gpio_config,
  1921. .gpio_release = msm_qsd_spi_gpio_release,
  1922. // .dma_config = msm_qsd_spi_dma_config,
  1923. };
  1924.  
  1925. static void __init msm_qsd_spi_init(void)
  1926. {
  1927. qsdnew_device_spi.dev.platform_data = &qsd_spi_pdata;
  1928. }
  1929. #endif
  1930.  
  1931. // KYPD_DRV * KYPD_SNS
  1932. #ifndef CONFIG_MSM_SSBI
  1933. static unsigned int vivo_keymap[] = {
  1934. KEY(0, 0, KEY_RIGHTALT),
  1935. KEY(0, 1, KEY_RIGHTSHIFT),
  1936. KEY(0, 2, KEY_UP),
  1937. KEY(0, 3, KEY_DOWN),
  1938. KEY(0, 4, KEY_LEFT),
  1939. KEY(0, 5, KEY_RIGHT),
  1940. KEY(0, 6, KEY_SEND),/*for CDMA dummy key*/
  1941.  
  1942. KEY(1, 0, KEY_MENU),
  1943. KEY(1, 1, KEY_BACKSPACE),
  1944. KEY(1, 2, KEY_M),
  1945. KEY(1, 3, KEY_HOME),/*XA : KEY(1, 3, KEY_WWW),*/
  1946. KEY(1, 4, KEY_RESERVED),
  1947. KEY(1, 5, KEY_RESERVED),
  1948. KEY(1, 6, KEY_END),/*for CDMA dummy key*/
  1949.  
  1950. KEY(2, 0, KEY_ENTER),
  1951. KEY(2, 1, KEY_SPACE),
  1952. KEY(2, 2, KEY_Q),
  1953. KEY(2, 3, KEY_W),
  1954. KEY(2, 4, KEY_E),
  1955. KEY(2, 5, KEY_R),
  1956. KEY(2, 6, KEY_T),
  1957.  
  1958. KEY(3, 0, KEY_F13),
  1959. KEY(3, 1, KEY_QUESTION),
  1960. KEY(3, 2, KEY_Y),
  1961. KEY(3, 3, KEY_U),
  1962. KEY(3, 4, KEY_I),
  1963. KEY(3, 5, KEY_O),
  1964. KEY(3, 6, KEY_P),
  1965.  
  1966. KEY(4, 0, KEY_F14),
  1967. KEY(4, 1, KEY_DOT),
  1968. KEY(4, 2, KEY_A),
  1969. KEY(4, 3, KEY_S),
  1970. KEY(4, 4, KEY_D),
  1971. KEY(4, 5, KEY_F),
  1972. KEY(4, 6, KEY_G),
  1973.  
  1974. KEY(5, 0, KEY_BACK),
  1975. KEY(5, 1, KEY_COMMA),
  1976. KEY(5, 2, KEY_H),
  1977. KEY(5, 3, KEY_J),
  1978. KEY(5, 4, KEY_K),
  1979. KEY(5, 5, KEY_L),
  1980. KEY(5, 6, KEY_Z),
  1981.  
  1982. KEY(6, 0, KEY_SEARCH),
  1983. KEY(6, 1, KEY_EMAIL),
  1984. KEY(6, 2, KEY_X),
  1985. KEY(6, 3, KEY_C),
  1986. KEY(6, 4, KEY_V),
  1987. KEY(6, 5, KEY_B),
  1988. KEY(6, 6, KEY_N),
  1989. };
  1990.  
  1991. /* REVISIT - this needs to be done through add_subdevice
  1992. * API
  1993. */
  1994. static struct resource resources_keypad[] = {
  1995. {
  1996. .start = PM8058_IRQ_KEYPAD,
  1997. .end = PM8058_IRQ_KEYPAD,
  1998. .flags = IORESOURCE_IRQ,
  1999. },
  2000. {
  2001. .start = PM8058_IRQ_KEYSTUCK,
  2002. .end = PM8058_IRQ_KEYSTUCK,
  2003. .flags = IORESOURCE_IRQ,
  2004. },
  2005. };
  2006.  
  2007. static struct pmic8058_keypad_data vivo_keypad_data = {
  2008. .input_name = "vivo-keypad",
  2009. .input_phys_device = "vivo-keypad/input0",
  2010. .num_rows = 7,
  2011. .num_cols = 7,
  2012. .rows_gpio_start = 8,
  2013. .cols_gpio_start = 0,
  2014. .keymap_size = ARRAY_SIZE(vivo_keymap),
  2015. .keymap = vivo_keymap,
  2016. .debounce_ms = {8, 10},
  2017. .scan_delay_ms = 32,
  2018. .row_hold_ns = 91500,
  2019. .wakeup = 1,
  2020. };
  2021.  
  2022. /* Put sub devices with fixed location first in sub_devices array */
  2023. #define PM8058_SUBDEV_KPD 0
  2024.  
  2025. static struct pm8058_platform_data pm8058_vivo_data = {
  2026. .pm_irqs = {
  2027. [PM8058_IRQ_KEYPAD - PM8058_FIRST_IRQ] = 74,
  2028. [PM8058_IRQ_KEYSTUCK - PM8058_FIRST_IRQ] = 75,
  2029. },
  2030. .init = &pm8058_gpios_init,
  2031.  
  2032. .num_subdevs = 5,
  2033. .sub_devices = {
  2034.  
  2035. { .name = "pm8058-keypad",
  2036. .num_resources = ARRAY_SIZE(resources_keypad),
  2037. .resources = resources_keypad,
  2038. },
  2039.  
  2040. { .name = "pm8058-gpio",
  2041. },
  2042. { .name = "pm8058-mpp",
  2043. },
  2044. { .name = "pm8058-pwm",
  2045. },
  2046. { .name = "pm8058-nfc",
  2047. },
  2048. },
  2049. };
  2050.  
  2051. static struct i2c_board_info pm8058_boardinfo[] __initdata = {
  2052. {
  2053. I2C_BOARD_INFO("pm8058-core", 0),
  2054. .irq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
  2055. .platform_data = &pm8058_vivo_data,
  2056. },
  2057. };
  2058. #endif
  2059.  
  2060. #ifdef CONFIG_I2C_SSBI
  2061. static struct msm_i2c_platform_data msm_i2c_ssbi6_pdata = {
  2062. .rsl_id = "D:PMIC_SSBI"
  2063. };
  2064.  
  2065. static struct msm_i2c_platform_data msm_i2c_ssbi7_pdata = {
  2066. .rsl_id = "D:CODEC_SSBI"
  2067. };
  2068. #endif
  2069.  
  2070. #if defined(CONFIG_MARIMBA_CORE) && \
  2071. (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
  2072. static struct platform_device msm_bt_power_device = {
  2073. .name = "bt_power",
  2074. };
  2075.  
  2076.  
  2077.  
  2078. static int marimba_bt(int on)
  2079. {
  2080. int rc;
  2081. int i;
  2082. struct marimba config = { .mod_id = MARIMBA_SLAVE_ID_MARIMBA };
  2083.  
  2084. struct marimba_config_register {
  2085. u8 reg;
  2086. u8 value;
  2087. u8 mask;
  2088. } *p;
  2089.  
  2090. size_t config_size;
  2091.  
  2092. struct marimba_config_register bt_on[] = {
  2093. { 0xE5, 0x0B, 0x0F },
  2094. { 0x05, 0x02, 0x07 },
  2095. { 0x06, 0x88, 0xFF },
  2096. { 0xE7, 0x21, 0x21 },
  2097. };
  2098.  
  2099. struct marimba_config_register bt_off[] = {
  2100. { 0xE5, 0x0B, 0x0F },
  2101. { 0x05, 0x02, 0x07 },
  2102. { 0x06, 0x88, 0xFF },
  2103. { 0xE7, 0x00, 0x21 },
  2104. };
  2105.  
  2106. p = on ? bt_on : bt_off;
  2107. config_size = on ? ARRAY_SIZE(bt_on) : ARRAY_SIZE(bt_off);
  2108.  
  2109. for (i = 0; i < config_size; i++) {
  2110. rc = marimba_write_bit_mask(&config,
  2111. (p+i)->reg,
  2112. &((p+i)->value),
  2113. sizeof((p+i)->value),
  2114. (p+i)->mask);
  2115. if (rc < 0) {
  2116. printk(KERN_ERR
  2117. "%s: reg %d write failed: %d\n",
  2118. __func__, (p+i)->reg, rc);
  2119. return rc;
  2120. }
  2121. }
  2122. return 0;
  2123. }
  2124.  
  2125. static int bluetooth_power(int on)
  2126. {
  2127. int rc;
  2128. struct vreg *vreg_wlan;
  2129.  
  2130. vreg_wlan = vreg_get(NULL, "wlan");
  2131.  
  2132. if (IS_ERR(vreg_wlan)) {
  2133. printk(KERN_ERR "%s: vreg get failed (%ld)\n",
  2134. __func__, PTR_ERR(vreg_wlan));
  2135. return PTR_ERR(vreg_wlan);
  2136. }
  2137.  
  2138. if (on) {
  2139. rc = msm_gpios_enable(bt_config_power_on,
  2140. ARRAY_SIZE(bt_config_power_on));
  2141.  
  2142. if (rc < 0) {
  2143. printk(KERN_ERR
  2144. "%s: gpio config failed: %d\n",
  2145. __func__, rc);
  2146. return rc;
  2147. }
  2148.  
  2149. rc = vreg_set_level(vreg_wlan, PMIC_VREG_WLAN_LEVEL);
  2150. if (rc) {
  2151. printk(KERN_ERR "%s: vreg wlan set level failed (%d)\n",
  2152. __func__, rc);
  2153. return -EIO;
  2154. }
  2155. rc = vreg_enable(vreg_wlan);
  2156. if (rc) {
  2157. printk(KERN_ERR "%s: vreg wlan enable failed (%d)\n",
  2158. __func__, rc);
  2159. return -EIO;
  2160. }
  2161. rc = marimba_bt(on);
  2162. if (rc)
  2163. return -EIO;
  2164. } else {
  2165. rc = marimba_bt(on);
  2166. if (rc)
  2167. return -EIO;
  2168. rc = vreg_disable(vreg_wlan);
  2169. if (rc) {
  2170. printk(KERN_ERR "%s: vreg wlan disable failed (%d)\n",
  2171. __func__, rc);
  2172. return -EIO;
  2173. }
  2174.  
  2175. rc = msm_gpios_enable(bt_config_power_off,
  2176. ARRAY_SIZE(bt_config_power_off));
  2177. if (rc < 0) {
  2178. printk(KERN_ERR
  2179. "%s: gpio config failed: %d\n",
  2180. __func__, rc);
  2181. return rc;
  2182. }
  2183. }
  2184.  
  2185. printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
  2186.  
  2187. return 0;
  2188. }
  2189.  
  2190. static void __init bt_power_init(void)
  2191. {
  2192. msm_bt_power_device.dev.platform_data = &bluetooth_power;
  2193. }
  2194. #else
  2195. #define bt_power_init(x) do {} while (0)
  2196. #endif
  2197.  
  2198. static struct platform_device vivo_rfkill = {
  2199. .name = "vivo_rfkill",
  2200. .id = -1,
  2201. };
  2202.  
  2203. static struct android_pmem_platform_data android_pmem_kernel_ebi1_pdata = {
  2204. .name = PMEM_KERNEL_EBI1_DATA_NAME,
  2205. .start = PMEM_KERNEL_EBI1_BASE,
  2206. .size = PMEM_KERNEL_EBI1_SIZE,
  2207. .cached = 0,
  2208. };
  2209.  
  2210. static struct platform_device android_pmem_kernel_ebi1_devices = {
  2211. .name = "android_pmem",
  2212. .id = 2,
  2213. .dev = {.platform_data = &android_pmem_kernel_ebi1_pdata },
  2214. };
  2215.  
  2216. static struct platform_device *devices[] __initdata = {
  2217. &msm_device_uart2,
  2218. &msm_device_smd,
  2219. &vivo_rfkill,
  2220. #ifdef CONFIG_I2C_SSBI
  2221. &msm_device_ssbi6,
  2222. &msm_device_ssbi7,
  2223. #endif
  2224. #ifdef CONFIG_SPI_QSD_NEW
  2225. &qsdnew_device_spi,
  2226. #endif
  2227. &msm_device_i2c,
  2228. &msm_device_i2c_2,
  2229. &qup_device_i2c,
  2230. &htc_headset_mgr,
  2231. &htc_battery_pdev,
  2232. #ifdef CONFIG_MSM7KV2_AUDIO
  2233. &msm_aictl_device,
  2234. &msm_mi2s_device,
  2235. &msm_lpa_device,
  2236. &msm_device_adspdec,
  2237. #endif
  2238. &android_pmem_kernel_ebi1_devices,
  2239. &msm_device_vidc_720p,
  2240. #ifdef CONFIG_MSM_GEMINI
  2241. &msm_gemini_device,
  2242. #endif
  2243. #ifdef CONFIG_MSM7KV2_AUDIO
  2244. &msm_aux_pcm_device,
  2245. #endif
  2246. #ifdef CONFIG_S5K3H1GX
  2247. &msm_camera_sensor_s5k3h1gx,
  2248. #endif
  2249. #ifdef CONFIG_S5K6AAFX
  2250. &msm_camera_sensor_s5k6aafx,
  2251. #endif
  2252. #if defined(CONFIG_MARIMBA_CORE) && \
  2253. (defined(CONFIG_MSM_BT_POWER) || defined(CONFIG_MSM_BT_POWER_MODULE))
  2254. &msm_bt_power_device,
  2255. #endif
  2256.  
  2257. #ifdef CONFIG_MSM_ROTATOR
  2258. &msm_rotator_device,
  2259. #endif
  2260. &pm8058_leds,
  2261. &vivo_flashlight_device,
  2262. };
  2263.  
  2264. #ifdef CONFIG_SERIAL_MSM_HS
  2265. static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
  2266. .rx_wakeup_irq = MSM_GPIO_TO_INT(VIVO_GPIO_BT_HOST_WAKE),
  2267. .inject_rx_on_wakeup = 0,
  2268. .cpu_lock_supported = 1,
  2269.  
  2270. /* for bcm */
  2271. .bt_wakeup_pin_supported = 1,
  2272. .bt_wakeup_pin = VIVO_GPIO_BT_CHIP_WAKE,
  2273. .host_wakeup_pin = VIVO_GPIO_BT_HOST_WAKE,
  2274.  
  2275. };
  2276. #endif
  2277.  
  2278. /* for bcm */
  2279. static char bdaddress[20];
  2280. extern unsigned char *get_bt_bd_ram(void);
  2281.  
  2282. static void bt_export_bd_address(void)
  2283. {
  2284. unsigned char cTemp[6];
  2285.  
  2286. memcpy(cTemp, get_bt_bd_ram(), 6);
  2287. sprintf(bdaddress, "%02x:%02x:%02x:%02x:%02x:%02x",
  2288. cTemp[0], cTemp[1], cTemp[2], cTemp[3], cTemp[4], cTemp[5]);
  2289. printk(KERN_INFO "YoYo--BD_ADDRESS=%s\n", bdaddress);
  2290. }
  2291.  
  2292. module_param_string(bdaddress, bdaddress, sizeof(bdaddress), S_IWUSR | S_IRUGO);
  2293. MODULE_PARM_DESC(bdaddress, "BT MAC ADDRESS");
  2294.  
  2295. static char bt_chip_id[10] = "bcm4329";
  2296. module_param_string(bt_chip_id, bt_chip_id, sizeof(bt_chip_id), S_IWUSR | S_IRUGO);
  2297. MODULE_PARM_DESC(bt_chip_id, "BT's chip id");
  2298.  
  2299. static char bt_fw_version[10] = "v2.0.38";
  2300. module_param_string(bt_fw_version, bt_fw_version, sizeof(bt_fw_version), S_IWUSR | S_IRUGO);
  2301. MODULE_PARM_DESC(bt_fw_version, "BT's fw version");
  2302.  
  2303. static struct msm_i2c_device_platform_data msm_i2c_pdata = {
  2304. .i2c_clock = 400000,
  2305. .clock_strength = GPIO_8MA,
  2306. .data_strength = GPIO_4MA,
  2307. };
  2308.  
  2309. static void __init msm_device_i2c_init(void)
  2310. {
  2311. msm_i2c_gpio_init();
  2312. msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
  2313. }
  2314.  
  2315. //static struct vreg *qup_vreg;
  2316. static void qup_i2c_gpio_config(int adap_id, int config_type)
  2317. {
  2318. unsigned id;
  2319. /* Each adapter gets 2 lines from the table */
  2320. if (adap_id != 4)
  2321. return;
  2322. if (config_type) {
  2323. id = PCOM_GPIO_CFG(16, 2, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_16MA);
  2324. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  2325. id = PCOM_GPIO_CFG(17, 2, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_16MA);
  2326. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  2327. } else {
  2328. id = PCOM_GPIO_CFG(16, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_16MA);
  2329. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  2330. id = PCOM_GPIO_CFG(17, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_16MA);
  2331. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  2332. }
  2333. }
  2334.  
  2335. static struct msm_i2c_platform_data qup_i2c_pdata = {
  2336. .clk_freq = 384000,
  2337. .pclk = "camif_pad_pclk",
  2338. .msm_i2c_config_gpio = qup_i2c_gpio_config,
  2339. };
  2340.  
  2341. static void __init qup_device_i2c_init(void)
  2342. {
  2343. // if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
  2344. // pr_err("failed to request I2C gpios\n");
  2345.  
  2346. qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
  2347.  
  2348. }
  2349.  
  2350.  
  2351. static struct msm_pmem_setting pmem_setting = {
  2352. .pmem_start = MSM_PMEM_MDP_BASE,
  2353. .pmem_size = MSM_PMEM_MDP_SIZE,
  2354. .pmem_adsp_start = MSM_PMEM_ADSP_BASE,
  2355. .pmem_adsp_size = MSM_PMEM_ADSP_SIZE,
  2356. // .pmem_gpu0_start = MSM_PMEM_GPU0_BASE,
  2357. // .pmem_gpu0_size = MSM_PMEM_GPU0_SIZE,
  2358. // .pmem_gpu1_start = MSM_PMEM_GPU1_BASE,
  2359. // .pmem_gpu1_size = MSM_PMEM_GPU1_SIZE,
  2360. .pmem_camera_start = MSM_PMEM_CAMERA_BASE,
  2361. .pmem_camera_size = MSM_PMEM_CAMERA_SIZE,
  2362. .ram_console_start = MSM_RAM_CONSOLE_BASE,
  2363. .ram_console_size = MSM_RAM_CONSOLE_SIZE,
  2364. .kgsl_start = MSM_GPU_MEM_BASE,
  2365. .kgsl_size = MSM_GPU_MEM_SIZE,
  2366. };
  2367.  
  2368.  
  2369. static struct msm_acpu_clock_platform_data vivo_clock_data = {
  2370. .acpu_switch_time_us = 50,
  2371. .vdd_switch_time_us = 62,
  2372. .wait_for_irq_khz = 0,
  2373. };
  2374.  
  2375. static unsigned vivo_perf_acpu_table[] = {
  2376. 245000000,
  2377. 768000000,
  2378. 1024000000,
  2379. };
  2380.  
  2381. static struct perflock_platform_data vivo_perflock_data = {
  2382. .perf_acpu_table = vivo_perf_acpu_table,
  2383. .table_size = ARRAY_SIZE(vivo_perf_acpu_table),
  2384. };
  2385. #ifdef CONFIG_MSM_SSBI
  2386. static int vivo_pmic_init(struct device *dev)
  2387. {
  2388. struct pm8058_chip *pm_chip = NULL;
  2389.  
  2390. pm8058_gpios_init(pm_chip);
  2391. return 0;
  2392. }
  2393.  
  2394. static struct pm8058_platform_data vivo_pm8058_pdata = {
  2395. .irq_base = PM8058_FIRST_IRQ,
  2396. .gpio_base = FIRST_BOARD_GPIO,
  2397. .init = vivo_pmic_init,
  2398. .num_subdevs = 3,
  2399. .sub_devices_htc = {
  2400. { .name = "pm8058-gpio",
  2401. },
  2402. { .name = "pm8058-mpp",
  2403. },
  2404. { .name = "pm8058-pwm",
  2405. },
  2406. },
  2407. };
  2408.  
  2409. static struct msm_ssbi_platform_data vivo_ssbi_pmic_pdata = {
  2410. .slave = {
  2411. .name = "pm8058-core",
  2412. .irq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
  2413. .platform_data = &vivo_pm8058_pdata,
  2414. },
  2415. .rspinlock_name = "D:PMIC_SSBI",
  2416. };
  2417.  
  2418. static int __init vivo_ssbi_pmic_init(void)
  2419. {
  2420. int ret;
  2421. u32 id;
  2422.  
  2423. pr_info("%s()\n", __func__);
  2424. id = PCOM_GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_INPUT,
  2425. GPIO_NO_PULL, GPIO_2MA);
  2426. ret = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  2427. if (ret)
  2428. pr_err("%s: gpio %d cfg failed\n", __func__,
  2429. PMIC_GPIO_INT);
  2430.  
  2431. ret = gpiochip_reserve(vivo_pm8058_pdata.gpio_base,
  2432. PM8058_GPIOS);
  2433. WARN(ret, "can't reserve pm8058 gpios. badness will ensue...\n");
  2434. msm_device_ssbi_pmic.dev.platform_data = &vivo_ssbi_pmic_pdata;
  2435. return platform_device_register(&msm_device_ssbi_pmic);
  2436. }
  2437. #endif
  2438.  
  2439. static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
  2440. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].supported = 1,
  2441. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].suspend_enabled = 1,
  2442. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].idle_enabled = 1,
  2443. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency = 8594,
  2444. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].residency = 23740,
  2445.  
  2446. [MSM_PM_SLEEP_MODE_APPS_SLEEP].supported = 1,
  2447. [MSM_PM_SLEEP_MODE_APPS_SLEEP].suspend_enabled = 1,
  2448. [MSM_PM_SLEEP_MODE_APPS_SLEEP].idle_enabled = 1,
  2449. [MSM_PM_SLEEP_MODE_APPS_SLEEP].latency = 8594,
  2450. [MSM_PM_SLEEP_MODE_APPS_SLEEP].residency = 23740,
  2451.  
  2452. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE].supported = 1,
  2453. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE].suspend_enabled = 0,
  2454. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE].idle_enabled = 0,
  2455. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE].latency = 500,
  2456. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE].residency = 6000,
  2457.  
  2458. [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].supported = 1,
  2459. [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].suspend_enabled
  2460. = 1,
  2461. [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].idle_enabled = 0,
  2462. [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency = 443,
  2463. [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].residency = 1098,
  2464.  
  2465. [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].supported = 1,
  2466. [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].suspend_enabled = 1,
  2467. [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].idle_enabled = 1,
  2468. [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].latency = 2,
  2469. [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT].residency = 0,
  2470. };
  2471.  
  2472. static struct msm_spm_platform_data msm_spm_data __initdata = {
  2473. .reg_base_addr = MSM_SAW_BASE,
  2474.  
  2475. .reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
  2476. .reg_init_values[MSM_SPM_REG_SAW_SPM_CTL] = 0x18,
  2477. .reg_init_values[MSM_SPM_REG_SAW_SPM_SLP_TMR_DLY] = 0x00006666,
  2478. .reg_init_values[MSM_SPM_REG_SAW_SPM_WAKE_TMR_DLY] = 0xFF000666,
  2479.  
  2480. .reg_init_values[MSM_SPM_REG_SAW_SLP_CLK_EN] = 0x01,
  2481. .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_PRECLMP_EN] = 0x03,
  2482. .reg_init_values[MSM_SPM_REG_SAW_SLP_HSFS_POSTCLMP_EN] = 0x00,
  2483.  
  2484. .reg_init_values[MSM_SPM_REG_SAW_SLP_CLMP_EN] = 0x01,
  2485. .reg_init_values[MSM_SPM_REG_SAW_SLP_RST_EN] = 0x00,
  2486. .reg_init_values[MSM_SPM_REG_SAW_SPM_MPM_CFG] = 0x00,
  2487.  
  2488. .awake_vlevel = 0xF2,
  2489. .retention_vlevel = 0xE0,
  2490. .collapse_vlevel = 0x72,
  2491. .retention_mid_vlevel = 0xE0,
  2492. .collapse_mid_vlevel = 0xE0,
  2493.  
  2494. .vctl_timeout_us = 50,
  2495. };
  2496.  
  2497. static ssize_t vivo_virtual_keys_show(struct kobject *kobj,
  2498. struct kobj_attribute *attr, char *buf)
  2499. {
  2500. return sprintf(buf,
  2501. __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":58:860:74:60"
  2502. ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":185:860:80:60"
  2503. ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":300:860:90:60"
  2504. ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":417:860:64:60"
  2505. "\n");
  2506. }
  2507.  
  2508. static struct kobj_attribute vivo_virtual_keys_attr = {
  2509. .attr = {
  2510. .name = "virtualkeys.atmel-touchscreen",
  2511. .mode = S_IRUGO,
  2512. },
  2513. .show = &vivo_virtual_keys_show,
  2514. };
  2515.  
  2516. static struct kobj_attribute vivo_cy8c_virtual_keys_attr = {
  2517. .attr = {
  2518. .name = "virtualkeys.cy8c-touchscreen",
  2519. .mode = S_IRUGO,
  2520. },
  2521. .show = &vivo_virtual_keys_show,
  2522. };
  2523.  
  2524. static struct attribute *vivo_properties_attrs[] = {
  2525. &vivo_virtual_keys_attr.attr,
  2526. &vivo_cy8c_virtual_keys_attr.attr,
  2527. NULL
  2528. };
  2529.  
  2530. static struct attribute_group vivo_properties_attr_group = {
  2531. .attrs = vivo_properties_attrs,
  2532. };
  2533.  
  2534. static void vivo_reset(void)
  2535. {
  2536. gpio_set_value(VIVO_GPIO_PS_HOLD, 0);
  2537. }
  2538.  
  2539. static void __init vivo_init(void)
  2540. {
  2541. int rc = 0;
  2542. struct kobject *properties_kobj;
  2543.  
  2544. printk("vivo_init() revision=%d\n", system_rev);
  2545.  
  2546. /* Must set msm_hw_reset_hook before first proc comm */
  2547. msm_hw_reset_hook = vivo_reset;
  2548.  
  2549. if (socinfo_init() < 0)
  2550. printk(KERN_ERR "%s: socinfo_init() failed!\n", __func__);
  2551.  
  2552. msm_clock_init();
  2553.  
  2554. /* for bcm */
  2555. bt_export_bd_address();
  2556.  
  2557. #if defined(CONFIG_MSM_SERIAL_DEBUGGER)
  2558. if (!opt_disable_uart2)
  2559. msm_serial_debug_init(MSM_UART2_PHYS, INT_UART2,
  2560. &msm_device_uart2.dev, 23, MSM_GPIO_TO_INT(VIVO_GPIO_UART2_RX));
  2561. #endif
  2562.  
  2563. #ifdef CONFIG_SERIAL_MSM_HS
  2564. msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
  2565. msm_device_uart_dm1.name = "msm_serial_hs_bcm"; /* for bcm */
  2566. msm_add_serial_devices(3);
  2567. #else
  2568. msm_add_serial_devices(0);
  2569. #endif
  2570. /* disable microp */
  2571. /*gpio_direction_output(VIVO_GPIO_UP_RESET_N, 0);*/
  2572. msm_spm_init(&msm_spm_data, 1);
  2573. msm_acpu_clock_init(&vivo_clock_data);
  2574. perflock_init(&vivo_perflock_data);
  2575.  
  2576. properties_kobj = kobject_create_and_add("board_properties", NULL);
  2577. if (properties_kobj)
  2578. rc = sysfs_create_group(properties_kobj,
  2579. &vivo_properties_attr_group);
  2580. if (!properties_kobj || rc)
  2581. pr_err("failed to create board_properties\n");
  2582.  
  2583. msm_pm_set_platform_data(msm_pm_data);
  2584. msm_device_i2c_init();
  2585. qup_device_i2c_init();
  2586. msm7x30_init_marimba();
  2587. #ifdef CONFIG_MSM7KV2_AUDIO
  2588. msm_snddev_init();
  2589. aux_pcm_gpio_init();
  2590. #endif
  2591. i2c_register_board_info(2, msm_marimba_board_info,
  2592. ARRAY_SIZE(msm_marimba_board_info));
  2593. i2c_register_board_info(4 /* QUP ID */, msm_camera_boardinfo,
  2594. ARRAY_SIZE(msm_camera_boardinfo));
  2595.  
  2596. msm_init_pmic_vibrator();
  2597.  
  2598. #ifdef CONFIG_USB_ANDROID
  2599. vivo_add_usb_devices();
  2600. #endif
  2601. #ifdef CONFIG_USB_FUNCTION
  2602. msm_add_usb_devices(NULL, NULL);
  2603. #endif
  2604.  
  2605. msm_add_mem_devices(&pmem_setting);
  2606.  
  2607. platform_add_devices(devices, ARRAY_SIZE(devices));
  2608.  
  2609. if (system_rev == 0) {
  2610. #ifdef CONFIG_INPUT_CAPELLA_CM3602
  2611. pr_info("[%s] register devices_CM3602_Proximity\n", __func__);
  2612. platform_device_register(&capella_cm3602);
  2613. platform_device_register(&lightsensor_pdev);
  2614. #endif
  2615. } else {
  2616. #ifdef CONFIG_INPUT_CAPELLA_CM3628
  2617. pr_info("[%s] register i2c_CM3628_devices\n", __func__);
  2618. i2c_register_board_info(0, i2c_CM3628_devices,
  2619. ARRAY_SIZE(i2c_CM3628_devices));
  2620. #endif
  2621. }
  2622.  
  2623. if (board_emmc_boot()) {
  2624. #if defined(CONFIG_MSM_RMT_STORAGE_SERVER)
  2625. rmt_storage_add_ramfs();
  2626. #endif
  2627. create_proc_read_entry("emmc", 0, NULL, emmc_partition_read_proc, NULL);
  2628. } else
  2629. platform_device_register(&msm_device_nand);
  2630.  
  2631. #ifdef CONFIG_MSM_SSBI
  2632. vivo_ssbi_pmic_init();
  2633. #endif
  2634.  
  2635. config_vivo_emmc_gpios(); /* for emmc gpio reset test */
  2636. rc = vivo_init_mmc(system_rev);
  2637. if (rc != 0)
  2638. pr_crit("%s: Unable to initialize MMC\n", __func__);
  2639.  
  2640. #ifdef CONFIG_SPI_QSD_NEW
  2641. msm_qsd_spi_init();
  2642. #endif
  2643. spi_register_board_info(msm_spi_board_info, ARRAY_SIZE(msm_spi_board_info));
  2644.  
  2645. i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
  2646.  
  2647. i2c_register_board_info(0, i2c_Sensors_devices,
  2648. ARRAY_SIZE(i2c_Sensors_devices));
  2649.  
  2650. #ifdef CONFIG_I2C_SSBI
  2651. msm_device_ssbi6.dev.platform_data = &msm_i2c_ssbi6_pdata;
  2652. msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
  2653. #endif
  2654. vivo_audio_init();
  2655. vivo_init_keypad();
  2656. vivo_wifi_init();
  2657. //vivo and vivow will share one panel code
  2658. vivow_init_panel(system_rev);
  2659.  
  2660. if (system_rev == 0) {
  2661. pm8058_leds_data.led_config = pm_led_config;
  2662. pm8058_leds_data.num_leds = ARRAY_SIZE(pm_led_config);
  2663. }
  2664. }
  2665.  
  2666. static void __init vivo_fixup(struct machine_desc *desc, struct tag *tags,
  2667. char **cmdline, struct meminfo *mi)
  2668. {
  2669. printk("[%s]\n", __func__);
  2670.  
  2671. mi->nr_banks = 2;
  2672. mi->bank[0].start = MSM_LINUX_BASE1;
  2673. mi->bank[0].node = PHYS_TO_NID(MSM_LINUX_BASE1);
  2674. mi->bank[0].size = MSM_LINUX_SIZE1 + MSM_MEM_256MB_OFFSET;
  2675. mi->bank[1].start = MSM_LINUX_BASE2;
  2676. mi->bank[1].node = PHYS_TO_NID(MSM_LINUX_BASE2);
  2677. mi->bank[1].size = MSM_LINUX_SIZE2;
  2678. }
  2679.  
  2680. static void __init vivo_map_io(void)
  2681. {
  2682. printk("[%s]\n", __func__);
  2683.  
  2684. msm_map_common_io();
  2685. }
  2686.  
  2687. extern struct sys_timer msm_timer;
  2688.  
  2689. MACHINE_START(VIVO, "vivo")
  2690. #ifdef CONFIG_MSM_DEBUG_UART
  2691. .phys_io = MSM_DEBUG_UART_PHYS,
  2692. .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
  2693. #endif
  2694. .boot_params = 0x04400100,
  2695. .fixup = vivo_fixup,
  2696. .map_io = vivo_map_io,
  2697. .init_irq = msm_init_irq,
  2698. .init_machine = vivo_init,
  2699. .timer = &msm_timer,
  2700. MACHINE_END
Advertisement
Add Comment
Please, Sign In to add comment