board-innovator.c 11 KB

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