palmtx.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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. };
  134. /******************************************************************************
  135. * GPIO keyboard
  136. ******************************************************************************/
  137. static unsigned int palmtx_matrix_keys[] = {
  138. KEY(0, 0, KEY_POWER),
  139. KEY(0, 1, KEY_F1),
  140. KEY(0, 2, KEY_ENTER),
  141. KEY(1, 0, KEY_F2),
  142. KEY(1, 1, KEY_F3),
  143. KEY(1, 2, KEY_F4),
  144. KEY(2, 0, KEY_UP),
  145. KEY(2, 2, KEY_DOWN),
  146. KEY(3, 0, KEY_RIGHT),
  147. KEY(3, 2, KEY_LEFT),
  148. };
  149. static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
  150. .matrix_key_rows = 4,
  151. .matrix_key_cols = 3,
  152. .matrix_key_map = palmtx_matrix_keys,
  153. .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
  154. .debounce_interval = 30,
  155. };
  156. /******************************************************************************
  157. * GPIO keys
  158. ******************************************************************************/
  159. static struct gpio_keys_button palmtx_pxa_buttons[] = {
  160. {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  161. };
  162. static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
  163. .buttons = palmtx_pxa_buttons,
  164. .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
  165. };
  166. static struct platform_device palmtx_pxa_keys = {
  167. .name = "gpio-keys",
  168. .id = -1,
  169. .dev = {
  170. .platform_data = &palmtx_pxa_keys_data,
  171. },
  172. };
  173. /******************************************************************************
  174. * Backlight
  175. ******************************************************************************/
  176. static int palmtx_backlight_init(struct device *dev)
  177. {
  178. int ret;
  179. ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
  180. if (ret)
  181. goto err;
  182. ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
  183. if (ret)
  184. goto err2;
  185. ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
  186. if (ret)
  187. goto err2;
  188. ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
  189. if (ret)
  190. goto err3;
  191. return 0;
  192. err3:
  193. gpio_free(GPIO_NR_PALMTX_LCD_POWER);
  194. err2:
  195. gpio_free(GPIO_NR_PALMTX_BL_POWER);
  196. err:
  197. return ret;
  198. }
  199. static int palmtx_backlight_notify(int brightness)
  200. {
  201. gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
  202. gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
  203. return brightness;
  204. }
  205. static void palmtx_backlight_exit(struct device *dev)
  206. {
  207. gpio_free(GPIO_NR_PALMTX_BL_POWER);
  208. gpio_free(GPIO_NR_PALMTX_LCD_POWER);
  209. }
  210. static struct platform_pwm_backlight_data palmtx_backlight_data = {
  211. .pwm_id = 0,
  212. .max_brightness = PALMTX_MAX_INTENSITY,
  213. .dft_brightness = PALMTX_MAX_INTENSITY,
  214. .pwm_period_ns = PALMTX_PERIOD_NS,
  215. .init = palmtx_backlight_init,
  216. .notify = palmtx_backlight_notify,
  217. .exit = palmtx_backlight_exit,
  218. };
  219. static struct platform_device palmtx_backlight = {
  220. .name = "pwm-backlight",
  221. .dev = {
  222. .parent = &pxa27x_device_pwm0.dev,
  223. .platform_data = &palmtx_backlight_data,
  224. },
  225. };
  226. /******************************************************************************
  227. * IrDA
  228. ******************************************************************************/
  229. static int palmtx_irda_startup(struct device *dev)
  230. {
  231. int err;
  232. err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
  233. if (err)
  234. goto err;
  235. err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
  236. if (err)
  237. gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
  238. err:
  239. return err;
  240. }
  241. static void palmtx_irda_shutdown(struct device *dev)
  242. {
  243. gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
  244. }
  245. static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
  246. {
  247. gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
  248. pxa2xx_transceiver_mode(dev, mode);
  249. }
  250. static struct pxaficp_platform_data palmtx_ficp_platform_data = {
  251. .startup = palmtx_irda_startup,
  252. .shutdown = palmtx_irda_shutdown,
  253. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  254. .transceiver_mode = palmtx_irda_transceiver_mode,
  255. };
  256. /******************************************************************************
  257. * UDC
  258. ******************************************************************************/
  259. static struct gpio_vbus_mach_info palmtx_udc_info = {
  260. .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
  261. .gpio_vbus_inverted = 1,
  262. .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP,
  263. };
  264. static struct platform_device palmtx_gpio_vbus = {
  265. .name = "gpio-vbus",
  266. .id = -1,
  267. .dev = {
  268. .platform_data = &palmtx_udc_info,
  269. },
  270. };
  271. /******************************************************************************
  272. * Power supply
  273. ******************************************************************************/
  274. static int power_supply_init(struct device *dev)
  275. {
  276. int ret;
  277. ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
  278. if (ret)
  279. goto err1;
  280. ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
  281. if (ret)
  282. goto err2;
  283. return 0;
  284. err2:
  285. gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
  286. err1:
  287. return ret;
  288. }
  289. static int palmtx_is_ac_online(void)
  290. {
  291. return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
  292. }
  293. static void power_supply_exit(struct device *dev)
  294. {
  295. gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
  296. }
  297. static char *palmtx_supplicants[] = {
  298. "main-battery",
  299. };
  300. static struct pda_power_pdata power_supply_info = {
  301. .init = power_supply_init,
  302. .is_ac_online = palmtx_is_ac_online,
  303. .exit = power_supply_exit,
  304. .supplied_to = palmtx_supplicants,
  305. .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
  306. };
  307. static struct platform_device power_supply = {
  308. .name = "pda-power",
  309. .id = -1,
  310. .dev = {
  311. .platform_data = &power_supply_info,
  312. },
  313. };
  314. /******************************************************************************
  315. * WM97xx battery
  316. ******************************************************************************/
  317. static struct wm97xx_batt_info wm97xx_batt_pdata = {
  318. .batt_aux = WM97XX_AUX_ID3,
  319. .temp_aux = WM97XX_AUX_ID2,
  320. .charge_gpio = -1,
  321. .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
  322. .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
  323. .batt_mult = 1000,
  324. .batt_div = 414,
  325. .temp_mult = 1,
  326. .temp_div = 1,
  327. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  328. .batt_name = "main-batt",
  329. };
  330. /******************************************************************************
  331. * aSoC audio
  332. ******************************************************************************/
  333. static struct palm27x_asoc_info palmtx_asoc_pdata = {
  334. .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT,
  335. };
  336. static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
  337. .reset_gpio = 95,
  338. };
  339. static struct platform_device palmtx_asoc = {
  340. .name = "palm27x-asoc",
  341. .id = -1,
  342. .dev = {
  343. .platform_data = &palmtx_asoc_pdata,
  344. },
  345. };
  346. /******************************************************************************
  347. * Framebuffer
  348. ******************************************************************************/
  349. static struct pxafb_mode_info palmtx_lcd_modes[] = {
  350. {
  351. .pixclock = 57692,
  352. .xres = 320,
  353. .yres = 480,
  354. .bpp = 16,
  355. .left_margin = 32,
  356. .right_margin = 1,
  357. .upper_margin = 7,
  358. .lower_margin = 1,
  359. .hsync_len = 4,
  360. .vsync_len = 1,
  361. },
  362. };
  363. static struct pxafb_mach_info palmtx_lcd_screen = {
  364. .modes = palmtx_lcd_modes,
  365. .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
  366. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  367. };
  368. /******************************************************************************
  369. * Power management - standby
  370. ******************************************************************************/
  371. static void __init palmtx_pm_init(void)
  372. {
  373. static u32 resume[] = {
  374. 0xe3a00101, /* mov r0, #0x40000000 */
  375. 0xe380060f, /* orr r0, r0, #0x00f00000 */
  376. 0xe590f008, /* ldr pc, [r0, #0x08] */
  377. };
  378. /* copy the bootloader */
  379. memcpy(phys_to_virt(PALMTX_STR_BASE), resume, sizeof(resume));
  380. }
  381. /******************************************************************************
  382. * Machine init
  383. ******************************************************************************/
  384. static struct platform_device *devices[] __initdata = {
  385. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  386. &palmtx_pxa_keys,
  387. #endif
  388. &palmtx_backlight,
  389. &power_supply,
  390. &palmtx_asoc,
  391. &palmtx_gpio_vbus,
  392. };
  393. static struct map_desc palmtx_io_desc[] __initdata = {
  394. {
  395. .virtual = PALMTX_PCMCIA_VIRT,
  396. .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
  397. .length = PALMTX_PCMCIA_SIZE,
  398. .type = MT_DEVICE
  399. },
  400. };
  401. static void __init palmtx_map_io(void)
  402. {
  403. pxa_map_io();
  404. iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
  405. }
  406. /* setup udc GPIOs initial state */
  407. static void __init palmtx_udc_init(void)
  408. {
  409. if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) {
  410. gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1);
  411. gpio_free(GPIO_NR_PALMTX_USB_PULLUP);
  412. }
  413. }
  414. static void __init palmtx_init(void)
  415. {
  416. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
  417. palmtx_pm_init();
  418. set_pxa_fb_info(&palmtx_lcd_screen);
  419. pxa_set_mci_info(&palmtx_mci_platform_data);
  420. palmtx_udc_init();
  421. pxa_set_ac97_info(&palmtx_ac97_pdata);
  422. pxa_set_ficp_info(&palmtx_ficp_platform_data);
  423. pxa_set_keypad_info(&palmtx_keypad_platform_data);
  424. wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
  425. platform_add_devices(devices, ARRAY_SIZE(devices));
  426. }
  427. MACHINE_START(PALMTX, "Palm T|X")
  428. .phys_io = PALMTX_PHYS_IO_START,
  429. .io_pg_offst = io_p2v(0x40000000),
  430. .boot_params = 0xa0000100,
  431. .map_io = palmtx_map_io,
  432. .init_irq = pxa27x_init_irq,
  433. .timer = &pxa_timer,
  434. .init_machine = palmtx_init
  435. MACHINE_END