palmte2.c 10 KB

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