palmte2.c 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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. .enable_gpio = -1,
  148. .init = palmte2_backlight_init,
  149. .notify = palmte2_backlight_notify,
  150. .exit = palmte2_backlight_exit,
  151. };
  152. static struct platform_device palmte2_backlight = {
  153. .name = "pwm-backlight",
  154. .dev = {
  155. .parent = &pxa25x_device_pwm0.dev,
  156. .platform_data = &palmte2_backlight_data,
  157. },
  158. };
  159. /******************************************************************************
  160. * IrDA
  161. ******************************************************************************/
  162. static struct pxaficp_platform_data palmte2_ficp_platform_data = {
  163. .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
  164. .transceiver_cap = IR_SIRMODE | IR_OFF,
  165. };
  166. /******************************************************************************
  167. * UDC
  168. ******************************************************************************/
  169. static struct gpio_vbus_mach_info palmte2_udc_info = {
  170. .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
  171. .gpio_vbus_inverted = 1,
  172. .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
  173. };
  174. static struct platform_device palmte2_gpio_vbus = {
  175. .name = "gpio-vbus",
  176. .id = -1,
  177. .dev = {
  178. .platform_data = &palmte2_udc_info,
  179. },
  180. };
  181. /******************************************************************************
  182. * Power supply
  183. ******************************************************************************/
  184. static int power_supply_init(struct device *dev)
  185. {
  186. int ret;
  187. ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
  188. if (ret)
  189. goto err1;
  190. ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
  191. if (ret)
  192. goto err2;
  193. return 0;
  194. err2:
  195. gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
  196. err1:
  197. return ret;
  198. }
  199. static int palmte2_is_ac_online(void)
  200. {
  201. return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
  202. }
  203. static void power_supply_exit(struct device *dev)
  204. {
  205. gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
  206. }
  207. static char *palmte2_supplicants[] = {
  208. "main-battery",
  209. };
  210. static struct pda_power_pdata power_supply_info = {
  211. .init = power_supply_init,
  212. .is_ac_online = palmte2_is_ac_online,
  213. .exit = power_supply_exit,
  214. .supplied_to = palmte2_supplicants,
  215. .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
  216. };
  217. static struct platform_device power_supply = {
  218. .name = "pda-power",
  219. .id = -1,
  220. .dev = {
  221. .platform_data = &power_supply_info,
  222. },
  223. };
  224. /******************************************************************************
  225. * WM97xx audio, battery
  226. ******************************************************************************/
  227. static struct wm97xx_batt_pdata palmte2_batt_pdata = {
  228. .batt_aux = WM97XX_AUX_ID3,
  229. .temp_aux = WM97XX_AUX_ID2,
  230. .charge_gpio = -1,
  231. .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
  232. .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
  233. .batt_mult = 1000,
  234. .batt_div = 414,
  235. .temp_mult = 1,
  236. .temp_div = 1,
  237. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  238. .batt_name = "main-batt",
  239. };
  240. static struct wm97xx_pdata palmte2_wm97xx_pdata = {
  241. .batt_pdata = &palmte2_batt_pdata,
  242. };
  243. static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
  244. .codec_pdata = { &palmte2_wm97xx_pdata, },
  245. };
  246. static struct palm27x_asoc_info palmte2_asoc_pdata = {
  247. .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
  248. };
  249. static struct platform_device palmte2_asoc = {
  250. .name = "palm27x-asoc",
  251. .id = -1,
  252. .dev = {
  253. .platform_data = &palmte2_asoc_pdata,
  254. },
  255. };
  256. /******************************************************************************
  257. * Framebuffer
  258. ******************************************************************************/
  259. static struct pxafb_mode_info palmte2_lcd_modes[] = {
  260. {
  261. .pixclock = 77757,
  262. .xres = 320,
  263. .yres = 320,
  264. .bpp = 16,
  265. .left_margin = 28,
  266. .right_margin = 7,
  267. .upper_margin = 7,
  268. .lower_margin = 5,
  269. .hsync_len = 4,
  270. .vsync_len = 1,
  271. },
  272. };
  273. static struct pxafb_mach_info palmte2_lcd_screen = {
  274. .modes = palmte2_lcd_modes,
  275. .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
  276. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  277. };
  278. /******************************************************************************
  279. * Machine init
  280. ******************************************************************************/
  281. static struct platform_device *devices[] __initdata = {
  282. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  283. &palmte2_pxa_keys,
  284. #endif
  285. &palmte2_backlight,
  286. &power_supply,
  287. &palmte2_asoc,
  288. &palmte2_gpio_vbus,
  289. };
  290. /* setup udc GPIOs initial state */
  291. static void __init palmte2_udc_init(void)
  292. {
  293. if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
  294. gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
  295. gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
  296. }
  297. }
  298. static void __init palmte2_init(void)
  299. {
  300. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
  301. pxa_set_ffuart_info(NULL);
  302. pxa_set_btuart_info(NULL);
  303. pxa_set_stuart_info(NULL);
  304. pxa_set_fb_info(NULL, &palmte2_lcd_screen);
  305. pxa_set_mci_info(&palmte2_mci_platform_data);
  306. palmte2_udc_init();
  307. pxa_set_ac97_info(&palmte2_ac97_pdata);
  308. pxa_set_ficp_info(&palmte2_ficp_platform_data);
  309. platform_add_devices(devices, ARRAY_SIZE(devices));
  310. }
  311. MACHINE_START(PALMTE2, "Palm Tungsten|E2")
  312. .atag_offset = 0x100,
  313. .map_io = pxa25x_map_io,
  314. .nr_irqs = PXA_NR_IRQS,
  315. .init_irq = pxa25x_init_irq,
  316. .handle_irq = pxa25x_handle_irq,
  317. .init_time = pxa_timer_init,
  318. .init_machine = palmte2_init,
  319. .restart = pxa_restart,
  320. MACHINE_END