PageRenderTime 686ms CodeModel.GetById 26ms RepoModel.GetById 5ms app.codeStats 0ms

/arch/arm/mach-fsm/board-trout.c

https://bitbucket.org/sammyz/iscream_thunderc-2.6.35-rebase
C | 881 lines | 752 code | 101 blank | 28 comment | 18 complexity | 85504ef419dca79703d2018dfdcf69cd MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /* arch/arm/mach-msm/board-trout.c
  2. *
  3. * Copyright (C) 2008 Google, Inc.
  4. * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/input.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/i2c.h>
  22. #include <linux/irq.h>
  23. #include <linux/keyreset.h>
  24. #include <linux/leds.h>
  25. #include <linux/switch.h>
  26. #include <linux/../../../drivers/staging/android/timed_gpio.h>
  27. #include <linux/synaptics_i2c_rmi.h>
  28. #include <linux/akm8976.h>
  29. #include <linux/sysdev.h>
  30. #include <linux/android_pmem.h>
  31. #include <linux/delay.h>
  32. #include <asm/gpio.h>
  33. #include <mach/hardware.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/mach/flash.h>
  38. #include <asm/system.h>
  39. #include <mach/system.h>
  40. #include <mach/vreg.h>
  41. #include <asm/io.h>
  42. #include <asm/delay.h>
  43. #include <asm/setup.h>
  44. #include <linux/gpio_event.h>
  45. #include <linux/mtd/nand.h>
  46. #include <linux/mtd/partitions.h>
  47. #include <asm/mach/mmc.h>
  48. #include <linux/mmc/sdio_ids.h>
  49. #include <linux/msm_audio.h>
  50. #include "board-trout.h"
  51. #include "gpio_chip.h"
  52. #include "pm.h"
  53. #include <mach/board.h>
  54. #include <mach/board_htc.h>
  55. #include <mach/msm_serial_hs.h>
  56. #include <mach/htc_pwrsink.h>
  57. #ifdef CONFIG_HTC_HEADSET
  58. #include <mach/htc_headset.h>
  59. #endif
  60. #ifdef CONFIG_WIFI_CONTROL_FUNC
  61. #include <linux/wifi_tiwlan.h>
  62. #endif
  63. #include "proc_comm.h"
  64. #include "devices.h"
  65. void msm_init_irq(void);
  66. void msm_init_gpio(void);
  67. extern int trout_init_mmc(unsigned int);
  68. #ifdef CONFIG_WIFI_CONTROL_FUNC
  69. #ifdef CONFIG_WIFI_MEM_PREALLOC
  70. extern int trout_init_wifi_mem(void);
  71. #endif
  72. extern struct wifi_platform_data trout_wifi_control;
  73. #endif
  74. struct trout_axis_info {
  75. struct gpio_event_axis_info info;
  76. uint16_t in_state;
  77. uint16_t out_state;
  78. };
  79. static bool nav_just_on;
  80. static int nav_on_jiffies;
  81. uint16_t trout_axis_map(struct gpio_event_axis_info *info, uint16_t in)
  82. {
  83. struct trout_axis_info *ai = container_of(info, struct trout_axis_info, info);
  84. uint16_t out = ai->out_state;
  85. if (nav_just_on) {
  86. if (jiffies == nav_on_jiffies || jiffies == nav_on_jiffies + 1)
  87. goto ignore;
  88. nav_just_on = 0;
  89. }
  90. if((ai->in_state ^ in) & 1)
  91. out--;
  92. if((ai->in_state ^ in) & 2)
  93. out++;
  94. ai->out_state = out;
  95. ignore:
  96. ai->in_state = in;
  97. return out;
  98. }
  99. int trout_nav_power(const struct gpio_event_platform_data *pdata, bool on)
  100. {
  101. gpio_set_value(TROUT_GPIO_JOG_EN, on);
  102. if (on) {
  103. nav_just_on = 1;
  104. nav_on_jiffies = jiffies;
  105. }
  106. return 0;
  107. }
  108. static uint32_t trout_4_x_axis_gpios[] = {
  109. TROUT_4_BALL_LEFT_0, TROUT_4_BALL_RIGHT_0
  110. };
  111. static uint32_t trout_5_x_axis_gpios[] = {
  112. TROUT_5_BALL_LEFT_0, TROUT_5_BALL_RIGHT_0
  113. };
  114. static struct trout_axis_info trout_x_axis = {
  115. .info = {
  116. .info.func = gpio_event_axis_func,
  117. .count = ARRAY_SIZE(trout_5_x_axis_gpios),
  118. .type = EV_REL,
  119. .code = REL_X,
  120. .decoded_size = 1U << ARRAY_SIZE(trout_5_x_axis_gpios),
  121. .map = trout_axis_map,
  122. .gpio = trout_5_x_axis_gpios,
  123. .flags = GPIOEAF_PRINT_UNKNOWN_DIRECTION /*| GPIOEAF_PRINT_RAW | GPIOEAF_PRINT_EVENT */
  124. }
  125. };
  126. static uint32_t trout_4_y_axis_gpios[] = {
  127. TROUT_4_BALL_UP_0, TROUT_4_BALL_DOWN_0
  128. };
  129. static uint32_t trout_5_y_axis_gpios[] = {
  130. TROUT_5_BALL_UP_0, TROUT_5_BALL_DOWN_0
  131. };
  132. static struct trout_axis_info trout_y_axis = {
  133. .info = {
  134. .info.func = gpio_event_axis_func,
  135. .count = ARRAY_SIZE(trout_5_y_axis_gpios),
  136. .type = EV_REL,
  137. .code = REL_Y,
  138. .decoded_size = 1U << ARRAY_SIZE(trout_5_y_axis_gpios),
  139. .map = trout_axis_map,
  140. .gpio = trout_5_y_axis_gpios,
  141. .flags = GPIOEAF_PRINT_UNKNOWN_DIRECTION /*| GPIOEAF_PRINT_RAW | GPIOEAF_PRINT_EVENT */
  142. }
  143. };
  144. static struct gpio_event_direct_entry trout_nav_buttons[] = {
  145. { TROUT_GPIO_NAVI_ACT_N, BTN_MOUSE }
  146. };
  147. static struct gpio_event_input_info trout_nav_button_info = {
  148. .info.func = gpio_event_input_func,
  149. .flags = 0,
  150. .type = EV_KEY,
  151. .keymap = trout_nav_buttons,
  152. .keymap_size = ARRAY_SIZE(trout_nav_buttons)
  153. };
  154. static struct gpio_event_info *trout_nav_info[] = {
  155. &trout_x_axis.info.info,
  156. &trout_y_axis.info.info,
  157. &trout_nav_button_info.info
  158. };
  159. static struct gpio_event_platform_data trout_nav_data = {
  160. .name = "trout-nav",
  161. .info = trout_nav_info,
  162. .info_count = ARRAY_SIZE(trout_nav_info),
  163. .power = trout_nav_power,
  164. };
  165. static struct platform_device trout_nav_device = {
  166. .name = GPIO_EVENT_DEV_NAME,
  167. .id = 2,
  168. .dev = {
  169. .platform_data = &trout_nav_data,
  170. },
  171. };
  172. static int trout_reset_keys_up[] = {
  173. BTN_MOUSE,
  174. 0
  175. };
  176. static struct keyreset_platform_data trout_reset_keys_pdata = {
  177. .keys_up = trout_reset_keys_up,
  178. .keys_down = {
  179. KEY_SEND,
  180. KEY_MENU,
  181. KEY_END,
  182. 0
  183. },
  184. };
  185. struct platform_device trout_reset_keys_device = {
  186. .name = KEYRESET_NAME,
  187. .dev.platform_data = &trout_reset_keys_pdata,
  188. };
  189. static int trout_ts_power(int on)
  190. {
  191. int tp_ls_gpio = system_rev < 5 ? TROUT_4_TP_LS_EN : TROUT_5_TP_LS_EN;
  192. if (on) {
  193. gpio_set_value(TROUT_GPIO_TP_I2C_PULL, 1);
  194. gpio_set_value(TROUT_GPIO_TP_EN, 1);
  195. /* touchscreen must be powered before we enable i2c pullup */
  196. msleep(2);
  197. /* enable touch panel level shift */
  198. gpio_set_value(tp_ls_gpio, 1);
  199. msleep(2);
  200. }
  201. else {
  202. gpio_set_value(tp_ls_gpio, 0);
  203. udelay(50);
  204. gpio_set_value(TROUT_GPIO_TP_EN, 0);
  205. gpio_set_value(TROUT_GPIO_TP_I2C_PULL, 0);
  206. }
  207. return 0;
  208. }
  209. static struct synaptics_i2c_rmi_platform_data trout_ts_data[] = {
  210. {
  211. .version = 0x010c,
  212. .power = trout_ts_power,
  213. .flags = SYNAPTICS_FLIP_Y | SYNAPTICS_SNAP_TO_INACTIVE_EDGE,
  214. .inactive_left = -100 * 0x10000 / 4334,
  215. .inactive_right = -100 * 0x10000 / 4334,
  216. .inactive_top = -40 * 0x10000 / 6696,
  217. .inactive_bottom = -40 * 0x10000 / 6696,
  218. .snap_left_on = 300 * 0x10000 / 4334,
  219. .snap_left_off = 310 * 0x10000 / 4334,
  220. .snap_right_on = 300 * 0x10000 / 4334,
  221. .snap_right_off = 310 * 0x10000 / 4334,
  222. .snap_top_on = 100 * 0x10000 / 6696,
  223. .snap_top_off = 110 * 0x10000 / 6696,
  224. .snap_bottom_on = 100 * 0x10000 / 6696,
  225. .snap_bottom_off = 110 * 0x10000 / 6696,
  226. },
  227. {
  228. .flags = SYNAPTICS_FLIP_Y | SYNAPTICS_SNAP_TO_INACTIVE_EDGE,
  229. .inactive_left = ((4674 - 4334) / 2 + 200) * 0x10000 / 4334,
  230. .inactive_right = ((4674 - 4334) / 2 + 200) * 0x10000 / 4334,
  231. .inactive_top = ((6946 - 6696) / 2) * 0x10000 / 6696,
  232. .inactive_bottom = ((6946 - 6696) / 2) * 0x10000 / 6696,
  233. }
  234. };
  235. static struct akm8976_platform_data compass_platform_data = {
  236. .reset = TROUT_GPIO_COMPASS_RST_N,
  237. .clk_on = TROUT_GPIO_COMPASS_32K_EN,
  238. .intr = TROUT_GPIO_COMPASS_IRQ,
  239. };
  240. static struct i2c_board_info i2c_devices[] = {
  241. {
  242. I2C_BOARD_INFO(SYNAPTICS_I2C_RMI_NAME, 0x20),
  243. .platform_data = trout_ts_data,
  244. .irq = TROUT_GPIO_TO_INT(TROUT_GPIO_TP_ATT_N)
  245. },
  246. {
  247. I2C_BOARD_INFO("elan-touch", 0x10),
  248. .irq = TROUT_GPIO_TO_INT(TROUT_GPIO_TP_ATT_N),
  249. },
  250. {
  251. I2C_BOARD_INFO("akm8976", 0x1C),
  252. .platform_data = &compass_platform_data,
  253. .irq = TROUT_GPIO_TO_INT(TROUT_GPIO_COMPASS_IRQ),
  254. },
  255. {
  256. I2C_BOARD_INFO("pca963x", 0x62),
  257. },
  258. #if defined(CONFIG_MSM_CAMERA) && defined(CONFIG_MT9T013)
  259. {
  260. I2C_BOARD_INFO("mt9t013", 0x6C),
  261. },
  262. #endif
  263. #ifdef CONFIG_SENSORS_MT9T013
  264. {
  265. I2C_BOARD_INFO("mt9t013", 0x6C >> 1),
  266. },
  267. #endif
  268. };
  269. static struct timed_gpio timed_gpios[] = {
  270. {
  271. .name = "vibrator",
  272. .gpio = TROUT_GPIO_HAPTIC_PWM,
  273. .max_timeout = 15000,
  274. },
  275. {
  276. .name = "flash",
  277. .gpio = TROUT_GPIO_FLASH_EN,
  278. .max_timeout = 400,
  279. },
  280. };
  281. static struct timed_gpio_platform_data timed_gpio_data = {
  282. .num_gpios = ARRAY_SIZE(timed_gpios),
  283. .gpios = timed_gpios,
  284. };
  285. static struct platform_device android_timed_gpios = {
  286. .name = "timed-gpio",
  287. .id = -1,
  288. .dev = {
  289. .platform_data = &timed_gpio_data,
  290. },
  291. };
  292. static struct gpio_led android_led_list[] = {
  293. {
  294. .name = "spotlight",
  295. .gpio = TROUT_GPIO_SPOTLIGHT_EN,
  296. },
  297. {
  298. .name = "keyboard-backlight",
  299. .gpio = TROUT_GPIO_QTKEY_LED_EN,
  300. },
  301. {
  302. .name = "button-backlight",
  303. .gpio = TROUT_GPIO_UI_LED_EN,
  304. },
  305. };
  306. static struct gpio_led_platform_data android_leds_data = {
  307. .num_leds = ARRAY_SIZE(android_led_list),
  308. .leds = android_led_list,
  309. };
  310. static struct platform_device android_leds = {
  311. .name = "leds-gpio",
  312. .id = -1,
  313. .dev = {
  314. .platform_data = &android_leds_data,
  315. },
  316. };
  317. static struct gpio_switch_platform_data sd_door_switch_data = {
  318. .name = "sd-door",
  319. .gpio = TROUT_GPIO_SD_DOOR_N,
  320. .state_on = "open",
  321. .state_off = "closed",
  322. };
  323. static struct platform_device sd_door_switch = {
  324. .name = "switch-gpio",
  325. .id = -1,
  326. .dev = {
  327. .platform_data = &sd_door_switch_data,
  328. },
  329. };
  330. #ifdef CONFIG_HTC_HEADSET
  331. static void h2w_config_cpld(int route)
  332. {
  333. switch (route) {
  334. case H2W_UART3:
  335. gpio_set_value(TROUT_GPIO_H2W_SEL0, 0);
  336. gpio_set_value(TROUT_GPIO_H2W_SEL1, 1);
  337. break;
  338. case H2W_GPIO:
  339. gpio_set_value(TROUT_GPIO_H2W_SEL0, 0);
  340. gpio_set_value(TROUT_GPIO_H2W_SEL1, 0);
  341. break;
  342. }
  343. }
  344. static void h2w_init_cpld(void)
  345. {
  346. h2w_config_cpld(H2W_UART3);
  347. gpio_set_value(TROUT_GPIO_H2W_CLK_DIR, 0);
  348. gpio_set_value(TROUT_GPIO_H2W_DAT_DIR, 0);
  349. }
  350. static struct h2w_platform_data trout_h2w_data = {
  351. .cable_in1 = TROUT_GPIO_CABLE_IN1,
  352. .cable_in2 = TROUT_GPIO_CABLE_IN2,
  353. .h2w_clk = TROUT_GPIO_H2W_CLK_GPI,
  354. .h2w_data = TROUT_GPIO_H2W_DAT_GPI,
  355. .debug_uart = H2W_UART3,
  356. .config_cpld = h2w_config_cpld,
  357. .init_cpld = h2w_init_cpld,
  358. };
  359. static struct platform_device trout_h2w = {
  360. .name = "h2w",
  361. .id = -1,
  362. .dev = {
  363. .platform_data = &trout_h2w_data,
  364. },
  365. };
  366. #endif
  367. static void trout_phy_reset(void)
  368. {
  369. gpio_set_value(TROUT_GPIO_USB_PHY_RST_N, 0);
  370. mdelay(10);
  371. gpio_set_value(TROUT_GPIO_USB_PHY_RST_N, 1);
  372. mdelay(10);
  373. }
  374. static void config_camera_on_gpios(void);
  375. static void config_camera_off_gpios(void);
  376. #ifdef CONFIG_MSM_CAMERA
  377. static struct msm_camera_device_platform_data msm_camera_device_data = {
  378. .camera_gpio_on = config_camera_on_gpios,
  379. .camera_gpio_off = config_camera_off_gpios,
  380. .ioext.mdcphy = MSM_MDC_PHYS,
  381. .ioext.mdcsz = MSM_MDC_SIZE,
  382. .ioext.appphy = MSM_CLK_CTL_PHYS,
  383. .ioext.appsz = MSM_CLK_CTL_SIZE,
  384. };
  385. #ifdef CONFIG_MT9T013
  386. static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
  387. .sensor_name = "mt9t013",
  388. .sensor_reset = 108,
  389. .sensor_pwd = 85,
  390. .vcm_pwd = TROUT_GPIO_VCM_PWDN,
  391. .pdata = &msm_camera_device_data,
  392. .flash_type = MSM_CAMERA_FLASH_NONE
  393. };
  394. static struct platform_device msm_camera_sensor_mt9t013 = {
  395. .name = "msm_camera_mt9t013",
  396. .dev = {
  397. .platform_data = &msm_camera_sensor_mt9t013_data,
  398. },
  399. };
  400. #endif
  401. #endif
  402. #ifdef CONFIG_SENSORS_MT9T013
  403. static struct msm_camera_legacy_device_platform_data msm_camera_device_mt9t013 = {
  404. .sensor_reset = 108,
  405. .sensor_pwd = 85,
  406. .vcm_pwd = TROUT_GPIO_VCM_PWDN,
  407. .config_gpio_on = config_camera_on_gpios,
  408. .config_gpio_off = config_camera_off_gpios,
  409. };
  410. static struct platform_device trout_camera = {
  411. .name = "camera",
  412. .dev = {
  413. .platform_data = &msm_camera_device_mt9t013,
  414. },
  415. };
  416. #endif
  417. static struct pwr_sink trout_pwrsink_table[] = {
  418. {
  419. .id = PWRSINK_AUDIO,
  420. .ua_max = 90000,
  421. },
  422. {
  423. .id = PWRSINK_BACKLIGHT,
  424. .ua_max = 128000,
  425. },
  426. {
  427. .id = PWRSINK_LED_BUTTON,
  428. .ua_max = 17000,
  429. },
  430. {
  431. .id = PWRSINK_LED_KEYBOARD,
  432. .ua_max = 22000,
  433. },
  434. {
  435. .id = PWRSINK_GP_CLK,
  436. .ua_max = 30000,
  437. },
  438. {
  439. .id = PWRSINK_BLUETOOTH,
  440. .ua_max = 15000,
  441. },
  442. {
  443. .id = PWRSINK_CAMERA,
  444. .ua_max = 0,
  445. },
  446. {
  447. .id = PWRSINK_SDCARD,
  448. .ua_max = 0,
  449. },
  450. {
  451. .id = PWRSINK_VIDEO,
  452. .ua_max = 0,
  453. },
  454. {
  455. .id = PWRSINK_WIFI,
  456. .ua_max = 200000,
  457. },
  458. {
  459. .id = PWRSINK_SYSTEM_LOAD,
  460. .ua_max = 63000,
  461. .percent_util = 100,
  462. },
  463. };
  464. static struct pwr_sink_platform_data trout_pwrsink_data = {
  465. .num_sinks = ARRAY_SIZE(trout_pwrsink_table),
  466. .sinks = trout_pwrsink_table,
  467. .suspend_late = NULL,
  468. .resume_early = NULL,
  469. .suspend_early = NULL,
  470. .resume_late = NULL,
  471. };
  472. static struct platform_device trout_pwr_sink = {
  473. .name = "htc_pwrsink",
  474. .id = -1,
  475. .dev = {
  476. .platform_data = &trout_pwrsink_data,
  477. },
  478. };
  479. static struct platform_device trout_rfkill = {
  480. .name = "trout_rfkill",
  481. .id = -1,
  482. };
  483. static struct msm_pmem_setting pmem_setting = {
  484. .pmem_start = MSM_PMEM_MDP_BASE,
  485. .pmem_size = MSM_PMEM_MDP_SIZE,
  486. .pmem_adsp_start = MSM_PMEM_ADSP_BASE,
  487. .pmem_adsp_size = MSM_PMEM_ADSP_SIZE,
  488. .pmem_gpu0_start = MSM_PMEM_GPU0_BASE,
  489. .pmem_gpu0_size = MSM_PMEM_GPU0_SIZE,
  490. .pmem_gpu1_start = MSM_PMEM_GPU1_BASE,
  491. .pmem_gpu1_size = MSM_PMEM_GPU1_SIZE,
  492. .pmem_camera_start = MSM_PMEM_CAMERA_BASE,
  493. .pmem_camera_size = MSM_PMEM_CAMERA_SIZE,
  494. .ram_console_start = MSM_RAM_CONSOLE_BASE,
  495. .ram_console_size = MSM_RAM_CONSOLE_SIZE,
  496. };
  497. #ifdef CONFIG_WIFI_CONTROL_FUNC
  498. static struct platform_device trout_wifi = {
  499. .name = "msm_wifi",
  500. .id = 1,
  501. .num_resources = 0,
  502. .resource = NULL,
  503. .dev = {
  504. .platform_data = &trout_wifi_control,
  505. },
  506. };
  507. #endif
  508. #define SND(num, desc) { .name = desc, .id = num }
  509. static struct snd_endpoint snd_endpoints_list[] = {
  510. SND(0, "HANDSET"),
  511. SND(1, "SPEAKER"),
  512. SND(2, "HEADSET"),
  513. SND(3, "BT"),
  514. SND(44, "BT_EC_OFF"),
  515. SND(10, "HEADSET_AND_SPEAKER"),
  516. SND(256, "CURRENT"),
  517. /* Bluetooth accessories. */
  518. SND(12, "HTC BH S100"),
  519. SND(13, "HTC BH M100"),
  520. SND(14, "Motorola H500"),
  521. SND(15, "Nokia HS-36W"),
  522. SND(16, "PLT 510v.D"),
  523. SND(17, "M2500 by Plantronics"),
  524. SND(18, "Nokia HDW-3"),
  525. SND(19, "HBH-608"),
  526. SND(20, "HBH-DS970"),
  527. SND(21, "i.Tech BlueBAND"),
  528. SND(22, "Nokia BH-800"),
  529. SND(23, "Motorola H700"),
  530. SND(24, "HTC BH M200"),
  531. SND(25, "Jabra JX10"),
  532. SND(26, "320Plantronics"),
  533. SND(27, "640Plantronics"),
  534. SND(28, "Jabra BT500"),
  535. SND(29, "Motorola HT820"),
  536. SND(30, "HBH-IV840"),
  537. SND(31, "6XXPlantronics"),
  538. SND(32, "3XXPlantronics"),
  539. SND(33, "HBH-PV710"),
  540. SND(34, "Motorola H670"),
  541. SND(35, "HBM-300"),
  542. SND(36, "Nokia BH-208"),
  543. SND(37, "Samsung WEP410"),
  544. SND(38, "Jabra BT8010"),
  545. SND(39, "Motorola S9"),
  546. SND(40, "Jabra BT620s"),
  547. SND(41, "Nokia BH-902"),
  548. SND(42, "HBH-DS220"),
  549. SND(43, "HBH-DS980"),
  550. };
  551. #undef SND
  552. static struct msm_snd_endpoints trout_snd_endpoints = {
  553. .endpoints = snd_endpoints_list,
  554. .num = ARRAY_SIZE(snd_endpoints_list),
  555. };
  556. static struct platform_device trout_snd = {
  557. .name = "msm_snd",
  558. .id = -1,
  559. .dev = {
  560. .platform_data = &trout_snd_endpoints,
  561. },
  562. };
  563. static struct platform_device *devices[] __initdata = {
  564. &msm_device_smd,
  565. &msm_device_dmov,
  566. &msm_device_nand,
  567. &msm_device_i2c,
  568. &msm_device_uart1,
  569. #if !defined(CONFIG_MSM_SERIAL_DEBUGGER) && !defined(CONFIG_TROUT_H2W)
  570. &msm_device_uart3,
  571. #endif
  572. #ifdef CONFIG_SERIAL_MSM_HS
  573. &msm_device_uart_dm1,
  574. #endif
  575. &trout_nav_device,
  576. &trout_reset_keys_device,
  577. &android_leds,
  578. &sd_door_switch,
  579. &android_timed_gpios,
  580. #ifdef CONFIG_MT9T013
  581. &msm_camera_sensor_mt9t013,
  582. #endif
  583. #ifdef CONFIG_SENSORS_MT9T013
  584. &trout_camera,
  585. #endif
  586. &trout_rfkill,
  587. #ifdef CONFIG_WIFI_CONTROL_FUNC
  588. &trout_wifi,
  589. #endif
  590. #ifdef CONFIG_HTC_HEADSET
  591. &trout_h2w,
  592. #endif
  593. #ifdef CONFIG_HTC_PWRSINK
  594. &trout_pwr_sink,
  595. #endif
  596. &trout_snd,
  597. };
  598. extern struct sys_timer msm_timer;
  599. static void __init trout_init_irq(void)
  600. {
  601. printk("trout_init_irq()\n");
  602. msm_init_irq();
  603. }
  604. static uint opt_disable_uart3;
  605. module_param_named(disable_uart3, opt_disable_uart3, uint, 0);
  606. static void trout_reset(void)
  607. {
  608. gpio_set_value(TROUT_GPIO_PS_HOLD, 0);
  609. }
  610. static uint32_t gpio_table[] = {
  611. /* BLUETOOTH */
  612. #ifdef CONFIG_SERIAL_MSM_HS
  613. PCOM_GPIO_CFG(43, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* RTS */
  614. PCOM_GPIO_CFG(44, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* CTS */
  615. PCOM_GPIO_CFG(45, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* RX */
  616. PCOM_GPIO_CFG(46, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* TX */
  617. #else
  618. PCOM_GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* RTS */
  619. PCOM_GPIO_CFG(44, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* CTS */
  620. PCOM_GPIO_CFG(45, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* RX */
  621. PCOM_GPIO_CFG(46, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* TX */
  622. #endif
  623. };
  624. static uint32_t camera_off_gpio_table[] = {
  625. /* CAMERA */
  626. PCOM_GPIO_CFG(2, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* DAT2 */
  627. PCOM_GPIO_CFG(3, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* DAT3 */
  628. PCOM_GPIO_CFG(4, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* DAT4 */
  629. PCOM_GPIO_CFG(5, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* DAT5 */
  630. PCOM_GPIO_CFG(6, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* DAT6 */
  631. PCOM_GPIO_CFG(7, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* DAT7 */
  632. PCOM_GPIO_CFG(8, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* DAT8 */
  633. PCOM_GPIO_CFG(9, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* DAT9 */
  634. PCOM_GPIO_CFG(10, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* DAT10 */
  635. PCOM_GPIO_CFG(11, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* DAT11 */
  636. PCOM_GPIO_CFG(12, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* PCLK */
  637. PCOM_GPIO_CFG(13, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* HSYNC_IN */
  638. PCOM_GPIO_CFG(14, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* VSYNC_IN */
  639. PCOM_GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* MCLK */
  640. };
  641. static uint32_t camera_on_gpio_table[] = {
  642. /* CAMERA */
  643. PCOM_GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
  644. PCOM_GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
  645. PCOM_GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
  646. PCOM_GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
  647. PCOM_GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
  648. PCOM_GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
  649. PCOM_GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
  650. PCOM_GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
  651. PCOM_GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
  652. PCOM_GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
  653. PCOM_GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* PCLK */
  654. PCOM_GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
  655. PCOM_GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
  656. PCOM_GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_16MA), /* MCLK */
  657. };
  658. static void config_gpio_table(uint32_t *table, int len)
  659. {
  660. int n;
  661. unsigned id;
  662. for(n = 0; n < len; n++) {
  663. id = table[n];
  664. msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &id, 0);
  665. }
  666. }
  667. static void config_camera_on_gpios(void)
  668. {
  669. config_gpio_table(camera_on_gpio_table,
  670. ARRAY_SIZE(camera_on_gpio_table));
  671. }
  672. static void config_camera_off_gpios(void)
  673. {
  674. config_gpio_table(camera_off_gpio_table,
  675. ARRAY_SIZE(camera_off_gpio_table));
  676. }
  677. static void __init config_gpios(void)
  678. {
  679. config_gpio_table(gpio_table, ARRAY_SIZE(gpio_table));
  680. config_camera_off_gpios();
  681. }
  682. void msm_serial_debug_init(unsigned int base, int irq,
  683. struct device *clk_device, int signal_irq);
  684. static struct msm_acpu_clock_platform_data trout_clock_data = {
  685. .acpu_switch_time_us = 20,
  686. .max_speed_delta_khz = 256000,
  687. .vdd_switch_time_us = 62,
  688. };
  689. #ifdef CONFIG_SERIAL_MSM_HS
  690. static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = {
  691. .wakeup_irq = MSM_GPIO_TO_INT(45),
  692. .inject_rx_on_wakeup = 1,
  693. .rx_to_inject = 0x32,
  694. };
  695. #endif
  696. static struct msm_pm_platform_data msm_pm_data[MSM_PM_SLEEP_MODE_NR] = {
  697. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency = 16000,
  698. [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency = 12000,
  699. [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency = 2000,
  700. };
  701. static void __init trout_init(void)
  702. {
  703. int rc;
  704. printk("trout_init() revision=%d\n", system_rev);
  705. /*
  706. * Setup common MSM GPIOS
  707. */
  708. config_gpios();
  709. msm_hw_reset_hook = trout_reset;
  710. gpio_direction_output(system_rev < 5 ?
  711. TROUT_4_TP_LS_EN : TROUT_5_TP_LS_EN, 0);
  712. msm_acpu_clock_init(&trout_clock_data);
  713. #if defined(CONFIG_MSM_SERIAL_DEBUGGER)
  714. if (!opt_disable_uart3)
  715. msm_serial_debug_init(MSM_UART3_PHYS, INT_UART3,
  716. &msm_device_uart3.dev, 1);
  717. #endif
  718. /* gpio_configure(108, IRQF_TRIGGER_LOW); */
  719. /* put the AF VCM in powerdown mode to avoid noise */
  720. gpio_set_value(TROUT_GPIO_VCM_PWDN, 1);
  721. mdelay(100);
  722. if (system_rev < 5) {
  723. trout_x_axis.info.gpio = trout_4_x_axis_gpios;
  724. trout_y_axis.info.gpio = trout_4_y_axis_gpios;
  725. }
  726. #ifdef CONFIG_SERIAL_MSM_HS
  727. msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
  728. #endif
  729. msm_add_usb_devices(trout_phy_reset);
  730. msm_add_mem_devices(&pmem_setting);
  731. rc = trout_init_mmc(system_rev);
  732. if (rc)
  733. printk(KERN_CRIT "%s: MMC init failure (%d)\n", __func__, rc);
  734. #ifdef CONFIG_WIFI_MEM_PREALLOC
  735. rc = trout_init_wifi_mem();
  736. if (rc)
  737. printk(KERN_CRIT "%s: WiFi Memory init failure (%d)\n", __func__, rc);
  738. #endif
  739. platform_add_devices(devices, ARRAY_SIZE(devices));
  740. i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
  741. msm_pm_set_platform_data(msm_pm_data, ARRAY_SIZE(msm_pm_data));
  742. /* SD card door should wake the device */
  743. set_irq_wake(TROUT_GPIO_TO_INT(TROUT_GPIO_SD_DOOR_N), 1);
  744. }
  745. static struct map_desc trout_io_desc[] __initdata = {
  746. {
  747. .virtual = TROUT_CPLD_BASE,
  748. .pfn = __phys_to_pfn(TROUT_CPLD_START),
  749. .length = TROUT_CPLD_SIZE,
  750. .type = MT_DEVICE_NONSHARED
  751. }
  752. };
  753. static void __init trout_fixup(struct machine_desc *desc, struct tag *tags,
  754. char **cmdline, struct meminfo *mi)
  755. {
  756. mi->nr_banks=1;
  757. mi->bank[0].start = PHYS_OFFSET;
  758. mi->bank[0].node = PHYS_TO_NID(PHYS_OFFSET);
  759. mi->bank[0].size = (101*1024*1024);
  760. }
  761. static void __init trout_map_io(void)
  762. {
  763. msm_shared_ram_phys = 0x01F00000;
  764. msm_map_common_io();
  765. iotable_init(trout_io_desc, ARRAY_SIZE(trout_io_desc));
  766. msm_clock_init(msm_clocks_7x01a, msm_num_clocks_7x01a);
  767. }
  768. MACHINE_START(TROUT, "trout")
  769. /* Maintainer: Brian Swetland <swetland@google.com> */
  770. #ifdef CONFIG_MSM_DEBUG_UART
  771. .phys_io = MSM_DEBUG_UART_PHYS,
  772. .io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
  773. #endif
  774. .boot_params = PHYS_OFFSET + 0x100,
  775. .fixup = trout_fixup,
  776. .map_io = trout_map_io,
  777. .init_irq = trout_init_irq,
  778. .init_machine = trout_init,
  779. .timer = &msm_timer,
  780. MACHINE_END