palmtx.c 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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/platnand.h>
  31. #include <linux/mtd/mtd.h>
  32. #include <linux/mtd/physmap.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include "pxa27x.h"
  37. #include <mach/audio.h>
  38. #include <mach/palmtx.h>
  39. #include <linux/platform_data/mmc-pxamci.h>
  40. #include <linux/platform_data/video-pxafb.h>
  41. #include <linux/platform_data/irda-pxaficp.h>
  42. #include <linux/platform_data/keypad-pxa27x.h>
  43. #include "udc.h"
  44. #include <linux/platform_data/asoc-palm27x.h>
  45. #include "palm27x.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. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  117. static struct mtd_partition palmtx_partitions[] = {
  118. {
  119. .name = "Flash",
  120. .offset = 0x00000000,
  121. .size = MTDPART_SIZ_FULL,
  122. .mask_flags = 0
  123. }
  124. };
  125. static struct physmap_flash_data palmtx_flash_data[] = {
  126. {
  127. .width = 2, /* bankwidth in bytes */
  128. .parts = palmtx_partitions,
  129. .nr_parts = ARRAY_SIZE(palmtx_partitions)
  130. }
  131. };
  132. static struct resource palmtx_flash_resource = {
  133. .start = PXA_CS0_PHYS,
  134. .end = PXA_CS0_PHYS + SZ_8M - 1,
  135. .flags = IORESOURCE_MEM,
  136. };
  137. static struct platform_device palmtx_flash = {
  138. .name = "physmap-flash",
  139. .id = 0,
  140. .resource = &palmtx_flash_resource,
  141. .num_resources = 1,
  142. .dev = {
  143. .platform_data = palmtx_flash_data,
  144. },
  145. };
  146. static void __init palmtx_nor_init(void)
  147. {
  148. platform_device_register(&palmtx_flash);
  149. }
  150. #else
  151. static inline void palmtx_nor_init(void) {}
  152. #endif
  153. /******************************************************************************
  154. * GPIO keyboard
  155. ******************************************************************************/
  156. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  157. static const unsigned int palmtx_matrix_keys[] = {
  158. KEY(0, 0, KEY_POWER),
  159. KEY(0, 1, KEY_F1),
  160. KEY(0, 2, KEY_ENTER),
  161. KEY(1, 0, KEY_F2),
  162. KEY(1, 1, KEY_F3),
  163. KEY(1, 2, KEY_F4),
  164. KEY(2, 0, KEY_UP),
  165. KEY(2, 2, KEY_DOWN),
  166. KEY(3, 0, KEY_RIGHT),
  167. KEY(3, 2, KEY_LEFT),
  168. };
  169. static struct matrix_keymap_data palmtx_matrix_keymap_data = {
  170. .keymap = palmtx_matrix_keys,
  171. .keymap_size = ARRAY_SIZE(palmtx_matrix_keys),
  172. };
  173. static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
  174. .matrix_key_rows = 4,
  175. .matrix_key_cols = 3,
  176. .matrix_keymap_data = &palmtx_matrix_keymap_data,
  177. .debounce_interval = 30,
  178. };
  179. static void __init palmtx_kpc_init(void)
  180. {
  181. pxa_set_keypad_info(&palmtx_keypad_platform_data);
  182. }
  183. #else
  184. static inline void palmtx_kpc_init(void) {}
  185. #endif
  186. /******************************************************************************
  187. * GPIO keys
  188. ******************************************************************************/
  189. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  190. static struct gpio_keys_button palmtx_pxa_buttons[] = {
  191. {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  192. };
  193. static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
  194. .buttons = palmtx_pxa_buttons,
  195. .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
  196. };
  197. static struct platform_device palmtx_pxa_keys = {
  198. .name = "gpio-keys",
  199. .id = -1,
  200. .dev = {
  201. .platform_data = &palmtx_pxa_keys_data,
  202. },
  203. };
  204. static void __init palmtx_keys_init(void)
  205. {
  206. platform_device_register(&palmtx_pxa_keys);
  207. }
  208. #else
  209. static inline void palmtx_keys_init(void) {}
  210. #endif
  211. /******************************************************************************
  212. * NAND Flash
  213. ******************************************************************************/
  214. #if defined(CONFIG_MTD_NAND_PLATFORM) || \
  215. defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  216. static void palmtx_nand_cmd_ctl(struct nand_chip *this, int cmd,
  217. unsigned int ctrl)
  218. {
  219. char __iomem *nandaddr = this->legacy.IO_ADDR_W;
  220. if (cmd == NAND_CMD_NONE)
  221. return;
  222. if (ctrl & NAND_CLE)
  223. writeb(cmd, PALMTX_NAND_CLE_VIRT);
  224. else if (ctrl & NAND_ALE)
  225. writeb(cmd, PALMTX_NAND_ALE_VIRT);
  226. else
  227. writeb(cmd, nandaddr);
  228. }
  229. static struct mtd_partition palmtx_partition_info[] = {
  230. [0] = {
  231. .name = "palmtx-0",
  232. .offset = 0,
  233. .size = MTDPART_SIZ_FULL
  234. },
  235. };
  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. },
  244. .ctrl = {
  245. .cmd_ctrl = palmtx_nand_cmd_ctl,
  246. },
  247. };
  248. static struct resource palmtx_nand_resource[] = {
  249. [0] = {
  250. .start = PXA_CS1_PHYS,
  251. .end = PXA_CS1_PHYS + SZ_1M - 1,
  252. .flags = IORESOURCE_MEM,
  253. },
  254. };
  255. static struct platform_device palmtx_nand = {
  256. .name = "gen_nand",
  257. .num_resources = ARRAY_SIZE(palmtx_nand_resource),
  258. .resource = palmtx_nand_resource,
  259. .id = -1,
  260. .dev = {
  261. .platform_data = &palmtx_nand_platdata,
  262. }
  263. };
  264. static void __init palmtx_nand_init(void)
  265. {
  266. platform_device_register(&palmtx_nand);
  267. }
  268. #else
  269. static inline void palmtx_nand_init(void) {}
  270. #endif
  271. /******************************************************************************
  272. * Machine init
  273. ******************************************************************************/
  274. static struct map_desc palmtx_io_desc[] __initdata = {
  275. {
  276. .virtual = (unsigned long)PALMTX_PCMCIA_VIRT,
  277. .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
  278. .length = PALMTX_PCMCIA_SIZE,
  279. .type = MT_DEVICE,
  280. }, {
  281. .virtual = (unsigned long)PALMTX_NAND_ALE_VIRT,
  282. .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
  283. .length = SZ_1M,
  284. .type = MT_DEVICE,
  285. }, {
  286. .virtual = (unsigned long)PALMTX_NAND_CLE_VIRT,
  287. .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
  288. .length = SZ_1M,
  289. .type = MT_DEVICE,
  290. }
  291. };
  292. static void __init palmtx_map_io(void)
  293. {
  294. pxa27x_map_io();
  295. iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
  296. }
  297. static void __init palmtx_init(void)
  298. {
  299. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
  300. pxa_set_ffuart_info(NULL);
  301. pxa_set_btuart_info(NULL);
  302. pxa_set_stuart_info(NULL);
  303. palm27x_mmc_init(GPIO_NR_PALMTX_SD_DETECT_N, GPIO_NR_PALMTX_SD_READONLY,
  304. GPIO_NR_PALMTX_SD_POWER, 0);
  305. palm27x_pm_init(PALMTX_STR_BASE);
  306. palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
  307. palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N,
  308. GPIO_NR_PALMTX_USB_PULLUP, 1);
  309. palm27x_irda_init(GPIO_NR_PALMTX_IR_DISABLE);
  310. palm27x_ac97_init(PALMTX_BAT_MIN_VOLTAGE, PALMTX_BAT_MAX_VOLTAGE,
  311. GPIO_NR_PALMTX_EARPHONE_DETECT, 95);
  312. palm27x_pwm_init(GPIO_NR_PALMTX_BL_POWER, GPIO_NR_PALMTX_LCD_POWER);
  313. palm27x_power_init(GPIO_NR_PALMTX_POWER_DETECT, -1);
  314. palm27x_pmic_init();
  315. palmtx_kpc_init();
  316. palmtx_keys_init();
  317. palmtx_nor_init();
  318. palmtx_nand_init();
  319. }
  320. MACHINE_START(PALMTX, "Palm T|X")
  321. .atag_offset = 0x100,
  322. .map_io = palmtx_map_io,
  323. .nr_irqs = PXA_NR_IRQS,
  324. .init_irq = pxa27x_init_irq,
  325. .handle_irq = pxa27x_handle_irq,
  326. .init_time = pxa_timer_init,
  327. .init_machine = palmtx_init,
  328. .restart = pxa_restart,
  329. MACHINE_END