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