palmtreo.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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 "pxa27x.h"
  32. #include "pxa27x-udc.h"
  33. #include <mach/audio.h>
  34. #include "palmtreo.h"
  35. #include <linux/platform_data/mmc-pxamci.h>
  36. #include <linux/platform_data/video-pxafb.h>
  37. #include <linux/platform_data/irda-pxaficp.h>
  38. #include <linux/platform_data/keypad-pxa27x.h>
  39. #include "udc.h"
  40. #include <linux/platform_data/usb-ohci-pxa27x.h>
  41. #include <mach/pxa2xx-regs.h>
  42. #include <linux/platform_data/asoc-palm27x.h>
  43. #include <linux/platform_data/media/camera-pxa.h>
  44. #include "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. /* Quick Capture Interface */
  90. GPIO84_CIF_FV,
  91. GPIO85_CIF_LV,
  92. GPIO53_CIF_MCLK,
  93. GPIO54_CIF_PCLK,
  94. GPIO81_CIF_DD_0,
  95. GPIO55_CIF_DD_1,
  96. GPIO51_CIF_DD_2,
  97. GPIO50_CIF_DD_3,
  98. GPIO52_CIF_DD_4,
  99. GPIO48_CIF_DD_5,
  100. GPIO17_CIF_DD_6,
  101. GPIO12_CIF_DD_7,
  102. /* I2C */
  103. GPIO117_I2C_SCL,
  104. GPIO118_I2C_SDA,
  105. /* GSM */
  106. GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */
  107. GPIO34_FFUART_RXD,
  108. GPIO35_FFUART_CTS,
  109. GPIO39_FFUART_TXD,
  110. GPIO41_FFUART_RTS,
  111. /* MISC. */
  112. GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */
  113. GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */
  114. GPIO116_GPIO, /* headphone detect */
  115. GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */
  116. };
  117. #ifdef CONFIG_MACH_TREO680
  118. static unsigned long treo680_pin_config[] __initdata = {
  119. GPIO33_GPIO, /* SD read only */
  120. /* MATRIX KEYPAD - different wake up source */
  121. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  122. GPIO99_KP_MKIN_5,
  123. /* LCD... L_BIAS alt fn not configured on Treo680; is GPIO instead */
  124. GPIOxx_LCD_16BPP,
  125. GPIO74_LCD_FCLK,
  126. GPIO75_LCD_LCLK,
  127. GPIO76_LCD_PCLK,
  128. };
  129. #endif /* CONFIG_MACH_TREO680 */
  130. #ifdef CONFIG_MACH_CENTRO
  131. static unsigned long centro685_pin_config[] __initdata = {
  132. /* Bluetooth attached to BT UART*/
  133. MFP_CFG_OUT(GPIO80, AF0, DRIVE_LOW), /* power: LOW = off */
  134. GPIO42_BTUART_RXD,
  135. GPIO43_BTUART_TXD,
  136. GPIO44_BTUART_CTS,
  137. GPIO45_BTUART_RTS,
  138. /* MATRIX KEYPAD - different wake up source */
  139. GPIO100_KP_MKIN_0,
  140. GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
  141. /* LCD */
  142. GPIOxx_LCD_TFT_16BPP,
  143. };
  144. #endif /* CONFIG_MACH_CENTRO */
  145. /******************************************************************************
  146. * GPIO keyboard
  147. ******************************************************************************/
  148. #if IS_ENABLED(CONFIG_KEYBOARD_PXA27x)
  149. static const unsigned int treo680_matrix_keys[] = {
  150. KEY(0, 0, KEY_F8), /* Red/Off/Power */
  151. KEY(0, 1, KEY_LEFT),
  152. KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
  153. KEY(0, 3, KEY_L),
  154. KEY(0, 4, KEY_A),
  155. KEY(0, 5, KEY_Q),
  156. KEY(0, 6, KEY_P),
  157. KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
  158. KEY(1, 1, KEY_RIGHT),
  159. KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
  160. KEY(1, 3, KEY_Z),
  161. KEY(1, 4, KEY_S),
  162. KEY(1, 5, KEY_W),
  163. KEY(2, 0, KEY_F1), /* Phone */
  164. KEY(2, 1, KEY_UP),
  165. KEY(2, 2, KEY_0),
  166. KEY(2, 3, KEY_X),
  167. KEY(2, 4, KEY_D),
  168. KEY(2, 5, KEY_E),
  169. KEY(3, 0, KEY_F10), /* Calendar */
  170. KEY(3, 1, KEY_DOWN),
  171. KEY(3, 2, KEY_SPACE),
  172. KEY(3, 3, KEY_C),
  173. KEY(3, 4, KEY_F),
  174. KEY(3, 5, KEY_R),
  175. KEY(4, 0, KEY_F12), /* Mail */
  176. KEY(4, 1, KEY_KPENTER),
  177. KEY(4, 2, KEY_RIGHTALT), /* Alt */
  178. KEY(4, 3, KEY_V),
  179. KEY(4, 4, KEY_G),
  180. KEY(4, 5, KEY_T),
  181. KEY(5, 0, KEY_F9), /* Home */
  182. KEY(5, 1, KEY_PAGEUP), /* Side up */
  183. KEY(5, 2, KEY_DOT),
  184. KEY(5, 3, KEY_B),
  185. KEY(5, 4, KEY_H),
  186. KEY(5, 5, KEY_Y),
  187. KEY(6, 0, KEY_TAB), /* Side Activate */
  188. KEY(6, 1, KEY_PAGEDOWN), /* Side down */
  189. KEY(6, 2, KEY_ENTER),
  190. KEY(6, 3, KEY_N),
  191. KEY(6, 4, KEY_J),
  192. KEY(6, 5, KEY_U),
  193. KEY(7, 0, KEY_F6), /* Green/Call */
  194. KEY(7, 1, KEY_O),
  195. KEY(7, 2, KEY_BACKSPACE),
  196. KEY(7, 3, KEY_M),
  197. KEY(7, 4, KEY_K),
  198. KEY(7, 5, KEY_I),
  199. };
  200. static const unsigned int centro_matrix_keys[] = {
  201. KEY(0, 0, KEY_F9), /* Home */
  202. KEY(0, 1, KEY_LEFT),
  203. KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
  204. KEY(0, 3, KEY_L),
  205. KEY(0, 4, KEY_A),
  206. KEY(0, 5, KEY_Q),
  207. KEY(0, 6, KEY_P),
  208. KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
  209. KEY(1, 1, KEY_RIGHT),
  210. KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
  211. KEY(1, 3, KEY_Z),
  212. KEY(1, 4, KEY_S),
  213. KEY(1, 5, KEY_W),
  214. KEY(2, 0, KEY_F1), /* Phone */
  215. KEY(2, 1, KEY_UP),
  216. KEY(2, 2, KEY_0),
  217. KEY(2, 3, KEY_X),
  218. KEY(2, 4, KEY_D),
  219. KEY(2, 5, KEY_E),
  220. KEY(3, 0, KEY_F10), /* Calendar */
  221. KEY(3, 1, KEY_DOWN),
  222. KEY(3, 2, KEY_SPACE),
  223. KEY(3, 3, KEY_C),
  224. KEY(3, 4, KEY_F),
  225. KEY(3, 5, KEY_R),
  226. KEY(4, 0, KEY_F12), /* Mail */
  227. KEY(4, 1, KEY_KPENTER),
  228. KEY(4, 2, KEY_RIGHTALT), /* Alt */
  229. KEY(4, 3, KEY_V),
  230. KEY(4, 4, KEY_G),
  231. KEY(4, 5, KEY_T),
  232. KEY(5, 0, KEY_F8), /* Red/Off/Power */
  233. KEY(5, 1, KEY_PAGEUP), /* Side up */
  234. KEY(5, 2, KEY_DOT),
  235. KEY(5, 3, KEY_B),
  236. KEY(5, 4, KEY_H),
  237. KEY(5, 5, KEY_Y),
  238. KEY(6, 0, KEY_TAB), /* Side Activate */
  239. KEY(6, 1, KEY_PAGEDOWN), /* Side down */
  240. KEY(6, 2, KEY_ENTER),
  241. KEY(6, 3, KEY_N),
  242. KEY(6, 4, KEY_J),
  243. KEY(6, 5, KEY_U),
  244. KEY(7, 0, KEY_F6), /* Green/Call */
  245. KEY(7, 1, KEY_O),
  246. KEY(7, 2, KEY_BACKSPACE),
  247. KEY(7, 3, KEY_M),
  248. KEY(7, 4, KEY_K),
  249. KEY(7, 5, KEY_I),
  250. };
  251. static struct matrix_keymap_data treo680_matrix_keymap_data = {
  252. .keymap = treo680_matrix_keys,
  253. .keymap_size = ARRAY_SIZE(treo680_matrix_keys),
  254. };
  255. static struct matrix_keymap_data centro_matrix_keymap_data = {
  256. .keymap = centro_matrix_keys,
  257. .keymap_size = ARRAY_SIZE(centro_matrix_keys),
  258. };
  259. static struct pxa27x_keypad_platform_data treo680_keypad_pdata = {
  260. .matrix_key_rows = 8,
  261. .matrix_key_cols = 7,
  262. .matrix_keymap_data = &treo680_matrix_keymap_data,
  263. .direct_key_map = { KEY_CONNECT },
  264. .direct_key_num = 1,
  265. .debounce_interval = 30,
  266. };
  267. static void __init palmtreo_kpc_init(void)
  268. {
  269. static struct pxa27x_keypad_platform_data *data = &treo680_keypad_pdata;
  270. if (machine_is_centro())
  271. data->matrix_keymap_data = &centro_matrix_keymap_data;
  272. pxa_set_keypad_info(&treo680_keypad_pdata);
  273. }
  274. #else
  275. static inline void palmtreo_kpc_init(void) {}
  276. #endif
  277. /******************************************************************************
  278. * USB host
  279. ******************************************************************************/
  280. #if IS_ENABLED(CONFIG_USB_OHCI_HCD)
  281. static struct pxaohci_platform_data treo680_ohci_info = {
  282. .port_mode = PMM_PERPORT_MODE,
  283. .flags = ENABLE_PORT1 | ENABLE_PORT3,
  284. .power_budget = 0,
  285. };
  286. static void __init palmtreo_uhc_init(void)
  287. {
  288. if (machine_is_treo680())
  289. pxa_set_ohci_info(&treo680_ohci_info);
  290. }
  291. #else
  292. static inline void palmtreo_uhc_init(void) {}
  293. #endif
  294. /******************************************************************************
  295. * Vibra and LEDs
  296. ******************************************************************************/
  297. static struct gpio_led treo680_gpio_leds[] = {
  298. {
  299. .name = "treo680:vibra:vibra",
  300. .default_trigger = "none",
  301. .gpio = GPIO_NR_TREO680_VIBRATE_EN,
  302. },
  303. {
  304. .name = "treo680:green:led",
  305. .default_trigger = "mmc0",
  306. .gpio = GPIO_NR_TREO_GREEN_LED,
  307. },
  308. {
  309. .name = "treo680:white:keybbl",
  310. .default_trigger = "none",
  311. .gpio = GPIO_NR_TREO680_KEYB_BL,
  312. },
  313. };
  314. static struct gpio_led_platform_data treo680_gpio_led_info = {
  315. .leds = treo680_gpio_leds,
  316. .num_leds = ARRAY_SIZE(treo680_gpio_leds),
  317. };
  318. static struct gpio_led centro_gpio_leds[] = {
  319. {
  320. .name = "centro:vibra:vibra",
  321. .default_trigger = "none",
  322. .gpio = GPIO_NR_CENTRO_VIBRATE_EN,
  323. },
  324. {
  325. .name = "centro:green:led",
  326. .default_trigger = "mmc0",
  327. .gpio = GPIO_NR_TREO_GREEN_LED,
  328. },
  329. {
  330. .name = "centro:white:keybbl",
  331. .default_trigger = "none",
  332. .active_low = 1,
  333. .gpio = GPIO_NR_CENTRO_KEYB_BL,
  334. },
  335. };
  336. static struct gpio_led_platform_data centro_gpio_led_info = {
  337. .leds = centro_gpio_leds,
  338. .num_leds = ARRAY_SIZE(centro_gpio_leds),
  339. };
  340. static struct platform_device palmtreo_leds = {
  341. .name = "leds-gpio",
  342. .id = -1,
  343. };
  344. static void __init palmtreo_leds_init(void)
  345. {
  346. if (machine_is_centro())
  347. palmtreo_leds.dev.platform_data = &centro_gpio_led_info;
  348. else if (machine_is_treo680())
  349. palmtreo_leds.dev.platform_data = &treo680_gpio_led_info;
  350. platform_device_register(&palmtreo_leds);
  351. }
  352. /******************************************************************************
  353. * diskonchip docg4 flash
  354. ******************************************************************************/
  355. #if defined(CONFIG_MACH_TREO680)
  356. /* REVISIT: does the centro have this device also? */
  357. #if IS_ENABLED(CONFIG_MTD_NAND_DOCG4)
  358. static struct resource docg4_resources[] = {
  359. {
  360. .start = 0x00000000,
  361. .end = 0x00001FFF,
  362. .flags = IORESOURCE_MEM,
  363. },
  364. };
  365. static struct platform_device treo680_docg4_flash = {
  366. .name = "docg4",
  367. .id = -1,
  368. .resource = docg4_resources,
  369. .num_resources = ARRAY_SIZE(docg4_resources),
  370. };
  371. static void __init treo680_docg4_flash_init(void)
  372. {
  373. platform_device_register(&treo680_docg4_flash);
  374. }
  375. #else
  376. static inline void treo680_docg4_flash_init(void) {}
  377. #endif
  378. #endif
  379. /******************************************************************************
  380. * Machine init
  381. ******************************************************************************/
  382. static void __init treo_reserve(void)
  383. {
  384. memblock_reserve(0xa0000000, 0x1000);
  385. memblock_reserve(0xa2000000, 0x1000);
  386. }
  387. static void __init palmphone_common_init(void)
  388. {
  389. pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
  390. pxa_set_ffuart_info(NULL);
  391. pxa_set_btuart_info(NULL);
  392. pxa_set_stuart_info(NULL);
  393. palm27x_pm_init(TREO_STR_BASE);
  394. palm27x_lcd_init(GPIO_NR_TREO_BL_POWER, &palm_320x320_new_lcd_mode);
  395. palm27x_udc_init(GPIO_NR_TREO_USB_DETECT, GPIO_NR_TREO_USB_PULLUP, 1);
  396. palm27x_irda_init(GPIO_NR_TREO_IR_EN);
  397. palm27x_ac97_init(-1, -1, -1, 95);
  398. palm27x_pwm_init(GPIO_NR_TREO_BL_POWER, -1);
  399. palm27x_power_init(GPIO_NR_TREO_POWER_DETECT, -1);
  400. palm27x_pmic_init();
  401. palmtreo_kpc_init();
  402. palmtreo_uhc_init();
  403. palmtreo_leds_init();
  404. }
  405. #ifdef CONFIG_MACH_TREO680
  406. void __init treo680_gpio_init(void)
  407. {
  408. unsigned int gpio;
  409. /* drive all three lcd gpios high initially */
  410. const unsigned long lcd_flags = GPIOF_INIT_HIGH | GPIOF_DIR_OUT;
  411. /*
  412. * LCD GPIO initialization...
  413. */
  414. /*
  415. * This is likely the power to the lcd. Toggling it low/high appears to
  416. * turn the lcd off/on. Can be toggled after lcd is initialized without
  417. * any apparent adverse effects to the lcd operation. Note that this
  418. * gpio line is used by the lcd controller as the L_BIAS signal, but
  419. * treo680 configures it as gpio.
  420. */
  421. gpio = GPIO_NR_TREO680_LCD_POWER;
  422. if (gpio_request_one(gpio, lcd_flags, "LCD power") < 0)
  423. goto fail;
  424. /*
  425. * These two are called "enables", for lack of a better understanding.
  426. * If either of these are toggled after the lcd is initialized, the
  427. * image becomes degraded. N.B. The IPL shipped with the treo
  428. * configures GPIO_NR_TREO680_LCD_EN_N as output and drives it high. If
  429. * the IPL is ever reprogrammed, this initialization may be need to be
  430. * revisited.
  431. */
  432. gpio = GPIO_NR_TREO680_LCD_EN;
  433. if (gpio_request_one(gpio, lcd_flags, "LCD enable") < 0)
  434. goto fail;
  435. gpio = GPIO_NR_TREO680_LCD_EN_N;
  436. if (gpio_request_one(gpio, lcd_flags, "LCD enable_n") < 0)
  437. goto fail;
  438. /* driving this low turns LCD on */
  439. gpio_set_value(GPIO_NR_TREO680_LCD_EN_N, 0);
  440. return;
  441. fail:
  442. pr_err("gpio %d initialization failed\n", gpio);
  443. gpio_free(GPIO_NR_TREO680_LCD_POWER);
  444. gpio_free(GPIO_NR_TREO680_LCD_EN);
  445. gpio_free(GPIO_NR_TREO680_LCD_EN_N);
  446. }
  447. static void __init treo680_init(void)
  448. {
  449. pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
  450. palmphone_common_init();
  451. treo680_gpio_init();
  452. palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, GPIO_NR_TREO680_SD_READONLY,
  453. GPIO_NR_TREO680_SD_POWER, 0);
  454. treo680_docg4_flash_init();
  455. }
  456. #endif
  457. #ifdef CONFIG_MACH_CENTRO
  458. static void __init centro_init(void)
  459. {
  460. pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
  461. palmphone_common_init();
  462. palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, -1,
  463. GPIO_NR_CENTRO_SD_POWER, 1);
  464. }
  465. #endif
  466. #ifdef CONFIG_MACH_TREO680
  467. MACHINE_START(TREO680, "Palm Treo 680")
  468. .atag_offset = 0x100,
  469. .map_io = pxa27x_map_io,
  470. .reserve = treo_reserve,
  471. .nr_irqs = PXA_NR_IRQS,
  472. .init_irq = pxa27x_init_irq,
  473. .handle_irq = pxa27x_handle_irq,
  474. .init_time = pxa_timer_init,
  475. .init_machine = treo680_init,
  476. .restart = pxa_restart,
  477. MACHINE_END
  478. #endif
  479. #ifdef CONFIG_MACH_CENTRO
  480. MACHINE_START(CENTRO, "Palm Centro 685")
  481. .atag_offset = 0x100,
  482. .map_io = pxa27x_map_io,
  483. .reserve = treo_reserve,
  484. .nr_irqs = PXA_NR_IRQS,
  485. .init_irq = pxa27x_init_irq,
  486. .handle_irq = pxa27x_handle_irq,
  487. .init_time = pxa_timer_init,
  488. .init_machine = centro_init,
  489. .restart = pxa_restart,
  490. MACHINE_END
  491. #endif