board-palmte.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /*
  2. * linux/arch/arm/mach-omap1/board-palmte.c
  3. *
  4. * Modified from board-generic.c
  5. *
  6. * Support for the Palm Tungsten E PDA.
  7. *
  8. * Original version : Laurent Gonzalez
  9. *
  10. * Maintainers : http://palmtelinux.sf.net
  11. * palmtelinux-developpers@lists.sf.net
  12. *
  13. * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License version 2 as
  17. * published by the Free Software Foundation.
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/input.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/partitions.h>
  25. #include <linux/mtd/physmap.h>
  26. #include <linux/spi/spi.h>
  27. #include <linux/interrupt.h>
  28. #include <linux/apm-emulation.h>
  29. #include <mach/hardware.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <mach/gpio.h>
  34. #include <plat/flash.h>
  35. #include <plat/mux.h>
  36. #include <plat/usb.h>
  37. #include <plat/tc.h>
  38. #include <plat/dma.h>
  39. #include <plat/board.h>
  40. #include <plat/irda.h>
  41. #include <plat/keypad.h>
  42. #include <plat/common.h>
  43. #define PALMTE_USBDETECT_GPIO 0
  44. #define PALMTE_USB_OR_DC_GPIO 1
  45. #define PALMTE_TSC_GPIO 4
  46. #define PALMTE_PINTDAV_GPIO 6
  47. #define PALMTE_MMC_WP_GPIO 8
  48. #define PALMTE_MMC_POWER_GPIO 9
  49. #define PALMTE_HDQ_GPIO 11
  50. #define PALMTE_HEADPHONES_GPIO 14
  51. #define PALMTE_SPEAKER_GPIO 15
  52. #define PALMTE_DC_GPIO OMAP_MPUIO(2)
  53. #define PALMTE_MMC_SWITCH_GPIO OMAP_MPUIO(4)
  54. #define PALMTE_MMC1_GPIO OMAP_MPUIO(6)
  55. #define PALMTE_MMC2_GPIO OMAP_MPUIO(7)
  56. #define PALMTE_MMC3_GPIO OMAP_MPUIO(11)
  57. static void __init omap_palmte_init_irq(void)
  58. {
  59. omap1_init_common_hw();
  60. omap_init_irq();
  61. omap_gpio_init();
  62. }
  63. static const int palmte_keymap[] = {
  64. KEY(0, 0, KEY_F1), /* Calendar */
  65. KEY(0, 1, KEY_F2), /* Contacts */
  66. KEY(0, 2, KEY_F3), /* Tasks List */
  67. KEY(0, 3, KEY_F4), /* Note Pad */
  68. KEY(0, 4, KEY_POWER),
  69. KEY(1, 0, KEY_LEFT),
  70. KEY(1, 1, KEY_DOWN),
  71. KEY(1, 2, KEY_UP),
  72. KEY(1, 3, KEY_RIGHT),
  73. KEY(1, 4, KEY_ENTER),
  74. 0,
  75. };
  76. static struct omap_kp_platform_data palmte_kp_data = {
  77. .rows = 8,
  78. .cols = 8,
  79. .keymap = (int *) palmte_keymap,
  80. .rep = 1,
  81. .delay = 12,
  82. };
  83. static struct resource palmte_kp_resources[] = {
  84. [0] = {
  85. .start = INT_KEYBOARD,
  86. .end = INT_KEYBOARD,
  87. .flags = IORESOURCE_IRQ,
  88. },
  89. };
  90. static struct platform_device palmte_kp_device = {
  91. .name = "omap-keypad",
  92. .id = -1,
  93. .dev = {
  94. .platform_data = &palmte_kp_data,
  95. },
  96. .num_resources = ARRAY_SIZE(palmte_kp_resources),
  97. .resource = palmte_kp_resources,
  98. };
  99. static struct mtd_partition palmte_rom_partitions[] = {
  100. /* PalmOS "Small ROM", contains the bootloader and the debugger */
  101. {
  102. .name = "smallrom",
  103. .offset = 0,
  104. .size = 0xa000,
  105. .mask_flags = MTD_WRITEABLE,
  106. },
  107. /* PalmOS "Big ROM", a filesystem with all the OS code and data */
  108. {
  109. .name = "bigrom",
  110. .offset = SZ_128K,
  111. /*
  112. * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
  113. * 0x7b0000 bytes in the English-only ("enUS") version.
  114. */
  115. .size = 0x7b0000,
  116. .mask_flags = MTD_WRITEABLE,
  117. },
  118. };
  119. static struct physmap_flash_data palmte_rom_data = {
  120. .width = 2,
  121. .set_vpp = omap1_set_vpp,
  122. .parts = palmte_rom_partitions,
  123. .nr_parts = ARRAY_SIZE(palmte_rom_partitions),
  124. };
  125. static struct resource palmte_rom_resource = {
  126. .start = OMAP_CS0_PHYS,
  127. .end = OMAP_CS0_PHYS + SZ_8M - 1,
  128. .flags = IORESOURCE_MEM,
  129. };
  130. static struct platform_device palmte_rom_device = {
  131. .name = "physmap-flash",
  132. .id = -1,
  133. .dev = {
  134. .platform_data = &palmte_rom_data,
  135. },
  136. .num_resources = 1,
  137. .resource = &palmte_rom_resource,
  138. };
  139. static struct platform_device palmte_lcd_device = {
  140. .name = "lcd_palmte",
  141. .id = -1,
  142. };
  143. static struct omap_backlight_config palmte_backlight_config = {
  144. .default_intensity = 0xa0,
  145. };
  146. static struct platform_device palmte_backlight_device = {
  147. .name = "omap-bl",
  148. .id = -1,
  149. .dev = {
  150. .platform_data = &palmte_backlight_config,
  151. },
  152. };
  153. static struct omap_irda_config palmte_irda_config = {
  154. .transceiver_cap = IR_SIRMODE,
  155. .rx_channel = OMAP_DMA_UART3_RX,
  156. .tx_channel = OMAP_DMA_UART3_TX,
  157. .dest_start = UART3_THR,
  158. .src_start = UART3_RHR,
  159. .tx_trigger = 0,
  160. .rx_trigger = 0,
  161. };
  162. static struct resource palmte_irda_resources[] = {
  163. [0] = {
  164. .start = INT_UART3,
  165. .end = INT_UART3,
  166. .flags = IORESOURCE_IRQ,
  167. },
  168. };
  169. static struct platform_device palmte_irda_device = {
  170. .name = "omapirda",
  171. .id = -1,
  172. .dev = {
  173. .platform_data = &palmte_irda_config,
  174. },
  175. .num_resources = ARRAY_SIZE(palmte_irda_resources),
  176. .resource = palmte_irda_resources,
  177. };
  178. static struct platform_device *palmte_devices[] __initdata = {
  179. &palmte_rom_device,
  180. &palmte_kp_device,
  181. &palmte_lcd_device,
  182. &palmte_backlight_device,
  183. &palmte_irda_device,
  184. };
  185. static struct omap_usb_config palmte_usb_config __initdata = {
  186. .register_dev = 1, /* Mini-B only receptacle */
  187. .hmc_mode = 0,
  188. .pins[0] = 2,
  189. };
  190. static struct omap_lcd_config palmte_lcd_config __initdata = {
  191. .ctrl_name = "internal",
  192. };
  193. static struct omap_board_config_kernel palmte_config[] __initdata = {
  194. { OMAP_TAG_LCD, &palmte_lcd_config },
  195. };
  196. static struct spi_board_info palmte_spi_info[] __initdata = {
  197. {
  198. .modalias = "tsc2102",
  199. .bus_num = 2, /* uWire (officially) */
  200. .chip_select = 0, /* As opposed to 3 */
  201. .irq = OMAP_GPIO_IRQ(PALMTE_PINTDAV_GPIO),
  202. .max_speed_hz = 8000000,
  203. },
  204. };
  205. static void palmte_headphones_detect(void *data, int state)
  206. {
  207. if (state) {
  208. /* Headphones connected, disable speaker */
  209. gpio_set_value(PALMTE_SPEAKER_GPIO, 0);
  210. printk(KERN_INFO "PM: speaker off\n");
  211. } else {
  212. /* Headphones unplugged, re-enable speaker */
  213. gpio_set_value(PALMTE_SPEAKER_GPIO, 1);
  214. printk(KERN_INFO "PM: speaker on\n");
  215. }
  216. }
  217. static void __init palmte_misc_gpio_setup(void)
  218. {
  219. /* Set TSC2102 PINTDAV pin as input (used by TSC2102 driver) */
  220. if (gpio_request(PALMTE_PINTDAV_GPIO, "TSC2102 PINTDAV") < 0) {
  221. printk(KERN_ERR "Could not reserve PINTDAV GPIO!\n");
  222. return;
  223. }
  224. gpio_direction_input(PALMTE_PINTDAV_GPIO);
  225. /* Set USB-or-DC-IN pin as input (unused) */
  226. if (gpio_request(PALMTE_USB_OR_DC_GPIO, "USB/DC-IN") < 0) {
  227. printk(KERN_ERR "Could not reserve cable signal GPIO!\n");
  228. return;
  229. }
  230. gpio_direction_input(PALMTE_USB_OR_DC_GPIO);
  231. }
  232. static void __init omap_palmte_init(void)
  233. {
  234. /* mux pins for uarts */
  235. omap_cfg_reg(UART1_TX);
  236. omap_cfg_reg(UART1_RTS);
  237. omap_cfg_reg(UART2_TX);
  238. omap_cfg_reg(UART2_RTS);
  239. omap_cfg_reg(UART3_TX);
  240. omap_cfg_reg(UART3_RX);
  241. omap_board_config = palmte_config;
  242. omap_board_config_size = ARRAY_SIZE(palmte_config);
  243. platform_add_devices(palmte_devices, ARRAY_SIZE(palmte_devices));
  244. spi_register_board_info(palmte_spi_info, ARRAY_SIZE(palmte_spi_info));
  245. palmte_misc_gpio_setup();
  246. omap_serial_init();
  247. omap1_usb_init(&palmte_usb_config);
  248. omap_register_i2c_bus(1, 100, NULL, 0);
  249. }
  250. static void __init omap_palmte_map_io(void)
  251. {
  252. omap1_map_common_io();
  253. }
  254. MACHINE_START(OMAP_PALMTE, "OMAP310 based Palm Tungsten E")
  255. .phys_io = 0xfff00000,
  256. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  257. .boot_params = 0x10000100,
  258. .map_io = omap_palmte_map_io,
  259. .reserve = omap_reserve,
  260. .init_irq = omap_palmte_init_irq,
  261. .init_machine = omap_palmte_init,
  262. .timer = &omap_timer,
  263. MACHINE_END