palmt5.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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/memblock.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/palmt5.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 palmt5_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. /* USB */
  70. GPIO15_GPIO, /* usb detect */
  71. GPIO93_GPIO, /* usb power */
  72. /* MATRIX KEYPAD */
  73. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  74. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  75. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  76. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  77. GPIO103_KP_MKOUT_0,
  78. GPIO104_KP_MKOUT_1,
  79. GPIO105_KP_MKOUT_2,
  80. /* LCD */
  81. GPIOxx_LCD_TFT_16BPP,
  82. /* PWM */
  83. GPIO16_PWM0_OUT,
  84. /* FFUART */
  85. GPIO34_FFUART_RXD,
  86. GPIO39_FFUART_TXD,
  87. /* MISC */
  88. GPIO10_GPIO, /* hotsync button */
  89. GPIO90_GPIO, /* power detect */
  90. GPIO107_GPIO, /* earphone detect */
  91. };
  92. /******************************************************************************
  93. * SD/MMC card controller
  94. ******************************************************************************/
  95. static struct pxamci_platform_data palmt5_mci_platform_data = {
  96. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  97. .gpio_card_detect = GPIO_NR_PALMT5_SD_DETECT_N,
  98. .gpio_card_ro = GPIO_NR_PALMT5_SD_READONLY,
  99. .gpio_power = GPIO_NR_PALMT5_SD_POWER,
  100. .detect_delay_ms = 200,
  101. };
  102. /******************************************************************************
  103. * GPIO keyboard
  104. ******************************************************************************/
  105. static unsigned int palmt5_matrix_keys[] = {
  106. KEY(0, 0, KEY_POWER),
  107. KEY(0, 1, KEY_F1),
  108. KEY(0, 2, KEY_ENTER),
  109. KEY(1, 0, KEY_F2),
  110. KEY(1, 1, KEY_F3),
  111. KEY(1, 2, KEY_F4),
  112. KEY(2, 0, KEY_UP),
  113. KEY(2, 2, KEY_DOWN),
  114. KEY(3, 0, KEY_RIGHT),
  115. KEY(3, 2, KEY_LEFT),
  116. };
  117. static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data = {
  118. .matrix_key_rows = 4,
  119. .matrix_key_cols = 3,
  120. .matrix_key_map = palmt5_matrix_keys,
  121. .matrix_key_map_size = ARRAY_SIZE(palmt5_matrix_keys),
  122. .debounce_interval = 30,
  123. };
  124. /******************************************************************************
  125. * GPIO keys
  126. ******************************************************************************/
  127. static struct gpio_keys_button palmt5_pxa_buttons[] = {
  128. {KEY_F8, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  129. };
  130. static struct gpio_keys_platform_data palmt5_pxa_keys_data = {
  131. .buttons = palmt5_pxa_buttons,
  132. .nbuttons = ARRAY_SIZE(palmt5_pxa_buttons),
  133. };
  134. static struct platform_device palmt5_pxa_keys = {
  135. .name = "gpio-keys",
  136. .id = -1,
  137. .dev = {
  138. .platform_data = &palmt5_pxa_keys_data,
  139. },
  140. };
  141. /******************************************************************************
  142. * Backlight
  143. ******************************************************************************/
  144. static int palmt5_backlight_init(struct device *dev)
  145. {
  146. int ret;
  147. ret = gpio_request(GPIO_NR_PALMT5_BL_POWER, "BL POWER");
  148. if (ret)
  149. goto err;
  150. ret = gpio_direction_output(GPIO_NR_PALMT5_BL_POWER, 0);
  151. if (ret)
  152. goto err2;
  153. ret = gpio_request(GPIO_NR_PALMT5_LCD_POWER, "LCD POWER");
  154. if (ret)
  155. goto err2;
  156. ret = gpio_direction_output(GPIO_NR_PALMT5_LCD_POWER, 0);
  157. if (ret)
  158. goto err3;
  159. return 0;
  160. err3:
  161. gpio_free(GPIO_NR_PALMT5_LCD_POWER);
  162. err2:
  163. gpio_free(GPIO_NR_PALMT5_BL_POWER);
  164. err:
  165. return ret;
  166. }
  167. static int palmt5_backlight_notify(struct device *dev, int brightness)
  168. {
  169. gpio_set_value(GPIO_NR_PALMT5_BL_POWER, brightness);
  170. gpio_set_value(GPIO_NR_PALMT5_LCD_POWER, brightness);
  171. return brightness;
  172. }
  173. static void palmt5_backlight_exit(struct device *dev)
  174. {
  175. gpio_free(GPIO_NR_PALMT5_BL_POWER);
  176. gpio_free(GPIO_NR_PALMT5_LCD_POWER);
  177. }
  178. static struct platform_pwm_backlight_data palmt5_backlight_data = {
  179. .pwm_id = 0,
  180. .max_brightness = PALMT5_MAX_INTENSITY,
  181. .dft_brightness = PALMT5_MAX_INTENSITY,
  182. .pwm_period_ns = PALMT5_PERIOD_NS,
  183. .init = palmt5_backlight_init,
  184. .notify = palmt5_backlight_notify,
  185. .exit = palmt5_backlight_exit,
  186. };
  187. static struct platform_device palmt5_backlight = {
  188. .name = "pwm-backlight",
  189. .dev = {
  190. .parent = &pxa27x_device_pwm0.dev,
  191. .platform_data = &palmt5_backlight_data,
  192. },
  193. };
  194. /******************************************************************************
  195. * IrDA
  196. ******************************************************************************/
  197. static struct pxaficp_platform_data palmt5_ficp_platform_data = {
  198. .gpio_pwdown = GPIO_NR_PALMT5_IR_DISABLE,
  199. .transceiver_cap = IR_SIRMODE | IR_OFF,
  200. };
  201. /******************************************************************************
  202. * UDC
  203. ******************************************************************************/
  204. static struct gpio_vbus_mach_info palmt5_udc_info = {
  205. .gpio_vbus = GPIO_NR_PALMT5_USB_DETECT_N,
  206. .gpio_vbus_inverted = 1,
  207. .gpio_pullup = GPIO_NR_PALMT5_USB_PULLUP,
  208. };
  209. static struct platform_device palmt5_gpio_vbus = {
  210. .name = "gpio-vbus",
  211. .id = -1,
  212. .dev = {
  213. .platform_data = &palmt5_udc_info,
  214. },
  215. };
  216. /******************************************************************************
  217. * Power supply
  218. ******************************************************************************/
  219. static int power_supply_init(struct device *dev)
  220. {
  221. int ret;
  222. ret = gpio_request(GPIO_NR_PALMT5_POWER_DETECT, "CABLE_STATE_AC");
  223. if (ret)
  224. goto err1;
  225. ret = gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT);
  226. if (ret)
  227. goto err2;
  228. return 0;
  229. err2:
  230. gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
  231. err1:
  232. return ret;
  233. }
  234. static int palmt5_is_ac_online(void)
  235. {
  236. return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT);
  237. }
  238. static void power_supply_exit(struct device *dev)
  239. {
  240. gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
  241. }
  242. static char *palmt5_supplicants[] = {
  243. "main-battery",
  244. };
  245. static struct pda_power_pdata power_supply_info = {
  246. .init = power_supply_init,
  247. .is_ac_online = palmt5_is_ac_online,
  248. .exit = power_supply_exit,
  249. .supplied_to = palmt5_supplicants,
  250. .num_supplicants = ARRAY_SIZE(palmt5_supplicants),
  251. };
  252. static struct platform_device power_supply = {
  253. .name = "pda-power",
  254. .id = -1,
  255. .dev = {
  256. .platform_data = &power_supply_info,
  257. },
  258. };
  259. /******************************************************************************
  260. * WM97xx battery
  261. ******************************************************************************/
  262. static struct wm97xx_batt_info wm97xx_batt_pdata = {
  263. .batt_aux = WM97XX_AUX_ID3,
  264. .temp_aux = WM97XX_AUX_ID2,
  265. .charge_gpio = -1,
  266. .max_voltage = PALMT5_BAT_MAX_VOLTAGE,
  267. .min_voltage = PALMT5_BAT_MIN_VOLTAGE,
  268. .batt_mult = 1000,
  269. .batt_div = 414,
  270. .temp_mult = 1,
  271. .temp_div = 1,
  272. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  273. .batt_name = "main-batt",
  274. };
  275. /******************************************************************************
  276. * aSoC audio
  277. ******************************************************************************/
  278. static struct palm27x_asoc_info palmt5_asoc_pdata = {
  279. .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT,
  280. };
  281. static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
  282. .reset_gpio = 95,
  283. };
  284. static struct platform_device palmt5_asoc = {
  285. .name = "palm27x-asoc",
  286. .id = -1,
  287. .dev = {
  288. .platform_data = &palmt5_asoc_pdata,
  289. },
  290. };
  291. /******************************************************************************
  292. * Framebuffer
  293. ******************************************************************************/
  294. static struct pxafb_mode_info palmt5_lcd_modes[] = {
  295. {
  296. .pixclock = 57692,
  297. .xres = 320,
  298. .yres = 480,
  299. .bpp = 16,
  300. .left_margin = 32,
  301. .right_margin = 1,
  302. .upper_margin = 7,
  303. .lower_margin = 1,
  304. .hsync_len = 4,
  305. .vsync_len = 1,
  306. },
  307. };
  308. static struct pxafb_mach_info palmt5_lcd_screen = {
  309. .modes = palmt5_lcd_modes,
  310. .num_modes = ARRAY_SIZE(palmt5_lcd_modes),
  311. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  312. };
  313. /******************************************************************************
  314. * Power management - standby
  315. ******************************************************************************/
  316. static void __init palmt5_pm_init(void)
  317. {
  318. static u32 resume[] = {
  319. 0xe3a00101, /* mov r0, #0x40000000 */
  320. 0xe380060f, /* orr r0, r0, #0x00f00000 */
  321. 0xe590f008, /* ldr pc, [r0, #0x08] */
  322. };
  323. /* copy the bootloader */
  324. memcpy(phys_to_virt(PALMT5_STR_BASE), resume, sizeof(resume));
  325. }
  326. /******************************************************************************
  327. * Machine init
  328. ******************************************************************************/
  329. static struct platform_device *devices[] __initdata = {
  330. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  331. &palmt5_pxa_keys,
  332. #endif
  333. &palmt5_backlight,
  334. &power_supply,
  335. &palmt5_asoc,
  336. &palmt5_gpio_vbus,
  337. };
  338. /* setup udc GPIOs initial state */
  339. static void __init palmt5_udc_init(void)
  340. {
  341. if (!gpio_request(GPIO_NR_PALMT5_USB_PULLUP, "UDC Vbus")) {
  342. gpio_direction_output(GPIO_NR_PALMT5_USB_PULLUP, 1);
  343. gpio_free(GPIO_NR_PALMT5_USB_PULLUP);
  344. }
  345. }
  346. static void __init palmt5_reserve(void)
  347. {
  348. memblock_reserve(0xa0200000, 0x1000);
  349. }
  350. static void __init palmt5_init(void)
  351. {
  352. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
  353. pxa_set_ffuart_info(NULL);
  354. pxa_set_btuart_info(NULL);
  355. pxa_set_stuart_info(NULL);
  356. palmt5_pm_init();
  357. set_pxa_fb_info(&palmt5_lcd_screen);
  358. pxa_set_mci_info(&palmt5_mci_platform_data);
  359. palmt5_udc_init();
  360. pxa_set_ac97_info(&palmt5_ac97_pdata);
  361. pxa_set_ficp_info(&palmt5_ficp_platform_data);
  362. pxa_set_keypad_info(&palmt5_keypad_platform_data);
  363. wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
  364. platform_add_devices(devices, ARRAY_SIZE(devices));
  365. }
  366. MACHINE_START(PALMT5, "Palm Tungsten|T5")
  367. .phys_io = PALMT5_PHYS_IO_START,
  368. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  369. .boot_params = 0xa0000100,
  370. .map_io = pxa_map_io,
  371. .reserve = palmt5_reserve,
  372. .init_irq = pxa27x_init_irq,
  373. .timer = &pxa_timer,
  374. .init_machine = palmt5_init
  375. MACHINE_END