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