palmtc.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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 <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <mach/audio.h>
  31. #include <mach/palmtc.h>
  32. #include <mach/mmc.h>
  33. #include <mach/pxafb.h>
  34. #include <mach/mfp-pxa25x.h>
  35. #include <mach/irda.h>
  36. #include <mach/udc.h>
  37. #include <mach/pxa2xx-regs.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. GPIO58_LCD_LDD_0,
  77. GPIO59_LCD_LDD_1,
  78. GPIO60_LCD_LDD_2,
  79. GPIO61_LCD_LDD_3,
  80. GPIO62_LCD_LDD_4,
  81. GPIO63_LCD_LDD_5,
  82. GPIO64_LCD_LDD_6,
  83. GPIO65_LCD_LDD_7,
  84. GPIO66_LCD_LDD_8,
  85. GPIO67_LCD_LDD_9,
  86. GPIO68_LCD_LDD_10,
  87. GPIO69_LCD_LDD_11,
  88. GPIO70_LCD_LDD_12,
  89. GPIO71_LCD_LDD_13,
  90. GPIO72_LCD_LDD_14,
  91. GPIO73_LCD_LDD_15,
  92. GPIO74_LCD_FCLK,
  93. GPIO75_LCD_LCLK,
  94. GPIO76_LCD_PCLK,
  95. GPIO77_LCD_BIAS,
  96. /* MATRIX KEYPAD */
  97. GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 0 */
  98. GPIO9_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 1 */
  99. GPIO10_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 2 */
  100. GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* in 3 */
  101. GPIO18_GPIO | MFP_LPM_DRIVE_LOW, /* out 0 */
  102. GPIO19_GPIO | MFP_LPM_DRIVE_LOW, /* out 1 */
  103. GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* out 2 */
  104. GPIO21_GPIO | MFP_LPM_DRIVE_LOW, /* out 3 */
  105. GPIO22_GPIO | MFP_LPM_DRIVE_LOW, /* out 4 */
  106. GPIO23_GPIO | MFP_LPM_DRIVE_LOW, /* out 5 */
  107. GPIO24_GPIO | MFP_LPM_DRIVE_LOW, /* out 6 */
  108. GPIO25_GPIO | MFP_LPM_DRIVE_LOW, /* out 7 */
  109. GPIO26_GPIO | MFP_LPM_DRIVE_LOW, /* out 8 */
  110. GPIO27_GPIO | MFP_LPM_DRIVE_LOW, /* out 9 */
  111. GPIO79_GPIO | MFP_LPM_DRIVE_LOW, /* out 10 */
  112. GPIO80_GPIO | MFP_LPM_DRIVE_LOW, /* out 11 */
  113. /* PXA GPIO KEYS */
  114. GPIO7_GPIO | WAKEUP_ON_EDGE_BOTH, /* hotsync button on cradle */
  115. /* MISC */
  116. GPIO1_RST, /* reset */
  117. GPIO2_GPIO, /* earphone detect */
  118. GPIO16_GPIO, /* backlight switch */
  119. };
  120. /******************************************************************************
  121. * SD/MMC card controller
  122. ******************************************************************************/
  123. static struct pxamci_platform_data palmtc_mci_platform_data = {
  124. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  125. .gpio_power = GPIO_NR_PALMTC_SD_POWER,
  126. .gpio_card_ro = GPIO_NR_PALMTC_SD_READONLY,
  127. .gpio_card_detect = GPIO_NR_PALMTC_SD_DETECT_N,
  128. .detect_delay = 20,
  129. };
  130. /******************************************************************************
  131. * GPIO keys
  132. ******************************************************************************/
  133. static struct gpio_keys_button palmtc_pxa_buttons[] = {
  134. {KEY_F8, GPIO_NR_PALMTC_HOTSYNC_BUTTON, 1, "HotSync Button", EV_KEY, 1},
  135. };
  136. static struct gpio_keys_platform_data palmtc_pxa_keys_data = {
  137. .buttons = palmtc_pxa_buttons,
  138. .nbuttons = ARRAY_SIZE(palmtc_pxa_buttons),
  139. };
  140. static struct platform_device palmtc_pxa_keys = {
  141. .name = "gpio-keys",
  142. .id = -1,
  143. .dev = {
  144. .platform_data = &palmtc_pxa_keys_data,
  145. },
  146. };
  147. /******************************************************************************
  148. * Backlight
  149. ******************************************************************************/
  150. static int palmtc_backlight_init(struct device *dev)
  151. {
  152. int ret;
  153. ret = gpio_request(GPIO_NR_PALMTC_BL_POWER, "BL POWER");
  154. if (ret)
  155. goto err;
  156. ret = gpio_direction_output(GPIO_NR_PALMTC_BL_POWER, 1);
  157. if (ret)
  158. goto err2;
  159. return 0;
  160. err2:
  161. gpio_free(GPIO_NR_PALMTC_BL_POWER);
  162. err:
  163. return ret;
  164. }
  165. static int palmtc_backlight_notify(int brightness)
  166. {
  167. /* backlight is on when GPIO16 AF0 is high */
  168. gpio_set_value(GPIO_NR_PALMTC_BL_POWER, brightness);
  169. return brightness;
  170. }
  171. static void palmtc_backlight_exit(struct device *dev)
  172. {
  173. gpio_free(GPIO_NR_PALMTC_BL_POWER);
  174. }
  175. static struct platform_pwm_backlight_data palmtc_backlight_data = {
  176. .pwm_id = 1,
  177. .max_brightness = PALMTC_MAX_INTENSITY,
  178. .dft_brightness = PALMTC_MAX_INTENSITY,
  179. .pwm_period_ns = PALMTC_PERIOD_NS,
  180. .init = palmtc_backlight_init,
  181. .notify = palmtc_backlight_notify,
  182. .exit = palmtc_backlight_exit,
  183. };
  184. static struct platform_device palmtc_backlight = {
  185. .name = "pwm-backlight",
  186. .dev = {
  187. .parent = &pxa25x_device_pwm1.dev,
  188. .platform_data = &palmtc_backlight_data,
  189. },
  190. };
  191. /******************************************************************************
  192. * IrDA
  193. ******************************************************************************/
  194. static struct pxaficp_platform_data palmtc_ficp_platform_data = {
  195. .gpio_pwdown = GPIO_NR_PALMTC_IR_DISABLE,
  196. .transceiver_cap = IR_SIRMODE | IR_OFF,
  197. };
  198. /******************************************************************************
  199. * Keyboard
  200. ******************************************************************************/
  201. static const uint32_t palmtc_matrix_keys[] = {
  202. KEY(0, 0, KEY_F1),
  203. KEY(0, 1, KEY_X),
  204. KEY(0, 2, KEY_POWER),
  205. KEY(0, 3, KEY_TAB),
  206. KEY(0, 4, KEY_A),
  207. KEY(0, 5, KEY_Q),
  208. KEY(0, 6, KEY_LEFTSHIFT),
  209. KEY(0, 7, KEY_Z),
  210. KEY(0, 8, KEY_S),
  211. KEY(0, 9, KEY_W),
  212. KEY(0, 10, KEY_E),
  213. KEY(0, 11, KEY_UP),
  214. KEY(1, 0, KEY_F2),
  215. KEY(1, 1, KEY_DOWN),
  216. KEY(1, 3, KEY_D),
  217. KEY(1, 4, KEY_C),
  218. KEY(1, 5, KEY_F),
  219. KEY(1, 6, KEY_R),
  220. KEY(1, 7, KEY_SPACE),
  221. KEY(1, 8, KEY_V),
  222. KEY(1, 9, KEY_G),
  223. KEY(1, 10, KEY_T),
  224. KEY(1, 11, KEY_LEFT),
  225. KEY(2, 0, KEY_F3),
  226. KEY(2, 1, KEY_LEFTCTRL),
  227. KEY(2, 3, KEY_H),
  228. KEY(2, 4, KEY_Y),
  229. KEY(2, 5, KEY_N),
  230. KEY(2, 6, KEY_J),
  231. KEY(2, 7, KEY_U),
  232. KEY(2, 8, KEY_M),
  233. KEY(2, 9, KEY_K),
  234. KEY(2, 10, KEY_I),
  235. KEY(2, 11, KEY_RIGHT),
  236. KEY(3, 0, KEY_F4),
  237. KEY(3, 1, KEY_ENTER),
  238. KEY(3, 3, KEY_DOT),
  239. KEY(3, 4, KEY_L),
  240. KEY(3, 5, KEY_O),
  241. KEY(3, 6, KEY_LEFTALT),
  242. KEY(3, 7, KEY_ENTER),
  243. KEY(3, 8, KEY_BACKSPACE),
  244. KEY(3, 9, KEY_P),
  245. KEY(3, 10, KEY_B),
  246. KEY(3, 11, KEY_FN),
  247. };
  248. const struct matrix_keymap_data palmtc_keymap_data = {
  249. .keymap = palmtc_matrix_keys,
  250. .keymap_size = ARRAY_SIZE(palmtc_matrix_keys),
  251. };
  252. const static unsigned int palmtc_keypad_row_gpios[] = {
  253. 0, 9, 10, 11
  254. };
  255. const static unsigned int palmtc_keypad_col_gpios[] = {
  256. 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 79, 80
  257. };
  258. static struct matrix_keypad_platform_data palmtc_keypad_platform_data = {
  259. .keymap_data = &palmtc_keymap_data,
  260. .row_gpios = palmtc_keypad_row_gpios,
  261. .num_row_gpios = ARRAY_SIZE(palmtc_keypad_row_gpios),
  262. .col_gpios = palmtc_keypad_col_gpios,
  263. .num_col_gpios = ARRAY_SIZE(palmtc_keypad_col_gpios),
  264. .active_low = 1,
  265. .debounce_ms = 20,
  266. .col_scan_delay_us = 5,
  267. };
  268. static struct platform_device palmtc_keyboard = {
  269. .name = "matrix-keypad",
  270. .id = -1,
  271. .dev = {
  272. .platform_data = &palmtc_keypad_platform_data,
  273. },
  274. };
  275. /******************************************************************************
  276. * UDC
  277. ******************************************************************************/
  278. static struct pxa2xx_udc_mach_info palmtc_udc_info __initdata = {
  279. .gpio_vbus = GPIO_NR_PALMTC_USB_DETECT_N,
  280. .gpio_vbus_inverted = 1,
  281. .gpio_pullup = GPIO_NR_PALMTC_USB_POWER,
  282. };
  283. /******************************************************************************
  284. * Touchscreen / Battery / GPIO-extender
  285. ******************************************************************************/
  286. static struct platform_device palmtc_ucb1400_core = {
  287. .name = "ucb1400_core",
  288. .id = -1,
  289. };
  290. /******************************************************************************
  291. * NOR Flash
  292. ******************************************************************************/
  293. static struct resource palmtc_flash_resource = {
  294. .start = PXA_CS0_PHYS,
  295. .end = PXA_CS0_PHYS + SZ_16M - 1,
  296. .flags = IORESOURCE_MEM,
  297. };
  298. static struct mtd_partition palmtc_flash_parts[] = {
  299. {
  300. .name = "U-Boot Bootloader",
  301. .offset = 0x0,
  302. .size = 0x40000,
  303. },
  304. {
  305. .name = "Linux Kernel",
  306. .offset = 0x40000,
  307. .size = 0x2c0000,
  308. },
  309. {
  310. .name = "Filesystem",
  311. .offset = 0x300000,
  312. .size = 0xcc0000,
  313. },
  314. {
  315. .name = "U-Boot Environment",
  316. .offset = 0xfc0000,
  317. .size = MTDPART_SIZ_FULL,
  318. },
  319. };
  320. static struct physmap_flash_data palmtc_flash_data = {
  321. .width = 4,
  322. .parts = palmtc_flash_parts,
  323. .nr_parts = ARRAY_SIZE(palmtc_flash_parts),
  324. };
  325. static struct platform_device palmtc_flash = {
  326. .name = "physmap-flash",
  327. .id = -1,
  328. .resource = &palmtc_flash_resource,
  329. .num_resources = 1,
  330. .dev = {
  331. .platform_data = &palmtc_flash_data,
  332. },
  333. };
  334. /******************************************************************************
  335. * Framebuffer
  336. ******************************************************************************/
  337. static struct pxafb_mode_info palmtc_lcd_modes[] = {
  338. {
  339. .pixclock = 115384,
  340. .xres = 320,
  341. .yres = 320,
  342. .bpp = 16,
  343. .left_margin = 27,
  344. .right_margin = 7,
  345. .upper_margin = 7,
  346. .lower_margin = 8,
  347. .hsync_len = 6,
  348. .vsync_len = 1,
  349. },
  350. };
  351. static struct pxafb_mach_info palmtc_lcd_screen = {
  352. .modes = palmtc_lcd_modes,
  353. .num_modes = ARRAY_SIZE(palmtc_lcd_modes),
  354. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  355. };
  356. /******************************************************************************
  357. * Machine init
  358. ******************************************************************************/
  359. static struct platform_device *devices[] __initdata = {
  360. &palmtc_backlight,
  361. &palmtc_ucb1400_core,
  362. &palmtc_keyboard,
  363. &palmtc_pxa_keys,
  364. &palmtc_flash,
  365. };
  366. static void __init palmtc_init(void)
  367. {
  368. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtc_pin_config));
  369. set_pxa_fb_info(&palmtc_lcd_screen);
  370. pxa_set_mci_info(&palmtc_mci_platform_data);
  371. pxa_set_udc_info(&palmtc_udc_info);
  372. pxa_set_ac97_info(NULL);
  373. pxa_set_ficp_info(&palmtc_ficp_platform_data);
  374. platform_add_devices(devices, ARRAY_SIZE(devices));
  375. };
  376. MACHINE_START(PALMTC, "Palm Tungsten|C")
  377. .phys_io = 0x40000000,
  378. .boot_params = 0xa0000100,
  379. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  380. .map_io = pxa_map_io,
  381. .init_irq = pxa25x_init_irq,
  382. .timer = &pxa_timer,
  383. .init_machine = palmtc_init
  384. MACHINE_END