board-innovator.c 11 KB

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