palmtx.c 14 KB

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