palmtx.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Hardware definitions for PalmTX
  4. *
  5. * Author: Marek Vasut <[email protected]>
  6. *
  7. * Based on work of:
  8. * Alex Osborne <[email protected]>
  9. * Cristiano P. <[email protected]>
  10. * Jan Herman <[email protected]>
  11. * Michal Hrusecky
  12. *
  13. * (find more info at www.hackndev.com)
  14. */
  15. #include <linux/platform_device.h>
  16. #include <linux/delay.h>
  17. #include <linux/irq.h>
  18. #include <linux/gpio_keys.h>
  19. #include <linux/input.h>
  20. #include <linux/pda_power.h>
  21. #include <linux/pwm_backlight.h>
  22. #include <linux/gpio.h>
  23. #include <linux/wm97xx.h>
  24. #include <linux/power_supply.h>
  25. #include <linux/mtd/platnand.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/physmap.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include "pxa27x.h"
  32. #include <linux/platform_data/asoc-pxa.h>
  33. #include "palmtx.h"
  34. #include <linux/platform_data/mmc-pxamci.h>
  35. #include <linux/platform_data/video-pxafb.h>
  36. #include <linux/platform_data/irda-pxaficp.h>
  37. #include <linux/platform_data/keypad-pxa27x.h>
  38. #include "udc.h"
  39. #include <linux/platform_data/asoc-palm27x.h>
  40. #include "palm27x.h"
  41. #include "generic.h"
  42. #include "devices.h"
  43. /******************************************************************************
  44. * Pin configuration
  45. ******************************************************************************/
  46. static unsigned long palmtx_pin_config[] __initdata = {
  47. /* MMC */
  48. GPIO32_MMC_CLK,
  49. GPIO92_MMC_DAT_0,
  50. GPIO109_MMC_DAT_1,
  51. GPIO110_MMC_DAT_2,
  52. GPIO111_MMC_DAT_3,
  53. GPIO112_MMC_CMD,
  54. GPIO14_GPIO, /* SD detect */
  55. GPIO114_GPIO, /* SD power */
  56. GPIO115_GPIO, /* SD r/o switch */
  57. /* AC97 */
  58. GPIO28_AC97_BITCLK,
  59. GPIO29_AC97_SDATA_IN_0,
  60. GPIO30_AC97_SDATA_OUT,
  61. GPIO31_AC97_SYNC,
  62. GPIO89_AC97_SYSCLK,
  63. GPIO95_AC97_nRESET,
  64. /* IrDA */
  65. GPIO40_GPIO, /* ir disable */
  66. GPIO46_FICP_RXD,
  67. GPIO47_FICP_TXD,
  68. /* PWM */
  69. GPIO16_PWM0_OUT,
  70. /* USB */
  71. GPIO13_GPIO, /* usb detect */
  72. GPIO93_GPIO, /* usb power */
  73. /* PCMCIA */
  74. GPIO48_nPOE,
  75. GPIO49_nPWE,
  76. GPIO50_nPIOR,
  77. GPIO51_nPIOW,
  78. GPIO85_nPCE_1,
  79. GPIO54_nPCE_2,
  80. GPIO79_PSKTSEL,
  81. GPIO55_nPREG,
  82. GPIO56_nPWAIT,
  83. GPIO57_nIOIS16,
  84. GPIO94_GPIO, /* wifi power 1 */
  85. GPIO108_GPIO, /* wifi power 2 */
  86. GPIO116_GPIO, /* wifi ready */
  87. /* MATRIX KEYPAD */
  88. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  89. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  90. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  91. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  92. GPIO103_KP_MKOUT_0,
  93. GPIO104_KP_MKOUT_1,
  94. GPIO105_KP_MKOUT_2,
  95. /* LCD */
  96. GPIOxx_LCD_TFT_16BPP,
  97. /* FFUART */
  98. GPIO34_FFUART_RXD,
  99. GPIO39_FFUART_TXD,
  100. /* NAND */
  101. GPIO15_nCS_1,
  102. GPIO18_RDY,
  103. /* MISC. */
  104. GPIO10_GPIO, /* hotsync button */
  105. GPIO12_GPIO, /* power detect */
  106. GPIO107_GPIO, /* earphone detect */
  107. };
  108. /******************************************************************************
  109. * NOR Flash
  110. ******************************************************************************/
  111. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  112. static struct mtd_partition palmtx_partitions[] = {
  113. {
  114. .name = "Flash",
  115. .offset = 0x00000000,
  116. .size = MTDPART_SIZ_FULL,
  117. .mask_flags = 0
  118. }
  119. };
  120. static struct physmap_flash_data palmtx_flash_data[] = {
  121. {
  122. .width = 2, /* bankwidth in bytes */
  123. .parts = palmtx_partitions,
  124. .nr_parts = ARRAY_SIZE(palmtx_partitions)
  125. }
  126. };
  127. static struct resource palmtx_flash_resource = {
  128. .start = PXA_CS0_PHYS,
  129. .end = PXA_CS0_PHYS + SZ_8M - 1,
  130. .flags = IORESOURCE_MEM,
  131. };
  132. static struct platform_device palmtx_flash = {
  133. .name = "physmap-flash",
  134. .id = 0,
  135. .resource = &palmtx_flash_resource,
  136. .num_resources = 1,
  137. .dev = {
  138. .platform_data = palmtx_flash_data,
  139. },
  140. };
  141. static void __init palmtx_nor_init(void)
  142. {
  143. platform_device_register(&palmtx_flash);
  144. }
  145. #else
  146. static inline void palmtx_nor_init(void) {}
  147. #endif
  148. /******************************************************************************
  149. * GPIO keyboard
  150. ******************************************************************************/
  151. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  152. static const unsigned int palmtx_matrix_keys[] = {
  153. KEY(0, 0, KEY_POWER),
  154. KEY(0, 1, KEY_F1),
  155. KEY(0, 2, KEY_ENTER),
  156. KEY(1, 0, KEY_F2),
  157. KEY(1, 1, KEY_F3),
  158. KEY(1, 2, KEY_F4),
  159. KEY(2, 0, KEY_UP),
  160. KEY(2, 2, KEY_DOWN),
  161. KEY(3, 0, KEY_RIGHT),
  162. KEY(3, 2, KEY_LEFT),
  163. };
  164. static struct matrix_keymap_data palmtx_matrix_keymap_data = {
  165. .keymap = palmtx_matrix_keys,
  166. .keymap_size = ARRAY_SIZE(palmtx_matrix_keys),
  167. };
  168. static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
  169. .matrix_key_rows = 4,
  170. .matrix_key_cols = 3,
  171. .matrix_keymap_data = &palmtx_matrix_keymap_data,
  172. .debounce_interval = 30,
  173. };
  174. static void __init palmtx_kpc_init(void)
  175. {
  176. pxa_set_keypad_info(&palmtx_keypad_platform_data);
  177. }
  178. #else
  179. static inline void palmtx_kpc_init(void) {}
  180. #endif
  181. /******************************************************************************
  182. * GPIO keys
  183. ******************************************************************************/
  184. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  185. static struct gpio_keys_button palmtx_pxa_buttons[] = {
  186. {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  187. };
  188. static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
  189. .buttons = palmtx_pxa_buttons,
  190. .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
  191. };
  192. static struct platform_device palmtx_pxa_keys = {
  193. .name = "gpio-keys",
  194. .id = -1,
  195. .dev = {
  196. .platform_data = &palmtx_pxa_keys_data,
  197. },
  198. };
  199. static void __init palmtx_keys_init(void)
  200. {
  201. platform_device_register(&palmtx_pxa_keys);
  202. }
  203. #else
  204. static inline void palmtx_keys_init(void) {}
  205. #endif
  206. /******************************************************************************
  207. * NAND Flash
  208. ******************************************************************************/
  209. #if defined(CONFIG_MTD_NAND_PLATFORM) || \
  210. defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
  211. static void palmtx_nand_cmd_ctl(struct nand_chip *this, int cmd,
  212. unsigned int ctrl)
  213. {
  214. char __iomem *nandaddr = this->legacy.IO_ADDR_W;
  215. if (cmd == NAND_CMD_NONE)
  216. return;
  217. if (ctrl & NAND_CLE)
  218. writeb(cmd, PALMTX_NAND_CLE_VIRT);
  219. else if (ctrl & NAND_ALE)
  220. writeb(cmd, PALMTX_NAND_ALE_VIRT);
  221. else
  222. writeb(cmd, nandaddr);
  223. }
  224. static struct mtd_partition palmtx_partition_info[] = {
  225. [0] = {
  226. .name = "palmtx-0",
  227. .offset = 0,
  228. .size = MTDPART_SIZ_FULL
  229. },
  230. };
  231. struct platform_nand_data palmtx_nand_platdata = {
  232. .chip = {
  233. .nr_chips = 1,
  234. .chip_offset = 0,
  235. .nr_partitions = ARRAY_SIZE(palmtx_partition_info),
  236. .partitions = palmtx_partition_info,
  237. .chip_delay = 20,
  238. },
  239. .ctrl = {
  240. .cmd_ctrl = palmtx_nand_cmd_ctl,
  241. },
  242. };
  243. static struct resource palmtx_nand_resource[] = {
  244. [0] = {
  245. .start = PXA_CS1_PHYS,
  246. .end = PXA_CS1_PHYS + SZ_1M - 1,
  247. .flags = IORESOURCE_MEM,
  248. },
  249. };
  250. static struct platform_device palmtx_nand = {
  251. .name = "gen_nand",
  252. .num_resources = ARRAY_SIZE(palmtx_nand_resource),
  253. .resource = palmtx_nand_resource,
  254. .id = -1,
  255. .dev = {
  256. .platform_data = &palmtx_nand_platdata,
  257. }
  258. };
  259. static void __init palmtx_nand_init(void)
  260. {
  261. platform_device_register(&palmtx_nand);
  262. }
  263. #else
  264. static inline void palmtx_nand_init(void) {}
  265. #endif
  266. /******************************************************************************
  267. * Machine init
  268. ******************************************************************************/
  269. static struct map_desc palmtx_io_desc[] __initdata = {
  270. {
  271. .virtual = (unsigned long)PALMTX_PCMCIA_VIRT,
  272. .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
  273. .length = PALMTX_PCMCIA_SIZE,
  274. .type = MT_DEVICE,
  275. }, {
  276. .virtual = (unsigned long)PALMTX_NAND_ALE_VIRT,
  277. .pfn = __phys_to_pfn(PALMTX_NAND_ALE_PHYS),
  278. .length = SZ_1M,
  279. .type = MT_DEVICE,
  280. }, {
  281. .virtual = (unsigned long)PALMTX_NAND_CLE_VIRT,
  282. .pfn = __phys_to_pfn(PALMTX_NAND_CLE_PHYS),
  283. .length = SZ_1M,
  284. .type = MT_DEVICE,
  285. }
  286. };
  287. static void __init palmtx_map_io(void)
  288. {
  289. pxa27x_map_io();
  290. iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
  291. }
  292. static struct gpiod_lookup_table palmtx_mci_gpio_table = {
  293. .dev_id = "pxa2xx-mci.0",
  294. .table = {
  295. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_DETECT_N,
  296. "cd", GPIO_ACTIVE_LOW),
  297. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_READONLY,
  298. "wp", GPIO_ACTIVE_LOW),
  299. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_POWER,
  300. "power", GPIO_ACTIVE_HIGH),
  301. { },
  302. },
  303. };
  304. static struct gpiod_lookup_table palmtx_wm97xx_touch_gpio_table = {
  305. .dev_id = "wm97xx-touch",
  306. .table = {
  307. GPIO_LOOKUP("gpio-pxa", 27, "touch", GPIO_ACTIVE_HIGH),
  308. { },
  309. },
  310. };
  311. static void __init palmtx_init(void)
  312. {
  313. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
  314. pxa_set_ffuart_info(NULL);
  315. pxa_set_btuart_info(NULL);
  316. pxa_set_stuart_info(NULL);
  317. palm27x_mmc_init(&palmtx_mci_gpio_table);
  318. gpiod_add_lookup_table(&palmtx_wm97xx_touch_gpio_table);
  319. palm27x_pm_init(PALMTX_STR_BASE);
  320. palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
  321. palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N,
  322. GPIO_NR_PALMTX_USB_PULLUP, 1);
  323. palm27x_irda_init(GPIO_NR_PALMTX_IR_DISABLE);
  324. palm27x_ac97_init(PALMTX_BAT_MIN_VOLTAGE, PALMTX_BAT_MAX_VOLTAGE,
  325. GPIO_NR_PALMTX_EARPHONE_DETECT, 95);
  326. palm27x_pwm_init(GPIO_NR_PALMTX_BL_POWER, GPIO_NR_PALMTX_LCD_POWER);
  327. palm27x_power_init(GPIO_NR_PALMTX_POWER_DETECT, -1);
  328. palm27x_pmic_init();
  329. palmtx_kpc_init();
  330. palmtx_keys_init();
  331. palmtx_nor_init();
  332. palmtx_nand_init();
  333. }
  334. MACHINE_START(PALMTX, "Palm T|X")
  335. .atag_offset = 0x100,
  336. .map_io = palmtx_map_io,
  337. .nr_irqs = PXA_NR_IRQS,
  338. .init_irq = pxa27x_init_irq,
  339. .handle_irq = pxa27x_handle_irq,
  340. .init_time = pxa_timer_init,
  341. .init_machine = palmtx_init,
  342. .restart = pxa_restart,
  343. MACHINE_END