palmtc.c 13 KB

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