palmte2.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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. GPIO58_LCD_LDD_0,
  67. GPIO59_LCD_LDD_1,
  68. GPIO60_LCD_LDD_2,
  69. GPIO61_LCD_LDD_3,
  70. GPIO62_LCD_LDD_4,
  71. GPIO63_LCD_LDD_5,
  72. GPIO64_LCD_LDD_6,
  73. GPIO65_LCD_LDD_7,
  74. GPIO66_LCD_LDD_8,
  75. GPIO67_LCD_LDD_9,
  76. GPIO68_LCD_LDD_10,
  77. GPIO69_LCD_LDD_11,
  78. GPIO70_LCD_LDD_12,
  79. GPIO71_LCD_LDD_13,
  80. GPIO72_LCD_LDD_14,
  81. GPIO73_LCD_LDD_15,
  82. GPIO74_LCD_FCLK,
  83. GPIO75_LCD_LCLK,
  84. GPIO76_LCD_PCLK,
  85. GPIO77_LCD_BIAS,
  86. /* GPIO KEYS */
  87. GPIO5_GPIO, /* notes */
  88. GPIO7_GPIO, /* tasks */
  89. GPIO11_GPIO, /* calendar */
  90. GPIO13_GPIO, /* contacts */
  91. GPIO14_GPIO, /* center */
  92. GPIO19_GPIO, /* left */
  93. GPIO20_GPIO, /* right */
  94. GPIO21_GPIO, /* down */
  95. GPIO22_GPIO, /* up */
  96. /* MISC */
  97. GPIO1_RST, /* reset */
  98. GPIO4_GPIO, /* Hotsync button */
  99. GPIO9_GPIO, /* power detect */
  100. GPIO15_GPIO, /* earphone detect */
  101. GPIO37_GPIO, /* LCD power */
  102. GPIO56_GPIO, /* Backlight power */
  103. };
  104. /******************************************************************************
  105. * SD/MMC card controller
  106. ******************************************************************************/
  107. static struct pxamci_platform_data palmte2_mci_platform_data = {
  108. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  109. .gpio_card_detect = GPIO_NR_PALMTE2_SD_DETECT_N,
  110. .gpio_card_ro = GPIO_NR_PALMTE2_SD_READONLY,
  111. .gpio_power = GPIO_NR_PALMTE2_SD_POWER,
  112. };
  113. /******************************************************************************
  114. * GPIO keys
  115. ******************************************************************************/
  116. static struct gpio_keys_button palmte2_pxa_buttons[] = {
  117. {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
  118. {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
  119. {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
  120. {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
  121. {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
  122. {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
  123. {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
  124. {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
  125. {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
  126. };
  127. static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
  128. .buttons = palmte2_pxa_buttons,
  129. .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
  130. };
  131. static struct platform_device palmte2_pxa_keys = {
  132. .name = "gpio-keys",
  133. .id = -1,
  134. .dev = {
  135. .platform_data = &palmte2_pxa_keys_data,
  136. },
  137. };
  138. /******************************************************************************
  139. * Backlight
  140. ******************************************************************************/
  141. static int palmte2_backlight_init(struct device *dev)
  142. {
  143. int ret;
  144. ret = gpio_request(GPIO_NR_PALMTE2_BL_POWER, "BL POWER");
  145. if (ret)
  146. goto err;
  147. ret = gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER, 0);
  148. if (ret)
  149. goto err2;
  150. ret = gpio_request(GPIO_NR_PALMTE2_LCD_POWER, "LCD POWER");
  151. if (ret)
  152. goto err2;
  153. ret = gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER, 0);
  154. if (ret)
  155. goto err3;
  156. return 0;
  157. err3:
  158. gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
  159. err2:
  160. gpio_free(GPIO_NR_PALMTE2_BL_POWER);
  161. err:
  162. return ret;
  163. }
  164. static int palmte2_backlight_notify(int brightness)
  165. {
  166. gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
  167. gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
  168. return brightness;
  169. }
  170. static void palmte2_backlight_exit(struct device *dev)
  171. {
  172. gpio_free(GPIO_NR_PALMTE2_BL_POWER);
  173. gpio_free(GPIO_NR_PALMTE2_LCD_POWER);
  174. }
  175. static struct platform_pwm_backlight_data palmte2_backlight_data = {
  176. .pwm_id = 0,
  177. .max_brightness = PALMTE2_MAX_INTENSITY,
  178. .dft_brightness = PALMTE2_MAX_INTENSITY,
  179. .pwm_period_ns = PALMTE2_PERIOD_NS,
  180. .init = palmte2_backlight_init,
  181. .notify = palmte2_backlight_notify,
  182. .exit = palmte2_backlight_exit,
  183. };
  184. static struct platform_device palmte2_backlight = {
  185. .name = "pwm-backlight",
  186. .dev = {
  187. .parent = &pxa25x_device_pwm0.dev,
  188. .platform_data = &palmte2_backlight_data,
  189. },
  190. };
  191. /******************************************************************************
  192. * IrDA
  193. ******************************************************************************/
  194. static struct pxaficp_platform_data palmte2_ficp_platform_data = {
  195. .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
  196. .transceiver_cap = IR_SIRMODE | IR_OFF,
  197. };
  198. /******************************************************************************
  199. * UDC
  200. ******************************************************************************/
  201. static struct gpio_vbus_mach_info palmte2_udc_info = {
  202. .gpio_vbus = GPIO_NR_PALMTE2_USB_DETECT_N,
  203. .gpio_vbus_inverted = 1,
  204. .gpio_pullup = GPIO_NR_PALMTE2_USB_PULLUP,
  205. };
  206. static struct platform_device palmte2_gpio_vbus = {
  207. .name = "gpio-vbus",
  208. .id = -1,
  209. .dev = {
  210. .platform_data = &palmte2_udc_info,
  211. },
  212. };
  213. /******************************************************************************
  214. * Power supply
  215. ******************************************************************************/
  216. static int power_supply_init(struct device *dev)
  217. {
  218. int ret;
  219. ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
  220. if (ret)
  221. goto err1;
  222. ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
  223. if (ret)
  224. goto err2;
  225. return 0;
  226. err2:
  227. gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
  228. err1:
  229. return ret;
  230. }
  231. static int palmte2_is_ac_online(void)
  232. {
  233. return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
  234. }
  235. static void power_supply_exit(struct device *dev)
  236. {
  237. gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
  238. }
  239. static char *palmte2_supplicants[] = {
  240. "main-battery",
  241. };
  242. static struct pda_power_pdata power_supply_info = {
  243. .init = power_supply_init,
  244. .is_ac_online = palmte2_is_ac_online,
  245. .exit = power_supply_exit,
  246. .supplied_to = palmte2_supplicants,
  247. .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
  248. };
  249. static struct platform_device power_supply = {
  250. .name = "pda-power",
  251. .id = -1,
  252. .dev = {
  253. .platform_data = &power_supply_info,
  254. },
  255. };
  256. /******************************************************************************
  257. * WM97xx battery
  258. ******************************************************************************/
  259. static struct wm97xx_batt_info wm97xx_batt_pdata = {
  260. .batt_aux = WM97XX_AUX_ID3,
  261. .temp_aux = WM97XX_AUX_ID2,
  262. .charge_gpio = -1,
  263. .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
  264. .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
  265. .batt_mult = 1000,
  266. .batt_div = 414,
  267. .temp_mult = 1,
  268. .temp_div = 1,
  269. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  270. .batt_name = "main-batt",
  271. };
  272. /******************************************************************************
  273. * aSoC audio
  274. ******************************************************************************/
  275. static struct palm27x_asoc_info palmte2_asoc_pdata = {
  276. .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
  277. };
  278. static struct platform_device palmte2_asoc = {
  279. .name = "palm27x-asoc",
  280. .id = -1,
  281. .dev = {
  282. .platform_data = &palmte2_asoc_pdata,
  283. },
  284. };
  285. /******************************************************************************
  286. * Framebuffer
  287. ******************************************************************************/
  288. static struct pxafb_mode_info palmte2_lcd_modes[] = {
  289. {
  290. .pixclock = 77757,
  291. .xres = 320,
  292. .yres = 320,
  293. .bpp = 16,
  294. .left_margin = 28,
  295. .right_margin = 7,
  296. .upper_margin = 7,
  297. .lower_margin = 5,
  298. .hsync_len = 4,
  299. .vsync_len = 1,
  300. },
  301. };
  302. static struct pxafb_mach_info palmte2_lcd_screen = {
  303. .modes = palmte2_lcd_modes,
  304. .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
  305. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  306. };
  307. /******************************************************************************
  308. * Machine init
  309. ******************************************************************************/
  310. static struct platform_device *devices[] __initdata = {
  311. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  312. &palmte2_pxa_keys,
  313. #endif
  314. &palmte2_backlight,
  315. &power_supply,
  316. &palmte2_asoc,
  317. &palmte2_gpio_vbus,
  318. };
  319. /* setup udc GPIOs initial state */
  320. static void __init palmte2_udc_init(void)
  321. {
  322. if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
  323. gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
  324. gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
  325. }
  326. }
  327. static void __init palmte2_init(void)
  328. {
  329. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
  330. set_pxa_fb_info(&palmte2_lcd_screen);
  331. pxa_set_mci_info(&palmte2_mci_platform_data);
  332. palmte2_udc_init();
  333. pxa_set_ac97_info(NULL);
  334. pxa_set_ficp_info(&palmte2_ficp_platform_data);
  335. wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
  336. platform_add_devices(devices, ARRAY_SIZE(devices));
  337. }
  338. MACHINE_START(PALMTE2, "Palm Tungsten|E2")
  339. .phys_io = 0x40000000,
  340. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  341. .boot_params = 0xa0000100,
  342. .map_io = pxa_map_io,
  343. .init_irq = pxa25x_init_irq,
  344. .timer = &pxa_timer,
  345. .init_machine = palmte2_init
  346. MACHINE_END