board-palmtt.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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 "flash.h"
  35. #include <mach/mux.h>
  36. #include <linux/omap-dma.h>
  37. #include <mach/tc.h>
  38. #include <linux/platform_data/keypad-omap.h>
  39. #include <mach/hardware.h>
  40. #include <mach/usb.h>
  41. #include "common.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 platform_device palmtt_spi_device = {
  149. .name = "spi_palmtt",
  150. .id = -1,
  151. };
  152. static struct omap_backlight_config palmtt_backlight_config = {
  153. .default_intensity = 0xa0,
  154. };
  155. static struct platform_device palmtt_backlight_device = {
  156. .name = "omap-bl",
  157. .id = -1,
  158. .dev = {
  159. .platform_data= &palmtt_backlight_config,
  160. },
  161. };
  162. static struct omap_led_config palmtt_led_config[] = {
  163. {
  164. .cdev = {
  165. .name = "palmtt:led0",
  166. },
  167. .gpio = PALMTT_LED_GPIO,
  168. },
  169. };
  170. static struct omap_led_platform_data palmtt_led_data = {
  171. .nr_leds = ARRAY_SIZE(palmtt_led_config),
  172. .leds = palmtt_led_config,
  173. };
  174. static struct platform_device palmtt_led_device = {
  175. .name = "omap-led",
  176. .id = -1,
  177. .dev = {
  178. .platform_data = &palmtt_led_data,
  179. },
  180. };
  181. static struct platform_device *palmtt_devices[] __initdata = {
  182. &palmtt_flash_device,
  183. &palmtt_kp_device,
  184. &palmtt_lcd_device,
  185. &palmtt_spi_device,
  186. &palmtt_backlight_device,
  187. &palmtt_led_device,
  188. };
  189. static int palmtt_get_pendown_state(void)
  190. {
  191. return !gpio_get_value(6);
  192. }
  193. static const struct ads7846_platform_data palmtt_ts_info = {
  194. .model = 7846,
  195. .vref_delay_usecs = 100, /* internal, no capacitor */
  196. .x_plate_ohms = 419,
  197. .y_plate_ohms = 486,
  198. .get_pendown_state = palmtt_get_pendown_state,
  199. };
  200. static struct spi_board_info __initdata palmtt_boardinfo[] = {
  201. {
  202. /* MicroWire (bus 2) CS0 has an ads7846e */
  203. .modalias = "ads7846",
  204. .platform_data = &palmtt_ts_info,
  205. .max_speed_hz = 120000 /* max sample rate at 3V */
  206. * 26 /* command + data + overhead */,
  207. .bus_num = 2,
  208. .chip_select = 0,
  209. }
  210. };
  211. static struct omap_usb_config palmtt_usb_config __initdata = {
  212. .register_dev = 1,
  213. .hmc_mode = 0,
  214. .pins[0] = 2,
  215. };
  216. static struct omap_lcd_config palmtt_lcd_config __initdata = {
  217. .ctrl_name = "internal",
  218. };
  219. static void __init omap_mpu_wdt_mode(int mode) {
  220. if (mode)
  221. omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
  222. else {
  223. omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
  224. omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
  225. }
  226. }
  227. static void __init omap_palmtt_init(void)
  228. {
  229. /* mux pins for uarts */
  230. omap_cfg_reg(UART1_TX);
  231. omap_cfg_reg(UART1_RTS);
  232. omap_cfg_reg(UART2_TX);
  233. omap_cfg_reg(UART2_RTS);
  234. omap_cfg_reg(UART3_TX);
  235. omap_cfg_reg(UART3_RX);
  236. omap_mpu_wdt_mode(0);
  237. platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices));
  238. palmtt_boardinfo[0].irq = gpio_to_irq(6);
  239. spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
  240. omap_serial_init();
  241. omap1_usb_init(&palmtt_usb_config);
  242. omap_register_i2c_bus(1, 100, NULL, 0);
  243. omapfb_set_lcd_config(&palmtt_lcd_config);
  244. }
  245. MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T")
  246. .atag_offset = 0x100,
  247. .map_io = omap15xx_map_io,
  248. .init_early = omap1_init_early,
  249. .init_irq = omap1_init_irq,
  250. .handle_irq = omap1_handle_irq,
  251. .init_machine = omap_palmtt_init,
  252. .init_late = omap1_init_late,
  253. .init_time = omap1_timer_init,
  254. .restart = omap1_restart,
  255. MACHINE_END