palmte2.c 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /*
  2. * Hardware definitions for Palm Tungsten|E2
  3. *
  4. * Author:
  5. * Carlos Eduardo Medaglia Dyonisio <cadu@nerdfeliz.com>
  6. *
  7. * Rewrite for mainline:
  8. * Marek Vasut <marek.vasut@gmail.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. *
  14. * (find more info at www.hackndev.com)
  15. *
  16. */
  17. #include <linux/platform_device.h>
  18. #include <linux/delay.h>
  19. #include <linux/irq.h>
  20. #include <linux/gpio_keys.h>
  21. #include <linux/input.h>
  22. #include <linux/pda_power.h>
  23. #include <linux/pwm_backlight.h>
  24. #include <linux/gpio.h>
  25. #include <linux/wm97xx.h>
  26. #include <linux/power_supply.h>
  27. #include <linux/usb/gpio_vbus.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include <mach/pxa25x.h>
  32. #include <mach/audio.h>
  33. #include <mach/palmte2.h>
  34. #include <linux/platform_data/mmc-pxamci.h>
  35. #include <linux/platform_data/video-pxafb.h>
  36. #include <linux/platform_data/irda-pxaficp.h>
  37. #include <mach/udc.h>
  38. #include <linux/platform_data/asoc-palm27x.h>
  39. #include "generic.h"
  40. #include "devices.h"
  41. /******************************************************************************
  42. * Pin configuration
  43. ******************************************************************************/
  44. static unsigned long palmte2_pin_config[] __initdata = {
  45. /* MMC */
  46. GPIO6_MMC_CLK,
  47. GPIO8_MMC_CS0,
  48. GPIO10_GPIO, /* SD detect */
  49. GPIO55_GPIO, /* SD power */
  50. GPIO51_GPIO, /* SD r/o switch */
  51. /* AC97 */
  52. GPIO28_AC97_BITCLK,
  53. GPIO29_AC97_SDATA_IN_0,
  54. GPIO30_AC97_SDATA_OUT,
  55. GPIO31_AC97_SYNC,
  56. /* PWM */
  57. GPIO16_PWM0_OUT,
  58. /* USB */
  59. GPIO15_GPIO, /* usb detect */
  60. GPIO53_GPIO, /* usb power */
  61. /* IrDA */
  62. GPIO48_GPIO, /* ir disable */
  63. GPIO46_FICP_RXD,
  64. GPIO47_FICP_TXD,
  65. /* LCD */
  66. GPIOxx_LCD_TFT_16BPP,
  67. /* GPIO KEYS */
  68. GPIO5_GPIO, /* notes */
  69. GPIO7_GPIO, /* tasks */
  70. GPIO11_GPIO, /* calendar */
  71. GPIO13_GPIO, /* contacts */
  72. GPIO14_GPIO, /* center */
  73. GPIO19_GPIO, /* left */
  74. GPIO20_GPIO, /* right */
  75. GPIO21_GPIO, /* down */
  76. GPIO22_GPIO, /* up */
  77. /* MISC */
  78. GPIO1_RST, /* reset */
  79. GPIO4_GPIO, /* Hotsync button */
  80. GPIO9_GPIO, /* power detect */
  81. GPIO15_GPIO, /* earphone detect */
  82. GPIO37_GPIO, /* LCD power */
  83. GPIO56_GPIO, /* Backlight power */
  84. };
  85. /******************************************************************************
  86. * SD/MMC card controller
  87. ******************************************************************************/
  88. static struct pxamci_platform_data palmte2_mci_platform_data = {
  89. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  90. .gpio_card_detect = GPIO_NR_PALMTE2_SD_DETECT_N,
  91. .gpio_card_ro = GPIO_NR_PALMTE2_SD_READONLY,
  92. .gpio_power = GPIO_NR_PALMTE2_SD_POWER,
  93. };
  94. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  95. /******************************************************************************
  96. * GPIO keys
  97. ******************************************************************************/
  98. static struct gpio_keys_button palmte2_pxa_buttons[] = {
  99. {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
  100. {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
  101. {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
  102. {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
  103. {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
  104. {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
  105. {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
  106. {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
  107. {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
  108. };
  109. static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
  110. .buttons = palmte2_pxa_buttons,
  111. .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
  112. };
  113. static struct platform_device palmte2_pxa_keys = {
  114. .name = "gpio-keys",
  115. .id = -1,
  116. .dev = {
  117. .platform_data = &palmte2_pxa_keys_data,
  118. },
  119. };
  120. #endif
  121. /******************************************************************************
  122. * Backlight
  123. ******************************************************************************/
  124. static struct gpio palmte_bl_gpios[] = {
  125. { GPIO_NR_PALMTE2_BL_POWER, GPIOF_INIT_LOW, "Backlight power" },
  126. { GPIO_NR_PALMTE2_LCD_POWER, GPIOF_INIT_LOW, "LCD power" },
  127. };
  128. static int palmte2_backlight_init(struct device *dev)
  129. {
  130. return gpio_request_array(ARRAY_AND_SIZE(palmte_bl_gpios));
  131. }
  132. static int palmte2_backlight_notify(struct device *dev, int brightness)
  133. {
  134. gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
  135. gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
  136. return brightness;
  137. }
  138. static void palmte2_backlight_exit(struct device *dev)
  139. {
  140. gpio_free_array(ARRAY_AND_SIZE(palmte_bl_gpios));
  141. }
  142. static struct platform_pwm_backlight_data palmte2_backlight_data = {
  143. .pwm_id = 0,
  144. .max_brightness = PALMTE2_MAX_INTENSITY,
  145. .dft_brightness = PALMTE2_MAX_INTENSITY,
  146. .pwm_period_ns = PALMTE2_PERIOD_NS,
  147. .init = palmte2_backlight_init,
  148. .notify = palmte2_backlight_notify,
  149. .exit = palmte2_backlight_exit,
  150. };
  151. static struct platform_device palmte2_backlight = {
  152. .name = "pwm-backlight",
  153. .dev = {
  154. .parent = &pxa25x_device_pwm0.dev,
  155. .platform_data = &palmte2_backlight_data,
  156. },
  157. };
  158. /******************************************************************************
  159. * IrDA
  160. ******************************************************************************/
  161. static struct pxaficp_platform_data palmte2_ficp_platform_data = {
  162. .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
  163. .transceiver_cap = IR_SIRMODE | IR_OFF,
  164. };
  165. /******************************************************************************
  166. * UDC
  167. ******************************************************************************/
  168. static struct gpio_vbus_mach_info palmte2_udc_info = {
  169. .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
  170. .gpio_vbus_inverted = 1,
  171. .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
  172. };
  173. static struct platform_device palmte2_gpio_vbus = {
  174. .name = "gpio-vbus",
  175. .id = -1,
  176. .dev = {
  177. .platform_data = &palmte2_udc_info,
  178. },
  179. };
  180. /******************************************************************************
  181. * Power supply
  182. ******************************************************************************/
  183. static int power_supply_init(struct device *dev)
  184. {
  185. int ret;
  186. ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
  187. if (ret)
  188. goto err1;
  189. ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
  190. if (ret)
  191. goto err2;
  192. return 0;
  193. err2:
  194. gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
  195. err1:
  196. return ret;
  197. }
  198. static int palmte2_is_ac_online(void)
  199. {
  200. return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
  201. }
  202. static void power_supply_exit(struct device *dev)
  203. {
  204. gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
  205. }
  206. static char *palmte2_supplicants[] = {
  207. "main-battery",
  208. };
  209. static struct pda_power_pdata power_supply_info = {
  210. .init = power_supply_init,
  211. .is_ac_online = palmte2_is_ac_online,
  212. .exit = power_supply_exit,
  213. .supplied_to = palmte2_supplicants,
  214. .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
  215. };
  216. static struct platform_device power_supply = {
  217. .name = "pda-power",
  218. .id = -1,
  219. .dev = {
  220. .platform_data = &power_supply_info,
  221. },
  222. };
  223. /******************************************************************************
  224. * WM97xx audio, battery
  225. ******************************************************************************/
  226. static struct wm97xx_batt_pdata palmte2_batt_pdata = {
  227. .batt_aux = WM97XX_AUX_ID3,
  228. .temp_aux = WM97XX_AUX_ID2,
  229. .charge_gpio = -1,
  230. .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
  231. .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
  232. .batt_mult = 1000,
  233. .batt_div = 414,
  234. .temp_mult = 1,
  235. .temp_div = 1,
  236. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  237. .batt_name = "main-batt",
  238. };
  239. static struct wm97xx_pdata palmte2_wm97xx_pdata = {
  240. .batt_pdata = &palmte2_batt_pdata,
  241. };
  242. static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
  243. .codec_pdata = { &palmte2_wm97xx_pdata, },
  244. };
  245. static struct palm27x_asoc_info palmte2_asoc_pdata = {
  246. .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
  247. };
  248. static struct platform_device palmte2_asoc = {
  249. .name = "palm27x-asoc",
  250. .id = -1,
  251. .dev = {
  252. .platform_data = &palmte2_asoc_pdata,
  253. },
  254. };
  255. /******************************************************************************
  256. * Framebuffer
  257. ******************************************************************************/
  258. static struct pxafb_mode_info palmte2_lcd_modes[] = {
  259. {
  260. .pixclock = 77757,
  261. .xres = 320,
  262. .yres = 320,
  263. .bpp = 16,
  264. .left_margin = 28,
  265. .right_margin = 7,
  266. .upper_margin = 7,
  267. .lower_margin = 5,
  268. .hsync_len = 4,
  269. .vsync_len = 1,
  270. },
  271. };
  272. static struct pxafb_mach_info palmte2_lcd_screen = {
  273. .modes = palmte2_lcd_modes,
  274. .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
  275. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  276. };
  277. /******************************************************************************
  278. * Machine init
  279. ******************************************************************************/
  280. static struct platform_device *devices[] __initdata = {
  281. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  282. &palmte2_pxa_keys,
  283. #endif
  284. &palmte2_backlight,
  285. &power_supply,
  286. &palmte2_asoc,
  287. &palmte2_gpio_vbus,
  288. };
  289. /* setup udc GPIOs initial state */
  290. static void __init palmte2_udc_init(void)
  291. {
  292. if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
  293. gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
  294. gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
  295. }
  296. }
  297. static void __init palmte2_init(void)
  298. {
  299. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
  300. pxa_set_ffuart_info(NULL);
  301. pxa_set_btuart_info(NULL);
  302. pxa_set_stuart_info(NULL);
  303. pxa_set_fb_info(NULL, &palmte2_lcd_screen);
  304. pxa_set_mci_info(&palmte2_mci_platform_data);
  305. palmte2_udc_init();
  306. pxa_set_ac97_info(&palmte2_ac97_pdata);
  307. pxa_set_ficp_info(&palmte2_ficp_platform_data);
  308. platform_add_devices(devices, ARRAY_SIZE(devices));
  309. }
  310. MACHINE_START(PALMTE2, "Palm Tungsten|E2")
  311. .atag_offset = 0x100,
  312. .map_io = pxa25x_map_io,
  313. .nr_irqs = PXA_NR_IRQS,
  314. .init_irq = pxa25x_init_irq,
  315. .handle_irq = pxa25x_handle_irq,
  316. .init_time = pxa_timer_init,
  317. .init_machine = palmte2_init,
  318. .restart = pxa_restart,
  319. MACHINE_END