palmtc.c 13 KB

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