treo680.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. /*
  2. * Hardware definitions for Palm Treo 680
  3. *
  4. * Author: Tomas Cech <sleep_walker@suse.cz>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * (find more info at www.hackndev.com)
  11. *
  12. */
  13. #include <linux/platform_device.h>
  14. #include <linux/delay.h>
  15. #include <linux/irq.h>
  16. #include <linux/gpio_keys.h>
  17. #include <linux/input.h>
  18. #include <linux/pda_power.h>
  19. #include <linux/pwm_backlight.h>
  20. #include <linux/gpio.h>
  21. #include <linux/wm97xx_batt.h>
  22. #include <linux/power_supply.h>
  23. #include <linux/sysdev.h>
  24. #include <linux/w1-gpio.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include <mach/pxa27x.h>
  29. #include <mach/pxa27x-udc.h>
  30. #include <mach/audio.h>
  31. #include <mach/treo680.h>
  32. #include <mach/mmc.h>
  33. #include <mach/pxafb.h>
  34. #include <mach/irda.h>
  35. #include <mach/pxa27x_keypad.h>
  36. #include <mach/udc.h>
  37. #include <mach/ohci.h>
  38. #include <mach/pxa2xx-regs.h>
  39. #include <mach/palmasoc.h>
  40. #include <mach/camera.h>
  41. #include <sound/pxa2xx-lib.h>
  42. #include "generic.h"
  43. #include "devices.h"
  44. /******************************************************************************
  45. * Pin configuration
  46. ******************************************************************************/
  47. static unsigned long treo680_pin_config[] __initdata = {
  48. /* MMC */
  49. GPIO32_MMC_CLK,
  50. GPIO92_MMC_DAT_0,
  51. GPIO109_MMC_DAT_1,
  52. GPIO110_MMC_DAT_2,
  53. GPIO111_MMC_DAT_3,
  54. GPIO112_MMC_CMD,
  55. GPIO33_GPIO, /* SD read only */
  56. GPIO113_GPIO, /* SD detect */
  57. /* AC97 */
  58. GPIO28_AC97_BITCLK,
  59. GPIO29_AC97_SDATA_IN_0,
  60. GPIO30_AC97_SDATA_OUT,
  61. GPIO31_AC97_SYNC,
  62. GPIO89_AC97_SYSCLK,
  63. GPIO95_AC97_nRESET,
  64. /* IrDA */
  65. GPIO46_FICP_RXD,
  66. GPIO47_FICP_TXD,
  67. /* PWM */
  68. GPIO16_PWM0_OUT,
  69. /* USB */
  70. GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* usb detect */
  71. /* MATRIX KEYPAD */
  72. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  73. GPIO101_KP_MKIN_1,
  74. GPIO102_KP_MKIN_2,
  75. GPIO97_KP_MKIN_3,
  76. GPIO98_KP_MKIN_4,
  77. GPIO99_KP_MKIN_5,
  78. GPIO91_KP_MKIN_6,
  79. GPIO13_KP_MKIN_7,
  80. GPIO103_KP_MKOUT_0 | MFP_LPM_DRIVE_HIGH,
  81. GPIO104_KP_MKOUT_1,
  82. GPIO105_KP_MKOUT_2,
  83. GPIO106_KP_MKOUT_3,
  84. GPIO107_KP_MKOUT_4,
  85. GPIO108_KP_MKOUT_5,
  86. GPIO96_KP_MKOUT_6,
  87. GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH, /* Hotsync button */
  88. /* LCD */
  89. GPIO58_LCD_LDD_0,
  90. GPIO59_LCD_LDD_1,
  91. GPIO60_LCD_LDD_2,
  92. GPIO61_LCD_LDD_3,
  93. GPIO62_LCD_LDD_4,
  94. GPIO63_LCD_LDD_5,
  95. GPIO64_LCD_LDD_6,
  96. GPIO65_LCD_LDD_7,
  97. GPIO66_LCD_LDD_8,
  98. GPIO67_LCD_LDD_9,
  99. GPIO68_LCD_LDD_10,
  100. GPIO69_LCD_LDD_11,
  101. GPIO70_LCD_LDD_12,
  102. GPIO71_LCD_LDD_13,
  103. GPIO72_LCD_LDD_14,
  104. GPIO73_LCD_LDD_15,
  105. GPIO74_LCD_FCLK,
  106. GPIO75_LCD_LCLK,
  107. GPIO76_LCD_PCLK,
  108. /* Quick Capture Interface */
  109. GPIO84_CIF_FV,
  110. GPIO85_CIF_LV,
  111. GPIO53_CIF_MCLK,
  112. GPIO54_CIF_PCLK,
  113. GPIO81_CIF_DD_0,
  114. GPIO55_CIF_DD_1,
  115. GPIO51_CIF_DD_2,
  116. GPIO50_CIF_DD_3,
  117. GPIO52_CIF_DD_4,
  118. GPIO48_CIF_DD_5,
  119. GPIO17_CIF_DD_6,
  120. GPIO12_CIF_DD_7,
  121. /* I2C */
  122. GPIO117_I2C_SCL,
  123. GPIO118_I2C_SDA,
  124. /* GSM */
  125. GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */
  126. GPIO34_FFUART_RXD,
  127. GPIO35_FFUART_CTS,
  128. GPIO39_FFUART_TXD,
  129. GPIO41_FFUART_RTS,
  130. /* MISC. */
  131. GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */
  132. GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */
  133. GPIO116_GPIO, /* headphone detect */
  134. GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */
  135. };
  136. /******************************************************************************
  137. * SD/MMC card controller
  138. ******************************************************************************/
  139. static struct pxamci_platform_data treo680_mci_platform_data = {
  140. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  141. .gpio_card_detect = GPIO_NR_TREO680_SD_DETECT_N,
  142. .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY,
  143. .gpio_power = GPIO_NR_TREO680_SD_POWER,
  144. };
  145. /******************************************************************************
  146. * GPIO keyboard
  147. ******************************************************************************/
  148. static unsigned int treo680_matrix_keys[] = {
  149. KEY(0, 0, KEY_F8), /* Red/Off/Power */
  150. KEY(0, 1, KEY_LEFT),
  151. KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
  152. KEY(0, 3, KEY_L),
  153. KEY(0, 4, KEY_A),
  154. KEY(0, 5, KEY_Q),
  155. KEY(0, 6, KEY_P),
  156. KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
  157. KEY(1, 1, KEY_RIGHT),
  158. KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
  159. KEY(1, 3, KEY_Z),
  160. KEY(1, 4, KEY_S),
  161. KEY(1, 5, KEY_W),
  162. KEY(2, 0, KEY_F1), /* Phone */
  163. KEY(2, 1, KEY_UP),
  164. KEY(2, 2, KEY_0),
  165. KEY(2, 3, KEY_X),
  166. KEY(2, 4, KEY_D),
  167. KEY(2, 5, KEY_E),
  168. KEY(3, 0, KEY_F10), /* Calendar */
  169. KEY(3, 1, KEY_DOWN),
  170. KEY(3, 2, KEY_SPACE),
  171. KEY(3, 3, KEY_C),
  172. KEY(3, 4, KEY_F),
  173. KEY(3, 5, KEY_R),
  174. KEY(4, 0, KEY_F12), /* Mail */
  175. KEY(4, 1, KEY_KPENTER),
  176. KEY(4, 2, KEY_RIGHTALT), /* Alt */
  177. KEY(4, 3, KEY_V),
  178. KEY(4, 4, KEY_G),
  179. KEY(4, 5, KEY_T),
  180. KEY(5, 0, KEY_F9), /* Home */
  181. KEY(5, 1, KEY_PAGEUP), /* Side up */
  182. KEY(5, 2, KEY_DOT),
  183. KEY(5, 3, KEY_B),
  184. KEY(5, 4, KEY_H),
  185. KEY(5, 5, KEY_Y),
  186. KEY(6, 0, KEY_TAB), /* Side Activate */
  187. KEY(6, 1, KEY_PAGEDOWN), /* Side down */
  188. KEY(6, 2, KEY_ENTER),
  189. KEY(6, 3, KEY_N),
  190. KEY(6, 4, KEY_J),
  191. KEY(6, 5, KEY_U),
  192. KEY(7, 0, KEY_F6), /* Green/Call */
  193. KEY(7, 1, KEY_O),
  194. KEY(7, 2, KEY_BACKSPACE),
  195. KEY(7, 3, KEY_M),
  196. KEY(7, 4, KEY_K),
  197. KEY(7, 5, KEY_I),
  198. };
  199. static struct pxa27x_keypad_platform_data treo680_keypad_platform_data = {
  200. .matrix_key_rows = 8,
  201. .matrix_key_cols = 7,
  202. .matrix_key_map = treo680_matrix_keys,
  203. .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
  204. .direct_key_map = { KEY_CONNECT },
  205. .direct_key_num = 1,
  206. .debounce_interval = 30,
  207. };
  208. /******************************************************************************
  209. * aSoC audio
  210. ******************************************************************************/
  211. static pxa2xx_audio_ops_t treo680_ac97_pdata = {
  212. .reset_gpio = 95,
  213. };
  214. /******************************************************************************
  215. * Backlight
  216. ******************************************************************************/
  217. static int treo680_backlight_init(struct device *dev)
  218. {
  219. int ret;
  220. ret = gpio_request(GPIO_NR_TREO680_BL_POWER, "BL POWER");
  221. if (ret)
  222. goto err;
  223. ret = gpio_direction_output(GPIO_NR_TREO680_BL_POWER, 0);
  224. if (ret)
  225. goto err2;
  226. ret = gpio_request(GPIO_NR_TREO680_LCD_POWER, "LCD POWER");
  227. if (ret)
  228. goto err2;
  229. ret = gpio_direction_output(GPIO_NR_TREO680_LCD_POWER, 0);
  230. if (ret)
  231. goto err3;
  232. return 0;
  233. err3:
  234. gpio_free(GPIO_NR_TREO680_LCD_POWER);
  235. err2:
  236. gpio_free(GPIO_NR_TREO680_BL_POWER);
  237. err:
  238. return ret;
  239. }
  240. static int treo680_backlight_notify(int brightness)
  241. {
  242. gpio_set_value(GPIO_NR_TREO680_BL_POWER, brightness);
  243. return TREO680_MAX_INTENSITY - brightness;
  244. };
  245. static void treo680_backlight_exit(struct device *dev)
  246. {
  247. gpio_free(GPIO_NR_TREO680_BL_POWER);
  248. gpio_free(GPIO_NR_TREO680_LCD_POWER);
  249. }
  250. static struct platform_pwm_backlight_data treo680_backlight_data = {
  251. .pwm_id = 0,
  252. .max_brightness = TREO680_MAX_INTENSITY,
  253. .dft_brightness = TREO680_DEFAULT_INTENSITY,
  254. .pwm_period_ns = TREO680_PERIOD_NS,
  255. .init = treo680_backlight_init,
  256. .notify = treo680_backlight_notify,
  257. .exit = treo680_backlight_exit,
  258. };
  259. static struct platform_device treo680_backlight = {
  260. .name = "pwm-backlight",
  261. .dev = {
  262. .parent = &pxa27x_device_pwm0.dev,
  263. .platform_data = &treo680_backlight_data,
  264. },
  265. };
  266. /******************************************************************************
  267. * IrDA
  268. ******************************************************************************/
  269. static void treo680_transceiver_mode(struct device *dev, int mode)
  270. {
  271. gpio_set_value(GPIO_NR_TREO680_IR_EN, mode & IR_OFF);
  272. pxa2xx_transceiver_mode(dev, mode);
  273. }
  274. static int treo680_irda_startup(struct device *dev)
  275. {
  276. int err;
  277. err = gpio_request(GPIO_NR_TREO680_IR_EN, "Ir port disable");
  278. if (err)
  279. goto err1;
  280. err = gpio_direction_output(GPIO_NR_TREO680_IR_EN, 1);
  281. if (err)
  282. goto err2;
  283. return 0;
  284. err2:
  285. dev_err(dev, "treo680_irda: cannot change IR gpio direction\n");
  286. gpio_free(GPIO_NR_TREO680_IR_EN);
  287. err1:
  288. dev_err(dev, "treo680_irda: cannot allocate IR gpio\n");
  289. return err;
  290. }
  291. static void treo680_irda_shutdown(struct device *dev)
  292. {
  293. gpio_free(GPIO_NR_TREO680_IR_EN);
  294. }
  295. static struct pxaficp_platform_data treo680_ficp_info = {
  296. .transceiver_cap = IR_FIRMODE | IR_SIRMODE | IR_OFF,
  297. .startup = treo680_irda_startup,
  298. .shutdown = treo680_irda_shutdown,
  299. .transceiver_mode = treo680_transceiver_mode,
  300. };
  301. /******************************************************************************
  302. * UDC
  303. ******************************************************************************/
  304. static struct pxa2xx_udc_mach_info treo680_udc_info __initdata = {
  305. .gpio_vbus = GPIO_NR_TREO680_USB_DETECT,
  306. .gpio_vbus_inverted = 1,
  307. .gpio_pullup = GPIO_NR_TREO680_USB_PULLUP,
  308. };
  309. /******************************************************************************
  310. * USB host
  311. ******************************************************************************/
  312. static struct pxaohci_platform_data treo680_ohci_info = {
  313. .port_mode = PMM_PERPORT_MODE,
  314. .flags = ENABLE_PORT1 | ENABLE_PORT3,
  315. .power_budget = 0,
  316. };
  317. /******************************************************************************
  318. * Power supply
  319. ******************************************************************************/
  320. static int power_supply_init(struct device *dev)
  321. {
  322. int ret;
  323. ret = gpio_request(GPIO_NR_TREO680_POWER_DETECT, "CABLE_STATE_AC");
  324. if (ret)
  325. goto err1;
  326. ret = gpio_direction_input(GPIO_NR_TREO680_POWER_DETECT);
  327. if (ret)
  328. goto err2;
  329. return 0;
  330. err2:
  331. gpio_free(GPIO_NR_TREO680_POWER_DETECT);
  332. err1:
  333. return ret;
  334. }
  335. static int treo680_is_ac_online(void)
  336. {
  337. return gpio_get_value(GPIO_NR_TREO680_POWER_DETECT);
  338. }
  339. static void power_supply_exit(struct device *dev)
  340. {
  341. gpio_free(GPIO_NR_TREO680_POWER_DETECT);
  342. }
  343. static char *treo680_supplicants[] = {
  344. "main-battery",
  345. };
  346. static struct pda_power_pdata power_supply_info = {
  347. .init = power_supply_init,
  348. .is_ac_online = treo680_is_ac_online,
  349. .exit = power_supply_exit,
  350. .supplied_to = treo680_supplicants,
  351. .num_supplicants = ARRAY_SIZE(treo680_supplicants),
  352. };
  353. static struct platform_device power_supply = {
  354. .name = "pda-power",
  355. .id = -1,
  356. .dev = {
  357. .platform_data = &power_supply_info,
  358. },
  359. };
  360. /******************************************************************************
  361. * Vibra and LEDs
  362. ******************************************************************************/
  363. static struct gpio_led gpio_leds[] = {
  364. {
  365. .name = "treo680:vibra:vibra",
  366. .default_trigger = "none",
  367. .gpio = GPIO_NR_TREO680_VIBRATE_EN,
  368. },
  369. {
  370. .name = "treo680:green:led",
  371. .default_trigger = "mmc0",
  372. .gpio = GPIO_NR_TREO680_GREEN_LED,
  373. },
  374. {
  375. .name = "treo680:keybbl:keybbl",
  376. .default_trigger = "none",
  377. .gpio = GPIO_NR_TREO680_KEYB_BL,
  378. },
  379. };
  380. static struct gpio_led_platform_data gpio_led_info = {
  381. .leds = gpio_leds,
  382. .num_leds = ARRAY_SIZE(gpio_leds),
  383. };
  384. static struct platform_device treo680_leds = {
  385. .name = "leds-gpio",
  386. .id = -1,
  387. .dev = {
  388. .platform_data = &gpio_led_info,
  389. }
  390. };
  391. /******************************************************************************
  392. * Framebuffer
  393. ******************************************************************************/
  394. /* TODO: add support for 324x324 */
  395. static struct pxafb_mode_info treo680_lcd_modes[] = {
  396. {
  397. .pixclock = 86538,
  398. .xres = 320,
  399. .yres = 320,
  400. .bpp = 16,
  401. .left_margin = 20,
  402. .right_margin = 8,
  403. .upper_margin = 8,
  404. .lower_margin = 5,
  405. .hsync_len = 4,
  406. .vsync_len = 1,
  407. },
  408. };
  409. static struct pxafb_mach_info treo680_lcd_screen = {
  410. .modes = treo680_lcd_modes,
  411. .num_modes = ARRAY_SIZE(treo680_lcd_modes),
  412. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  413. };
  414. /******************************************************************************
  415. * Power management - standby
  416. ******************************************************************************/
  417. static void __init treo680_pm_init(void)
  418. {
  419. static u32 resume[] = {
  420. 0xe3a00101, /* mov r0, #0x40000000 */
  421. 0xe380060f, /* orr r0, r0, #0x00f00000 */
  422. 0xe590f008, /* ldr pc, [r0, #0x08] */
  423. };
  424. /* this is where the bootloader jumps */
  425. memcpy(phys_to_virt(TREO680_STR_BASE), resume, sizeof(resume));
  426. }
  427. /******************************************************************************
  428. * Machine init
  429. ******************************************************************************/
  430. static struct platform_device *devices[] __initdata = {
  431. &treo680_backlight,
  432. &treo680_leds,
  433. &power_supply,
  434. };
  435. /* setup udc GPIOs initial state */
  436. static void __init treo680_udc_init(void)
  437. {
  438. if (!gpio_request(GPIO_NR_TREO680_USB_PULLUP, "UDC Vbus")) {
  439. gpio_direction_output(GPIO_NR_TREO680_USB_PULLUP, 1);
  440. gpio_free(GPIO_NR_TREO680_USB_PULLUP);
  441. }
  442. }
  443. static void __init treo680_init(void)
  444. {
  445. treo680_pm_init();
  446. pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
  447. pxa_set_keypad_info(&treo680_keypad_platform_data);
  448. set_pxa_fb_info(&treo680_lcd_screen);
  449. pxa_set_mci_info(&treo680_mci_platform_data);
  450. treo680_udc_init();
  451. pxa_set_udc_info(&treo680_udc_info);
  452. pxa_set_ac97_info(&treo680_ac97_pdata);
  453. pxa_set_ficp_info(&treo680_ficp_info);
  454. pxa_set_ohci_info(&treo680_ohci_info);
  455. platform_add_devices(devices, ARRAY_SIZE(devices));
  456. }
  457. MACHINE_START(TREO680, "Palm Treo 680")
  458. .phys_io = TREO680_PHYS_IO_START,
  459. .io_pg_offst = io_p2v(0x40000000),
  460. .boot_params = 0xa0000100,
  461. .map_io = pxa_map_io,
  462. .init_irq = pxa27x_init_irq,
  463. .timer = &pxa_timer,
  464. .init_machine = treo680_init,
  465. MACHINE_END