board-palmtt.c 6.2 KB

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