palmtx.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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 "pxa27x.h"
  38. #include <mach/audio.h>
  39. #include <mach/palmtx.h>
  40. #include <linux/platform_data/mmc-pxamci.h>
  41. #include <linux/platform_data/video-pxafb.h>
  42. #include <linux/platform_data/irda-pxaficp.h>
  43. #include <linux/platform_data/keypad-pxa27x.h>
  44. #include "udc.h"
  45. #include <linux/platform_data/asoc-palm27x.h>
  46. #include "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 const 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 matrix_keymap_data palmtx_matrix_keymap_data = {
  171. .keymap = palmtx_matrix_keys,
  172. .keymap_size = ARRAY_SIZE(palmtx_matrix_keys),
  173. };
  174. static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
  175. .matrix_key_rows = 4,
  176. .matrix_key_cols = 3,
  177. .matrix_keymap_data = &palmtx_matrix_keymap_data,
  178. .debounce_interval = 30,
  179. };
  180. static void __init palmtx_kpc_init(void)
  181. {
  182. pxa_set_keypad_info(&palmtx_keypad_platform_data);
  183. }
  184. #else
  185. static inline void palmtx_kpc_init(void) {}
  186. #endif
  187. /******************************************************************************
  188. * GPIO keys
  189. ******************************************************************************/
  190. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  191. static struct gpio_keys_button palmtx_pxa_buttons[] = {
  192. {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  193. };
  194. static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
  195. .buttons = palmtx_pxa_buttons,
  196. .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
  197. };
  198. static struct platform_device palmtx_pxa_keys = {
  199. .name = "gpio-keys",
  200. .id = -1,
  201. .dev = {
  202. .platform_data = &palmtx_pxa_keys_data,
  203. },
  204. };
  205. static void __init palmtx_keys_init(void)
  206. {
  207. platform_device_register(&palmtx_pxa_keys);
  208. }
  209. #else
  210. static inline void palmtx_keys_init(void) {}
  211. #endif
  212. /******************************************************************************
  213. * NAND Flash
  214. ******************************************************************************/
  215. #if defined(CONFIG_MTD_NAND_PLATFORM) || \
  216. defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  217. static void palmtx_nand_cmd_ctl(struct mtd_info *mtd, int cmd,
  218. unsigned int ctrl)
  219. {
  220. struct nand_chip *this = mtd_to_nand(mtd);
  221. char __iomem *nandaddr = this->IO_ADDR_W;
  222. if (cmd == NAND_CMD_NONE)
  223. return;
  224. if (ctrl & NAND_CLE)
  225. writeb(cmd, PALMTX_NAND_CLE_VIRT);
  226. else if (ctrl & NAND_ALE)
  227. writeb(cmd, PALMTX_NAND_ALE_VIRT);
  228. else
  229. writeb(cmd, nandaddr);
  230. }
  231. static struct mtd_partition palmtx_partition_info[] = {
  232. [0] = {
  233. .name = "palmtx-0",
  234. .offset = 0,
  235. .size = MTDPART_SIZ_FULL
  236. },
  237. };
  238. struct platform_nand_data palmtx_nand_platdata = {
  239. .chip = {
  240. .nr_chips = 1,
  241. .chip_offset = 0,
  242. .nr_partitions = ARRAY_SIZE(palmtx_partition_info),
  243. .partitions = palmtx_partition_info,
  244. .chip_delay = 20,
  245. },
  246. .ctrl = {
  247. .cmd_ctrl = palmtx_nand_cmd_ctl,
  248. },
  249. };
  250. static struct resource palmtx_nand_resource[] = {
  251. [0] = {
  252. .start = PXA_CS1_PHYS,
  253. .end = PXA_CS1_PHYS + SZ_1M - 1,
  254. .flags = IORESOURCE_MEM,
  255. },
  256. };
  257. static struct platform_device palmtx_nand = {
  258. .name = "gen_nand",
  259. .num_resources = ARRAY_SIZE(palmtx_nand_resource),
  260. .resource = palmtx_nand_resource,
  261. .id = -1,
  262. .dev = {
  263. .platform_data = &palmtx_nand_platdata,
  264. }
  265. };
  266. static void __init palmtx_nand_init(void)
  267. {
  268. platform_device_register(&palmtx_nand);
  269. }
  270. #else
  271. static inline void palmtx_nand_init(void) {}
  272. #endif
  273. /******************************************************************************
  274. * Machine init
  275. ******************************************************************************/
  276. static struct map_desc palmtx_io_desc[] __initdata = {
  277. {
  278. .virtual = (unsigned long)PALMTX_PCMCIA_VIRT,
  279. .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
  280. .length = PALMTX_PCMCIA_SIZE,
  281. .type = MT_DEVICE,
  282. }, {
  283. .virtual = (unsigned long)PALMTX_NAND_ALE_VIRT,
  284. .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
  285. .length = SZ_1M,
  286. .type = MT_DEVICE,
  287. }, {
  288. .virtual = (unsigned long)PALMTX_NAND_CLE_VIRT,
  289. .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
  290. .length = SZ_1M,
  291. .type = MT_DEVICE,
  292. }
  293. };
  294. static void __init palmtx_map_io(void)
  295. {
  296. pxa27x_map_io();
  297. iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
  298. }
  299. static void __init palmtx_init(void)
  300. {
  301. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
  302. pxa_set_ffuart_info(NULL);
  303. pxa_set_btuart_info(NULL);
  304. pxa_set_stuart_info(NULL);
  305. palm27x_mmc_init(GPIO_NR_PALMTX_SD_DETECT_N, GPIO_NR_PALMTX_SD_READONLY,
  306. GPIO_NR_PALMTX_SD_POWER, 0);
  307. palm27x_pm_init(PALMTX_STR_BASE);
  308. palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
  309. palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N,
  310. GPIO_NR_PALMTX_USB_PULLUP, 1);
  311. palm27x_irda_init(GPIO_NR_PALMTX_IR_DISABLE);
  312. palm27x_ac97_init(PALMTX_BAT_MIN_VOLTAGE, PALMTX_BAT_MAX_VOLTAGE,
  313. GPIO_NR_PALMTX_EARPHONE_DETECT, 95);
  314. palm27x_pwm_init(GPIO_NR_PALMTX_BL_POWER, GPIO_NR_PALMTX_LCD_POWER);
  315. palm27x_power_init(GPIO_NR_PALMTX_POWER_DETECT, -1);
  316. palm27x_pmic_init();
  317. palmtx_kpc_init();
  318. palmtx_keys_init();
  319. palmtx_nor_init();
  320. palmtx_nand_init();
  321. }
  322. MACHINE_START(PALMTX, "Palm T|X")
  323. .atag_offset = 0x100,
  324. .map_io = palmtx_map_io,
  325. .nr_irqs = PXA_NR_IRQS,
  326. .init_irq = pxa27x_init_irq,
  327. .handle_irq = pxa27x_handle_irq,
  328. .init_time = pxa_timer_init,
  329. .init_machine = palmtx_init,
  330. .restart = pxa_restart,
  331. MACHINE_END