board-palmtt.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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 <asm/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 <asm/arch/led.h>
  30. #include <asm/arch/mcbsp.h>
  31. #include <asm/arch/gpio.h>
  32. #include <asm/arch/mux.h>
  33. #include <asm/arch/usb.h>
  34. #include <asm/arch/dma.h>
  35. #include <asm/arch/tc.h>
  36. #include <asm/arch/board.h>
  37. #include <asm/arch/irda.h>
  38. #include <asm/arch/keypad.h>
  39. #include <asm/arch/common.h>
  40. #include <asm/arch/omap-alsa.h>
  41. #include <linux/input.h>
  42. #include <linux/spi/spi.h>
  43. #include <linux/spi/ads7846.h>
  44. static int palmtt_keymap[] = {
  45. KEY(0, 0, KEY_ESC),
  46. KEY(0, 1, KEY_SPACE),
  47. KEY(0, 2, KEY_LEFTCTRL),
  48. KEY(0, 3, KEY_TAB),
  49. KEY(0, 4, KEY_ENTER),
  50. KEY(1, 0, KEY_LEFT),
  51. KEY(1, 1, KEY_DOWN),
  52. KEY(1, 2, KEY_UP),
  53. KEY(1, 3, KEY_RIGHT),
  54. KEY(2, 0, KEY_SLEEP),
  55. KEY(2, 4, KEY_Y),
  56. 0
  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 flash_platform_data palmtt_flash_data = {
  97. .map_name = "cfi_probe",
  98. .width = 2,
  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 = "omapflash",
  109. .id = 0,
  110. .dev = {
  111. .platform_data = &palmtt_flash_data,
  112. },
  113. .num_resources = 1,
  114. .resource = &palmtt_flash_resource,
  115. };
  116. #define DEFAULT_BITPERSAMPLE 16
  117. static struct omap_mcbsp_reg_cfg mcbsp_regs = {
  118. .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
  119. .spcr1 = RINTM(3) | RRST,
  120. .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
  121. RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
  122. .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) |
  123. RWDLEN1(OMAP_MCBSP_WORD_16),
  124. .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
  125. XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
  126. .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) |
  127. XWDLEN1(OMAP_MCBSP_WORD_16),
  128. .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
  129. .srgr2 = GSYNC | CLKSP | FSGM |
  130. FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
  131. .pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
  132. };
  133. static struct omap_alsa_codec_config alsa_config = {
  134. .name = "PalmTT AIC23",
  135. .mcbsp_regs_alsa = &mcbsp_regs,
  136. .codec_configure_dev = NULL, // aic23_configure,
  137. .codec_set_samplerate = NULL, // aic23_set_samplerate,
  138. .codec_clock_setup = NULL, // aic23_clock_setup,
  139. .codec_clock_on = NULL, // aic23_clock_on,
  140. .codec_clock_off = NULL, // aic23_clock_off,
  141. .get_default_samplerate = NULL, // aic23_get_default_samplerate,
  142. };
  143. static struct platform_device palmtt_mcbsp1_device = {
  144. .name = "omap_alsa_mcbsp",
  145. .id = 1,
  146. .dev = {
  147. .platform_data = &alsa_config,
  148. },
  149. };
  150. static struct resource palmtt_kp_resources[] = {
  151. [0] = {
  152. .start = INT_KEYBOARD,
  153. .end = INT_KEYBOARD,
  154. .flags = IORESOURCE_IRQ,
  155. },
  156. };
  157. static struct omap_kp_platform_data palmtt_kp_data = {
  158. .rows = 6,
  159. .cols = 3,
  160. .keymap = palmtt_keymap,
  161. };
  162. static struct platform_device palmtt_kp_device = {
  163. .name = "omap-keypad",
  164. .id = -1,
  165. .dev = {
  166. .platform_data = &palmtt_kp_data,
  167. },
  168. .num_resources = ARRAY_SIZE(palmtt_kp_resources),
  169. .resource = palmtt_kp_resources,
  170. };
  171. static struct platform_device palmtt_lcd_device = {
  172. .name = "lcd_palmtt",
  173. .id = -1,
  174. };
  175. static struct omap_irda_config palmtt_irda_config = {
  176. .transceiver_cap = IR_SIRMODE,
  177. .rx_channel = OMAP_DMA_UART3_RX,
  178. .tx_channel = OMAP_DMA_UART3_TX,
  179. .dest_start = UART3_THR,
  180. .src_start = UART3_RHR,
  181. .tx_trigger = 0,
  182. .rx_trigger = 0,
  183. };
  184. static struct resource palmtt_irda_resources[] = {
  185. [0] = {
  186. .start = INT_UART3,
  187. .end = INT_UART3,
  188. .flags = IORESOURCE_IRQ,
  189. },
  190. };
  191. static struct platform_device palmtt_irda_device = {
  192. .name = "omapirda",
  193. .id = -1,
  194. .dev = {
  195. .platform_data = &palmtt_irda_config,
  196. },
  197. .num_resources = ARRAY_SIZE(palmtt_irda_resources),
  198. .resource = palmtt_irda_resources,
  199. };
  200. static struct platform_device palmtt_spi_device = {
  201. .name = "spi_palmtt",
  202. .id = -1,
  203. };
  204. static struct omap_backlight_config palmtt_backlight_config = {
  205. .default_intensity = 0xa0,
  206. };
  207. static struct platform_device palmtt_backlight_device = {
  208. .name = "omap-bl",
  209. .id = -1,
  210. .dev = {
  211. .platform_data= &palmtt_backlight_config,
  212. },
  213. };
  214. static struct omap_led_config palmtt_led_config[] = {
  215. {
  216. .cdev = {
  217. .name = "palmtt:led0",
  218. },
  219. .gpio = PALMTT_LED_GPIO,
  220. },
  221. };
  222. static struct omap_led_platform_data palmtt_led_data = {
  223. .nr_leds = ARRAY_SIZE(palmtt_led_config),
  224. .leds = palmtt_led_config,
  225. };
  226. static struct platform_device palmtt_led_device = {
  227. .name = "omap-led",
  228. .id = -1,
  229. .dev = {
  230. .platform_data = &palmtt_led_data,
  231. },
  232. };
  233. static struct platform_device *palmtt_devices[] __initdata = {
  234. &palmtt_flash_device,
  235. &palmtt_mcbsp1_device,
  236. &palmtt_kp_device,
  237. &palmtt_lcd_device,
  238. &palmtt_irda_device,
  239. &palmtt_spi_device,
  240. &palmtt_backlight_device,
  241. &palmtt_led_device,
  242. };
  243. static int palmtt_get_pendown_state(void)
  244. {
  245. return !omap_get_gpio_datain(6);
  246. }
  247. static const struct ads7846_platform_data palmtt_ts_info = {
  248. .model = 7846,
  249. .vref_delay_usecs = 100, /* internal, no capacitor */
  250. .x_plate_ohms = 419,
  251. .y_plate_ohms = 486,
  252. .get_pendown_state = palmtt_get_pendown_state,
  253. };
  254. static struct spi_board_info __initdata palmtt_boardinfo[] = {
  255. {
  256. /* MicroWire (bus 2) CS0 has an ads7846e */
  257. .modalias = "ads7846",
  258. .platform_data = &palmtt_ts_info,
  259. .irq = OMAP_GPIO_IRQ(6),
  260. .max_speed_hz = 120000 /* max sample rate at 3V */
  261. * 26 /* command + data + overhead */,
  262. .bus_num = 2,
  263. .chip_select = 0,
  264. }
  265. };
  266. static void __init omap_palmtt_init_irq(void)
  267. {
  268. omap1_init_common_hw();
  269. omap_init_irq();
  270. }
  271. static struct omap_usb_config palmtt_usb_config __initdata = {
  272. .register_dev = 1,
  273. .hmc_mode = 0,
  274. .pins[0] = 2,
  275. };
  276. static struct omap_lcd_config palmtt_lcd_config __initdata = {
  277. .ctrl_name = "internal",
  278. };
  279. static struct omap_uart_config palmtt_uart_config __initdata = {
  280. .enabled_uarts = (1 << 0) | (1 << 1) | (0 << 2),
  281. };
  282. static struct omap_board_config_kernel palmtt_config[] = {
  283. { OMAP_TAG_USB, &palmtt_usb_config },
  284. { OMAP_TAG_LCD, &palmtt_lcd_config },
  285. { OMAP_TAG_UART, &palmtt_uart_config },
  286. };
  287. static void __init omap_mpu_wdt_mode(int mode) {
  288. if (mode)
  289. omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
  290. else {
  291. omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
  292. omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
  293. }
  294. }
  295. static void __init omap_palmtt_init(void)
  296. {
  297. omap_mpu_wdt_mode(0);
  298. omap_board_config = palmtt_config;
  299. omap_board_config_size = ARRAY_SIZE(palmtt_config);
  300. platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices));
  301. spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
  302. omap_serial_init();
  303. }
  304. static void __init omap_palmtt_map_io(void)
  305. {
  306. omap1_map_common_io();
  307. }
  308. MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T")
  309. .phys_io = 0xfff00000,
  310. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  311. .boot_params = 0x10000100,
  312. .map_io = omap_palmtt_map_io,
  313. .init_irq = omap_palmtt_init_irq,
  314. .init_machine = omap_palmtt_init,
  315. .timer = &omap_timer,
  316. MACHINE_END