board-palmtt.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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/mtd/physmap.h>
  24. #include <linux/leds.h>
  25. #include <mach/hardware.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/map.h>
  29. #include <plat/led.h>
  30. #include <mach/gpio.h>
  31. #include <plat/flash.h>
  32. #include <plat/mux.h>
  33. #include <plat/usb.h>
  34. #include <plat/dma.h>
  35. #include <plat/tc.h>
  36. #include <plat/board.h>
  37. #include <plat/irda.h>
  38. #include <plat/keypad.h>
  39. #include <plat/common.h>
  40. #include <linux/spi/spi.h>
  41. #include <linux/spi/ads7846.h>
  42. #define PALMTT_USBDETECT_GPIO 0
  43. #define PALMTT_CABLE_GPIO 1
  44. #define PALMTT_LED_GPIO 3
  45. #define PALMTT_PENIRQ_GPIO 6
  46. #define PALMTT_MMC_WP_GPIO 8
  47. #define PALMTT_HDQ_GPIO 11
  48. static const unsigned int palmtt_keymap[] = {
  49. KEY(0, 0, KEY_ESC),
  50. KEY(1, 0, KEY_SPACE),
  51. KEY(2, 0, KEY_LEFTCTRL),
  52. KEY(3, 0, KEY_TAB),
  53. KEY(4, 0, KEY_ENTER),
  54. KEY(0, 1, KEY_LEFT),
  55. KEY(1, 1, KEY_DOWN),
  56. KEY(2, 1, KEY_UP),
  57. KEY(3, 1, KEY_RIGHT),
  58. KEY(0, 2, KEY_SLEEP),
  59. KEY(4, 2, KEY_Y),
  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 physmap_flash_data palmtt_flash_data = {
  100. .width = 2,
  101. .set_vpp = omap1_set_vpp,
  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 = "physmap-flash",
  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 const struct matrix_keymap_data palmtt_keymap_data = {
  127. .keymap = palmtt_keymap,
  128. .keymap_size = ARRAY_SIZE(palmtt_keymap),
  129. };
  130. static struct omap_kp_platform_data palmtt_kp_data = {
  131. .rows = 6,
  132. .cols = 3,
  133. .keymap_data = &palmtt_keymap_data,
  134. };
  135. static struct platform_device palmtt_kp_device = {
  136. .name = "omap-keypad",
  137. .id = -1,
  138. .dev = {
  139. .platform_data = &palmtt_kp_data,
  140. },
  141. .num_resources = ARRAY_SIZE(palmtt_kp_resources),
  142. .resource = palmtt_kp_resources,
  143. };
  144. static struct platform_device palmtt_lcd_device = {
  145. .name = "lcd_palmtt",
  146. .id = -1,
  147. };
  148. static struct omap_irda_config palmtt_irda_config = {
  149. .transceiver_cap = IR_SIRMODE,
  150. .rx_channel = OMAP_DMA_UART3_RX,
  151. .tx_channel = OMAP_DMA_UART3_TX,
  152. .dest_start = UART3_THR,
  153. .src_start = UART3_RHR,
  154. .tx_trigger = 0,
  155. .rx_trigger = 0,
  156. };
  157. static struct resource palmtt_irda_resources[] = {
  158. [0] = {
  159. .start = INT_UART3,
  160. .end = INT_UART3,
  161. .flags = IORESOURCE_IRQ,
  162. },
  163. };
  164. static struct platform_device palmtt_irda_device = {
  165. .name = "omapirda",
  166. .id = -1,
  167. .dev = {
  168. .platform_data = &palmtt_irda_config,
  169. },
  170. .num_resources = ARRAY_SIZE(palmtt_irda_resources),
  171. .resource = palmtt_irda_resources,
  172. };
  173. static struct platform_device palmtt_spi_device = {
  174. .name = "spi_palmtt",
  175. .id = -1,
  176. };
  177. static struct omap_backlight_config palmtt_backlight_config = {
  178. .default_intensity = 0xa0,
  179. };
  180. static struct platform_device palmtt_backlight_device = {
  181. .name = "omap-bl",
  182. .id = -1,
  183. .dev = {
  184. .platform_data= &palmtt_backlight_config,
  185. },
  186. };
  187. static struct omap_led_config palmtt_led_config[] = {
  188. {
  189. .cdev = {
  190. .name = "palmtt:led0",
  191. },
  192. .gpio = PALMTT_LED_GPIO,
  193. },
  194. };
  195. static struct omap_led_platform_data palmtt_led_data = {
  196. .nr_leds = ARRAY_SIZE(palmtt_led_config),
  197. .leds = palmtt_led_config,
  198. };
  199. static struct platform_device palmtt_led_device = {
  200. .name = "omap-led",
  201. .id = -1,
  202. .dev = {
  203. .platform_data = &palmtt_led_data,
  204. },
  205. };
  206. static struct platform_device *palmtt_devices[] __initdata = {
  207. &palmtt_flash_device,
  208. &palmtt_kp_device,
  209. &palmtt_lcd_device,
  210. &palmtt_irda_device,
  211. &palmtt_spi_device,
  212. &palmtt_backlight_device,
  213. &palmtt_led_device,
  214. };
  215. static int palmtt_get_pendown_state(void)
  216. {
  217. return !gpio_get_value(6);
  218. }
  219. static const struct ads7846_platform_data palmtt_ts_info = {
  220. .model = 7846,
  221. .vref_delay_usecs = 100, /* internal, no capacitor */
  222. .x_plate_ohms = 419,
  223. .y_plate_ohms = 486,
  224. .get_pendown_state = palmtt_get_pendown_state,
  225. };
  226. static struct spi_board_info __initdata palmtt_boardinfo[] = {
  227. {
  228. /* MicroWire (bus 2) CS0 has an ads7846e */
  229. .modalias = "ads7846",
  230. .platform_data = &palmtt_ts_info,
  231. .irq = OMAP_GPIO_IRQ(6),
  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 void __init omap_palmtt_init_irq(void)
  239. {
  240. omap1_init_common_hw();
  241. omap_init_irq();
  242. }
  243. static struct omap_usb_config palmtt_usb_config __initdata = {
  244. .register_dev = 1,
  245. .hmc_mode = 0,
  246. .pins[0] = 2,
  247. };
  248. static struct omap_lcd_config palmtt_lcd_config __initdata = {
  249. .ctrl_name = "internal",
  250. };
  251. static struct omap_board_config_kernel palmtt_config[] __initdata = {
  252. { OMAP_TAG_LCD, &palmtt_lcd_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. /* mux pins for uarts */
  265. omap_cfg_reg(UART1_TX);
  266. omap_cfg_reg(UART1_RTS);
  267. omap_cfg_reg(UART2_TX);
  268. omap_cfg_reg(UART2_RTS);
  269. omap_cfg_reg(UART3_TX);
  270. omap_cfg_reg(UART3_RX);
  271. omap_mpu_wdt_mode(0);
  272. omap_board_config = palmtt_config;
  273. omap_board_config_size = ARRAY_SIZE(palmtt_config);
  274. platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices));
  275. spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
  276. omap_serial_init();
  277. omap1_usb_init(&palmtt_usb_config);
  278. omap_register_i2c_bus(1, 100, NULL, 0);
  279. }
  280. static void __init omap_palmtt_map_io(void)
  281. {
  282. omap1_map_common_io();
  283. }
  284. MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T")
  285. .boot_params = 0x10000100,
  286. .map_io = omap_palmtt_map_io,
  287. .reserve = omap_reserve,
  288. .init_irq = omap_palmtt_init_irq,
  289. .init_machine = omap_palmtt_init,
  290. .timer = &omap_timer,
  291. MACHINE_END