board-palmtt.c 7.0 KB

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