palmte2.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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 <mach/mmc.h>
  35. #include <mach/pxafb.h>
  36. #include <mach/irda.h>
  37. #include <mach/udc.h>
  38. #include <mach/palmasoc.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. /******************************************************************************
  95. * GPIO keys
  96. ******************************************************************************/
  97. static struct gpio_keys_button palmte2_pxa_buttons[] = {
  98. {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
  99. {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
  100. {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
  101. {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
  102. {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
  103. {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
  104. {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
  105. {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
  106. {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
  107. };
  108. static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
  109. .buttons = palmte2_pxa_buttons,
  110. .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
  111. };
  112. static struct platform_device palmte2_pxa_keys = {
  113. .name = "gpio-keys",
  114. .id = -1,
  115. .dev = {
  116. .platform_data = &palmte2_pxa_keys_data,
  117. },
  118. };
  119. /******************************************************************************
  120. * Backlight
  121. ******************************************************************************/
  122. static struct gpio palmte_bl_gpios[] = {
  123. { GPIO_NR_PALMTE2_BL_POWER, GPIOF_INIT_LOW, "Backlight power" },
  124. { GPIO_NR_PALMTE2_LCD_POWER, GPIOF_INIT_LOW, "LCD power" },
  125. };
  126. static int palmte2_backlight_init(struct device *dev)
  127. {
  128. return gpio_request_array(ARRAY_AND_SIZE(palmte_bl_gpios));
  129. }
  130. static int palmte2_backlight_notify(struct device *dev, int brightness)
  131. {
  132. gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
  133. gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
  134. return brightness;
  135. }
  136. static void palmte2_backlight_exit(struct device *dev)
  137. {
  138. gpio_free_array(ARRAY_AND_SIZE(palmte_bl_gpios));
  139. }
  140. static struct platform_pwm_backlight_data palmte2_backlight_data = {
  141. .pwm_id = 0,
  142. .max_brightness = PALMTE2_MAX_INTENSITY,
  143. .dft_brightness = PALMTE2_MAX_INTENSITY,
  144. .pwm_period_ns = PALMTE2_PERIOD_NS,
  145. .init = palmte2_backlight_init,
  146. .notify = palmte2_backlight_notify,
  147. .exit = palmte2_backlight_exit,
  148. };
  149. static struct platform_device palmte2_backlight = {
  150. .name = "pwm-backlight",
  151. .dev = {
  152. .parent = &pxa25x_device_pwm0.dev,
  153. .platform_data = &palmte2_backlight_data,
  154. },
  155. };
  156. /******************************************************************************
  157. * IrDA
  158. ******************************************************************************/
  159. static struct pxaficp_platform_data palmte2_ficp_platform_data = {
  160. .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
  161. .transceiver_cap = IR_SIRMODE | IR_OFF,
  162. };
  163. /******************************************************************************
  164. * UDC
  165. ******************************************************************************/
  166. static struct gpio_vbus_mach_info palmte2_udc_info = {
  167. .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
  168. .gpio_vbus_inverted = 1,
  169. .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
  170. };
  171. static struct platform_device palmte2_gpio_vbus = {
  172. .name = "gpio-vbus",
  173. .id = -1,
  174. .dev = {
  175. .platform_data = &palmte2_udc_info,
  176. },
  177. };
  178. /******************************************************************************
  179. * Power supply
  180. ******************************************************************************/
  181. static int power_supply_init(struct device *dev)
  182. {
  183. int ret;
  184. ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
  185. if (ret)
  186. goto err1;
  187. ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
  188. if (ret)
  189. goto err2;
  190. return 0;
  191. err2:
  192. gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
  193. err1:
  194. return ret;
  195. }
  196. static int palmte2_is_ac_online(void)
  197. {
  198. return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
  199. }
  200. static void power_supply_exit(struct device *dev)
  201. {
  202. gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
  203. }
  204. static char *palmte2_supplicants[] = {
  205. "main-battery",
  206. };
  207. static struct pda_power_pdata power_supply_info = {
  208. .init = power_supply_init,
  209. .is_ac_online = palmte2_is_ac_online,
  210. .exit = power_supply_exit,
  211. .supplied_to = palmte2_supplicants,
  212. .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
  213. };
  214. static struct platform_device power_supply = {
  215. .name = "pda-power",
  216. .id = -1,
  217. .dev = {
  218. .platform_data = &power_supply_info,
  219. },
  220. };
  221. /******************************************************************************
  222. * WM97xx audio, battery
  223. ******************************************************************************/
  224. static struct wm97xx_batt_pdata palmte2_batt_pdata = {
  225. .batt_aux = WM97XX_AUX_ID3,
  226. .temp_aux = WM97XX_AUX_ID2,
  227. .charge_gpio = -1,
  228. .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
  229. .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
  230. .batt_mult = 1000,
  231. .batt_div = 414,
  232. .temp_mult = 1,
  233. .temp_div = 1,
  234. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  235. .batt_name = "main-batt",
  236. };
  237. static struct wm97xx_pdata palmte2_wm97xx_pdata = {
  238. .batt_pdata = &palmte2_batt_pdata,
  239. };
  240. static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
  241. .codec_pdata = { &palmte2_wm97xx_pdata, },
  242. };
  243. static struct palm27x_asoc_info palmte2_asoc_pdata = {
  244. .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
  245. };
  246. static struct platform_device palmte2_asoc = {
  247. .name = "palm27x-asoc",
  248. .id = -1,
  249. .dev = {
  250. .platform_data = &palmte2_asoc_pdata,
  251. },
  252. };
  253. /******************************************************************************
  254. * Framebuffer
  255. ******************************************************************************/
  256. static struct pxafb_mode_info palmte2_lcd_modes[] = {
  257. {
  258. .pixclock = 77757,
  259. .xres = 320,
  260. .yres = 320,
  261. .bpp = 16,
  262. .left_margin = 28,
  263. .right_margin = 7,
  264. .upper_margin = 7,
  265. .lower_margin = 5,
  266. .hsync_len = 4,
  267. .vsync_len = 1,
  268. },
  269. };
  270. static struct pxafb_mach_info palmte2_lcd_screen = {
  271. .modes = palmte2_lcd_modes,
  272. .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
  273. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  274. };
  275. /******************************************************************************
  276. * Machine init
  277. ******************************************************************************/
  278. static struct platform_device *devices[] __initdata = {
  279. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  280. &palmte2_pxa_keys,
  281. #endif
  282. &palmte2_backlight,
  283. &power_supply,
  284. &palmte2_asoc,
  285. &palmte2_gpio_vbus,
  286. };
  287. /* setup udc GPIOs initial state */
  288. static void __init palmte2_udc_init(void)
  289. {
  290. if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
  291. gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
  292. gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
  293. }
  294. }
  295. static void __init palmte2_init(void)
  296. {
  297. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
  298. pxa_set_ffuart_info(NULL);
  299. pxa_set_btuart_info(NULL);
  300. pxa_set_stuart_info(NULL);
  301. pxa_set_fb_info(NULL, &palmte2_lcd_screen);
  302. pxa_set_mci_info(&palmte2_mci_platform_data);
  303. palmte2_udc_init();
  304. pxa_set_ac97_info(&palmte2_ac97_pdata);
  305. pxa_set_ficp_info(&palmte2_ficp_platform_data);
  306. platform_add_devices(devices, ARRAY_SIZE(devices));
  307. }
  308. MACHINE_START(PALMTE2, "Palm Tungsten|E2")
  309. .atag_offset = 0x100,
  310. .map_io = pxa25x_map_io,
  311. .nr_irqs = PXA_NR_IRQS,
  312. .init_irq = pxa25x_init_irq,
  313. .handle_irq = pxa25x_handle_irq,
  314. .timer = &pxa_timer,
  315. .init_machine = palmte2_init,
  316. .restart = pxa_restart,
  317. MACHINE_END