palmtx.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /*
  2. * Hardware definitions for PalmTX
  3. *
  4. * Author: Marek Vasut <marek.vasut@gmail.com>
  5. *
  6. * Based on work of:
  7. * Alex Osborne <ato@meshy.org>
  8. * Cristiano P. <cristianop@users.sourceforge.net>
  9. * Jan Herman <2hp@seznam.cz>
  10. * Michal Hrusecky
  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. * (find more info at www.hackndev.com)
  17. *
  18. */
  19. #include <linux/platform_device.h>
  20. #include <linux/delay.h>
  21. #include <linux/irq.h>
  22. #include <linux/gpio_keys.h>
  23. #include <linux/input.h>
  24. #include <linux/pwm_backlight.h>
  25. #include <linux/gpio.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <asm/arch/audio.h>
  30. #include <asm/arch/palmtx.h>
  31. #include <asm/arch/mmc.h>
  32. #include <asm/arch/pxafb.h>
  33. #include <asm/arch/pxa-regs.h>
  34. #include <asm/arch/mfp-pxa27x.h>
  35. #include <asm/arch/irda.h>
  36. #include <asm/arch/pxa27x_keypad.h>
  37. #include <asm/arch/udc.h>
  38. #include "generic.h"
  39. #include "devices.h"
  40. /******************************************************************************
  41. * Pin configuration
  42. ******************************************************************************/
  43. static unsigned long palmtx_pin_config[] __initdata = {
  44. /* MMC */
  45. GPIO32_MMC_CLK,
  46. GPIO92_MMC_DAT_0,
  47. GPIO109_MMC_DAT_1,
  48. GPIO110_MMC_DAT_2,
  49. GPIO111_MMC_DAT_3,
  50. GPIO112_MMC_CMD,
  51. /* AC97 */
  52. GPIO28_AC97_BITCLK,
  53. GPIO29_AC97_SDATA_IN_0,
  54. GPIO30_AC97_SDATA_OUT,
  55. GPIO31_AC97_SYNC,
  56. /* IrDA */
  57. GPIO46_FICP_RXD,
  58. GPIO47_FICP_TXD,
  59. /* PWM */
  60. GPIO16_PWM0_OUT,
  61. /* USB */
  62. GPIO13_GPIO,
  63. };
  64. /******************************************************************************
  65. * SD/MMC card controller
  66. ******************************************************************************/
  67. static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
  68. void *data)
  69. {
  70. int err = 0;
  71. /* Setup an interrupt for detecting card insert/remove events */
  72. err = request_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, palmtx_detect_int,
  73. IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
  74. IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
  75. "SD/MMC card detect", data);
  76. if (err) {
  77. printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
  78. __func__);
  79. return err;
  80. }
  81. err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
  82. if (err)
  83. goto pwr_err;
  84. err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
  85. if (err)
  86. goto ro_err;
  87. printk(KERN_DEBUG "%s: irq registered\n", __func__);
  88. return 0;
  89. ro_err:
  90. gpio_free(GPIO_NR_PALMTX_SD_POWER);
  91. pwr_err:
  92. free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, data);
  93. return err;
  94. }
  95. static void palmtx_mci_exit(struct device *dev, void *data)
  96. {
  97. gpio_free(GPIO_NR_PALMTX_SD_READONLY);
  98. gpio_free(GPIO_NR_PALMTX_SD_POWER);
  99. free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, data);
  100. }
  101. static void palmtx_mci_power(struct device *dev, unsigned int vdd)
  102. {
  103. struct pxamci_platform_data *p_d = dev->platform_data;
  104. gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd));
  105. }
  106. static int palmtx_mci_get_ro(struct device *dev)
  107. {
  108. return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
  109. }
  110. static struct pxamci_platform_data palmtx_mci_platform_data = {
  111. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  112. .setpower = palmtx_mci_power,
  113. .get_ro = palmtx_mci_get_ro,
  114. .init = palmtx_mci_init,
  115. .exit = palmtx_mci_exit,
  116. };
  117. /******************************************************************************
  118. * GPIO keyboard
  119. ******************************************************************************/
  120. static unsigned int palmtx_matrix_keys[] = {
  121. KEY(0, 0, KEY_POWER),
  122. KEY(0, 1, KEY_F1),
  123. KEY(0, 2, KEY_ENTER),
  124. KEY(1, 0, KEY_F2),
  125. KEY(1, 1, KEY_F3),
  126. KEY(1, 2, KEY_F4),
  127. KEY(2, 0, KEY_UP),
  128. KEY(2, 2, KEY_DOWN),
  129. KEY(3, 0, KEY_RIGHT),
  130. KEY(3, 2, KEY_LEFT),
  131. };
  132. static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
  133. .matrix_key_rows = 4,
  134. .matrix_key_cols = 3,
  135. .matrix_key_map = palmtx_matrix_keys,
  136. .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
  137. .debounce_interval = 30,
  138. };
  139. /******************************************************************************
  140. * GPIO keys
  141. ******************************************************************************/
  142. static struct gpio_keys_button palmtx_pxa_buttons[] = {
  143. {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
  144. };
  145. static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
  146. .buttons = palmtx_pxa_buttons,
  147. .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
  148. };
  149. static struct platform_device palmtx_pxa_keys = {
  150. .name = "gpio-keys",
  151. .id = -1,
  152. .dev = {
  153. .platform_data = &palmtx_pxa_keys_data,
  154. },
  155. };
  156. /******************************************************************************
  157. * Backlight
  158. ******************************************************************************/
  159. static int palmtx_backlight_init(struct device *dev)
  160. {
  161. int ret;
  162. ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
  163. if (ret)
  164. goto err;
  165. ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
  166. if (ret)
  167. goto err2;
  168. return 0;
  169. err2:
  170. gpio_free(GPIO_NR_PALMTX_BL_POWER);
  171. err:
  172. return ret;
  173. }
  174. static int palmtx_backlight_notify(int brightness)
  175. {
  176. gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
  177. gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
  178. return brightness;
  179. }
  180. static void palmtx_backlight_exit(struct device *dev)
  181. {
  182. gpio_free(GPIO_NR_PALMTX_BL_POWER);
  183. gpio_free(GPIO_NR_PALMTX_LCD_POWER);
  184. }
  185. static struct platform_pwm_backlight_data palmtx_backlight_data = {
  186. .pwm_id = 0,
  187. .max_brightness = PALMTX_MAX_INTENSITY,
  188. .dft_brightness = PALMTX_MAX_INTENSITY,
  189. .pwm_period_ns = PALMTX_PERIOD_NS,
  190. .init = palmtx_backlight_init,
  191. .notify = palmtx_backlight_notify,
  192. .exit = palmtx_backlight_exit,
  193. };
  194. static struct platform_device palmtx_backlight = {
  195. .name = "pwm-backlight",
  196. .dev = {
  197. .parent = &pxa27x_device_pwm0.dev,
  198. .platform_data = &palmtx_backlight_data,
  199. },
  200. };
  201. /******************************************************************************
  202. * IrDA
  203. ******************************************************************************/
  204. static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
  205. {
  206. gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
  207. pxa2xx_transceiver_mode(dev, mode);
  208. }
  209. static struct pxaficp_platform_data palmtx_ficp_platform_data = {
  210. .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
  211. .transceiver_mode = palmtx_irda_transceiver_mode,
  212. };
  213. /******************************************************************************
  214. * UDC
  215. ******************************************************************************/
  216. static void palmtx_udc_command(int cmd)
  217. {
  218. gpio_set_value(GPIO_NR_PALMTX_USB_POWER, !cmd);
  219. udelay(50);
  220. gpio_set_value(GPIO_NR_PALMTX_USB_PULLUP, !cmd);
  221. }
  222. static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
  223. .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
  224. .gpio_vbus_inverted = 1,
  225. .udc_command = palmtx_udc_command,
  226. };
  227. /******************************************************************************
  228. * Framebuffer
  229. ******************************************************************************/
  230. static struct pxafb_mode_info palmtx_lcd_modes[] = {
  231. {
  232. .pixclock = 57692,
  233. .xres = 320,
  234. .yres = 480,
  235. .bpp = 16,
  236. .left_margin = 32,
  237. .right_margin = 1,
  238. .upper_margin = 7,
  239. .lower_margin = 1,
  240. .hsync_len = 4,
  241. .vsync_len = 1,
  242. },
  243. };
  244. static struct pxafb_mach_info palmtx_lcd_screen = {
  245. .modes = palmtx_lcd_modes,
  246. .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
  247. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
  248. };
  249. /******************************************************************************
  250. * Machine init
  251. ******************************************************************************/
  252. static struct platform_device *devices[] __initdata = {
  253. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  254. &palmtx_pxa_keys,
  255. #endif
  256. &palmtx_backlight,
  257. };
  258. static struct map_desc palmtx_io_desc[] __initdata = {
  259. {
  260. .virtual = PALMTX_PCMCIA_VIRT,
  261. .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
  262. .length = PALMTX_PCMCIA_SIZE,
  263. .type = MT_DEVICE
  264. },
  265. };
  266. static void __init palmtx_map_io(void)
  267. {
  268. pxa_map_io();
  269. iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
  270. }
  271. static void __init palmtx_init(void)
  272. {
  273. pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
  274. set_pxa_fb_info(&palmtx_lcd_screen);
  275. pxa_set_mci_info(&palmtx_mci_platform_data);
  276. pxa_set_udc_info(&palmtx_udc_info);
  277. pxa_set_ac97_info(NULL);
  278. pxa_set_ficp_info(&palmtx_ficp_platform_data);
  279. pxa_set_keypad_info(&palmtx_keypad_platform_data);
  280. platform_add_devices(devices, ARRAY_SIZE(devices));
  281. }
  282. MACHINE_START(PALMTX, "Palm T|X")
  283. .phys_io = PALMTX_PHYS_IO_START,
  284. .io_pg_offst = io_p2v(0x40000000),
  285. .boot_params = 0xa0000100,
  286. .map_io = palmtx_map_io,
  287. .init_irq = pxa27x_init_irq,
  288. .timer = &pxa_timer,
  289. .init_machine = palmtx_init
  290. MACHINE_END