palmtx.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. /*
  2. * Hardware definitions for PalmTX
  3. *
  4. * Author: Marek Vasut <marek.vasut@gmail.com>
  5. *
  6. * Based on work of:
  7. * Alex Osborne <ato@meshy.org>
  8. * Cristiano P. <cristianop@users.sourceforge.net>
  9. * Jan Herman <2hp@seznam.cz>
  10. * Michal Hrusecky
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. *
  16. * (find more info at www.hackndev.com)
  17. *
  18. */
  19. #include <linux/platform_device.h>
  20. #include <linux/delay.h>
  21. #include <linux/irq.h>
  22. #include <linux/gpio_keys.h>
  23. #include <linux/input.h>
  24. #include <linux/pda_power.h>
  25. #include <linux/pwm_backlight.h>
  26. #include <linux/gpio.h>
  27. #include <linux/wm97xx_batt.h>
  28. #include <linux/power_supply.h>
  29. #include <linux/usb/gpio_vbus.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <mach/pxa27x.h>
  34. #include <mach/audio.h>
  35. #include <mach/palmtx.h>
  36. #include <mach/mmc.h>
  37. #include <mach/pxafb.h>
  38. #include <mach/irda.h>
  39. #include <mach/pxa27x_keypad.h>
  40. #include <mach/udc.h>
  41. #include <mach/palmasoc.h>
  42. #include "generic.h"
  43. #include "devices.h"
  44. /******************************************************************************
  45. * Pin configuration
  46. ******************************************************************************/
  47. static unsigned long palmtx_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. GPIO14_GPIO, /* SD detect */
  56. GPIO114_GPIO, /* SD power */
  57. GPIO115_GPIO, /* SD r/o switch */
  58. /* AC97 */
  59. GPIO28_AC97_BITCLK,
  60. GPIO29_AC97_SDATA_IN_0,
  61. GPIO30_AC97_SDATA_OUT,
  62. GPIO31_AC97_SYNC,
  63. GPIO89_AC97_SYSCLK,
  64. GPIO95_AC97_nRESET,
  65. /* IrDA */
  66. GPIO40_GPIO, /* ir disable */
  67. GPIO46_FICP_RXD,
  68. GPIO47_FICP_TXD,
  69. /* PWM */
  70. GPIO16_PWM0_OUT,
  71. /* USB */
  72. GPIO13_GPIO, /* usb detect */
  73. GPIO93_GPIO, /* usb power */
  74. /* PCMCIA */
  75. GPIO48_nPOE,
  76. GPIO49_nPWE,
  77. GPIO50_nPIOR,
  78. GPIO51_nPIOW,
  79. GPIO85_nPCE_1,
  80. GPIO54_nPCE_2,
  81. GPIO79_PSKTSEL,
  82. GPIO55_nPREG,
  83. GPIO56_nPWAIT,
  84. GPIO57_nIOIS16,
  85. GPIO94_GPIO, /* wifi power 1 */
  86. GPIO108_GPIO, /* wifi power 2 */
  87. GPIO116_GPIO, /* wifi ready */
  88. /* MATRIX KEYPAD */
  89. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  90. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  91. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  92. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  93. GPIO103_KP_MKOUT_0,
  94. GPIO104_KP_MKOUT_1,
  95. GPIO105_KP_MKOUT_2,
  96. /* LCD */
  97. GPIO58_LCD_LDD_0,
  98. GPIO59_LCD_LDD_1,
  99. GPIO60_LCD_LDD_2,
  100. GPIO61_LCD_LDD_3,
  101. GPIO62_LCD_LDD_4,
  102. GPIO63_LCD_LDD_5,
  103. GPIO64_LCD_LDD_6,
  104. GPIO65_LCD_LDD_7,
  105. GPIO66_LCD_LDD_8,
  106. GPIO67_LCD_LDD_9,
  107. GPIO68_LCD_LDD_10,
  108. GPIO69_LCD_LDD_11,
  109. GPIO70_LCD_LDD_12,
  110. GPIO71_LCD_LDD_13,
  111. GPIO72_LCD_LDD_14,
  112. GPIO73_LCD_LDD_15,
  113. GPIO74_LCD_FCLK,
  114. GPIO75_LCD_LCLK,
  115. GPIO76_LCD_PCLK,
  116. GPIO77_LCD_BIAS,
  117. /* FFUART */
  118. GPIO34_FFUART_RXD,
  119. GPIO39_FFUART_TXD,
  120. /* MISC. */
  121. GPIO10_GPIO, /* hotsync button */
  122. GPIO12_GPIO, /* power detect */
  123. GPIO107_GPIO, /* earphone detect */
  124. };
  125. /******************************************************************************
  126. * SD/MMC card controller
  127. ******************************************************************************/
  128. static struct pxamci_platform_data palmtx_mci_platform_data = {
  129. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  130. .gpio_card_detect = GPIO_NR_PALMTX_SD_DETECT_N,
  131. .gpio_card_ro = GPIO_NR_PALMTX_SD_READONLY,
  132. .gpio_power = GPIO_NR_PALMTX_SD_POWER,
  133. .detect_delay = 20,
  134. };
  135. /******************************************************************************
  136. * GPIO keyboard
  137. ******************************************************************************/
  138. static unsigned int palmtx_matrix_keys[] = {
  139. KEY(0, 0, KEY_POWER),
  140. KEY(0, 1, KEY_F1),
  141. KEY(0, 2, KEY_ENTER),
  142. KEY(1, 0, KEY_F2),
  143. KEY(1, 1, KEY_F3),
  144. KEY(1, 2, KEY_F4),
  145. KEY(2, 0, KEY_UP),
  146. KEY(2, 2, KEY_DOWN),
  147. KEY(3, 0, KEY_RIGHT),
  148. KEY(3, 2, KEY_LEFT),
  149. };
  150. static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
  151. .matrix_key_rows = 4,
  152. .matrix_key_cols = 3,
  153. .matrix_key_map = palmtx_matrix_keys,
  154. .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
  155. .debounce_interval = 30,
  156. };
  157. /******************************************************************************
  158. * GPIO keys
  159. ******************************************************************************/
  160. static struct gpio_keys_button palmtx_pxa_buttons[] = {
  161. {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  162. };
  163. static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
  164. .buttons = palmtx_pxa_buttons,
  165. .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
  166. };
  167. static struct platform_device palmtx_pxa_keys = {
  168. .name = "gpio-keys",
  169. .id = -1,
  170. .dev = {
  171. .platform_data = &palmtx_pxa_keys_data,
  172. },
  173. };
  174. /******************************************************************************
  175. * Backlight
  176. ******************************************************************************/
  177. static int palmtx_backlight_init(struct device *dev)
  178. {
  179. int ret;
  180. ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
  181. if (ret)
  182. goto err;
  183. ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
  184. if (ret)
  185. goto err2;
  186. ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
  187. if (ret)
  188. goto err2;
  189. ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
  190. if (ret)
  191. goto err3;
  192. return 0;
  193. err3:
  194. gpio_free(GPIO_NR_PALMTX_LCD_POWER);
  195. err2:
  196. gpio_free(GPIO_NR_PALMTX_BL_POWER);
  197. err:
  198. return ret;
  199. }
  200. static int palmtx_backlight_notify(int brightness)
  201. {
  202. gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
  203. gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
  204. return brightness;
  205. }
  206. static void palmtx_backlight_exit(struct device *dev)
  207. {
  208. gpio_free(GPIO_NR_PALMTX_BL_POWER);
  209. gpio_free(GPIO_NR_PALMTX_LCD_POWER);
  210. }
  211. static struct platform_pwm_backlight_data palmtx_backlight_data = {
  212. .pwm_id = 0,
  213. .max_brightness = PALMTX_MAX_INTENSITY,
  214. .dft_brightness = PALMTX_MAX_INTENSITY,
  215. .pwm_period_ns = PALMTX_PERIOD_NS,
  216. .init = palmtx_backlight_init,
  217. .notify = palmtx_backlight_notify,
  218. .exit = palmtx_backlight_exit,
  219. };
  220. static struct platform_device palmtx_backlight = {
  221. .name = "pwm-backlight",
  222. .dev = {
  223. .parent = &pxa27x_device_pwm0.dev,
  224. .platform_data = &palmtx_backlight_data,
  225. },
  226. };
  227. /******************************************************************************
  228. * IrDA
  229. ******************************************************************************/
  230. static int palmtx_irda_startup(struct device *dev)
  231. {
  232. int err;
  233. err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
  234. if (err)
  235. goto err;
  236. err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
  237. if (err)
  238. gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
  239. err:
  240. return err;
  241. }
  242. static void palmtx_irda_shutdown(struct device *dev)
  243. {
  244. gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
  245. }
  246. static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
  247. {
  248. gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
  249. pxa2xx_transceiver_mode(dev, mode);
  250. }
  251. static struct pxaficp_platform_data palmtx_ficp_platform_data = {
  252. .startup = palmtx_irda_startup,
  253. .shutdown = palmtx_irda_shutdown,
  254. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  255. .transceiver_mode = palmtx_irda_transceiver_mode,
  256. };
  257. /******************************************************************************
  258. * UDC
  259. ******************************************************************************/
  260. static struct gpio_vbus_mach_info palmtx_udc_info = {
  261. .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
  262. .gpio_vbus_inverted = 1,
  263. .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP,
  264. };
  265. static struct platform_device palmtx_gpio_vbus = {
  266. .name = "gpio-vbus",
  267. .id = -1,
  268. .dev = {
  269. .platform_data = &palmtx_udc_info,
  270. },
  271. };
  272. /******************************************************************************
  273. * Power supply
  274. ******************************************************************************/
  275. static int power_supply_init(struct device *dev)
  276. {
  277. int ret;
  278. ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
  279. if (ret)
  280. goto err1;
  281. ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
  282. if (ret)
  283. goto err2;
  284. return 0;
  285. err2:
  286. gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
  287. err1:
  288. return ret;
  289. }
  290. static int palmtx_is_ac_online(void)
  291. {
  292. return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
  293. }
  294. static void power_supply_exit(struct device *dev)
  295. {
  296. gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
  297. }
  298. static char *palmtx_supplicants[] = {
  299. "main-battery",
  300. };
  301. static struct pda_power_pdata power_supply_info = {
  302. .init = power_supply_init,
  303. .is_ac_online = palmtx_is_ac_online,
  304. .exit = power_supply_exit,
  305. .supplied_to = palmtx_supplicants,
  306. .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
  307. };
  308. static struct platform_device power_supply = {
  309. .name = "pda-power",
  310. .id = -1,
  311. .dev = {
  312. .platform_data = &power_supply_info,
  313. },
  314. };
  315. /******************************************************************************
  316. * WM97xx battery
  317. ******************************************************************************/
  318. static struct wm97xx_batt_info wm97xx_batt_pdata = {
  319. .batt_aux = WM97XX_AUX_ID3,
  320. .temp_aux = WM97XX_AUX_ID2,
  321. .charge_gpio = -1,
  322. .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
  323. .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
  324. .batt_mult = 1000,
  325. .batt_div = 414,
  326. .temp_mult = 1,
  327. .temp_div = 1,
  328. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  329. .batt_name = "main-batt",
  330. };
  331. /******************************************************************************
  332. * aSoC audio
  333. ******************************************************************************/
  334. static struct palm27x_asoc_info palmtx_asoc_pdata = {
  335. .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT,
  336. };
  337. static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
  338. .reset_gpio = 95,
  339. };
  340. static struct platform_device palmtx_asoc = {
  341. .name = "palm27x-asoc",
  342. .id = -1,
  343. .dev = {
  344. .platform_data = &palmtx_asoc_pdata,
  345. },
  346. };
  347. /******************************************************************************
  348. * Framebuffer
  349. ******************************************************************************/
  350. static struct pxafb_mode_info palmtx_lcd_modes[] = {
  351. {
  352. .pixclock = 57692,
  353. .xres = 320,
  354. .yres = 480,
  355. .bpp = 16,
  356. .left_margin = 32,
  357. .right_margin = 1,
  358. .upper_margin = 7,
  359. .lower_margin = 1,
  360. .hsync_len = 4,
  361. .vsync_len = 1,
  362. },
  363. };
  364. static struct pxafb_mach_info palmtx_lcd_screen = {
  365. .modes = palmtx_lcd_modes,
  366. .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
  367. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  368. };
  369. /******************************************************************************
  370. * Power management - standby
  371. ******************************************************************************/
  372. static void __init palmtx_pm_init(void)
  373. {
  374. static u32 resume[] = {
  375. 0xe3a00101, /* mov r0, #0x40000000 */
  376. 0xe380060f, /* orr r0, r0, #0x00f00000 */
  377. 0xe590f008, /* ldr pc, [r0, #0x08] */
  378. };
  379. /* copy the bootloader */
  380. memcpy(phys_to_virt(PALMTX_STR_BASE), resume, sizeof(resume));
  381. }
  382. /******************************************************************************
  383. * Machine init
  384. ******************************************************************************/
  385. static struct platform_device *devices[] __initdata = {
  386. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  387. &palmtx_pxa_keys,
  388. #endif
  389. &palmtx_backlight,
  390. &power_supply,
  391. &palmtx_asoc,
  392. &palmtx_gpio_vbus,
  393. };
  394. static struct map_desc palmtx_io_desc[] __initdata = {
  395. {
  396. .virtual = PALMTX_PCMCIA_VIRT,
  397. .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
  398. .length = PALMTX_PCMCIA_SIZE,
  399. .type = MT_DEVICE
  400. },
  401. };
  402. static void __init palmtx_map_io(void)
  403. {
  404. pxa_map_io();
  405. iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
  406. }
  407. /* setup udc GPIOs initial state */
  408. static void __init palmtx_udc_init(void)
  409. {
  410. if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) {
  411. gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1);
  412. gpio_free(GPIO_NR_PALMTX_USB_PULLUP);
  413. }
  414. }
  415. static void __init palmtx_init(void)
  416. {
  417. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
  418. palmtx_pm_init();
  419. set_pxa_fb_info(&palmtx_lcd_screen);
  420. pxa_set_mci_info(&palmtx_mci_platform_data);
  421. palmtx_udc_init();
  422. pxa_set_ac97_info(&palmtx_ac97_pdata);
  423. pxa_set_ficp_info(&palmtx_ficp_platform_data);
  424. pxa_set_keypad_info(&palmtx_keypad_platform_data);
  425. wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
  426. platform_add_devices(devices, ARRAY_SIZE(devices));
  427. }
  428. MACHINE_START(PALMTX, "Palm T|X")
  429. .phys_io = PALMTX_PHYS_IO_START,
  430. .io_pg_offst = io_p2v(0x40000000),
  431. .boot_params = 0xa0000100,
  432. .map_io = palmtx_map_io,
  433. .init_irq = pxa27x_init_irq,
  434. .timer = &pxa_timer,
  435. .init_machine = palmtx_init
  436. MACHINE_END