palmtx.c 14 KB

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