board-palmtt.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. /*
  2. * linux/arch/arm/mach-omap1/board-palmtt.c
  3. *
  4. * Modified from board-palmtt2.c
  5. *
  6. * Modified and amended for Palm Tungsten|T
  7. * by Marek Vasut <marek.vasut@gmail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/delay.h>
  14. #include <linux/gpio.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/notifier.h>
  19. #include <linux/clk.h>
  20. #include <linux/input.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/mtd/mtd.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <linux/mtd/physmap.h>
  25. #include <linux/leds.h>
  26. #include <linux/omapfb.h>
  27. #include <linux/spi/spi.h>
  28. #include <linux/spi/ads7846.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/arch.h>
  31. #include <asm/mach/map.h>
  32. #include <plat/led.h>
  33. #include <plat/flash.h>
  34. #include <plat/mux.h>
  35. #include <plat/usb.h>
  36. #include <plat/dma.h>
  37. #include <plat/tc.h>
  38. #include <plat/board.h>
  39. #include <plat/irda.h>
  40. #include <plat/keypad.h>
  41. #include <mach/hardware.h>
  42. #include "common.h"
  43. #define PALMTT_USBDETECT_GPIO 0
  44. #define PALMTT_CABLE_GPIO 1
  45. #define PALMTT_LED_GPIO 3
  46. #define PALMTT_PENIRQ_GPIO 6
  47. #define PALMTT_MMC_WP_GPIO 8
  48. #define PALMTT_HDQ_GPIO 11
  49. static const unsigned int palmtt_keymap[] = {
  50. KEY(0, 0, KEY_ESC),
  51. KEY(1, 0, KEY_SPACE),
  52. KEY(2, 0, KEY_LEFTCTRL),
  53. KEY(3, 0, KEY_TAB),
  54. KEY(4, 0, KEY_ENTER),
  55. KEY(0, 1, KEY_LEFT),
  56. KEY(1, 1, KEY_DOWN),
  57. KEY(2, 1, KEY_UP),
  58. KEY(3, 1, KEY_RIGHT),
  59. KEY(0, 2, KEY_SLEEP),
  60. KEY(4, 2, KEY_Y),
  61. };
  62. static struct mtd_partition palmtt_partitions[] = {
  63. {
  64. .name = "write8k",
  65. .offset = 0,
  66. .size = SZ_8K,
  67. .mask_flags = 0,
  68. },
  69. {
  70. .name = "PalmOS-BootLoader(ro)",
  71. .offset = SZ_8K,
  72. .size = 7 * SZ_8K,
  73. .mask_flags = MTD_WRITEABLE,
  74. },
  75. {
  76. .name = "u-boot",
  77. .offset = MTDPART_OFS_APPEND,
  78. .size = 8 * SZ_8K,
  79. .mask_flags = 0,
  80. },
  81. {
  82. .name = "PalmOS-FS(ro)",
  83. .offset = MTDPART_OFS_APPEND,
  84. .size = 7 * SZ_1M + 4 * SZ_64K - 16 * SZ_8K,
  85. .mask_flags = MTD_WRITEABLE,
  86. },
  87. {
  88. .name = "u-boot(rez)",
  89. .offset = MTDPART_OFS_APPEND,
  90. .size = SZ_128K,
  91. .mask_flags = 0
  92. },
  93. {
  94. .name = "empty",
  95. .offset = MTDPART_OFS_APPEND,
  96. .size = MTDPART_SIZ_FULL,
  97. .mask_flags = 0
  98. }
  99. };
  100. static struct physmap_flash_data palmtt_flash_data = {
  101. .width = 2,
  102. .set_vpp = omap1_set_vpp,
  103. .parts = palmtt_partitions,
  104. .nr_parts = ARRAY_SIZE(palmtt_partitions),
  105. };
  106. static struct resource palmtt_flash_resource = {
  107. .start = OMAP_CS0_PHYS,
  108. .end = OMAP_CS0_PHYS + SZ_8M - 1,
  109. .flags = IORESOURCE_MEM,
  110. };
  111. static struct platform_device palmtt_flash_device = {
  112. .name = "physmap-flash",
  113. .id = 0,
  114. .dev = {
  115. .platform_data = &palmtt_flash_data,
  116. },
  117. .num_resources = 1,
  118. .resource = &palmtt_flash_resource,
  119. };
  120. static struct resource palmtt_kp_resources[] = {
  121. [0] = {
  122. .start = INT_KEYBOARD,
  123. .end = INT_KEYBOARD,
  124. .flags = IORESOURCE_IRQ,
  125. },
  126. };
  127. static const struct matrix_keymap_data palmtt_keymap_data = {
  128. .keymap = palmtt_keymap,
  129. .keymap_size = ARRAY_SIZE(palmtt_keymap),
  130. };
  131. static struct omap_kp_platform_data palmtt_kp_data = {
  132. .rows = 6,
  133. .cols = 3,
  134. .keymap_data = &palmtt_keymap_data,
  135. };
  136. static struct platform_device palmtt_kp_device = {
  137. .name = "omap-keypad",
  138. .id = -1,
  139. .dev = {
  140. .platform_data = &palmtt_kp_data,
  141. },
  142. .num_resources = ARRAY_SIZE(palmtt_kp_resources),
  143. .resource = palmtt_kp_resources,
  144. };
  145. static struct platform_device palmtt_lcd_device = {
  146. .name = "lcd_palmtt",
  147. .id = -1,
  148. };
  149. static struct omap_irda_config palmtt_irda_config = {
  150. .transceiver_cap = IR_SIRMODE,
  151. .rx_channel = OMAP_DMA_UART3_RX,
  152. .tx_channel = OMAP_DMA_UART3_TX,
  153. .dest_start = UART3_THR,
  154. .src_start = UART3_RHR,
  155. .tx_trigger = 0,
  156. .rx_trigger = 0,
  157. };
  158. static struct resource palmtt_irda_resources[] = {
  159. [0] = {
  160. .start = INT_UART3,
  161. .end = INT_UART3,
  162. .flags = IORESOURCE_IRQ,
  163. },
  164. };
  165. static struct platform_device palmtt_irda_device = {
  166. .name = "omapirda",
  167. .id = -1,
  168. .dev = {
  169. .platform_data = &palmtt_irda_config,
  170. },
  171. .num_resources = ARRAY_SIZE(palmtt_irda_resources),
  172. .resource = palmtt_irda_resources,
  173. };
  174. static struct platform_device palmtt_spi_device = {
  175. .name = "spi_palmtt",
  176. .id = -1,
  177. };
  178. static struct omap_backlight_config palmtt_backlight_config = {
  179. .default_intensity = 0xa0,
  180. };
  181. static struct platform_device palmtt_backlight_device = {
  182. .name = "omap-bl",
  183. .id = -1,
  184. .dev = {
  185. .platform_data= &palmtt_backlight_config,
  186. },
  187. };
  188. static struct omap_led_config palmtt_led_config[] = {
  189. {
  190. .cdev = {
  191. .name = "palmtt:led0",
  192. },
  193. .gpio = PALMTT_LED_GPIO,
  194. },
  195. };
  196. static struct omap_led_platform_data palmtt_led_data = {
  197. .nr_leds = ARRAY_SIZE(palmtt_led_config),
  198. .leds = palmtt_led_config,
  199. };
  200. static struct platform_device palmtt_led_device = {
  201. .name = "omap-led",
  202. .id = -1,
  203. .dev = {
  204. .platform_data = &palmtt_led_data,
  205. },
  206. };
  207. static struct platform_device *palmtt_devices[] __initdata = {
  208. &palmtt_flash_device,
  209. &palmtt_kp_device,
  210. &palmtt_lcd_device,
  211. &palmtt_irda_device,
  212. &palmtt_spi_device,
  213. &palmtt_backlight_device,
  214. &palmtt_led_device,
  215. };
  216. static int palmtt_get_pendown_state(void)
  217. {
  218. return !gpio_get_value(6);
  219. }
  220. static const struct ads7846_platform_data palmtt_ts_info = {
  221. .model = 7846,
  222. .vref_delay_usecs = 100, /* internal, no capacitor */
  223. .x_plate_ohms = 419,
  224. .y_plate_ohms = 486,
  225. .get_pendown_state = palmtt_get_pendown_state,
  226. };
  227. static struct spi_board_info __initdata palmtt_boardinfo[] = {
  228. {
  229. /* MicroWire (bus 2) CS0 has an ads7846e */
  230. .modalias = "ads7846",
  231. .platform_data = &palmtt_ts_info,
  232. .max_speed_hz = 120000 /* max sample rate at 3V */
  233. * 26 /* command + data + overhead */,
  234. .bus_num = 2,
  235. .chip_select = 0,
  236. }
  237. };
  238. static struct omap_usb_config palmtt_usb_config __initdata = {
  239. .register_dev = 1,
  240. .hmc_mode = 0,
  241. .pins[0] = 2,
  242. };
  243. static struct omap_lcd_config palmtt_lcd_config __initdata = {
  244. .ctrl_name = "internal",
  245. };
  246. static void __init omap_mpu_wdt_mode(int mode) {
  247. if (mode)
  248. omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
  249. else {
  250. omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
  251. omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
  252. }
  253. }
  254. static void __init omap_palmtt_init(void)
  255. {
  256. /* mux pins for uarts */
  257. omap_cfg_reg(UART1_TX);
  258. omap_cfg_reg(UART1_RTS);
  259. omap_cfg_reg(UART2_TX);
  260. omap_cfg_reg(UART2_RTS);
  261. omap_cfg_reg(UART3_TX);
  262. omap_cfg_reg(UART3_RX);
  263. omap_mpu_wdt_mode(0);
  264. platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices));
  265. palmtt_boardinfo[0].irq = gpio_to_irq(6);
  266. spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
  267. omap_serial_init();
  268. omap1_usb_init(&palmtt_usb_config);
  269. omap_register_i2c_bus(1, 100, NULL, 0);
  270. omapfb_set_lcd_config(&palmtt_lcd_config);
  271. }
  272. MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T")
  273. .atag_offset = 0x100,
  274. .map_io = omap15xx_map_io,
  275. .init_early = omap1_init_early,
  276. .reserve = omap_reserve,
  277. .init_irq = omap1_init_irq,
  278. .init_machine = omap_palmtt_init,
  279. .timer = &omap1_timer,
  280. .restart = omap1_restart,
  281. MACHINE_END