board-innovator.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. /*
  2. * linux/arch/arm/mach-omap1/board-innovator.c
  3. *
  4. * Board specific inits for OMAP-1510 and OMAP-1610 Innovator
  5. *
  6. * Copyright (C) 2001 RidgeRun, Inc.
  7. * Author: Greg Lonnon <glonnon@ridgerun.com>
  8. *
  9. * Copyright (C) 2002 MontaVista Software, Inc.
  10. *
  11. * Separated FPGA interrupts from innovator1510.c and cleaned up for 2.6
  12. * Copyright (C) 2004 Nokia Corporation by Tony Lindrgen <tony@atomide.com>
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/delay.h>
  22. #include <linux/mtd/mtd.h>
  23. #include <linux/mtd/partitions.h>
  24. #include <linux/input.h>
  25. #include <asm/hardware.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/mach/arch.h>
  28. #include <asm/mach/flash.h>
  29. #include <asm/mach/map.h>
  30. #include <asm/arch/mux.h>
  31. #include <asm/arch/fpga.h>
  32. #include <asm/arch/gpio.h>
  33. #include <asm/arch/tc.h>
  34. #include <asm/arch/usb.h>
  35. #include <asm/arch/keypad.h>
  36. #include <asm/arch/common.h>
  37. #include <asm/arch/mcbsp.h>
  38. #include <asm/arch/omap-alsa.h>
  39. static int innovator_keymap[] = {
  40. KEY(0, 0, KEY_F1),
  41. KEY(0, 3, KEY_DOWN),
  42. KEY(1, 1, KEY_F2),
  43. KEY(1, 2, KEY_RIGHT),
  44. KEY(2, 0, KEY_F3),
  45. KEY(2, 1, KEY_F4),
  46. KEY(2, 2, KEY_UP),
  47. KEY(3, 2, KEY_ENTER),
  48. KEY(3, 3, KEY_LEFT),
  49. 0
  50. };
  51. static struct mtd_partition innovator_partitions[] = {
  52. /* bootloader (U-Boot, etc) in first sector */
  53. {
  54. .name = "bootloader",
  55. .offset = 0,
  56. .size = SZ_128K,
  57. .mask_flags = MTD_WRITEABLE, /* force read-only */
  58. },
  59. /* bootloader params in the next sector */
  60. {
  61. .name = "params",
  62. .offset = MTDPART_OFS_APPEND,
  63. .size = SZ_128K,
  64. .mask_flags = 0,
  65. },
  66. /* kernel */
  67. {
  68. .name = "kernel",
  69. .offset = MTDPART_OFS_APPEND,
  70. .size = SZ_2M,
  71. .mask_flags = 0
  72. },
  73. /* rest of flash1 is a file system */
  74. {
  75. .name = "rootfs",
  76. .offset = MTDPART_OFS_APPEND,
  77. .size = SZ_16M - SZ_2M - 2 * SZ_128K,
  78. .mask_flags = 0
  79. },
  80. /* file system */
  81. {
  82. .name = "filesystem",
  83. .offset = MTDPART_OFS_APPEND,
  84. .size = MTDPART_SIZ_FULL,
  85. .mask_flags = 0
  86. }
  87. };
  88. static struct flash_platform_data innovator_flash_data = {
  89. .map_name = "cfi_probe",
  90. .width = 2,
  91. .parts = innovator_partitions,
  92. .nr_parts = ARRAY_SIZE(innovator_partitions),
  93. };
  94. static struct resource innovator_flash_resource = {
  95. .start = OMAP_CS0_PHYS,
  96. .end = OMAP_CS0_PHYS + SZ_32M - 1,
  97. .flags = IORESOURCE_MEM,
  98. };
  99. static struct platform_device innovator_flash_device = {
  100. .name = "omapflash",
  101. .id = 0,
  102. .dev = {
  103. .platform_data = &innovator_flash_data,
  104. },
  105. .num_resources = 1,
  106. .resource = &innovator_flash_resource,
  107. };
  108. #define DEFAULT_BITPERSAMPLE 16
  109. static struct omap_mcbsp_reg_cfg mcbsp_regs = {
  110. .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
  111. .spcr1 = RINTM(3) | RRST,
  112. .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
  113. RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
  114. .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
  115. .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
  116. XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
  117. .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
  118. .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
  119. .srgr2 = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
  120. /*.pcr0 = FSXM | FSRM | CLKXM | CLKRM | CLKXP | CLKRP,*/ /* mcbsp: master */
  121. .pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
  122. };
  123. static struct omap_alsa_codec_config alsa_config = {
  124. .name = "OMAP Innovator AIC23",
  125. .mcbsp_regs_alsa = &mcbsp_regs,
  126. .codec_configure_dev = NULL, // aic23_configure,
  127. .codec_set_samplerate = NULL, // aic23_set_samplerate,
  128. .codec_clock_setup = NULL, // aic23_clock_setup,
  129. .codec_clock_on = NULL, // aic23_clock_on,
  130. .codec_clock_off = NULL, // aic23_clock_off,
  131. .get_default_samplerate = NULL, // aic23_get_default_samplerate,
  132. };
  133. static struct platform_device innovator_mcbsp1_device = {
  134. .name = "omap_alsa_mcbsp",
  135. .id = 1,
  136. .dev = {
  137. .platform_data = &alsa_config,
  138. },
  139. };
  140. static struct resource innovator_kp_resources[] = {
  141. [0] = {
  142. .start = INT_KEYBOARD,
  143. .end = INT_KEYBOARD,
  144. .flags = IORESOURCE_IRQ,
  145. },
  146. };
  147. static struct omap_kp_platform_data innovator_kp_data = {
  148. .rows = 8,
  149. .cols = 8,
  150. .keymap = innovator_keymap,
  151. .keymapsize = ARRAY_SIZE(innovator_keymap),
  152. .delay = 4,
  153. };
  154. static struct platform_device innovator_kp_device = {
  155. .name = "omap-keypad",
  156. .id = -1,
  157. .dev = {
  158. .platform_data = &innovator_kp_data,
  159. },
  160. .num_resources = ARRAY_SIZE(innovator_kp_resources),
  161. .resource = innovator_kp_resources,
  162. };
  163. #ifdef CONFIG_ARCH_OMAP15XX
  164. #include <linux/spi/spi.h>
  165. #include <linux/spi/ads7846.h>
  166. /* Only FPGA needs to be mapped here. All others are done with ioremap */
  167. static struct map_desc innovator1510_io_desc[] __initdata = {
  168. {
  169. .virtual = OMAP1510_FPGA_BASE,
  170. .pfn = __phys_to_pfn(OMAP1510_FPGA_START),
  171. .length = OMAP1510_FPGA_SIZE,
  172. .type = MT_DEVICE
  173. }
  174. };
  175. static struct resource innovator1510_smc91x_resources[] = {
  176. [0] = {
  177. .start = OMAP1510_FPGA_ETHR_START, /* Physical */
  178. .end = OMAP1510_FPGA_ETHR_START + 0xf,
  179. .flags = IORESOURCE_MEM,
  180. },
  181. [1] = {
  182. .start = OMAP1510_INT_ETHER,
  183. .end = OMAP1510_INT_ETHER,
  184. .flags = IORESOURCE_IRQ,
  185. },
  186. };
  187. static struct platform_device innovator1510_smc91x_device = {
  188. .name = "smc91x",
  189. .id = 0,
  190. .num_resources = ARRAY_SIZE(innovator1510_smc91x_resources),
  191. .resource = innovator1510_smc91x_resources,
  192. };
  193. static struct platform_device innovator1510_lcd_device = {
  194. .name = "lcd_inn1510",
  195. .id = -1,
  196. };
  197. static struct platform_device innovator1510_spi_device = {
  198. .name = "spi_inn1510",
  199. .id = -1,
  200. };
  201. static struct platform_device *innovator1510_devices[] __initdata = {
  202. &innovator_flash_device,
  203. &innovator1510_smc91x_device,
  204. &innovator_mcbsp1_device,
  205. &innovator_kp_device,
  206. &innovator1510_lcd_device,
  207. &innovator1510_spi_device,
  208. };
  209. static int innovator_get_pendown_state(void)
  210. {
  211. return !(fpga_read(OMAP1510_FPGA_TOUCHSCREEN) & (1 << 5));
  212. }
  213. static const struct ads7846_platform_data innovator1510_ts_info = {
  214. .model = 7846,
  215. .vref_delay_usecs = 100, /* internal, no capacitor */
  216. .x_plate_ohms = 419,
  217. .y_plate_ohms = 486,
  218. .get_pendown_state = innovator_get_pendown_state,
  219. };
  220. static struct spi_board_info __initdata innovator1510_boardinfo[] = { {
  221. /* FPGA (bus "10") CS0 has an ads7846e */
  222. .modalias = "ads7846",
  223. .platform_data = &innovator1510_ts_info,
  224. .irq = OMAP1510_INT_FPGA_TS,
  225. .max_speed_hz = 120000 /* max sample rate at 3V */
  226. * 26 /* command + data + overhead */,
  227. .bus_num = 10,
  228. .chip_select = 0,
  229. } };
  230. #endif /* CONFIG_ARCH_OMAP15XX */
  231. #ifdef CONFIG_ARCH_OMAP16XX
  232. static struct resource innovator1610_smc91x_resources[] = {
  233. [0] = {
  234. .start = INNOVATOR1610_ETHR_START, /* Physical */
  235. .end = INNOVATOR1610_ETHR_START + 0xf,
  236. .flags = IORESOURCE_MEM,
  237. },
  238. [1] = {
  239. .start = OMAP_GPIO_IRQ(0),
  240. .end = OMAP_GPIO_IRQ(0),
  241. .flags = IORESOURCE_IRQ,
  242. },
  243. };
  244. static struct platform_device innovator1610_smc91x_device = {
  245. .name = "smc91x",
  246. .id = 0,
  247. .num_resources = ARRAY_SIZE(innovator1610_smc91x_resources),
  248. .resource = innovator1610_smc91x_resources,
  249. };
  250. static struct platform_device innovator1610_lcd_device = {
  251. .name = "inn1610_lcd",
  252. .id = -1,
  253. };
  254. static struct platform_device *innovator1610_devices[] __initdata = {
  255. &innovator_flash_device,
  256. &innovator1610_smc91x_device,
  257. &innovator_kp_device,
  258. &innovator1610_lcd_device,
  259. };
  260. #endif /* CONFIG_ARCH_OMAP16XX */
  261. static void __init innovator_init_smc91x(void)
  262. {
  263. if (cpu_is_omap1510()) {
  264. fpga_write(fpga_read(OMAP1510_FPGA_RST) & ~1,
  265. OMAP1510_FPGA_RST);
  266. udelay(750);
  267. } else {
  268. if ((omap_request_gpio(0)) < 0) {
  269. printk("Error requesting gpio 0 for smc91x irq\n");
  270. return;
  271. }
  272. }
  273. }
  274. static void __init innovator_init_irq(void)
  275. {
  276. omap1_init_common_hw();
  277. omap_init_irq();
  278. omap_gpio_init();
  279. #ifdef CONFIG_ARCH_OMAP15XX
  280. if (cpu_is_omap1510()) {
  281. omap1510_fpga_init_irq();
  282. }
  283. #endif
  284. innovator_init_smc91x();
  285. }
  286. #ifdef CONFIG_ARCH_OMAP15XX
  287. static struct omap_usb_config innovator1510_usb_config __initdata = {
  288. /* for bundled non-standard host and peripheral cables */
  289. .hmc_mode = 4,
  290. .register_host = 1,
  291. .pins[1] = 6,
  292. .pins[2] = 6, /* Conflicts with UART2 */
  293. .register_dev = 1,
  294. .pins[0] = 2,
  295. };
  296. static struct omap_lcd_config innovator1510_lcd_config __initdata = {
  297. .ctrl_name = "internal",
  298. };
  299. #endif
  300. #ifdef CONFIG_ARCH_OMAP16XX
  301. static struct omap_usb_config h2_usb_config __initdata = {
  302. /* usb1 has a Mini-AB port and external isp1301 transceiver */
  303. .otg = 2,
  304. #ifdef CONFIG_USB_GADGET_OMAP
  305. .hmc_mode = 19, // 0:host(off) 1:dev|otg 2:disabled
  306. // .hmc_mode = 21, // 0:host(off) 1:dev(loopback) 2:host(loopback)
  307. #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  308. /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
  309. .hmc_mode = 20, // 1:dev|otg(off) 1:host 2:disabled
  310. #endif
  311. .pins[1] = 3,
  312. };
  313. static struct omap_lcd_config innovator1610_lcd_config __initdata = {
  314. .ctrl_name = "internal",
  315. };
  316. #endif
  317. static struct omap_mmc_config innovator_mmc_config __initdata = {
  318. .mmc [0] = {
  319. .enabled = 1,
  320. .wire4 = 1,
  321. .wp_pin = OMAP_MPUIO(3),
  322. .power_pin = -1, /* FPGA F3 UIO42 */
  323. .switch_pin = -1, /* FPGA F4 UIO43 */
  324. },
  325. };
  326. static struct omap_uart_config innovator_uart_config __initdata = {
  327. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  328. };
  329. static struct omap_board_config_kernel innovator_config[] = {
  330. { OMAP_TAG_USB, NULL },
  331. { OMAP_TAG_LCD, NULL },
  332. { OMAP_TAG_MMC, &innovator_mmc_config },
  333. { OMAP_TAG_UART, &innovator_uart_config },
  334. };
  335. static void __init innovator_init(void)
  336. {
  337. #ifdef CONFIG_ARCH_OMAP15XX
  338. if (cpu_is_omap1510()) {
  339. platform_add_devices(innovator1510_devices, ARRAY_SIZE(innovator1510_devices));
  340. spi_register_board_info(innovator1510_boardinfo,
  341. ARRAY_SIZE(innovator1510_boardinfo));
  342. }
  343. #endif
  344. #ifdef CONFIG_ARCH_OMAP16XX
  345. if (!cpu_is_omap1510()) {
  346. platform_add_devices(innovator1610_devices, ARRAY_SIZE(innovator1610_devices));
  347. }
  348. #endif
  349. #ifdef CONFIG_ARCH_OMAP15XX
  350. if (cpu_is_omap1510()) {
  351. innovator_config[0].data = &innovator1510_usb_config;
  352. innovator_config[1].data = &innovator1510_lcd_config;
  353. }
  354. #endif
  355. #ifdef CONFIG_ARCH_OMAP16XX
  356. if (cpu_is_omap1610()) {
  357. innovator_config[0].data = &h2_usb_config;
  358. innovator_config[1].data = &innovator1610_lcd_config;
  359. }
  360. #endif
  361. omap_board_config = innovator_config;
  362. omap_board_config_size = ARRAY_SIZE(innovator_config);
  363. omap_serial_init();
  364. }
  365. static void __init innovator_map_io(void)
  366. {
  367. omap1_map_common_io();
  368. #ifdef CONFIG_ARCH_OMAP15XX
  369. if (cpu_is_omap1510()) {
  370. iotable_init(innovator1510_io_desc, ARRAY_SIZE(innovator1510_io_desc));
  371. udelay(10); /* Delay needed for FPGA */
  372. /* Dump the Innovator FPGA rev early - useful info for support. */
  373. printk("Innovator FPGA Rev %d.%d Board Rev %d\n",
  374. fpga_read(OMAP1510_FPGA_REV_HIGH),
  375. fpga_read(OMAP1510_FPGA_REV_LOW),
  376. fpga_read(OMAP1510_FPGA_BOARD_REV));
  377. }
  378. #endif
  379. }
  380. MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
  381. /* Maintainer: MontaVista Software, Inc. */
  382. .phys_io = 0xfff00000,
  383. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  384. .boot_params = 0x10000100,
  385. .map_io = innovator_map_io,
  386. .init_irq = innovator_init_irq,
  387. .init_machine = innovator_init,
  388. .timer = &omap_timer,
  389. MACHINE_END