palmtx.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. * Hardware definitions for PalmTX
  3. *
  4. * Author: Marek Vasut <marek.vasut@gmail.com>
  5. *
  6. * Based on work of:
  7. * Alex Osborne <ato@meshy.org>
  8. * Cristiano P. <cristianop@users.sourceforge.net>
  9. * Jan Herman <2hp@seznam.cz>
  10. * Michal Hrusecky
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. *
  16. * (find more info at www.hackndev.com)
  17. *
  18. */
  19. #include <linux/platform_device.h>
  20. #include <linux/delay.h>
  21. #include <linux/irq.h>
  22. #include <linux/gpio_keys.h>
  23. #include <linux/input.h>
  24. #include <linux/pda_power.h>
  25. #include <linux/pwm_backlight.h>
  26. #include <linux/gpio.h>
  27. #include <linux/wm97xx_batt.h>
  28. #include <linux/power_supply.h>
  29. #include <linux/usb/gpio_vbus.h>
  30. #include <linux/mtd/nand.h>
  31. #include <linux/mtd/partitions.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <mach/pxa27x.h>
  36. #include <mach/audio.h>
  37. #include <mach/palmtx.h>
  38. #include <mach/mmc.h>
  39. #include <mach/pxafb.h>
  40. #include <mach/irda.h>
  41. #include <mach/pxa27x_keypad.h>
  42. #include <mach/udc.h>
  43. #include <mach/palmasoc.h>
  44. #include "generic.h"
  45. #include "devices.h"
  46. /******************************************************************************
  47. * Pin configuration
  48. ******************************************************************************/
  49. static unsigned long palmtx_pin_config[] __initdata = {
  50. /* MMC */
  51. GPIO32_MMC_CLK,
  52. GPIO92_MMC_DAT_0,
  53. GPIO109_MMC_DAT_1,
  54. GPIO110_MMC_DAT_2,
  55. GPIO111_MMC_DAT_3,
  56. GPIO112_MMC_CMD,
  57. GPIO14_GPIO, /* SD detect */
  58. GPIO114_GPIO, /* SD power */
  59. GPIO115_GPIO, /* SD r/o switch */
  60. /* AC97 */
  61. GPIO28_AC97_BITCLK,
  62. GPIO29_AC97_SDATA_IN_0,
  63. GPIO30_AC97_SDATA_OUT,
  64. GPIO31_AC97_SYNC,
  65. GPIO89_AC97_SYSCLK,
  66. GPIO95_AC97_nRESET,
  67. /* IrDA */
  68. GPIO40_GPIO, /* ir disable */
  69. GPIO46_FICP_RXD,
  70. GPIO47_FICP_TXD,
  71. /* PWM */
  72. GPIO16_PWM0_OUT,
  73. /* USB */
  74. GPIO13_GPIO, /* usb detect */
  75. GPIO93_GPIO, /* usb power */
  76. /* PCMCIA */
  77. GPIO48_nPOE,
  78. GPIO49_nPWE,
  79. GPIO50_nPIOR,
  80. GPIO51_nPIOW,
  81. GPIO85_nPCE_1,
  82. GPIO54_nPCE_2,
  83. GPIO79_PSKTSEL,
  84. GPIO55_nPREG,
  85. GPIO56_nPWAIT,
  86. GPIO57_nIOIS16,
  87. GPIO94_GPIO, /* wifi power 1 */
  88. GPIO108_GPIO, /* wifi power 2 */
  89. GPIO116_GPIO, /* wifi ready */
  90. /* MATRIX KEYPAD */
  91. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  92. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  93. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  94. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  95. GPIO103_KP_MKOUT_0,
  96. GPIO104_KP_MKOUT_1,
  97. GPIO105_KP_MKOUT_2,
  98. /* LCD */
  99. GPIO58_LCD_LDD_0,
  100. GPIO59_LCD_LDD_1,
  101. GPIO60_LCD_LDD_2,
  102. GPIO61_LCD_LDD_3,
  103. GPIO62_LCD_LDD_4,
  104. GPIO63_LCD_LDD_5,
  105. GPIO64_LCD_LDD_6,
  106. GPIO65_LCD_LDD_7,
  107. GPIO66_LCD_LDD_8,
  108. GPIO67_LCD_LDD_9,
  109. GPIO68_LCD_LDD_10,
  110. GPIO69_LCD_LDD_11,
  111. GPIO70_LCD_LDD_12,
  112. GPIO71_LCD_LDD_13,
  113. GPIO72_LCD_LDD_14,
  114. GPIO73_LCD_LDD_15,
  115. GPIO74_LCD_FCLK,
  116. GPIO75_LCD_LCLK,
  117. GPIO76_LCD_PCLK,
  118. GPIO77_LCD_BIAS,
  119. /* FFUART */
  120. GPIO34_FFUART_RXD,
  121. GPIO39_FFUART_TXD,
  122. /* NAND */
  123. GPIO15_nCS_1,
  124. GPIO18_RDY,
  125. /* MISC. */
  126. GPIO10_GPIO, /* hotsync button */
  127. GPIO12_GPIO, /* power detect */
  128. GPIO107_GPIO, /* earphone detect */
  129. };
  130. /******************************************************************************
  131. * SD/MMC card controller
  132. ******************************************************************************/
  133. static struct pxamci_platform_data palmtx_mci_platform_data = {
  134. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  135. .gpio_card_detect = GPIO_NR_PALMTX_SD_DETECT_N,
  136. .gpio_card_ro = GPIO_NR_PALMTX_SD_READONLY,
  137. .gpio_power = GPIO_NR_PALMTX_SD_POWER,
  138. .detect_delay = 20,
  139. };
  140. /******************************************************************************
  141. * GPIO keyboard
  142. ******************************************************************************/
  143. static unsigned int palmtx_matrix_keys[] = {
  144. KEY(0, 0, KEY_POWER),
  145. KEY(0, 1, KEY_F1),
  146. KEY(0, 2, KEY_ENTER),
  147. KEY(1, 0, KEY_F2),
  148. KEY(1, 1, KEY_F3),
  149. KEY(1, 2, KEY_F4),
  150. KEY(2, 0, KEY_UP),
  151. KEY(2, 2, KEY_DOWN),
  152. KEY(3, 0, KEY_RIGHT),
  153. KEY(3, 2, KEY_LEFT),
  154. };
  155. static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
  156. .matrix_key_rows = 4,
  157. .matrix_key_cols = 3,
  158. .matrix_key_map = palmtx_matrix_keys,
  159. .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
  160. .debounce_interval = 30,
  161. };
  162. /******************************************************************************
  163. * GPIO keys
  164. ******************************************************************************/
  165. static struct gpio_keys_button palmtx_pxa_buttons[] = {
  166. {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  167. };
  168. static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
  169. .buttons = palmtx_pxa_buttons,
  170. .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
  171. };
  172. static struct platform_device palmtx_pxa_keys = {
  173. .name = "gpio-keys",
  174. .id = -1,
  175. .dev = {
  176. .platform_data = &palmtx_pxa_keys_data,
  177. },
  178. };
  179. /******************************************************************************
  180. * Backlight
  181. ******************************************************************************/
  182. static int palmtx_backlight_init(struct device *dev)
  183. {
  184. int ret;
  185. ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
  186. if (ret)
  187. goto err;
  188. ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
  189. if (ret)
  190. goto err2;
  191. ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
  192. if (ret)
  193. goto err2;
  194. ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
  195. if (ret)
  196. goto err3;
  197. return 0;
  198. err3:
  199. gpio_free(GPIO_NR_PALMTX_LCD_POWER);
  200. err2:
  201. gpio_free(GPIO_NR_PALMTX_BL_POWER);
  202. err:
  203. return ret;
  204. }
  205. static int palmtx_backlight_notify(int brightness)
  206. {
  207. gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
  208. gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
  209. return brightness;
  210. }
  211. static void palmtx_backlight_exit(struct device *dev)
  212. {
  213. gpio_free(GPIO_NR_PALMTX_BL_POWER);
  214. gpio_free(GPIO_NR_PALMTX_LCD_POWER);
  215. }
  216. static struct platform_pwm_backlight_data palmtx_backlight_data = {
  217. .pwm_id = 0,
  218. .max_brightness = PALMTX_MAX_INTENSITY,
  219. .dft_brightness = PALMTX_MAX_INTENSITY,
  220. .pwm_period_ns = PALMTX_PERIOD_NS,
  221. .init = palmtx_backlight_init,
  222. .notify = palmtx_backlight_notify,
  223. .exit = palmtx_backlight_exit,
  224. };
  225. static struct platform_device palmtx_backlight = {
  226. .name = "pwm-backlight",
  227. .dev = {
  228. .parent = &pxa27x_device_pwm0.dev,
  229. .platform_data = &palmtx_backlight_data,
  230. },
  231. };
  232. /******************************************************************************
  233. * IrDA
  234. ******************************************************************************/
  235. static int palmtx_irda_startup(struct device *dev)
  236. {
  237. int err;
  238. err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
  239. if (err)
  240. goto err;
  241. err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
  242. if (err)
  243. gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
  244. err:
  245. return err;
  246. }
  247. static void palmtx_irda_shutdown(struct device *dev)
  248. {
  249. gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
  250. }
  251. static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
  252. {
  253. gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
  254. pxa2xx_transceiver_mode(dev, mode);
  255. }
  256. static struct pxaficp_platform_data palmtx_ficp_platform_data = {
  257. .startup = palmtx_irda_startup,
  258. .shutdown = palmtx_irda_shutdown,
  259. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  260. .transceiver_mode = palmtx_irda_transceiver_mode,
  261. };
  262. /******************************************************************************
  263. * UDC
  264. ******************************************************************************/
  265. static struct gpio_vbus_mach_info palmtx_udc_info = {
  266. .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
  267. .gpio_vbus_inverted = 1,
  268. .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP,
  269. };
  270. static struct platform_device palmtx_gpio_vbus = {
  271. .name = "gpio-vbus",
  272. .id = -1,
  273. .dev = {
  274. .platform_data = &palmtx_udc_info,
  275. },
  276. };
  277. /******************************************************************************
  278. * Power supply
  279. ******************************************************************************/
  280. static int power_supply_init(struct device *dev)
  281. {
  282. int ret;
  283. ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
  284. if (ret)
  285. goto err1;
  286. ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
  287. if (ret)
  288. goto err2;
  289. return 0;
  290. err2:
  291. gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
  292. err1:
  293. return ret;
  294. }
  295. static int palmtx_is_ac_online(void)
  296. {
  297. return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
  298. }
  299. static void power_supply_exit(struct device *dev)
  300. {
  301. gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
  302. }
  303. static char *palmtx_supplicants[] = {
  304. "main-battery",
  305. };
  306. static struct pda_power_pdata power_supply_info = {
  307. .init = power_supply_init,
  308. .is_ac_online = palmtx_is_ac_online,
  309. .exit = power_supply_exit,
  310. .supplied_to = palmtx_supplicants,
  311. .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
  312. };
  313. static struct platform_device power_supply = {
  314. .name = "pda-power",
  315. .id = -1,
  316. .dev = {
  317. .platform_data = &power_supply_info,
  318. },
  319. };
  320. /******************************************************************************
  321. * WM97xx battery
  322. ******************************************************************************/
  323. static struct wm97xx_batt_info wm97xx_batt_pdata = {
  324. .batt_aux = WM97XX_AUX_ID3,
  325. .temp_aux = WM97XX_AUX_ID2,
  326. .charge_gpio = -1,
  327. .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
  328. .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
  329. .batt_mult = 1000,
  330. .batt_div = 414,
  331. .temp_mult = 1,
  332. .temp_div = 1,
  333. .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
  334. .batt_name = "main-batt",
  335. };
  336. /******************************************************************************
  337. * aSoC audio
  338. ******************************************************************************/
  339. static struct palm27x_asoc_info palmtx_asoc_pdata = {
  340. .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT,
  341. };
  342. static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
  343. .reset_gpio = 95,
  344. };
  345. static struct platform_device palmtx_asoc = {
  346. .name = "palm27x-asoc",
  347. .id = -1,
  348. .dev = {
  349. .platform_data = &palmtx_asoc_pdata,
  350. },
  351. };
  352. /******************************************************************************
  353. * Framebuffer
  354. ******************************************************************************/
  355. static struct pxafb_mode_info palmtx_lcd_modes[] = {
  356. {
  357. .pixclock = 57692,
  358. .xres = 320,
  359. .yres = 480,
  360. .bpp = 16,
  361. .left_margin = 32,
  362. .right_margin = 1,
  363. .upper_margin = 7,
  364. .lower_margin = 1,
  365. .hsync_len = 4,
  366. .vsync_len = 1,
  367. },
  368. };
  369. static struct pxafb_mach_info palmtx_lcd_screen = {
  370. .modes = palmtx_lcd_modes,
  371. .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
  372. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  373. };
  374. /******************************************************************************
  375. * NAND Flash
  376. ******************************************************************************/
  377. static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
  378. unsigned int ctrl)
  379. {
  380. struct nand_chip *this = mtd->priv;
  381. unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
  382. if (cmd == NAND_CMD_NONE)
  383. return;
  384. if (ctrl & NAND_CLE)
  385. writeb(cmd, PALMTX_NAND_CLE_VIRT);
  386. else if (ctrl & NAND_ALE)
  387. writeb(cmd, PALMTX_NAND_ALE_VIRT);
  388. else
  389. writeb(cmd, nandaddr);
  390. }
  391. static struct mtd_partition palmtx_partition_info[] = {
  392. [0] = {
  393. .name = "palmtx-0",
  394. .offset = 0,
  395. .size = MTDPART_SIZ_FULL
  396. },
  397. };
  398. static const char *palmtx_part_probes[] = { "cmdlinepart", NULL };
  399. struct platform_nand_data palmtx_nand_platdata = {
  400. .chip = {
  401. .nr_chips = 1,
  402. .chip_offset = 0,
  403. .nr_partitions = ARRAY_SIZE(palmtx_partition_info),
  404. .partitions = palmtx_partition_info,
  405. .chip_delay = 20,
  406. .part_probe_types = palmtx_part_probes,
  407. },
  408. .ctrl = {
  409. .cmd_ctrl = palmtx_nand_cmd_ctl,
  410. },
  411. };
  412. static struct resource palmtx_nand_resource[] = {
  413. [0] = {
  414. .start = PXA_CS1_PHYS,
  415. .end = PXA_CS1_PHYS + SZ_1M - 1,
  416. .flags = IORESOURCE_MEM,
  417. },
  418. };
  419. static struct platform_device palmtx_nand = {
  420. .name = "gen_nand",
  421. .num_resources = ARRAY_SIZE(palmtx_nand_resource),
  422. .resource = palmtx_nand_resource,
  423. .id = -1,
  424. .dev = {
  425. .platform_data = &palmtx_nand_platdata,
  426. }
  427. };
  428. /******************************************************************************
  429. * Power management - standby
  430. ******************************************************************************/
  431. static void __init palmtx_pm_init(void)
  432. {
  433. static u32 resume[] = {
  434. 0xe3a00101, /* mov r0, #0x40000000 */
  435. 0xe380060f, /* orr r0, r0, #0x00f00000 */
  436. 0xe590f008, /* ldr pc, [r0, #0x08] */
  437. };
  438. /* copy the bootloader */
  439. memcpy(phys_to_virt(PALMTX_STR_BASE), resume, sizeof(resume));
  440. }
  441. /******************************************************************************
  442. * Machine init
  443. ******************************************************************************/
  444. static struct platform_device *devices[] __initdata = {
  445. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  446. &palmtx_pxa_keys,
  447. #endif
  448. &palmtx_backlight,
  449. &power_supply,
  450. &palmtx_asoc,
  451. &palmtx_gpio_vbus,
  452. &palmtx_nand,
  453. };
  454. static struct map_desc palmtx_io_desc[] __initdata = {
  455. {
  456. .virtual = PALMTX_PCMCIA_VIRT,
  457. .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
  458. .length = PALMTX_PCMCIA_SIZE,
  459. .type = MT_DEVICE,
  460. }, {
  461. .virtual = PALMTX_NAND_ALE_VIRT,
  462. .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
  463. .length = SZ_1M,
  464. .type = MT_DEVICE,
  465. }, {
  466. .virtual = PALMTX_NAND_CLE_VIRT,
  467. .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
  468. .length = SZ_1M,
  469. .type = MT_DEVICE,
  470. }
  471. };
  472. static void __init palmtx_map_io(void)
  473. {
  474. pxa_map_io();
  475. iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
  476. }
  477. /* setup udc GPIOs initial state */
  478. static void __init palmtx_udc_init(void)
  479. {
  480. if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) {
  481. gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1);
  482. gpio_free(GPIO_NR_PALMTX_USB_PULLUP);
  483. }
  484. }
  485. static void __init palmtx_init(void)
  486. {
  487. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
  488. palmtx_pm_init();
  489. set_pxa_fb_info(&palmtx_lcd_screen);
  490. pxa_set_mci_info(&palmtx_mci_platform_data);
  491. palmtx_udc_init();
  492. pxa_set_ac97_info(&palmtx_ac97_pdata);
  493. pxa_set_ficp_info(&palmtx_ficp_platform_data);
  494. pxa_set_keypad_info(&palmtx_keypad_platform_data);
  495. wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
  496. platform_add_devices(devices, ARRAY_SIZE(devices));
  497. }
  498. MACHINE_START(PALMTX, "Palm T|X")
  499. .phys_io = PALMTX_PHYS_IO_START,
  500. .io_pg_offst = io_p2v(0x40000000),
  501. .boot_params = 0xa0000100,
  502. .map_io = palmtx_map_io,
  503. .init_irq = pxa27x_init_irq,
  504. .timer = &pxa_timer,
  505. .init_machine = palmtx_init
  506. MACHINE_END