palmtx.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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.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 <plat/pxa27x_keypad.h>
  44. #include <mach/udc.h>
  45. #include <mach/palmasoc.h>
  46. #include <mach/palm27x.h>
  47. #include "generic.h"
  48. #include "devices.h"
  49. /******************************************************************************
  50. * Pin configuration
  51. ******************************************************************************/
  52. static unsigned long palmtx_pin_config[] __initdata = {
  53. /* MMC */
  54. GPIO32_MMC_CLK,
  55. GPIO92_MMC_DAT_0,
  56. GPIO109_MMC_DAT_1,
  57. GPIO110_MMC_DAT_2,
  58. GPIO111_MMC_DAT_3,
  59. GPIO112_MMC_CMD,
  60. GPIO14_GPIO, /* SD detect */
  61. GPIO114_GPIO, /* SD power */
  62. GPIO115_GPIO, /* SD r/o switch */
  63. /* AC97 */
  64. GPIO28_AC97_BITCLK,
  65. GPIO29_AC97_SDATA_IN_0,
  66. GPIO30_AC97_SDATA_OUT,
  67. GPIO31_AC97_SYNC,
  68. GPIO89_AC97_SYSCLK,
  69. GPIO95_AC97_nRESET,
  70. /* IrDA */
  71. GPIO40_GPIO, /* ir disable */
  72. GPIO46_FICP_RXD,
  73. GPIO47_FICP_TXD,
  74. /* PWM */
  75. GPIO16_PWM0_OUT,
  76. /* USB */
  77. GPIO13_GPIO, /* usb detect */
  78. GPIO93_GPIO, /* usb power */
  79. /* PCMCIA */
  80. GPIO48_nPOE,
  81. GPIO49_nPWE,
  82. GPIO50_nPIOR,
  83. GPIO51_nPIOW,
  84. GPIO85_nPCE_1,
  85. GPIO54_nPCE_2,
  86. GPIO79_PSKTSEL,
  87. GPIO55_nPREG,
  88. GPIO56_nPWAIT,
  89. GPIO57_nIOIS16,
  90. GPIO94_GPIO, /* wifi power 1 */
  91. GPIO108_GPIO, /* wifi power 2 */
  92. GPIO116_GPIO, /* wifi ready */
  93. /* MATRIX KEYPAD */
  94. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  95. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  96. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  97. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  98. GPIO103_KP_MKOUT_0,
  99. GPIO104_KP_MKOUT_1,
  100. GPIO105_KP_MKOUT_2,
  101. /* LCD */
  102. GPIOxx_LCD_TFT_16BPP,
  103. /* FFUART */
  104. GPIO34_FFUART_RXD,
  105. GPIO39_FFUART_TXD,
  106. /* NAND */
  107. GPIO15_nCS_1,
  108. GPIO18_RDY,
  109. /* MISC. */
  110. GPIO10_GPIO, /* hotsync button */
  111. GPIO12_GPIO, /* power detect */
  112. GPIO107_GPIO, /* earphone detect */
  113. };
  114. /******************************************************************************
  115. * NOR Flash
  116. ******************************************************************************/
  117. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  118. static struct mtd_partition palmtx_partitions[] = {
  119. {
  120. .name = "Flash",
  121. .offset = 0x00000000,
  122. .size = MTDPART_SIZ_FULL,
  123. .mask_flags = 0
  124. }
  125. };
  126. static struct physmap_flash_data palmtx_flash_data[] = {
  127. {
  128. .width = 2, /* bankwidth in bytes */
  129. .parts = palmtx_partitions,
  130. .nr_parts = ARRAY_SIZE(palmtx_partitions)
  131. }
  132. };
  133. static struct resource palmtx_flash_resource = {
  134. .start = PXA_CS0_PHYS,
  135. .end = PXA_CS0_PHYS + SZ_8M - 1,
  136. .flags = IORESOURCE_MEM,
  137. };
  138. static struct platform_device palmtx_flash = {
  139. .name = "physmap-flash",
  140. .id = 0,
  141. .resource = &palmtx_flash_resource,
  142. .num_resources = 1,
  143. .dev = {
  144. .platform_data = palmtx_flash_data,
  145. },
  146. };
  147. static void __init palmtx_nor_init(void)
  148. {
  149. platform_device_register(&palmtx_flash);
  150. }
  151. #else
  152. static inline void palmtx_nor_init(void) {}
  153. #endif
  154. /******************************************************************************
  155. * GPIO keyboard
  156. ******************************************************************************/
  157. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  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. static void __init palmtx_kpc_init(void)
  178. {
  179. pxa_set_keypad_info(&palmtx_keypad_platform_data);
  180. }
  181. #else
  182. static inline void palmtx_kpc_init(void) {}
  183. #endif
  184. /******************************************************************************
  185. * GPIO keys
  186. ******************************************************************************/
  187. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  188. static struct gpio_keys_button palmtx_pxa_buttons[] = {
  189. {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  190. };
  191. static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
  192. .buttons = palmtx_pxa_buttons,
  193. .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
  194. };
  195. static struct platform_device palmtx_pxa_keys = {
  196. .name = "gpio-keys",
  197. .id = -1,
  198. .dev = {
  199. .platform_data = &palmtx_pxa_keys_data,
  200. },
  201. };
  202. static void __init palmtx_keys_init(void)
  203. {
  204. platform_device_register(&palmtx_pxa_keys);
  205. }
  206. #else
  207. static inline void palmtx_keys_init(void) {}
  208. #endif
  209. /******************************************************************************
  210. * NAND Flash
  211. ******************************************************************************/
  212. #if defined(CONFIG_MTD_NAND_PLATFORM) || \
  213. defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  214. static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
  215. unsigned int ctrl)
  216. {
  217. struct nand_chip *this = mtd->priv;
  218. unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
  219. if (cmd == NAND_CMD_NONE)
  220. return;
  221. if (ctrl & NAND_CLE)
  222. writeb(cmd, PALMTX_NAND_CLE_VIRT);
  223. else if (ctrl & NAND_ALE)
  224. writeb(cmd, PALMTX_NAND_ALE_VIRT);
  225. else
  226. writeb(cmd, nandaddr);
  227. }
  228. static struct mtd_partition palmtx_partition_info[] = {
  229. [0] = {
  230. .name = "palmtx-0",
  231. .offset = 0,
  232. .size = MTDPART_SIZ_FULL
  233. },
  234. };
  235. static const char *palmtx_part_probes[] = { "cmdlinepart", NULL };
  236. struct platform_nand_data palmtx_nand_platdata = {
  237. .chip = {
  238. .nr_chips = 1,
  239. .chip_offset = 0,
  240. .nr_partitions = ARRAY_SIZE(palmtx_partition_info),
  241. .partitions = palmtx_partition_info,
  242. .chip_delay = 20,
  243. .part_probe_types = palmtx_part_probes,
  244. },
  245. .ctrl = {
  246. .cmd_ctrl = palmtx_nand_cmd_ctl,
  247. },
  248. };
  249. static struct resource palmtx_nand_resource[] = {
  250. [0] = {
  251. .start = PXA_CS1_PHYS,
  252. .end = PXA_CS1_PHYS + SZ_1M - 1,
  253. .flags = IORESOURCE_MEM,
  254. },
  255. };
  256. static struct platform_device palmtx_nand = {
  257. .name = "gen_nand",
  258. .num_resources = ARRAY_SIZE(palmtx_nand_resource),
  259. .resource = palmtx_nand_resource,
  260. .id = -1,
  261. .dev = {
  262. .platform_data = &palmtx_nand_platdata,
  263. }
  264. };
  265. static void __init palmtx_nand_init(void)
  266. {
  267. platform_device_register(&palmtx_nand);
  268. }
  269. #else
  270. static inline void palmtx_nand_init(void) {}
  271. #endif
  272. /******************************************************************************
  273. * Machine init
  274. ******************************************************************************/
  275. static struct map_desc palmtx_io_desc[] __initdata = {
  276. {
  277. .virtual = PALMTX_PCMCIA_VIRT,
  278. .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
  279. .length = PALMTX_PCMCIA_SIZE,
  280. .type = MT_DEVICE,
  281. }, {
  282. .virtual = PALMTX_NAND_ALE_VIRT,
  283. .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
  284. .length = SZ_1M,
  285. .type = MT_DEVICE,
  286. }, {
  287. .virtual = PALMTX_NAND_CLE_VIRT,
  288. .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
  289. .length = SZ_1M,
  290. .type = MT_DEVICE,
  291. }
  292. };
  293. static void __init palmtx_map_io(void)
  294. {
  295. pxa27x_map_io();
  296. iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
  297. }
  298. static void __init palmtx_init(void)
  299. {
  300. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
  301. pxa_set_ffuart_info(NULL);
  302. pxa_set_btuart_info(NULL);
  303. pxa_set_stuart_info(NULL);
  304. palm27x_mmc_init(GPIO_NR_PALMTX_SD_DETECT_N, GPIO_NR_PALMTX_SD_READONLY,
  305. GPIO_NR_PALMTX_SD_POWER, 0);
  306. palm27x_pm_init(PALMTX_STR_BASE);
  307. palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
  308. palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N,
  309. GPIO_NR_PALMTX_USB_PULLUP, 1);
  310. palm27x_irda_init(GPIO_NR_PALMTX_IR_DISABLE);
  311. palm27x_ac97_init(PALMTX_BAT_MIN_VOLTAGE, PALMTX_BAT_MAX_VOLTAGE,
  312. GPIO_NR_PALMTX_EARPHONE_DETECT, 95);
  313. palm27x_pwm_init(GPIO_NR_PALMTX_BL_POWER, GPIO_NR_PALMTX_LCD_POWER);
  314. palm27x_power_init(GPIO_NR_PALMTX_POWER_DETECT, -1);
  315. palm27x_pmic_init();
  316. palmtx_kpc_init();
  317. palmtx_keys_init();
  318. palmtx_nor_init();
  319. palmtx_nand_init();
  320. }
  321. MACHINE_START(PALMTX, "Palm T|X")
  322. .boot_params = 0xa0000100,
  323. .map_io = palmtx_map_io,
  324. .init_irq = pxa27x_init_irq,
  325. .handle_irq = pxa27x_handle_irq,
  326. .timer = &pxa_timer,
  327. .init_machine = palmtx_init
  328. MACHINE_END