treo680.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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. return 0;
  227. err2:
  228. gpio_free(GPIO_NR_TREO680_BL_POWER);
  229. err:
  230. return ret;
  231. }
  232. static int treo680_backlight_notify(int brightness)
  233. {
  234. gpio_set_value(GPIO_NR_TREO680_BL_POWER, brightness);
  235. return TREO680_MAX_INTENSITY - brightness;
  236. };
  237. static void treo680_backlight_exit(struct device *dev)
  238. {
  239. gpio_free(GPIO_NR_TREO680_BL_POWER);
  240. }
  241. static struct platform_pwm_backlight_data treo680_backlight_data = {
  242. .pwm_id = 0,
  243. .max_brightness = TREO680_MAX_INTENSITY,
  244. .dft_brightness = TREO680_DEFAULT_INTENSITY,
  245. .pwm_period_ns = TREO680_PERIOD_NS,
  246. .init = treo680_backlight_init,
  247. .notify = treo680_backlight_notify,
  248. .exit = treo680_backlight_exit,
  249. };
  250. static struct platform_device treo680_backlight = {
  251. .name = "pwm-backlight",
  252. .dev = {
  253. .parent = &pxa27x_device_pwm0.dev,
  254. .platform_data = &treo680_backlight_data,
  255. },
  256. };
  257. /******************************************************************************
  258. * IrDA
  259. ******************************************************************************/
  260. static struct pxaficp_platform_data treo680_ficp_info = {
  261. .gpio_pwdown = GPIO_NR_TREO680_IR_EN,
  262. .transceiver_cap = IR_SIRMODE | IR_OFF,
  263. };
  264. /******************************************************************************
  265. * UDC
  266. ******************************************************************************/
  267. static struct pxa2xx_udc_mach_info treo680_udc_info __initdata = {
  268. .gpio_vbus = GPIO_NR_TREO680_USB_DETECT,
  269. .gpio_vbus_inverted = 1,
  270. .gpio_pullup = GPIO_NR_TREO680_USB_PULLUP,
  271. };
  272. /******************************************************************************
  273. * USB host
  274. ******************************************************************************/
  275. static struct pxaohci_platform_data treo680_ohci_info = {
  276. .port_mode = PMM_PERPORT_MODE,
  277. .flags = ENABLE_PORT1 | ENABLE_PORT3,
  278. .power_budget = 0,
  279. };
  280. /******************************************************************************
  281. * Power supply
  282. ******************************************************************************/
  283. static int power_supply_init(struct device *dev)
  284. {
  285. int ret;
  286. ret = gpio_request(GPIO_NR_TREO680_POWER_DETECT, "CABLE_STATE_AC");
  287. if (ret)
  288. goto err1;
  289. ret = gpio_direction_input(GPIO_NR_TREO680_POWER_DETECT);
  290. if (ret)
  291. goto err2;
  292. return 0;
  293. err2:
  294. gpio_free(GPIO_NR_TREO680_POWER_DETECT);
  295. err1:
  296. return ret;
  297. }
  298. static int treo680_is_ac_online(void)
  299. {
  300. return gpio_get_value(GPIO_NR_TREO680_POWER_DETECT);
  301. }
  302. static void power_supply_exit(struct device *dev)
  303. {
  304. gpio_free(GPIO_NR_TREO680_POWER_DETECT);
  305. }
  306. static char *treo680_supplicants[] = {
  307. "main-battery",
  308. };
  309. static struct pda_power_pdata power_supply_info = {
  310. .init = power_supply_init,
  311. .is_ac_online = treo680_is_ac_online,
  312. .exit = power_supply_exit,
  313. .supplied_to = treo680_supplicants,
  314. .num_supplicants = ARRAY_SIZE(treo680_supplicants),
  315. };
  316. static struct platform_device power_supply = {
  317. .name = "pda-power",
  318. .id = -1,
  319. .dev = {
  320. .platform_data = &power_supply_info,
  321. },
  322. };
  323. /******************************************************************************
  324. * Vibra and LEDs
  325. ******************************************************************************/
  326. static struct gpio_led gpio_leds[] = {
  327. {
  328. .name = "treo680:vibra:vibra",
  329. .default_trigger = "none",
  330. .gpio = GPIO_NR_TREO680_VIBRATE_EN,
  331. },
  332. {
  333. .name = "treo680:green:led",
  334. .default_trigger = "mmc0",
  335. .gpio = GPIO_NR_TREO680_GREEN_LED,
  336. },
  337. {
  338. .name = "treo680:keybbl:keybbl",
  339. .default_trigger = "none",
  340. .gpio = GPIO_NR_TREO680_KEYB_BL,
  341. },
  342. };
  343. static struct gpio_led_platform_data gpio_led_info = {
  344. .leds = gpio_leds,
  345. .num_leds = ARRAY_SIZE(gpio_leds),
  346. };
  347. static struct platform_device treo680_leds = {
  348. .name = "leds-gpio",
  349. .id = -1,
  350. .dev = {
  351. .platform_data = &gpio_led_info,
  352. }
  353. };
  354. /******************************************************************************
  355. * Framebuffer
  356. ******************************************************************************/
  357. /* TODO: add support for 324x324 */
  358. static struct pxafb_mode_info treo680_lcd_modes[] = {
  359. {
  360. .pixclock = 86538,
  361. .xres = 320,
  362. .yres = 320,
  363. .bpp = 16,
  364. .left_margin = 20,
  365. .right_margin = 8,
  366. .upper_margin = 8,
  367. .lower_margin = 5,
  368. .hsync_len = 4,
  369. .vsync_len = 1,
  370. },
  371. };
  372. static void treo680_lcd_power(int on, struct fb_var_screeninfo *info)
  373. {
  374. gpio_set_value(GPIO_NR_TREO680_BL_POWER, on);
  375. }
  376. static struct pxafb_mach_info treo680_lcd_screen = {
  377. .modes = treo680_lcd_modes,
  378. .num_modes = ARRAY_SIZE(treo680_lcd_modes),
  379. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  380. };
  381. /******************************************************************************
  382. * Power management - standby
  383. ******************************************************************************/
  384. static void __init treo680_pm_init(void)
  385. {
  386. static u32 resume[] = {
  387. 0xe3a00101, /* mov r0, #0x40000000 */
  388. 0xe380060f, /* orr r0, r0, #0x00f00000 */
  389. 0xe590f008, /* ldr pc, [r0, #0x08] */
  390. };
  391. /* this is where the bootloader jumps */
  392. memcpy(phys_to_virt(TREO680_STR_BASE), resume, sizeof(resume));
  393. }
  394. /******************************************************************************
  395. * Machine init
  396. ******************************************************************************/
  397. static struct platform_device *devices[] __initdata = {
  398. &treo680_backlight,
  399. &treo680_leds,
  400. &power_supply,
  401. };
  402. /* setup udc GPIOs initial state */
  403. static void __init treo680_udc_init(void)
  404. {
  405. if (!gpio_request(GPIO_NR_TREO680_USB_PULLUP, "UDC Vbus")) {
  406. gpio_direction_output(GPIO_NR_TREO680_USB_PULLUP, 1);
  407. gpio_free(GPIO_NR_TREO680_USB_PULLUP);
  408. }
  409. }
  410. static void __init treo680_lcd_power_init(void)
  411. {
  412. int ret;
  413. ret = gpio_request(GPIO_NR_TREO680_LCD_POWER, "LCD POWER");
  414. if (ret) {
  415. pr_err("Treo680: LCD power GPIO request failed!\n");
  416. return;
  417. }
  418. ret = gpio_direction_output(GPIO_NR_TREO680_LCD_POWER, 0);
  419. if (ret) {
  420. pr_err("Treo680: setting LCD power GPIO direction failed!\n");
  421. gpio_free(GPIO_NR_TREO680_LCD_POWER);
  422. return;
  423. }
  424. treo680_lcd_screen.pxafb_lcd_power = treo680_lcd_power;
  425. }
  426. static void __init treo680_init(void)
  427. {
  428. treo680_pm_init();
  429. pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
  430. pxa_set_keypad_info(&treo680_keypad_platform_data);
  431. treo680_lcd_power_init();
  432. set_pxa_fb_info(&treo680_lcd_screen);
  433. pxa_set_mci_info(&treo680_mci_platform_data);
  434. treo680_udc_init();
  435. pxa_set_udc_info(&treo680_udc_info);
  436. pxa_set_ac97_info(&treo680_ac97_pdata);
  437. pxa_set_ficp_info(&treo680_ficp_info);
  438. pxa_set_ohci_info(&treo680_ohci_info);
  439. platform_add_devices(devices, ARRAY_SIZE(devices));
  440. }
  441. MACHINE_START(TREO680, "Palm Treo 680")
  442. .phys_io = TREO680_PHYS_IO_START,
  443. .io_pg_offst = io_p2v(0x40000000),
  444. .boot_params = 0xa0000100,
  445. .map_io = pxa_map_io,
  446. .init_irq = pxa27x_init_irq,
  447. .timer = &pxa_timer,
  448. .init_machine = treo680_init,
  449. MACHINE_END