palmt5.c 11 KB

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