palmt5.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. /*
  2. * Hardware definitions for Palm Tungsten|T5
  3. *
  4. * Author: Marek Vasut <marek.vasut@gmail.com>
  5. *
  6. * Based on work of:
  7. * Ales Snuparek <snuparek@atlas.cz>
  8. * Justin Kendrick <twilightsentry@gmail.com>
  9. * RichardT5 <richard_t5@users.sourceforge.net>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. *
  15. * (find more info at www.hackndev.com)
  16. *
  17. */
  18. #include <linux/platform_device.h>
  19. #include <linux/delay.h>
  20. #include <linux/irq.h>
  21. #include <linux/gpio_keys.h>
  22. #include <linux/input.h>
  23. #include <linux/pda_power.h>
  24. #include <linux/pwm_backlight.h>
  25. #include <linux/gpio.h>
  26. #include <linux/wm97xx_batt.h>
  27. #include <linux/power_supply.h>
  28. #include <linux/usb/gpio_vbus.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/map.h>
  32. #include <mach/pxa27x.h>
  33. #include <mach/audio.h>
  34. #include <mach/palmt5.h>
  35. #include <mach/mmc.h>
  36. #include <mach/pxafb.h>
  37. #include <mach/irda.h>
  38. #include <mach/pxa27x_keypad.h>
  39. #include <mach/udc.h>
  40. #include <mach/palmasoc.h>
  41. #include "generic.h"
  42. #include "devices.h"
  43. /******************************************************************************
  44. * Pin configuration
  45. ******************************************************************************/
  46. static unsigned long palmt5_pin_config[] __initdata = {
  47. /* MMC */
  48. GPIO32_MMC_CLK,
  49. GPIO92_MMC_DAT_0,
  50. GPIO109_MMC_DAT_1,
  51. GPIO110_MMC_DAT_2,
  52. GPIO111_MMC_DAT_3,
  53. GPIO112_MMC_CMD,
  54. GPIO14_GPIO, /* SD detect */
  55. GPIO114_GPIO, /* SD power */
  56. GPIO115_GPIO, /* SD r/o switch */
  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. GPIO40_GPIO, /* ir disable */
  66. GPIO46_FICP_RXD,
  67. GPIO47_FICP_TXD,
  68. /* USB */
  69. GPIO15_GPIO, /* usb detect */
  70. GPIO93_GPIO, /* usb power */
  71. /* MATRIX KEYPAD */
  72. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  73. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  74. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  75. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  76. GPIO103_KP_MKOUT_0,
  77. GPIO104_KP_MKOUT_1,
  78. GPIO105_KP_MKOUT_2,
  79. /* LCD */
  80. GPIO58_LCD_LDD_0,
  81. GPIO59_LCD_LDD_1,
  82. GPIO60_LCD_LDD_2,
  83. GPIO61_LCD_LDD_3,
  84. GPIO62_LCD_LDD_4,
  85. GPIO63_LCD_LDD_5,
  86. GPIO64_LCD_LDD_6,
  87. GPIO65_LCD_LDD_7,
  88. GPIO66_LCD_LDD_8,
  89. GPIO67_LCD_LDD_9,
  90. GPIO68_LCD_LDD_10,
  91. GPIO69_LCD_LDD_11,
  92. GPIO70_LCD_LDD_12,
  93. GPIO71_LCD_LDD_13,
  94. GPIO72_LCD_LDD_14,
  95. GPIO73_LCD_LDD_15,
  96. GPIO74_LCD_FCLK,
  97. GPIO75_LCD_LCLK,
  98. GPIO76_LCD_PCLK,
  99. GPIO77_LCD_BIAS,
  100. /* PWM */
  101. GPIO16_PWM0_OUT,
  102. /* FFUART */
  103. GPIO34_FFUART_RXD,
  104. GPIO39_FFUART_TXD,
  105. /* MISC */
  106. GPIO10_GPIO, /* hotsync button */
  107. GPIO90_GPIO, /* power detect */
  108. GPIO107_GPIO, /* earphone detect */
  109. };
  110. /******************************************************************************
  111. * SD/MMC card controller
  112. ******************************************************************************/
  113. static struct pxamci_platform_data palmt5_mci_platform_data = {
  114. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  115. .gpio_card_detect = GPIO_NR_PALMT5_SD_DETECT_N,
  116. .gpio_card_ro = GPIO_NR_PALMT5_SD_READONLY,
  117. .gpio_power = GPIO_NR_PALMT5_SD_POWER,
  118. .detect_delay = 20,
  119. };
  120. /******************************************************************************
  121. * GPIO keyboard
  122. ******************************************************************************/
  123. static unsigned int palmt5_matrix_keys[] = {
  124. KEY(0, 0, KEY_POWER),
  125. KEY(0, 1, KEY_F1),
  126. KEY(0, 2, KEY_ENTER),
  127. KEY(1, 0, KEY_F2),
  128. KEY(1, 1, KEY_F3),
  129. KEY(1, 2, KEY_F4),
  130. KEY(2, 0, KEY_UP),
  131. KEY(2, 2, KEY_DOWN),
  132. KEY(3, 0, KEY_RIGHT),
  133. KEY(3, 2, KEY_LEFT),
  134. };
  135. static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data = {
  136. .matrix_key_rows = 4,
  137. .matrix_key_cols = 3,
  138. .matrix_key_map = palmt5_matrix_keys,
  139. .matrix_key_map_size = ARRAY_SIZE(palmt5_matrix_keys),
  140. .debounce_interval = 30,
  141. };
  142. /******************************************************************************
  143. * GPIO keys
  144. ******************************************************************************/
  145. static struct gpio_keys_button palmt5_pxa_buttons[] = {
  146. {KEY_F8, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  147. };
  148. static struct gpio_keys_platform_data palmt5_pxa_keys_data = {
  149. .buttons = palmt5_pxa_buttons,
  150. .nbuttons = ARRAY_SIZE(palmt5_pxa_buttons),
  151. };
  152. static struct platform_device palmt5_pxa_keys = {
  153. .name = "gpio-keys",
  154. .id = -1,
  155. .dev = {
  156. .platform_data = &palmt5_pxa_keys_data,
  157. },
  158. };
  159. /******************************************************************************
  160. * Backlight
  161. ******************************************************************************/
  162. static int palmt5_backlight_init(struct device *dev)
  163. {
  164. int ret;
  165. ret = gpio_request(GPIO_NR_PALMT5_BL_POWER, "BL POWER");
  166. if (ret)
  167. goto err;
  168. ret = gpio_direction_output(GPIO_NR_PALMT5_BL_POWER, 0);
  169. if (ret)
  170. goto err2;
  171. ret = gpio_request(GPIO_NR_PALMT5_LCD_POWER, "LCD POWER");
  172. if (ret)
  173. goto err2;
  174. ret = gpio_direction_output(GPIO_NR_PALMT5_LCD_POWER, 0);
  175. if (ret)
  176. goto err3;
  177. return 0;
  178. err3:
  179. gpio_free(GPIO_NR_PALMT5_LCD_POWER);
  180. err2:
  181. gpio_free(GPIO_NR_PALMT5_BL_POWER);
  182. err:
  183. return ret;
  184. }
  185. static int palmt5_backlight_notify(int brightness)
  186. {
  187. gpio_set_value(GPIO_NR_PALMT5_BL_POWER, brightness);
  188. gpio_set_value(GPIO_NR_PALMT5_LCD_POWER, brightness);
  189. return brightness;
  190. }
  191. static void palmt5_backlight_exit(struct device *dev)
  192. {
  193. gpio_free(GPIO_NR_PALMT5_BL_POWER);
  194. gpio_free(GPIO_NR_PALMT5_LCD_POWER);
  195. }
  196. static struct platform_pwm_backlight_data palmt5_backlight_data = {
  197. .pwm_id = 0,
  198. .max_brightness = PALMT5_MAX_INTENSITY,
  199. .dft_brightness = PALMT5_MAX_INTENSITY,
  200. .pwm_period_ns = PALMT5_PERIOD_NS,
  201. .init = palmt5_backlight_init,
  202. .notify = palmt5_backlight_notify,
  203. .exit = palmt5_backlight_exit,
  204. };
  205. static struct platform_device palmt5_backlight = {
  206. .name = "pwm-backlight",
  207. .dev = {
  208. .parent = &pxa27x_device_pwm0.dev,
  209. .platform_data = &palmt5_backlight_data,
  210. },
  211. };
  212. /******************************************************************************
  213. * IrDA
  214. ******************************************************************************/
  215. static struct pxaficp_platform_data palmt5_ficp_platform_data = {
  216. .gpio_pwdown = GPIO_NR_PALMT5_IR_DISABLE,
  217. .transceiver_cap = IR_SIRMODE | IR_OFF,
  218. };
  219. /******************************************************************************
  220. * UDC
  221. ******************************************************************************/
  222. static struct gpio_vbus_mach_info palmt5_udc_info = {
  223. .gpio_vbus = GPIO_NR_PALMT5_USB_DETECT_N,
  224. .gpio_vbus_inverted = 1,
  225. .gpio_pullup = GPIO_NR_PALMT5_USB_PULLUP,
  226. };
  227. static struct platform_device palmt5_gpio_vbus = {
  228. .name = "gpio-vbus",
  229. .id = -1,
  230. .dev = {
  231. .platform_data = &palmt5_udc_info,
  232. },
  233. };
  234. /******************************************************************************
  235. * Power supply
  236. ******************************************************************************/
  237. static int power_supply_init(struct device *dev)
  238. {
  239. int ret;
  240. ret = gpio_request(GPIO_NR_PALMT5_POWER_DETECT, "CABLE_STATE_AC");
  241. if (ret)
  242. goto err1;
  243. ret = gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT);
  244. if (ret)
  245. goto err2;
  246. return 0;
  247. err2:
  248. gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
  249. err1:
  250. return ret;
  251. }
  252. static int palmt5_is_ac_online(void)
  253. {
  254. return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT);
  255. }
  256. static void power_supply_exit(struct device *dev)
  257. {
  258. gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
  259. }
  260. static char *palmt5_supplicants[] = {
  261. "main-battery",
  262. };
  263. static struct pda_power_pdata power_supply_info = {
  264. .init = power_supply_init,
  265. .is_ac_online = palmt5_is_ac_online,
  266. .exit = power_supply_exit,
  267. .supplied_to = palmt5_supplicants,
  268. .num_supplicants = ARRAY_SIZE(palmt5_supplicants),
  269. };
  270. static struct platform_device power_supply = {
  271. .name = "pda-power",
  272. .id = -1,
  273. .dev = {
  274. .platform_data = &power_supply_info,
  275. },
  276. };
  277. /******************************************************************************
  278. * WM97xx battery
  279. ******************************************************************************/
  280. static struct wm97xx_batt_info wm97xx_batt_pdata = {
  281. .batt_aux = WM97XX_AUX_ID3,
  282. .temp_aux = WM97XX_AUX_ID2,
  283. .charge_gpio = -1,
  284. .max_voltage = PALMT5_BAT_MAX_VOLTAGE,
  285. .min_voltage = PALMT5_BAT_MIN_VOLTAGE,
  286. .batt_mult = 1000,
  287. .batt_div = 414,
  288. .temp_mult = 1,
  289. .temp_div = 1,
  290. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  291. .batt_name = "main-batt",
  292. };
  293. /******************************************************************************
  294. * aSoC audio
  295. ******************************************************************************/
  296. static struct palm27x_asoc_info palmt5_asoc_pdata = {
  297. .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT,
  298. };
  299. static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
  300. .reset_gpio = 95,
  301. };
  302. static struct platform_device palmt5_asoc = {
  303. .name = "palm27x-asoc",
  304. .id = -1,
  305. .dev = {
  306. .platform_data = &palmt5_asoc_pdata,
  307. },
  308. };
  309. /******************************************************************************
  310. * Framebuffer
  311. ******************************************************************************/
  312. static struct pxafb_mode_info palmt5_lcd_modes[] = {
  313. {
  314. .pixclock = 57692,
  315. .xres = 320,
  316. .yres = 480,
  317. .bpp = 16,
  318. .left_margin = 32,
  319. .right_margin = 1,
  320. .upper_margin = 7,
  321. .lower_margin = 1,
  322. .hsync_len = 4,
  323. .vsync_len = 1,
  324. },
  325. };
  326. static struct pxafb_mach_info palmt5_lcd_screen = {
  327. .modes = palmt5_lcd_modes,
  328. .num_modes = ARRAY_SIZE(palmt5_lcd_modes),
  329. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  330. };
  331. /******************************************************************************
  332. * Power management - standby
  333. ******************************************************************************/
  334. static void __init palmt5_pm_init(void)
  335. {
  336. static u32 resume[] = {
  337. 0xe3a00101, /* mov r0, #0x40000000 */
  338. 0xe380060f, /* orr r0, r0, #0x00f00000 */
  339. 0xe590f008, /* ldr pc, [r0, #0x08] */
  340. };
  341. /* copy the bootloader */
  342. memcpy(phys_to_virt(PALMT5_STR_BASE), resume, sizeof(resume));
  343. }
  344. /******************************************************************************
  345. * Machine init
  346. ******************************************************************************/
  347. static struct platform_device *devices[] __initdata = {
  348. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  349. &palmt5_pxa_keys,
  350. #endif
  351. &palmt5_backlight,
  352. &power_supply,
  353. &palmt5_asoc,
  354. &palmt5_gpio_vbus,
  355. };
  356. /* setup udc GPIOs initial state */
  357. static void __init palmt5_udc_init(void)
  358. {
  359. if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP, "UDC Vbus")) {
  360. gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP, 1);
  361. gpio_free(GPIO_NR_PALMT5_USB_PULLUP);
  362. }
  363. }
  364. static void __init palmt5_init(void)
  365. {
  366. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
  367. palmt5_pm_init();
  368. set_pxa_fb_info(&palmt5_lcd_screen);
  369. pxa_set_mci_info(&palmt5_mci_platform_data);
  370. palmt5_udc_init();
  371. pxa_set_ac97_info(&palmt5_ac97_pdata);
  372. pxa_set_ficp_info(&palmt5_ficp_platform_data);
  373. pxa_set_keypad_info(&palmt5_keypad_platform_data);
  374. wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
  375. platform_add_devices(devices, ARRAY_SIZE(devices));
  376. }
  377. MACHINE_START(PALMT5, "Palm Tungsten|T5")
  378. .phys_io = PALMT5_PHYS_IO_START,
  379. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  380. .boot_params = 0xa0000100,
  381. .map_io = pxa_map_io,
  382. .init_irq = pxa27x_init_irq,
  383. .timer = &pxa_timer,
  384. .init_machine = palmt5_init
  385. MACHINE_END