palmld.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Hardware definitions for Palm LifeDrive
  4. *
  5. * Author: Marek Vasut <[email protected]>
  6. *
  7. * Based on work of:
  8. * Alex Osborne <[email protected]>
  9. *
  10. * (find more info at www.hackndev.com)
  11. */
  12. #include <linux/platform_device.h>
  13. #include <linux/delay.h>
  14. #include <linux/irq.h>
  15. #include <linux/gpio_keys.h>
  16. #include <linux/input.h>
  17. #include <linux/pda_power.h>
  18. #include <linux/pwm_backlight.h>
  19. #include <linux/gpio.h>
  20. #include <linux/wm97xx.h>
  21. #include <linux/power_supply.h>
  22. #include <linux/mtd/mtd.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <linux/mtd/physmap.h>
  25. #include <asm/mach-types.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include "pxa27x.h"
  29. #include "palmld.h"
  30. #include <linux/platform_data/asoc-pxa.h>
  31. #include <linux/platform_data/mmc-pxamci.h>
  32. #include <linux/platform_data/video-pxafb.h>
  33. #include <linux/platform_data/irda-pxaficp.h>
  34. #include <linux/platform_data/keypad-pxa27x.h>
  35. #include <linux/platform_data/asoc-palm27x.h>
  36. #include "palm27x.h"
  37. #include "generic.h"
  38. #include "devices.h"
  39. /******************************************************************************
  40. * Pin configuration
  41. ******************************************************************************/
  42. static unsigned long palmld_pin_config[] __initdata = {
  43. /* MMC */
  44. GPIO32_MMC_CLK,
  45. GPIO92_MMC_DAT_0,
  46. GPIO109_MMC_DAT_1,
  47. GPIO110_MMC_DAT_2,
  48. GPIO111_MMC_DAT_3,
  49. GPIO112_MMC_CMD,
  50. GPIO14_GPIO, /* SD detect */
  51. GPIO114_GPIO, /* SD power */
  52. GPIO116_GPIO, /* SD r/o switch */
  53. /* AC97 */
  54. GPIO28_AC97_BITCLK,
  55. GPIO29_AC97_SDATA_IN_0,
  56. GPIO30_AC97_SDATA_OUT,
  57. GPIO31_AC97_SYNC,
  58. GPIO89_AC97_SYSCLK,
  59. GPIO95_AC97_nRESET,
  60. /* IrDA */
  61. GPIO108_GPIO, /* ir disable */
  62. GPIO46_FICP_RXD,
  63. GPIO47_FICP_TXD,
  64. /* MATRIX KEYPAD */
  65. GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
  66. GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
  67. GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
  68. GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
  69. GPIO103_KP_MKOUT_0,
  70. GPIO104_KP_MKOUT_1,
  71. GPIO105_KP_MKOUT_2,
  72. /* LCD */
  73. GPIOxx_LCD_TFT_16BPP,
  74. /* PWM */
  75. GPIO16_PWM0_OUT,
  76. /* GPIO KEYS */
  77. GPIO10_GPIO, /* hotsync button */
  78. GPIO12_GPIO, /* power switch */
  79. GPIO15_GPIO, /* lock switch */
  80. /* LEDs */
  81. GPIO52_GPIO, /* green led */
  82. GPIO94_GPIO, /* orange led */
  83. /* PCMCIA */
  84. GPIO48_nPOE,
  85. GPIO49_nPWE,
  86. GPIO50_nPIOR,
  87. GPIO51_nPIOW,
  88. GPIO85_nPCE_1,
  89. GPIO54_nPCE_2,
  90. GPIO79_PSKTSEL,
  91. GPIO55_nPREG,
  92. GPIO56_nPWAIT,
  93. GPIO57_nIOIS16,
  94. GPIO36_GPIO, /* wifi power */
  95. GPIO38_GPIO, /* wifi ready */
  96. GPIO81_GPIO, /* wifi reset */
  97. /* FFUART */
  98. GPIO34_FFUART_RXD,
  99. GPIO39_FFUART_TXD,
  100. /* HDD */
  101. GPIO98_GPIO, /* HDD reset */
  102. GPIO115_GPIO, /* HDD power */
  103. /* MISC */
  104. GPIO13_GPIO, /* earphone detect */
  105. };
  106. /******************************************************************************
  107. * NOR Flash
  108. ******************************************************************************/
  109. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  110. static struct mtd_partition palmld_partitions[] = {
  111. {
  112. .name = "Flash",
  113. .offset = 0x00000000,
  114. .size = MTDPART_SIZ_FULL,
  115. .mask_flags = 0
  116. }
  117. };
  118. static struct physmap_flash_data palmld_flash_data[] = {
  119. {
  120. .width = 2, /* bankwidth in bytes */
  121. .parts = palmld_partitions,
  122. .nr_parts = ARRAY_SIZE(palmld_partitions)
  123. }
  124. };
  125. static struct resource palmld_flash_resource = {
  126. .start = PXA_CS0_PHYS,
  127. .end = PXA_CS0_PHYS + SZ_4M - 1,
  128. .flags = IORESOURCE_MEM,
  129. };
  130. static struct platform_device palmld_flash = {
  131. .name = "physmap-flash",
  132. .id = 0,
  133. .resource = &palmld_flash_resource,
  134. .num_resources = 1,
  135. .dev = {
  136. .platform_data = palmld_flash_data,
  137. },
  138. };
  139. static void __init palmld_nor_init(void)
  140. {
  141. platform_device_register(&palmld_flash);
  142. }
  143. #else
  144. static inline void palmld_nor_init(void) {}
  145. #endif
  146. /******************************************************************************
  147. * GPIO keyboard
  148. ******************************************************************************/
  149. #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
  150. static const unsigned int palmld_matrix_keys[] = {
  151. KEY(0, 1, KEY_F2),
  152. KEY(0, 2, KEY_UP),
  153. KEY(1, 0, KEY_F3),
  154. KEY(1, 1, KEY_F4),
  155. KEY(1, 2, KEY_RIGHT),
  156. KEY(2, 0, KEY_F1),
  157. KEY(2, 1, KEY_F5),
  158. KEY(2, 2, KEY_DOWN),
  159. KEY(3, 0, KEY_F6),
  160. KEY(3, 1, KEY_ENTER),
  161. KEY(3, 2, KEY_LEFT),
  162. };
  163. static struct matrix_keymap_data palmld_matrix_keymap_data = {
  164. .keymap = palmld_matrix_keys,
  165. .keymap_size = ARRAY_SIZE(palmld_matrix_keys),
  166. };
  167. static struct pxa27x_keypad_platform_data palmld_keypad_platform_data = {
  168. .matrix_key_rows = 4,
  169. .matrix_key_cols = 3,
  170. .matrix_keymap_data = &palmld_matrix_keymap_data,
  171. .debounce_interval = 30,
  172. };
  173. static void __init palmld_kpc_init(void)
  174. {
  175. pxa_set_keypad_info(&palmld_keypad_platform_data);
  176. }
  177. #else
  178. static inline void palmld_kpc_init(void) {}
  179. #endif
  180. /******************************************************************************
  181. * GPIO keys
  182. ******************************************************************************/
  183. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  184. static struct gpio_keys_button palmld_pxa_buttons[] = {
  185. {KEY_F8, GPIO_NR_PALMLD_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  186. {KEY_F9, GPIO_NR_PALMLD_LOCK_SWITCH, 0, "Lock Switch" },
  187. {KEY_POWER, GPIO_NR_PALMLD_POWER_SWITCH, 0, "Power Switch" },
  188. };
  189. static struct gpio_keys_platform_data palmld_pxa_keys_data = {
  190. .buttons = palmld_pxa_buttons,
  191. .nbuttons = ARRAY_SIZE(palmld_pxa_buttons),
  192. };
  193. static struct platform_device palmld_pxa_keys = {
  194. .name = "gpio-keys",
  195. .id = -1,
  196. .dev = {
  197. .platform_data = &palmld_pxa_keys_data,
  198. },
  199. };
  200. static void __init palmld_keys_init(void)
  201. {
  202. platform_device_register(&palmld_pxa_keys);
  203. }
  204. #else
  205. static inline void palmld_keys_init(void) {}
  206. #endif
  207. /******************************************************************************
  208. * LEDs
  209. ******************************************************************************/
  210. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  211. struct gpio_led gpio_leds[] = {
  212. {
  213. .name = "palmld:green:led",
  214. .default_trigger = "none",
  215. .gpio = GPIO_NR_PALMLD_LED_GREEN,
  216. }, {
  217. .name = "palmld:amber:led",
  218. .default_trigger = "none",
  219. .gpio = GPIO_NR_PALMLD_LED_AMBER,
  220. },
  221. };
  222. static struct gpio_led_platform_data gpio_led_info = {
  223. .leds = gpio_leds,
  224. .num_leds = ARRAY_SIZE(gpio_leds),
  225. };
  226. static struct platform_device palmld_leds = {
  227. .name = "leds-gpio",
  228. .id = -1,
  229. .dev = {
  230. .platform_data = &gpio_led_info,
  231. }
  232. };
  233. static void __init palmld_leds_init(void)
  234. {
  235. platform_device_register(&palmld_leds);
  236. }
  237. #else
  238. static inline void palmld_leds_init(void) {}
  239. #endif
  240. /******************************************************************************
  241. * HDD
  242. ******************************************************************************/
  243. #if defined(CONFIG_PATA_PALMLD) || defined(CONFIG_PATA_PALMLD_MODULE)
  244. static struct resource palmld_ide_resources[] = {
  245. DEFINE_RES_MEM(PALMLD_IDE_PHYS, 0x1000),
  246. };
  247. static struct platform_device palmld_ide_device = {
  248. .name = "pata_palmld",
  249. .id = -1,
  250. .resource = palmld_ide_resources,
  251. .num_resources = ARRAY_SIZE(palmld_ide_resources),
  252. };
  253. static struct gpiod_lookup_table palmld_ide_gpio_table = {
  254. .dev_id = "pata_palmld",
  255. .table = {
  256. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_IDE_PWEN,
  257. "power", GPIO_ACTIVE_HIGH),
  258. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_IDE_RESET,
  259. "reset", GPIO_ACTIVE_LOW),
  260. { },
  261. },
  262. };
  263. static void __init palmld_ide_init(void)
  264. {
  265. gpiod_add_lookup_table(&palmld_ide_gpio_table);
  266. platform_device_register(&palmld_ide_device);
  267. }
  268. #else
  269. static inline void palmld_ide_init(void) {}
  270. #endif
  271. /******************************************************************************
  272. * Machine init
  273. ******************************************************************************/
  274. static struct map_desc palmld_io_desc[] __initdata = {
  275. {
  276. .virtual = PALMLD_IDE_VIRT,
  277. .pfn = __phys_to_pfn(PALMLD_IDE_PHYS),
  278. .length = PALMLD_IDE_SIZE,
  279. .type = MT_DEVICE
  280. },
  281. {
  282. .virtual = PALMLD_USB_VIRT,
  283. .pfn = __phys_to_pfn(PALMLD_USB_PHYS),
  284. .length = PALMLD_USB_SIZE,
  285. .type = MT_DEVICE
  286. },
  287. };
  288. static void __init palmld_map_io(void)
  289. {
  290. pxa27x_map_io();
  291. iotable_init(palmld_io_desc, ARRAY_SIZE(palmld_io_desc));
  292. }
  293. static struct gpiod_lookup_table palmld_mci_gpio_table = {
  294. .dev_id = "pxa2xx-mci.0",
  295. .table = {
  296. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_SD_DETECT_N,
  297. "cd", GPIO_ACTIVE_LOW),
  298. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_SD_READONLY,
  299. "wp", GPIO_ACTIVE_LOW),
  300. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_SD_POWER,
  301. "power", GPIO_ACTIVE_HIGH),
  302. { },
  303. },
  304. };
  305. static struct gpiod_lookup_table palmld_wm97xx_touch_gpio_table = {
  306. .dev_id = "wm97xx-touch",
  307. .table = {
  308. GPIO_LOOKUP("gpio-pxa", 27, "touch", GPIO_ACTIVE_HIGH),
  309. { },
  310. },
  311. };
  312. static void __init palmld_init(void)
  313. {
  314. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config));
  315. pxa_set_ffuart_info(NULL);
  316. pxa_set_btuart_info(NULL);
  317. pxa_set_stuart_info(NULL);
  318. palm27x_mmc_init(&palmld_mci_gpio_table);
  319. gpiod_add_lookup_table(&palmld_wm97xx_touch_gpio_table);
  320. palm27x_pm_init(PALMLD_STR_BASE);
  321. palm27x_lcd_init(-1, &palm_320x480_lcd_mode);
  322. palm27x_irda_init(GPIO_NR_PALMLD_IR_DISABLE);
  323. palm27x_ac97_init(PALMLD_BAT_MIN_VOLTAGE, PALMLD_BAT_MAX_VOLTAGE,
  324. GPIO_NR_PALMLD_EARPHONE_DETECT, 95);
  325. palm27x_pwm_init(GPIO_NR_PALMLD_BL_POWER, GPIO_NR_PALMLD_LCD_POWER);
  326. palm27x_power_init(GPIO_NR_PALMLD_POWER_DETECT,
  327. GPIO_NR_PALMLD_USB_DETECT_N);
  328. palm27x_pmic_init();
  329. palmld_kpc_init();
  330. palmld_keys_init();
  331. palmld_nor_init();
  332. palmld_leds_init();
  333. palmld_ide_init();
  334. }
  335. MACHINE_START(PALMLD, "Palm LifeDrive")
  336. .atag_offset = 0x100,
  337. .map_io = palmld_map_io,
  338. .nr_irqs = PXA_NR_IRQS,
  339. .init_irq = pxa27x_init_irq,
  340. .handle_irq = pxa27x_handle_irq,
  341. .init_time = pxa_timer_init,
  342. .init_machine = palmld_init,
  343. .restart = pxa_restart,
  344. MACHINE_END