palmte2.c 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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_batt.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/audio.h>
  32. #include <mach/palmte2.h>
  33. #include <mach/mmc.h>
  34. #include <mach/pxafb.h>
  35. #include <mach/mfp-pxa25x.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 int palmte2_backlight_init(struct device *dev)
  123. {
  124. int ret;
  125. ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER");
  126. if (ret)
  127. goto err;
  128. ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0);
  129. if (ret)
  130. goto err2;
  131. ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER");
  132. if (ret)
  133. goto err2;
  134. ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0);
  135. if (ret)
  136. goto err3;
  137. return 0;
  138. err3:
  139. gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
  140. err2:
  141. gpio_free(GPIO_NR_PALMTE2_BL_POWER);
  142. err:
  143. return ret;
  144. }
  145. static int palmte2_backlight_notify(struct device *dev, int brightness)
  146. {
  147. gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
  148. gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
  149. return brightness;
  150. }
  151. static void palmte2_backlight_exit(struct device *dev)
  152. {
  153. gpio_free(GPIO_NR_PALMTE2_BL_POWER);
  154. gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
  155. }
  156. static struct platform_pwm_backlight_data palmte2_backlight_data = {
  157. .pwm_id = 0,
  158. .max_brightness = PALMTE2_MAX_INTENSITY,
  159. .dft_brightness = PALMTE2_MAX_INTENSITY,
  160. .pwm_period_ns = PALMTE2_PERIOD_NS,
  161. .init = palmte2_backlight_init,
  162. .notify = palmte2_backlight_notify,
  163. .exit = palmte2_backlight_exit,
  164. };
  165. static struct platform_device palmte2_backlight = {
  166. .name = "pwm-backlight",
  167. .dev = {
  168. .parent = &pxa25x_device_pwm0.dev,
  169. .platform_data = &palmte2_backlight_data,
  170. },
  171. };
  172. /******************************************************************************
  173. * IrDA
  174. ******************************************************************************/
  175. static struct pxaficp_platform_data palmte2_ficp_platform_data = {
  176. .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
  177. .transceiver_cap = IR_SIRMODE | IR_OFF,
  178. };
  179. /******************************************************************************
  180. * UDC
  181. ******************************************************************************/
  182. static struct gpio_vbus_mach_info palmte2_udc_info = {
  183. .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
  184. .gpio_vbus_inverted = 1,
  185. .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
  186. };
  187. static struct platform_device palmte2_gpio_vbus = {
  188. .name = "gpio-vbus",
  189. .id = -1,
  190. .dev = {
  191. .platform_data = &palmte2_udc_info,
  192. },
  193. };
  194. /******************************************************************************
  195. * Power supply
  196. ******************************************************************************/
  197. static int power_supply_init(struct device *dev)
  198. {
  199. int ret;
  200. ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
  201. if (ret)
  202. goto err1;
  203. ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
  204. if (ret)
  205. goto err2;
  206. return 0;
  207. err2:
  208. gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
  209. err1:
  210. return ret;
  211. }
  212. static int palmte2_is_ac_online(void)
  213. {
  214. return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
  215. }
  216. static void power_supply_exit(struct device *dev)
  217. {
  218. gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
  219. }
  220. static char *palmte2_supplicants[] = {
  221. "main-battery",
  222. };
  223. static struct pda_power_pdata power_supply_info = {
  224. .init = power_supply_init,
  225. .is_ac_online = palmte2_is_ac_online,
  226. .exit = power_supply_exit,
  227. .supplied_to = palmte2_supplicants,
  228. .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
  229. };
  230. static struct platform_device power_supply = {
  231. .name = "pda-power",
  232. .id = -1,
  233. .dev = {
  234. .platform_data = &power_supply_info,
  235. },
  236. };
  237. /******************************************************************************
  238. * WM97xx battery
  239. ******************************************************************************/
  240. static struct wm97xx_batt_info wm97xx_batt_pdata = {
  241. .batt_aux = WM97XX_AUX_ID3,
  242. .temp_aux = WM97XX_AUX_ID2,
  243. .charge_gpio = -1,
  244. .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
  245. .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
  246. .batt_mult = 1000,
  247. .batt_div = 414,
  248. .temp_mult = 1,
  249. .temp_div = 1,
  250. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  251. .batt_name = "main-batt",
  252. };
  253. /******************************************************************************
  254. * aSoC audio
  255. ******************************************************************************/
  256. static struct palm27x_asoc_info palmte2_asoc_pdata = {
  257. .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
  258. };
  259. static struct platform_device palmte2_asoc = {
  260. .name = "palm27x-asoc",
  261. .id = -1,
  262. .dev = {
  263. .platform_data = &palmte2_asoc_pdata,
  264. },
  265. };
  266. /******************************************************************************
  267. * Framebuffer
  268. ******************************************************************************/
  269. static struct pxafb_mode_info palmte2_lcd_modes[] = {
  270. {
  271. .pixclock = 77757,
  272. .xres = 320,
  273. .yres = 320,
  274. .bpp = 16,
  275. .left_margin = 28,
  276. .right_margin = 7,
  277. .upper_margin = 7,
  278. .lower_margin = 5,
  279. .hsync_len = 4,
  280. .vsync_len = 1,
  281. },
  282. };
  283. static struct pxafb_mach_info palmte2_lcd_screen = {
  284. .modes = palmte2_lcd_modes,
  285. .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
  286. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  287. };
  288. /******************************************************************************
  289. * Machine init
  290. ******************************************************************************/
  291. static struct platform_device *devices[] __initdata = {
  292. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  293. &palmte2_pxa_keys,
  294. #endif
  295. &palmte2_backlight,
  296. &power_supply,
  297. &palmte2_asoc,
  298. &palmte2_gpio_vbus,
  299. };
  300. /* setup udc GPIOs initial state */
  301. static void __init palmte2_udc_init(void)
  302. {
  303. if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
  304. gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
  305. gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
  306. }
  307. }
  308. static void __init palmte2_init(void)
  309. {
  310. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
  311. pxa_set_ffuart_info(NULL);
  312. pxa_set_btuart_info(NULL);
  313. pxa_set_stuart_info(NULL);
  314. set_pxa_fb_info(&palmte2_lcd_screen);
  315. pxa_set_mci_info(&palmte2_mci_platform_data);
  316. palmte2_udc_init();
  317. pxa_set_ac97_info(NULL);
  318. pxa_set_ficp_info(&palmte2_ficp_platform_data);
  319. wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
  320. platform_add_devices(devices, ARRAY_SIZE(devices));
  321. }
  322. MACHINE_START(PALMTE2, "Palm Tungsten|E2")
  323. .phys_io = 0x40000000,
  324. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  325. .boot_params = 0xa0000100,
  326. .map_io = pxa_map_io,
  327. .init_irq = pxa25x_init_irq,
  328. .timer = &pxa_timer,
  329. .init_machine = palmte2_init
  330. MACHINE_END