palmtreo.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. /*
  2. * Hardware definitions for Palm Treo smartphones
  3. *
  4. * currently supported:
  5. * Palm Treo 680 (GSM)
  6. * Palm Centro 685 (GSM)
  7. *
  8. * Author: Tomas Cech <sleep_walker@suse.cz>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. *
  14. * (find more info at www.hackndev.com)
  15. *
  16. */
  17. #include <linux/platform_device.h>
  18. #include <linux/delay.h>
  19. #include <linux/irq.h>
  20. #include <linux/gpio_keys.h>
  21. #include <linux/input.h>
  22. #include <linux/memblock.h>
  23. #include <linux/pda_power.h>
  24. #include <linux/pwm_backlight.h>
  25. #include <linux/gpio.h>
  26. #include <linux/power_supply.h>
  27. #include <linux/w1-gpio.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include <mach/pxa27x.h>
  32. #include <mach/pxa27x-udc.h>
  33. #include <mach/audio.h>
  34. #include <mach/palmtreo.h>
  35. #include <mach/mmc.h>
  36. #include <mach/pxafb.h>
  37. #include <mach/irda.h>
  38. #include <plat/pxa27x_keypad.h>
  39. #include <mach/udc.h>
  40. #include <mach/ohci.h>
  41. #include <mach/pxa2xx-regs.h>
  42. #include <mach/palmasoc.h>
  43. #include <mach/camera.h>
  44. #include <mach/palm27x.h>
  45. #include <sound/pxa2xx-lib.h>
  46. #include "generic.h"
  47. #include "devices.h"
  48. /******************************************************************************
  49. * Pin configuration
  50. ******************************************************************************/
  51. static unsigned long treo_pin_config[] __initdata = {
  52. /* MMC */
  53. GPIO32_MMC_CLK,
  54. GPIO92_MMC_DAT_0,
  55. GPIO109_MMC_DAT_1,
  56. GPIO110_MMC_DAT_2,
  57. GPIO111_MMC_DAT_3,
  58. GPIO112_MMC_CMD,
  59. GPIO113_GPIO, /* SD detect */
  60. /* AC97 */
  61. GPIO28_AC97_BITCLK,
  62. GPIO29_AC97_SDATA_IN_0,
  63. GPIO30_AC97_SDATA_OUT,
  64. GPIO31_AC97_SYNC,
  65. GPIO89_AC97_SYSCLK,
  66. GPIO95_AC97_nRESET,
  67. /* IrDA */
  68. GPIO46_FICP_RXD,
  69. GPIO47_FICP_TXD,
  70. /* PWM */
  71. GPIO16_PWM0_OUT,
  72. /* USB */
  73. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* usb detect */
  74. /* MATRIX KEYPAD */
  75. GPIO101_KP_MKIN_1,
  76. GPIO102_KP_MKIN_2,
  77. GPIO97_KP_MKIN_3,
  78. GPIO98_KP_MKIN_4,
  79. GPIO91_KP_MKIN_6,
  80. GPIO13_KP_MKIN_7,
  81. GPIO103_KP_MKOUT_0 | MFP_LPM_DRIVE_HIGH,
  82. GPIO104_KP_MKOUT_1,
  83. GPIO105_KP_MKOUT_2,
  84. GPIO106_KP_MKOUT_3,
  85. GPIO107_KP_MKOUT_4,
  86. GPIO108_KP_MKOUT_5,
  87. GPIO96_KP_MKOUT_6,
  88. GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH, /* Hotsync button */
  89. /* LCD */
  90. GPIOxx_LCD_TFT_16BPP,
  91. /* Quick Capture Interface */
  92. GPIO84_CIF_FV,
  93. GPIO85_CIF_LV,
  94. GPIO53_CIF_MCLK,
  95. GPIO54_CIF_PCLK,
  96. GPIO81_CIF_DD_0,
  97. GPIO55_CIF_DD_1,
  98. GPIO51_CIF_DD_2,
  99. GPIO50_CIF_DD_3,
  100. GPIO52_CIF_DD_4,
  101. GPIO48_CIF_DD_5,
  102. GPIO17_CIF_DD_6,
  103. GPIO12_CIF_DD_7,
  104. /* I2C */
  105. GPIO117_I2C_SCL,
  106. GPIO118_I2C_SDA,
  107. /* GSM */
  108. GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */
  109. GPIO34_FFUART_RXD,
  110. GPIO35_FFUART_CTS,
  111. GPIO39_FFUART_TXD,
  112. GPIO41_FFUART_RTS,
  113. /* MISC. */
  114. GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */
  115. GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */
  116. GPIO116_GPIO, /* headphone detect */
  117. GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */
  118. };
  119. #ifdef CONFIG_MACH_TREO680
  120. static unsigned long treo680_pin_config[] __initdata = {
  121. GPIO33_GPIO, /* SD read only */
  122. /* MATRIX KEYPAD - different wake up source */
  123. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  124. GPIO99_KP_MKIN_5,
  125. };
  126. #endif /* CONFIG_MACH_TREO680 */
  127. #ifdef CONFIG_MACH_CENTRO
  128. static unsigned long centro685_pin_config[] __initdata = {
  129. /* Bluetooth attached to BT UART*/
  130. MFP_CFG_OUT(GPIO80, AF0, DRIVE_LOW), /* power: LOW = off */
  131. GPIO42_BTUART_RXD,
  132. GPIO43_BTUART_TXD,
  133. GPIO44_BTUART_CTS,
  134. GPIO45_BTUART_RTS,
  135. /* MATRIX KEYPAD - different wake up source */
  136. GPIO100_KP_MKIN_0,
  137. GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
  138. };
  139. #endif /* CONFIG_MACH_CENTRO */
  140. /******************************************************************************
  141. * GPIO keyboard
  142. ******************************************************************************/
  143. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  144. static unsigned int treo680_matrix_keys[] = {
  145. KEY(0, 0, KEY_F8), /* Red/Off/Power */
  146. KEY(0, 1, KEY_LEFT),
  147. KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
  148. KEY(0, 3, KEY_L),
  149. KEY(0, 4, KEY_A),
  150. KEY(0, 5, KEY_Q),
  151. KEY(0, 6, KEY_P),
  152. KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
  153. KEY(1, 1, KEY_RIGHT),
  154. KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
  155. KEY(1, 3, KEY_Z),
  156. KEY(1, 4, KEY_S),
  157. KEY(1, 5, KEY_W),
  158. KEY(2, 0, KEY_F1), /* Phone */
  159. KEY(2, 1, KEY_UP),
  160. KEY(2, 2, KEY_0),
  161. KEY(2, 3, KEY_X),
  162. KEY(2, 4, KEY_D),
  163. KEY(2, 5, KEY_E),
  164. KEY(3, 0, KEY_F10), /* Calendar */
  165. KEY(3, 1, KEY_DOWN),
  166. KEY(3, 2, KEY_SPACE),
  167. KEY(3, 3, KEY_C),
  168. KEY(3, 4, KEY_F),
  169. KEY(3, 5, KEY_R),
  170. KEY(4, 0, KEY_F12), /* Mail */
  171. KEY(4, 1, KEY_KPENTER),
  172. KEY(4, 2, KEY_RIGHTALT), /* Alt */
  173. KEY(4, 3, KEY_V),
  174. KEY(4, 4, KEY_G),
  175. KEY(4, 5, KEY_T),
  176. KEY(5, 0, KEY_F9), /* Home */
  177. KEY(5, 1, KEY_PAGEUP), /* Side up */
  178. KEY(5, 2, KEY_DOT),
  179. KEY(5, 3, KEY_B),
  180. KEY(5, 4, KEY_H),
  181. KEY(5, 5, KEY_Y),
  182. KEY(6, 0, KEY_TAB), /* Side Activate */
  183. KEY(6, 1, KEY_PAGEDOWN), /* Side down */
  184. KEY(6, 2, KEY_ENTER),
  185. KEY(6, 3, KEY_N),
  186. KEY(6, 4, KEY_J),
  187. KEY(6, 5, KEY_U),
  188. KEY(7, 0, KEY_F6), /* Green/Call */
  189. KEY(7, 1, KEY_O),
  190. KEY(7, 2, KEY_BACKSPACE),
  191. KEY(7, 3, KEY_M),
  192. KEY(7, 4, KEY_K),
  193. KEY(7, 5, KEY_I),
  194. };
  195. static unsigned int centro_matrix_keys[] = {
  196. KEY(0, 0, KEY_F9), /* Home */
  197. KEY(0, 1, KEY_LEFT),
  198. KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
  199. KEY(0, 3, KEY_L),
  200. KEY(0, 4, KEY_A),
  201. KEY(0, 5, KEY_Q),
  202. KEY(0, 6, KEY_P),
  203. KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
  204. KEY(1, 1, KEY_RIGHT),
  205. KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
  206. KEY(1, 3, KEY_Z),
  207. KEY(1, 4, KEY_S),
  208. KEY(1, 5, KEY_W),
  209. KEY(2, 0, KEY_F1), /* Phone */
  210. KEY(2, 1, KEY_UP),
  211. KEY(2, 2, KEY_0),
  212. KEY(2, 3, KEY_X),
  213. KEY(2, 4, KEY_D),
  214. KEY(2, 5, KEY_E),
  215. KEY(3, 0, KEY_F10), /* Calendar */
  216. KEY(3, 1, KEY_DOWN),
  217. KEY(3, 2, KEY_SPACE),
  218. KEY(3, 3, KEY_C),
  219. KEY(3, 4, KEY_F),
  220. KEY(3, 5, KEY_R),
  221. KEY(4, 0, KEY_F12), /* Mail */
  222. KEY(4, 1, KEY_KPENTER),
  223. KEY(4, 2, KEY_RIGHTALT), /* Alt */
  224. KEY(4, 3, KEY_V),
  225. KEY(4, 4, KEY_G),
  226. KEY(4, 5, KEY_T),
  227. KEY(5, 0, KEY_F8), /* Red/Off/Power */
  228. KEY(5, 1, KEY_PAGEUP), /* Side up */
  229. KEY(5, 2, KEY_DOT),
  230. KEY(5, 3, KEY_B),
  231. KEY(5, 4, KEY_H),
  232. KEY(5, 5, KEY_Y),
  233. KEY(6, 0, KEY_TAB), /* Side Activate */
  234. KEY(6, 1, KEY_PAGEDOWN), /* Side down */
  235. KEY(6, 2, KEY_ENTER),
  236. KEY(6, 3, KEY_N),
  237. KEY(6, 4, KEY_J),
  238. KEY(6, 5, KEY_U),
  239. KEY(7, 0, KEY_F6), /* Green/Call */
  240. KEY(7, 1, KEY_O),
  241. KEY(7, 2, KEY_BACKSPACE),
  242. KEY(7, 3, KEY_M),
  243. KEY(7, 4, KEY_K),
  244. KEY(7, 5, KEY_I),
  245. };
  246. static struct pxa27x_keypad_platform_data treo680_keypad_pdata = {
  247. .matrix_key_rows = 8,
  248. .matrix_key_cols = 7,
  249. .matrix_key_map = treo680_matrix_keys,
  250. .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
  251. .direct_key_map = { KEY_CONNECT },
  252. .direct_key_num = 1,
  253. .debounce_interval = 30,
  254. };
  255. static void __init palmtreo_kpc_init(void)
  256. {
  257. static struct pxa27x_keypad_platform_data *data = &treo680_keypad_pdata;
  258. if (machine_is_centro()) {
  259. data->matrix_key_map = centro_matrix_keys;
  260. data->matrix_key_map_size = ARRAY_SIZE(centro_matrix_keys);
  261. }
  262. pxa_set_keypad_info(&treo680_keypad_pdata);
  263. }
  264. #else
  265. static inline void palmtreo_kpc_init(void) {}
  266. #endif
  267. /******************************************************************************
  268. * USB host
  269. ******************************************************************************/
  270. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  271. static struct pxaohci_platform_data treo680_ohci_info = {
  272. .port_mode = PMM_PERPORT_MODE,
  273. .flags = ENABLE_PORT1 | ENABLE_PORT3,
  274. .power_budget = 0,
  275. };
  276. static void __init palmtreo_uhc_init(void)
  277. {
  278. if (machine_is_treo680())
  279. pxa_set_ohci_info(&treo680_ohci_info);
  280. }
  281. #else
  282. static inline void palmtreo_uhc_init(void) {}
  283. #endif
  284. /******************************************************************************
  285. * Vibra and LEDs
  286. ******************************************************************************/
  287. #ifdef CONFIG_MACH_TREO680
  288. static struct gpio_led treo680_gpio_leds[] = {
  289. {
  290. .name = "treo680:vibra:vibra",
  291. .default_trigger = "none",
  292. .gpio = GPIO_NR_TREO680_VIBRATE_EN,
  293. },
  294. {
  295. .name = "treo680:green:led",
  296. .default_trigger = "mmc0",
  297. .gpio = GPIO_NR_TREO_GREEN_LED,
  298. },
  299. {
  300. .name = "treo680:white:keybbl",
  301. .default_trigger = "none",
  302. .gpio = GPIO_NR_TREO680_KEYB_BL,
  303. },
  304. };
  305. static struct gpio_led_platform_data treo680_gpio_led_info = {
  306. .leds = treo680_gpio_leds,
  307. .num_leds = ARRAY_SIZE(treo680_gpio_leds),
  308. };
  309. static struct gpio_led centro_gpio_leds[] = {
  310. {
  311. .name = "centro:vibra:vibra",
  312. .default_trigger = "none",
  313. .gpio = GPIO_NR_CENTRO_VIBRATE_EN,
  314. },
  315. {
  316. .name = "centro:green:led",
  317. .default_trigger = "mmc0",
  318. .gpio = GPIO_NR_TREO_GREEN_LED,
  319. },
  320. {
  321. .name = "centro:white:keybbl",
  322. .default_trigger = "none",
  323. .active_low = 1,
  324. .gpio = GPIO_NR_CENTRO_KEYB_BL,
  325. },
  326. };
  327. static struct gpio_led_platform_data centro_gpio_led_info = {
  328. .leds = centro_gpio_leds,
  329. .num_leds = ARRAY_SIZE(centro_gpio_leds),
  330. };
  331. static struct platform_device palmtreo_leds = {
  332. .name = "leds-gpio",
  333. .id = -1,
  334. .dev = {
  335. .platform_data = &treo680_gpio_led_info,
  336. }
  337. };
  338. static void __init palmtreo_leds_init(void)
  339. {
  340. if (machine_is_centro())
  341. palmtreo_leds.dev.platform_data = &centro_gpio_led_info;
  342. platform_device_register(&palmtreo_leds);
  343. }
  344. #else
  345. static inline void palmtreo_leds_init(void) {}
  346. #endif
  347. /******************************************************************************
  348. * Machine init
  349. ******************************************************************************/
  350. static void __init treo_reserve(void)
  351. {
  352. memblock_reserve(0xa0000000, 0x1000);
  353. memblock_reserve(0xa2000000, 0x1000);
  354. }
  355. static void __init palmphone_common_init(void)
  356. {
  357. pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
  358. pxa_set_ffuart_info(NULL);
  359. pxa_set_btuart_info(NULL);
  360. pxa_set_stuart_info(NULL);
  361. palm27x_pm_init(TREO_STR_BASE);
  362. palm27x_lcd_init(GPIO_NR_TREO_BL_POWER, &palm_320x320_new_lcd_mode);
  363. palm27x_udc_init(GPIO_NR_TREO_USB_DETECT, GPIO_NR_TREO_USB_PULLUP, 1);
  364. palm27x_irda_init(GPIO_NR_TREO_IR_EN);
  365. palm27x_ac97_init(-1, -1, -1, 95);
  366. palm27x_pwm_init(GPIO_NR_TREO_BL_POWER, -1);
  367. palm27x_power_init(GPIO_NR_TREO_POWER_DETECT, -1);
  368. palm27x_pmic_init();
  369. palmtreo_kpc_init();
  370. palmtreo_uhc_init();
  371. palmtreo_leds_init();
  372. }
  373. static void __init treo680_init(void)
  374. {
  375. pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
  376. palmphone_common_init();
  377. palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, GPIO_NR_TREO680_SD_READONLY,
  378. GPIO_NR_TREO680_SD_POWER, 0);
  379. }
  380. static void __init centro_init(void)
  381. {
  382. pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
  383. palmphone_common_init();
  384. palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, -1,
  385. GPIO_NR_CENTRO_SD_POWER, 1);
  386. }
  387. MACHINE_START(TREO680, "Palm Treo 680")
  388. .boot_params = 0xa0000100,
  389. .map_io = pxa27x_map_io,
  390. .reserve = treo_reserve,
  391. .init_irq = pxa27x_init_irq,
  392. .handle_irq = pxa27x_handle_irq,
  393. .timer = &pxa_timer,
  394. .init_machine = treo680_init,
  395. MACHINE_END
  396. MACHINE_START(CENTRO, "Palm Centro 685")
  397. .boot_params = 0xa0000100,
  398. .map_io = pxa27x_map_io,
  399. .reserve = treo_reserve,
  400. .init_irq = pxa27x_init_irq,
  401. .handle_irq = pxa27x_handle_irq,
  402. .timer = &pxa_timer,
  403. .init_machine = centro_init,
  404. MACHINE_END