board-innovator.c 12 KB

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