palmtreo.c 11 KB

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