palmtc.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-pxa/palmtc.c
  4. *
  5. * Support for the Palm Tungsten|C
  6. *
  7. * Author: Marek Vasut <[email protected]>
  8. *
  9. * Based on work of:
  10. * Petr Blaha <[email protected]>
  11. * Chetan S. Kumar <[email protected]>
  12. */
  13. #include <linux/platform_device.h>
  14. #include <linux/delay.h>
  15. #include <linux/irq.h>
  16. #include <linux/input.h>
  17. #include <linux/pwm.h>
  18. #include <linux/pwm_backlight.h>
  19. #include <linux/gpio/machine.h>
  20. #include <linux/input/matrix_keypad.h>
  21. #include <linux/ucb1400.h>
  22. #include <linux/power_supply.h>
  23. #include <linux/gpio_keys.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 "pxa25x.h"
  29. #include <linux/platform_data/asoc-pxa.h>
  30. #include "palmtc.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 "udc.h"
  35. #include "generic.h"
  36. #include "devices.h"
  37. /******************************************************************************
  38. * Pin configuration
  39. ******************************************************************************/
  40. static unsigned long palmtc_pin_config[] __initdata = {
  41. /* MMC */
  42. GPIO6_MMC_CLK,
  43. GPIO8_MMC_CS0,
  44. GPIO12_GPIO, /* detect */
  45. GPIO32_GPIO, /* power */
  46. GPIO54_GPIO, /* r/o switch */
  47. /* PCMCIA */
  48. GPIO52_nPCE_1,
  49. GPIO53_nPCE_2,
  50. GPIO50_nPIOR,
  51. GPIO51_nPIOW,
  52. GPIO49_nPWE,
  53. GPIO48_nPOE,
  54. GPIO52_nPCE_1,
  55. GPIO53_nPCE_2,
  56. GPIO57_nIOIS16,
  57. GPIO56_nPWAIT,
  58. /* AC97 */
  59. GPIO28_AC97_BITCLK,
  60. GPIO29_AC97_SDATA_IN_0,
  61. GPIO30_AC97_SDATA_OUT,
  62. GPIO31_AC97_SYNC,
  63. /* IrDA */
  64. GPIO45_GPIO, /* ir disable */
  65. GPIO46_FICP_RXD,
  66. GPIO47_FICP_TXD,
  67. /* PWM */
  68. GPIO17_PWM1_OUT,
  69. /* USB */
  70. GPIO4_GPIO, /* detect */
  71. GPIO36_GPIO, /* pullup */
  72. /* LCD */
  73. GPIOxx_LCD_TFT_16BPP,
  74. /* MATRIX KEYPAD */
  75. GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 0 */
  76. GPIO9_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 1 */
  77. GPIO10_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 2 */
  78. GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 3 */
  79. GPIO18_GPIO | MFP_LPM_DRIVE_LOW, /* out 0 */
  80. GPIO19_GPIO | MFP_LPM_DRIVE_LOW, /* out 1 */
  81. GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* out 2 */
  82. GPIO21_GPIO | MFP_LPM_DRIVE_LOW, /* out 3 */
  83. GPIO22_GPIO | MFP_LPM_DRIVE_LOW, /* out 4 */
  84. GPIO23_GPIO | MFP_LPM_DRIVE_LOW, /* out 5 */
  85. GPIO24_GPIO | MFP_LPM_DRIVE_LOW, /* out 6 */
  86. GPIO25_GPIO | MFP_LPM_DRIVE_LOW, /* out 7 */
  87. GPIO26_GPIO | MFP_LPM_DRIVE_LOW, /* out 8 */
  88. GPIO27_GPIO | MFP_LPM_DRIVE_LOW, /* out 9 */
  89. GPIO79_GPIO | MFP_LPM_DRIVE_LOW, /* out 10 */
  90. GPIO80_GPIO | MFP_LPM_DRIVE_LOW, /* out 11 */
  91. /* PXA GPIO KEYS */
  92. GPIO7_GPIO | WAKEUP_ON_EDGE_BOTH, /* hotsync button on cradle */
  93. /* MISC */
  94. GPIO1_RST, /* reset */
  95. GPIO2_GPIO, /* earphone detect */
  96. GPIO16_GPIO, /* backlight switch */
  97. };
  98. /******************************************************************************
  99. * SD/MMC card controller
  100. ******************************************************************************/
  101. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  102. static struct pxamci_platform_data palmtc_mci_platform_data = {
  103. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  104. .detect_delay_ms = 200,
  105. };
  106. static struct gpiod_lookup_table palmtc_mci_gpio_table = {
  107. .dev_id = "pxa2xx-mci.0",
  108. .table = {
  109. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_DETECT_N,
  110. "cd", GPIO_ACTIVE_LOW),
  111. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_READONLY,
  112. "wp", GPIO_ACTIVE_LOW),
  113. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_POWER,
  114. "power", GPIO_ACTIVE_HIGH),
  115. { },
  116. },
  117. };
  118. static void __init palmtc_mmc_init(void)
  119. {
  120. gpiod_add_lookup_table(&palmtc_mci_gpio_table);
  121. pxa_set_mci_info(&palmtc_mci_platform_data);
  122. }
  123. #else
  124. static inline void palmtc_mmc_init(void) {}
  125. #endif
  126. /******************************************************************************
  127. * GPIO keys
  128. ******************************************************************************/
  129. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  130. static struct gpio_keys_button palmtc_pxa_buttons[] = {
  131. {KEY_F8, GPIO_NR_PALMTC_HOTSYNC_BUTTON, 1, "HotSync Button", EV_KEY, 1},
  132. };
  133. static struct gpio_keys_platform_data palmtc_pxa_keys_data = {
  134. .buttons = palmtc_pxa_buttons,
  135. .nbuttons = ARRAY_SIZE(palmtc_pxa_buttons),
  136. };
  137. static struct platform_device palmtc_pxa_keys = {
  138. .name = "gpio-keys",
  139. .id = -1,
  140. .dev = {
  141. .platform_data = &palmtc_pxa_keys_data,
  142. },
  143. };
  144. static void __init palmtc_keys_init(void)
  145. {
  146. platform_device_register(&palmtc_pxa_keys);
  147. }
  148. #else
  149. static inline void palmtc_keys_init(void) {}
  150. #endif
  151. /******************************************************************************
  152. * Backlight
  153. ******************************************************************************/
  154. #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
  155. static struct gpiod_lookup_table palmtc_pwm_bl_gpio_table = {
  156. .dev_id = "pwm-backlight.0",
  157. .table = {
  158. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_BL_POWER,
  159. "enable", GPIO_ACTIVE_HIGH),
  160. },
  161. };
  162. static struct pwm_lookup palmtc_pwm_lookup[] = {
  163. PWM_LOOKUP("pxa25x-pwm.1", 0, "pwm-backlight.0", NULL, PALMTC_PERIOD_NS,
  164. PWM_POLARITY_NORMAL),
  165. };
  166. static struct platform_pwm_backlight_data palmtc_backlight_data = {
  167. .max_brightness = PALMTC_MAX_INTENSITY,
  168. .dft_brightness = PALMTC_MAX_INTENSITY,
  169. };
  170. static struct platform_device palmtc_backlight = {
  171. .name = "pwm-backlight",
  172. .dev = {
  173. .parent = &pxa25x_device_pwm1.dev,
  174. .platform_data = &palmtc_backlight_data,
  175. },
  176. };
  177. static void __init palmtc_pwm_init(void)
  178. {
  179. gpiod_add_lookup_table(&palmtc_pwm_bl_gpio_table);
  180. pwm_add_table(palmtc_pwm_lookup, ARRAY_SIZE(palmtc_pwm_lookup));
  181. platform_device_register(&palmtc_backlight);
  182. }
  183. #else
  184. static inline void palmtc_pwm_init(void) {}
  185. #endif
  186. /******************************************************************************
  187. * IrDA
  188. ******************************************************************************/
  189. #if defined(CONFIG_IRDA) || defined(CONFIG_IRDA_MODULE)
  190. static struct pxaficp_platform_data palmtc_ficp_platform_data = {
  191. .gpio_pwdown = GPIO_NR_PALMTC_IR_DISABLE,
  192. .transceiver_cap = IR_SIRMODE | IR_OFF,
  193. };
  194. static void __init palmtc_irda_init(void)
  195. {
  196. pxa_set_ficp_info(&palmtc_ficp_platform_data);
  197. }
  198. #else
  199. static inline void palmtc_irda_init(void) {}
  200. #endif
  201. /******************************************************************************
  202. * Keyboard
  203. ******************************************************************************/
  204. #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
  205. static const uint32_t palmtc_matrix_keys[] = {
  206. KEY(0, 0, KEY_F1),
  207. KEY(0, 1, KEY_X),
  208. KEY(0, 2, KEY_POWER),
  209. KEY(0, 3, KEY_TAB),
  210. KEY(0, 4, KEY_A),
  211. KEY(0, 5, KEY_Q),
  212. KEY(0, 6, KEY_LEFTSHIFT),
  213. KEY(0, 7, KEY_Z),
  214. KEY(0, 8, KEY_S),
  215. KEY(0, 9, KEY_W),
  216. KEY(0, 10, KEY_E),
  217. KEY(0, 11, KEY_UP),
  218. KEY(1, 0, KEY_F2),
  219. KEY(1, 1, KEY_DOWN),
  220. KEY(1, 3, KEY_D),
  221. KEY(1, 4, KEY_C),
  222. KEY(1, 5, KEY_F),
  223. KEY(1, 6, KEY_R),
  224. KEY(1, 7, KEY_SPACE),
  225. KEY(1, 8, KEY_V),
  226. KEY(1, 9, KEY_G),
  227. KEY(1, 10, KEY_T),
  228. KEY(1, 11, KEY_LEFT),
  229. KEY(2, 0, KEY_F3),
  230. KEY(2, 1, KEY_LEFTCTRL),
  231. KEY(2, 3, KEY_H),
  232. KEY(2, 4, KEY_Y),
  233. KEY(2, 5, KEY_N),
  234. KEY(2, 6, KEY_J),
  235. KEY(2, 7, KEY_U),
  236. KEY(2, 8, KEY_M),
  237. KEY(2, 9, KEY_K),
  238. KEY(2, 10, KEY_I),
  239. KEY(2, 11, KEY_RIGHT),
  240. KEY(3, 0, KEY_F4),
  241. KEY(3, 1, KEY_ENTER),
  242. KEY(3, 3, KEY_DOT),
  243. KEY(3, 4, KEY_L),
  244. KEY(3, 5, KEY_O),
  245. KEY(3, 6, KEY_LEFTALT),
  246. KEY(3, 7, KEY_ENTER),
  247. KEY(3, 8, KEY_BACKSPACE),
  248. KEY(3, 9, KEY_P),
  249. KEY(3, 10, KEY_B),
  250. KEY(3, 11, KEY_FN),
  251. };
  252. const struct matrix_keymap_data palmtc_keymap_data = {
  253. .keymap = palmtc_matrix_keys,
  254. .keymap_size = ARRAY_SIZE(palmtc_matrix_keys),
  255. };
  256. static const unsigned int palmtc_keypad_row_gpios[] = {
  257. 0, 9, 10, 11
  258. };
  259. static const unsigned int palmtc_keypad_col_gpios[] = {
  260. 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80
  261. };
  262. static struct matrix_keypad_platform_data palmtc_keypad_platform_data = {
  263. .keymap_data = &palmtc_keymap_data,
  264. .row_gpios = palmtc_keypad_row_gpios,
  265. .num_row_gpios = ARRAY_SIZE(palmtc_keypad_row_gpios),
  266. .col_gpios = palmtc_keypad_col_gpios,
  267. .num_col_gpios = ARRAY_SIZE(palmtc_keypad_col_gpios),
  268. .active_low = 1,
  269. .debounce_ms = 20,
  270. .col_scan_delay_us = 5,
  271. };
  272. static struct platform_device palmtc_keyboard = {
  273. .name = "matrix-keypad",
  274. .id = -1,
  275. .dev = {
  276. .platform_data = &palmtc_keypad_platform_data,
  277. },
  278. };
  279. static void __init palmtc_mkp_init(void)
  280. {
  281. platform_device_register(&palmtc_keyboard);
  282. }
  283. #else
  284. static inline void palmtc_mkp_init(void) {}
  285. #endif
  286. /******************************************************************************
  287. * UDC
  288. ******************************************************************************/
  289. #if defined(CONFIG_USB_PXA25X)||defined(CONFIG_USB_PXA25X_MODULE)
  290. static struct gpiod_lookup_table palmtc_udc_gpiod_table = {
  291. .dev_id = "gpio-vbus",
  292. .table = {
  293. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_USB_DETECT_N,
  294. "vbus", GPIO_ACTIVE_LOW),
  295. GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_USB_POWER,
  296. "pullup", GPIO_ACTIVE_HIGH),
  297. { },
  298. },
  299. };
  300. static struct platform_device palmtc_gpio_vbus = {
  301. .name = "gpio-vbus",
  302. .id = -1,
  303. };
  304. static void __init palmtc_udc_init(void)
  305. {
  306. gpiod_add_lookup_table(&palmtc_udc_gpiod_table);
  307. platform_device_register(&palmtc_gpio_vbus);
  308. };
  309. #else
  310. static inline void palmtc_udc_init(void) {}
  311. #endif
  312. /******************************************************************************
  313. * Touchscreen / Battery / GPIO-extender
  314. ******************************************************************************/
  315. #if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
  316. defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
  317. static struct platform_device palmtc_ucb1400_device = {
  318. .name = "ucb1400_core",
  319. .id = -1,
  320. };
  321. static void __init palmtc_ts_init(void)
  322. {
  323. pxa_set_ac97_info(NULL);
  324. platform_device_register(&palmtc_ucb1400_device);
  325. }
  326. #else
  327. static inline void palmtc_ts_init(void) {}
  328. #endif
  329. /******************************************************************************
  330. * LEDs
  331. ******************************************************************************/
  332. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  333. struct gpio_led palmtc_gpio_leds[] = {
  334. {
  335. .name = "palmtc:green:user",
  336. .default_trigger = "none",
  337. .gpio = GPIO_NR_PALMTC_LED_POWER,
  338. .active_low = 1,
  339. }, {
  340. .name = "palmtc:vibra:vibra",
  341. .default_trigger = "none",
  342. .gpio = GPIO_NR_PALMTC_VIBRA_POWER,
  343. .active_low = 1,
  344. }
  345. };
  346. static struct gpio_led_platform_data palmtc_gpio_led_info = {
  347. .leds = palmtc_gpio_leds,
  348. .num_leds = ARRAY_SIZE(palmtc_gpio_leds),
  349. };
  350. static struct platform_device palmtc_leds = {
  351. .name = "leds-gpio",
  352. .id = -1,
  353. .dev = {
  354. .platform_data = &palmtc_gpio_led_info,
  355. }
  356. };
  357. static void __init palmtc_leds_init(void)
  358. {
  359. platform_device_register(&palmtc_leds);
  360. }
  361. #else
  362. static inline void palmtc_leds_init(void) {}
  363. #endif
  364. /******************************************************************************
  365. * NOR Flash
  366. ******************************************************************************/
  367. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  368. static struct resource palmtc_flash_resource = {
  369. .start = PXA_CS0_PHYS,
  370. .end = PXA_CS0_PHYS + SZ_16M - 1,
  371. .flags = IORESOURCE_MEM,
  372. };
  373. static struct mtd_partition palmtc_flash_parts[] = {
  374. {
  375. .name = "U-Boot Bootloader",
  376. .offset = 0x0,
  377. .size = 0x40000,
  378. },
  379. {
  380. .name = "Linux Kernel",
  381. .offset = 0x40000,
  382. .size = 0x2c0000,
  383. },
  384. {
  385. .name = "Filesystem",
  386. .offset = 0x300000,
  387. .size = 0xcc0000,
  388. },
  389. {
  390. .name = "U-Boot Environment",
  391. .offset = 0xfc0000,
  392. .size = MTDPART_SIZ_FULL,
  393. },
  394. };
  395. static struct physmap_flash_data palmtc_flash_data = {
  396. .width = 4,
  397. .parts = palmtc_flash_parts,
  398. .nr_parts = ARRAY_SIZE(palmtc_flash_parts),
  399. };
  400. static struct platform_device palmtc_flash = {
  401. .name = "physmap-flash",
  402. .id = -1,
  403. .resource = &palmtc_flash_resource,
  404. .num_resources = 1,
  405. .dev = {
  406. .platform_data = &palmtc_flash_data,
  407. },
  408. };
  409. static void __init palmtc_nor_init(void)
  410. {
  411. platform_device_register(&palmtc_flash);
  412. }
  413. #else
  414. static inline void palmtc_nor_init(void) {}
  415. #endif
  416. /******************************************************************************
  417. * Framebuffer
  418. ******************************************************************************/
  419. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  420. static struct pxafb_mode_info palmtc_lcd_modes[] = {
  421. {
  422. .pixclock = 115384,
  423. .xres = 320,
  424. .yres = 320,
  425. .bpp = 16,
  426. .left_margin = 27,
  427. .right_margin = 7,
  428. .upper_margin = 7,
  429. .lower_margin = 8,
  430. .hsync_len = 6,
  431. .vsync_len = 1,
  432. },
  433. };
  434. static struct pxafb_mach_info palmtc_lcd_screen = {
  435. .modes = palmtc_lcd_modes,
  436. .num_modes = ARRAY_SIZE(palmtc_lcd_modes),
  437. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  438. };
  439. static void __init palmtc_lcd_init(void)
  440. {
  441. pxa_set_fb_info(NULL, &palmtc_lcd_screen);
  442. }
  443. #else
  444. static inline void palmtc_lcd_init(void) {}
  445. #endif
  446. /******************************************************************************
  447. * Machine init
  448. ******************************************************************************/
  449. static void __init palmtc_init(void)
  450. {
  451. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config));
  452. pxa_set_ffuart_info(NULL);
  453. pxa_set_btuart_info(NULL);
  454. pxa_set_stuart_info(NULL);
  455. pxa_set_hwuart_info(NULL);
  456. palmtc_mmc_init();
  457. palmtc_keys_init();
  458. palmtc_pwm_init();
  459. palmtc_irda_init();
  460. palmtc_mkp_init();
  461. palmtc_udc_init();
  462. palmtc_ts_init();
  463. palmtc_nor_init();
  464. palmtc_lcd_init();
  465. palmtc_leds_init();
  466. };
  467. MACHINE_START(PALMTC, "Palm Tungsten|C")
  468. .atag_offset = 0x100,
  469. .map_io = pxa25x_map_io,
  470. .nr_irqs = PXA_NR_IRQS,
  471. .init_irq = pxa25x_init_irq,
  472. .handle_irq = pxa25x_handle_irq,
  473. .init_time = pxa_timer_init,
  474. .init_machine = palmtc_init,
  475. .restart = pxa_restart,
  476. MACHINE_END