palmld.c 13 KB

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