board-palmtt.c 6.8 KB

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