palmld.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. /*
  2. * Hardware definitions for Palm LifeDrive
  3. *
  4. * Author: Marek Vasut <marek.vasut@gmail.com>
  5. *
  6. * Based on work of:
  7. * Alex Osborne <ato@meshy.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * (find more info at www.hackndev.com)
  14. *
  15. */
  16. #include <linux/platform_device.h>
  17. #include <linux/delay.h>
  18. #include <linux/irq.h>
  19. #include <linux/gpio_keys.h>
  20. #include <linux/input.h>
  21. #include <linux/pda_power.h>
  22. #include <linux/pwm_backlight.h>
  23. #include <linux/gpio.h>
  24. #include <linux/wm97xx_batt.h>
  25. #include <linux/power_supply.h>
  26. #include <linux/sysdev.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <mach/pxa27x.h>
  31. #include <mach/audio.h>
  32. #include <mach/palmld.h>
  33. #include <mach/mmc.h>
  34. #include <mach/pxafb.h>
  35. #include <mach/irda.h>
  36. #include <mach/pxa27x_keypad.h>
  37. #include <mach/palmasoc.h>
  38. #include "generic.h"
  39. #include "devices.h"
  40. /******************************************************************************
  41. * Pin configuration
  42. ******************************************************************************/
  43. static unsigned long palmld_pin_config[] __initdata = {
  44. /* MMC */
  45. GPIO32_MMC_CLK,
  46. GPIO92_MMC_DAT_0,
  47. GPIO109_MMC_DAT_1,
  48. GPIO110_MMC_DAT_2,
  49. GPIO111_MMC_DAT_3,
  50. GPIO112_MMC_CMD,
  51. GPIO14_GPIO, /* SD detect */
  52. GPIO114_GPIO, /* SD power */
  53. GPIO116_GPIO, /* SD r/o switch */
  54. /* AC97 */
  55. GPIO28_AC97_BITCLK,
  56. GPIO29_AC97_SDATA_IN_0,
  57. GPIO30_AC97_SDATA_OUT,
  58. GPIO31_AC97_SYNC,
  59. GPIO89_AC97_SYSCLK,
  60. GPIO95_AC97_nRESET,
  61. /* IrDA */
  62. GPIO108_GPIO, /* ir disable */
  63. GPIO46_FICP_RXD,
  64. GPIO47_FICP_TXD,
  65. /* MATRIX KEYPAD */
  66. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  67. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  68. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  69. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  70. GPIO103_KP_MKOUT_0,
  71. GPIO104_KP_MKOUT_1,
  72. GPIO105_KP_MKOUT_2,
  73. /* LCD */
  74. GPIO58_LCD_LDD_0,
  75. GPIO59_LCD_LDD_1,
  76. GPIO60_LCD_LDD_2,
  77. GPIO61_LCD_LDD_3,
  78. GPIO62_LCD_LDD_4,
  79. GPIO63_LCD_LDD_5,
  80. GPIO64_LCD_LDD_6,
  81. GPIO65_LCD_LDD_7,
  82. GPIO66_LCD_LDD_8,
  83. GPIO67_LCD_LDD_9,
  84. GPIO68_LCD_LDD_10,
  85. GPIO69_LCD_LDD_11,
  86. GPIO70_LCD_LDD_12,
  87. GPIO71_LCD_LDD_13,
  88. GPIO72_LCD_LDD_14,
  89. GPIO73_LCD_LDD_15,
  90. GPIO74_LCD_FCLK,
  91. GPIO75_LCD_LCLK,
  92. GPIO76_LCD_PCLK,
  93. GPIO77_LCD_BIAS,
  94. /* PWM */
  95. GPIO16_PWM0_OUT,
  96. /* GPIO KEYS */
  97. GPIO10_GPIO, /* hotsync button */
  98. GPIO12_GPIO, /* power switch */
  99. GPIO15_GPIO, /* lock switch */
  100. /* LEDs */
  101. GPIO52_GPIO, /* green led */
  102. GPIO94_GPIO, /* orange led */
  103. /* PCMCIA */
  104. GPIO48_nPOE,
  105. GPIO49_nPWE,
  106. GPIO50_nPIOR,
  107. GPIO51_nPIOW,
  108. GPIO85_nPCE_1,
  109. GPIO54_nPCE_2,
  110. GPIO79_PSKTSEL,
  111. GPIO55_nPREG,
  112. GPIO56_nPWAIT,
  113. GPIO57_nIOIS16,
  114. GPIO36_GPIO, /* wifi power */
  115. GPIO38_GPIO, /* wifi ready */
  116. GPIO81_GPIO, /* wifi reset */
  117. /* FFUART */
  118. GPIO34_FFUART_RXD,
  119. GPIO39_FFUART_TXD,
  120. /* HDD */
  121. GPIO98_GPIO, /* HDD reset */
  122. GPIO115_GPIO, /* HDD power */
  123. /* MISC */
  124. GPIO13_GPIO, /* earphone detect */
  125. };
  126. /******************************************************************************
  127. * SD/MMC card controller
  128. ******************************************************************************/
  129. static struct pxamci_platform_data palmld_mci_platform_data = {
  130. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  131. .gpio_card_detect = GPIO_NR_PALMLD_SD_DETECT_N,
  132. .gpio_card_ro = GPIO_NR_PALMLD_SD_READONLY,
  133. .gpio_power = GPIO_NR_PALMLD_SD_POWER,
  134. .detect_delay = 20,
  135. };
  136. /******************************************************************************
  137. * GPIO keyboard
  138. ******************************************************************************/
  139. static unsigned int palmld_matrix_keys[] = {
  140. KEY(0, 1, KEY_F2),
  141. KEY(0, 2, KEY_UP),
  142. KEY(1, 0, KEY_F3),
  143. KEY(1, 1, KEY_F4),
  144. KEY(1, 2, KEY_RIGHT),
  145. KEY(2, 0, KEY_F1),
  146. KEY(2, 1, KEY_F5),
  147. KEY(2, 2, KEY_DOWN),
  148. KEY(3, 0, KEY_F6),
  149. KEY(3, 1, KEY_ENTER),
  150. KEY(3, 2, KEY_LEFT),
  151. };
  152. static struct pxa27x_keypad_platform_data palmld_keypad_platform_data = {
  153. .matrix_key_rows = 4,
  154. .matrix_key_cols = 3,
  155. .matrix_key_map = palmld_matrix_keys,
  156. .matrix_key_map_size = ARRAY_SIZE(palmld_matrix_keys),
  157. .debounce_interval = 30,
  158. };
  159. /******************************************************************************
  160. * GPIO keys
  161. ******************************************************************************/
  162. static struct gpio_keys_button palmld_pxa_buttons[] = {
  163. {KEY_F8, GPIO_NR_PALMLD_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  164. {KEY_F9, GPIO_NR_PALMLD_LOCK_SWITCH, 0, "Lock Switch" },
  165. {KEY_POWER, GPIO_NR_PALMLD_POWER_SWITCH, 0, "Power Switch" },
  166. };
  167. static struct gpio_keys_platform_data palmld_pxa_keys_data = {
  168. .buttons = palmld_pxa_buttons,
  169. .nbuttons = ARRAY_SIZE(palmld_pxa_buttons),
  170. };
  171. static struct platform_device palmld_pxa_keys = {
  172. .name = "gpio-keys",
  173. .id = -1,
  174. .dev = {
  175. .platform_data = &palmld_pxa_keys_data,
  176. },
  177. };
  178. /******************************************************************************
  179. * Backlight
  180. ******************************************************************************/
  181. static int palmld_backlight_init(struct device *dev)
  182. {
  183. int ret;
  184. ret = gpio_request(GPIO_NR_PALMLD_BL_POWER, "BL POWER");
  185. if (ret)
  186. goto err;
  187. ret = gpio_direction_output(GPIO_NR_PALMLD_BL_POWER, 0);
  188. if (ret)
  189. goto err2;
  190. ret = gpio_request(GPIO_NR_PALMLD_LCD_POWER, "LCD POWER");
  191. if (ret)
  192. goto err2;
  193. ret = gpio_direction_output(GPIO_NR_PALMLD_LCD_POWER, 0);
  194. if (ret)
  195. goto err3;
  196. return 0;
  197. err3:
  198. gpio_free(GPIO_NR_PALMLD_LCD_POWER);
  199. err2:
  200. gpio_free(GPIO_NR_PALMLD_BL_POWER);
  201. err:
  202. return ret;
  203. }
  204. static int palmld_backlight_notify(int brightness)
  205. {
  206. gpio_set_value(GPIO_NR_PALMLD_BL_POWER, brightness);
  207. gpio_set_value(GPIO_NR_PALMLD_LCD_POWER, brightness);
  208. return brightness;
  209. }
  210. static void palmld_backlight_exit(struct device *dev)
  211. {
  212. gpio_free(GPIO_NR_PALMLD_BL_POWER);
  213. gpio_free(GPIO_NR_PALMLD_LCD_POWER);
  214. }
  215. static struct platform_pwm_backlight_data palmld_backlight_data = {
  216. .pwm_id = 0,
  217. .max_brightness = PALMLD_MAX_INTENSITY,
  218. .dft_brightness = PALMLD_MAX_INTENSITY,
  219. .pwm_period_ns = PALMLD_PERIOD_NS,
  220. .init = palmld_backlight_init,
  221. .notify = palmld_backlight_notify,
  222. .exit = palmld_backlight_exit,
  223. };
  224. static struct platform_device palmld_backlight = {
  225. .name = "pwm-backlight",
  226. .dev = {
  227. .parent = &pxa27x_device_pwm0.dev,
  228. .platform_data = &palmld_backlight_data,
  229. },
  230. };
  231. /******************************************************************************
  232. * IrDA
  233. ******************************************************************************/
  234. static int palmld_irda_startup(struct device *dev)
  235. {
  236. int err;
  237. err = gpio_request(GPIO_NR_PALMLD_IR_DISABLE, "IR DISABLE");
  238. if (err)
  239. goto err;
  240. err = gpio_direction_output(GPIO_NR_PALMLD_IR_DISABLE, 1);
  241. if (err)
  242. gpio_free(GPIO_NR_PALMLD_IR_DISABLE);
  243. err:
  244. return err;
  245. }
  246. static void palmld_irda_shutdown(struct device *dev)
  247. {
  248. gpio_free(GPIO_NR_PALMLD_IR_DISABLE);
  249. }
  250. static void palmld_irda_transceiver_mode(struct device *dev, int mode)
  251. {
  252. gpio_set_value(GPIO_NR_PALMLD_IR_DISABLE, mode & IR_OFF);
  253. pxa2xx_transceiver_mode(dev, mode);
  254. }
  255. static struct pxaficp_platform_data palmld_ficp_platform_data = {
  256. .startup = palmld_irda_startup,
  257. .shutdown = palmld_irda_shutdown,
  258. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  259. .transceiver_mode = palmld_irda_transceiver_mode,
  260. };
  261. /******************************************************************************
  262. * LEDs
  263. ******************************************************************************/
  264. struct gpio_led gpio_leds[] = {
  265. {
  266. .name = "palmld:green:led",
  267. .default_trigger = "none",
  268. .gpio = GPIO_NR_PALMLD_LED_GREEN,
  269. }, {
  270. .name = "palmld:amber:led",
  271. .default_trigger = "none",
  272. .gpio = GPIO_NR_PALMLD_LED_AMBER,
  273. },
  274. };
  275. static struct gpio_led_platform_data gpio_led_info = {
  276. .leds = gpio_leds,
  277. .num_leds = ARRAY_SIZE(gpio_leds),
  278. };
  279. static struct platform_device palmld_leds = {
  280. .name = "leds-gpio",
  281. .id = -1,
  282. .dev = {
  283. .platform_data = &gpio_led_info,
  284. }
  285. };
  286. /******************************************************************************
  287. * Power supply
  288. ******************************************************************************/
  289. static int power_supply_init(struct device *dev)
  290. {
  291. int ret;
  292. ret = gpio_request(GPIO_NR_PALMLD_POWER_DETECT, "CABLE_STATE_AC");
  293. if (ret)
  294. goto err1;
  295. ret = gpio_direction_input(GPIO_NR_PALMLD_POWER_DETECT);
  296. if (ret)
  297. goto err2;
  298. ret = gpio_request(GPIO_NR_PALMLD_USB_DETECT_N, "CABLE_STATE_USB");
  299. if (ret)
  300. goto err2;
  301. ret = gpio_direction_input(GPIO_NR_PALMLD_USB_DETECT_N);
  302. if (ret)
  303. goto err3;
  304. return 0;
  305. err3:
  306. gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
  307. err2:
  308. gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
  309. err1:
  310. return ret;
  311. }
  312. static int palmld_is_ac_online(void)
  313. {
  314. return gpio_get_value(GPIO_NR_PALMLD_POWER_DETECT);
  315. }
  316. static int palmld_is_usb_online(void)
  317. {
  318. return !gpio_get_value(GPIO_NR_PALMLD_USB_DETECT_N);
  319. }
  320. static void power_supply_exit(struct device *dev)
  321. {
  322. gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
  323. gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
  324. }
  325. static char *palmld_supplicants[] = {
  326. "main-battery",
  327. };
  328. static struct pda_power_pdata power_supply_info = {
  329. .init = power_supply_init,
  330. .is_ac_online = palmld_is_ac_online,
  331. .is_usb_online = palmld_is_usb_online,
  332. .exit = power_supply_exit,
  333. .supplied_to = palmld_supplicants,
  334. .num_supplicants = ARRAY_SIZE(palmld_supplicants),
  335. };
  336. static struct platform_device power_supply = {
  337. .name = "pda-power",
  338. .id = -1,
  339. .dev = {
  340. .platform_data = &power_supply_info,
  341. },
  342. };
  343. /******************************************************************************
  344. * WM97xx battery
  345. ******************************************************************************/
  346. static struct wm97xx_batt_info wm97xx_batt_pdata = {
  347. .batt_aux = WM97XX_AUX_ID3,
  348. .temp_aux = WM97XX_AUX_ID2,
  349. .charge_gpio = -1,
  350. .max_voltage = PALMLD_BAT_MAX_VOLTAGE,
  351. .min_voltage = PALMLD_BAT_MIN_VOLTAGE,
  352. .batt_mult = 1000,
  353. .batt_div = 414,
  354. .temp_mult = 1,
  355. .temp_div = 1,
  356. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  357. .batt_name = "main-batt",
  358. };
  359. /******************************************************************************
  360. * aSoC audio
  361. ******************************************************************************/
  362. static struct palm27x_asoc_info palmld_asoc_pdata = {
  363. .jack_gpio = GPIO_NR_PALMLD_EARPHONE_DETECT,
  364. };
  365. static pxa2xx_audio_ops_t palmld_ac97_pdata = {
  366. .reset_gpio = 95,
  367. };
  368. static struct platform_device palmld_asoc = {
  369. .name = "palm27x-asoc",
  370. .id = -1,
  371. .dev = {
  372. .platform_data = &palmld_asoc_pdata,
  373. },
  374. };
  375. /******************************************************************************
  376. * HDD
  377. ******************************************************************************/
  378. static struct platform_device palmld_hdd = {
  379. .name = "pata_palmld",
  380. .id = -1,
  381. };
  382. /******************************************************************************
  383. * Framebuffer
  384. ******************************************************************************/
  385. static struct pxafb_mode_info palmld_lcd_modes[] = {
  386. {
  387. .pixclock = 57692,
  388. .xres = 320,
  389. .yres = 480,
  390. .bpp = 16,
  391. .left_margin = 32,
  392. .right_margin = 1,
  393. .upper_margin = 7,
  394. .lower_margin = 1,
  395. .hsync_len = 4,
  396. .vsync_len = 1,
  397. },
  398. };
  399. static struct pxafb_mach_info palmld_lcd_screen = {
  400. .modes = palmld_lcd_modes,
  401. .num_modes = ARRAY_SIZE(palmld_lcd_modes),
  402. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  403. };
  404. /******************************************************************************
  405. * Power management - standby
  406. ******************************************************************************/
  407. static void __init palmld_pm_init(void)
  408. {
  409. static u32 resume[] = {
  410. 0xe3a00101, /* mov r0, #0x40000000 */
  411. 0xe380060f, /* orr r0, r0, #0x00f00000 */
  412. 0xe590f008, /* ldr pc, [r0, #0x08] */
  413. };
  414. /* copy the bootloader */
  415. memcpy(phys_to_virt(PALMLD_STR_BASE), resume, sizeof(resume));
  416. }
  417. /******************************************************************************
  418. * Machine init
  419. ******************************************************************************/
  420. static struct platform_device *devices[] __initdata = {
  421. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  422. &palmld_pxa_keys,
  423. #endif
  424. &palmld_backlight,
  425. &palmld_leds,
  426. &power_supply,
  427. &palmld_asoc,
  428. &palmld_hdd,
  429. };
  430. static struct map_desc palmld_io_desc[] __initdata = {
  431. {
  432. .virtual = PALMLD_IDE_VIRT,
  433. .pfn = __phys_to_pfn(PALMLD_IDE_PHYS),
  434. .length = PALMLD_IDE_SIZE,
  435. .type = MT_DEVICE
  436. },
  437. {
  438. .virtual = PALMLD_USB_VIRT,
  439. .pfn = __phys_to_pfn(PALMLD_USB_PHYS),
  440. .length = PALMLD_USB_SIZE,
  441. .type = MT_DEVICE
  442. },
  443. };
  444. static void __init palmld_map_io(void)
  445. {
  446. pxa_map_io();
  447. iotable_init(palmld_io_desc, ARRAY_SIZE(palmld_io_desc));
  448. }
  449. static void __init palmld_init(void)
  450. {
  451. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config));
  452. palmld_pm_init();
  453. set_pxa_fb_info(&palmld_lcd_screen);
  454. pxa_set_mci_info(&palmld_mci_platform_data);
  455. pxa_set_ac97_info(&palmld_ac97_pdata);
  456. pxa_set_ficp_info(&palmld_ficp_platform_data);
  457. pxa_set_keypad_info(&palmld_keypad_platform_data);
  458. wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
  459. platform_add_devices(devices, ARRAY_SIZE(devices));
  460. }
  461. MACHINE_START(PALMLD, "Palm LifeDrive")
  462. .phys_io = PALMLD_PHYS_IO_START,
  463. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  464. .boot_params = 0xa0000100,
  465. .map_io = palmld_map_io,
  466. .init_irq = pxa27x_init_irq,
  467. .timer = &pxa_timer,
  468. .init_machine = palmld_init
  469. MACHINE_END