palmld.c 13 KB

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