board-innovator.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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/mmc.h>
  38. /* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
  39. #define INNOVATOR1610_ETHR_START 0x04000300
  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. static struct resource innovator_kp_resources[] = {
  110. [0] = {
  111. .start = INT_KEYBOARD,
  112. .end = INT_KEYBOARD,
  113. .flags = IORESOURCE_IRQ,
  114. },
  115. };
  116. static struct omap_kp_platform_data innovator_kp_data = {
  117. .rows = 8,
  118. .cols = 8,
  119. .keymap = innovator_keymap,
  120. .keymapsize = ARRAY_SIZE(innovator_keymap),
  121. .delay = 4,
  122. };
  123. static struct platform_device innovator_kp_device = {
  124. .name = "omap-keypad",
  125. .id = -1,
  126. .dev = {
  127. .platform_data = &innovator_kp_data,
  128. },
  129. .num_resources = ARRAY_SIZE(innovator_kp_resources),
  130. .resource = innovator_kp_resources,
  131. };
  132. #ifdef CONFIG_ARCH_OMAP15XX
  133. #include <linux/spi/spi.h>
  134. #include <linux/spi/ads7846.h>
  135. /* Only FPGA needs to be mapped here. All others are done with ioremap */
  136. static struct map_desc innovator1510_io_desc[] __initdata = {
  137. {
  138. .virtual = OMAP1510_FPGA_BASE,
  139. .pfn = __phys_to_pfn(OMAP1510_FPGA_START),
  140. .length = OMAP1510_FPGA_SIZE,
  141. .type = MT_DEVICE
  142. }
  143. };
  144. static struct resource innovator1510_smc91x_resources[] = {
  145. [0] = {
  146. .start = OMAP1510_FPGA_ETHR_START, /* Physical */
  147. .end = OMAP1510_FPGA_ETHR_START + 0xf,
  148. .flags = IORESOURCE_MEM,
  149. },
  150. [1] = {
  151. .start = OMAP1510_INT_ETHER,
  152. .end = OMAP1510_INT_ETHER,
  153. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  154. },
  155. };
  156. static struct platform_device innovator1510_smc91x_device = {
  157. .name = "smc91x",
  158. .id = 0,
  159. .num_resources = ARRAY_SIZE(innovator1510_smc91x_resources),
  160. .resource = innovator1510_smc91x_resources,
  161. };
  162. static struct platform_device innovator1510_lcd_device = {
  163. .name = "lcd_inn1510",
  164. .id = -1,
  165. };
  166. static struct platform_device innovator1510_spi_device = {
  167. .name = "spi_inn1510",
  168. .id = -1,
  169. };
  170. static struct platform_device *innovator1510_devices[] __initdata = {
  171. &innovator_flash_device,
  172. &innovator1510_smc91x_device,
  173. &innovator_kp_device,
  174. &innovator1510_lcd_device,
  175. &innovator1510_spi_device,
  176. };
  177. static int innovator_get_pendown_state(void)
  178. {
  179. return !(fpga_read(OMAP1510_FPGA_TOUCHSCREEN) & (1 << 5));
  180. }
  181. static const struct ads7846_platform_data innovator1510_ts_info = {
  182. .model = 7846,
  183. .vref_delay_usecs = 100, /* internal, no capacitor */
  184. .x_plate_ohms = 419,
  185. .y_plate_ohms = 486,
  186. .get_pendown_state = innovator_get_pendown_state,
  187. };
  188. static struct spi_board_info __initdata innovator1510_boardinfo[] = { {
  189. /* FPGA (bus "10") CS0 has an ads7846e */
  190. .modalias = "ads7846",
  191. .platform_data = &innovator1510_ts_info,
  192. .irq = OMAP1510_INT_FPGA_TS,
  193. .max_speed_hz = 120000 /* max sample rate at 3V */
  194. * 26 /* command + data + overhead */,
  195. .bus_num = 10,
  196. .chip_select = 0,
  197. } };
  198. #endif /* CONFIG_ARCH_OMAP15XX */
  199. #ifdef CONFIG_ARCH_OMAP16XX
  200. static struct resource innovator1610_smc91x_resources[] = {
  201. [0] = {
  202. .start = INNOVATOR1610_ETHR_START, /* Physical */
  203. .end = INNOVATOR1610_ETHR_START + 0xf,
  204. .flags = IORESOURCE_MEM,
  205. },
  206. [1] = {
  207. .start = OMAP_GPIO_IRQ(0),
  208. .end = OMAP_GPIO_IRQ(0),
  209. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  210. },
  211. };
  212. static struct platform_device innovator1610_smc91x_device = {
  213. .name = "smc91x",
  214. .id = 0,
  215. .num_resources = ARRAY_SIZE(innovator1610_smc91x_resources),
  216. .resource = innovator1610_smc91x_resources,
  217. };
  218. static struct platform_device innovator1610_lcd_device = {
  219. .name = "inn1610_lcd",
  220. .id = -1,
  221. };
  222. static struct platform_device *innovator1610_devices[] __initdata = {
  223. &innovator_flash_device,
  224. &innovator1610_smc91x_device,
  225. &innovator_kp_device,
  226. &innovator1610_lcd_device,
  227. };
  228. #endif /* CONFIG_ARCH_OMAP16XX */
  229. static void __init innovator_init_smc91x(void)
  230. {
  231. if (cpu_is_omap1510()) {
  232. fpga_write(fpga_read(OMAP1510_FPGA_RST) & ~1,
  233. OMAP1510_FPGA_RST);
  234. udelay(750);
  235. } else {
  236. if (gpio_request(0, "SMC91x irq") < 0) {
  237. printk("Error requesting gpio 0 for smc91x irq\n");
  238. return;
  239. }
  240. }
  241. }
  242. static void __init innovator_init_irq(void)
  243. {
  244. omap1_init_common_hw();
  245. omap_init_irq();
  246. omap_gpio_init();
  247. #ifdef CONFIG_ARCH_OMAP15XX
  248. if (cpu_is_omap1510()) {
  249. omap1510_fpga_init_irq();
  250. }
  251. #endif
  252. innovator_init_smc91x();
  253. }
  254. #ifdef CONFIG_ARCH_OMAP15XX
  255. static struct omap_usb_config innovator1510_usb_config __initdata = {
  256. /* for bundled non-standard host and peripheral cables */
  257. .hmc_mode = 4,
  258. .register_host = 1,
  259. .pins[1] = 6,
  260. .pins[2] = 6, /* Conflicts with UART2 */
  261. .register_dev = 1,
  262. .pins[0] = 2,
  263. };
  264. static struct omap_lcd_config innovator1510_lcd_config __initdata = {
  265. .ctrl_name = "internal",
  266. };
  267. #endif
  268. #ifdef CONFIG_ARCH_OMAP16XX
  269. static struct omap_usb_config h2_usb_config __initdata = {
  270. /* usb1 has a Mini-AB port and external isp1301 transceiver */
  271. .otg = 2,
  272. #ifdef CONFIG_USB_GADGET_OMAP
  273. .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
  274. /* .hmc_mode = 21,*/ /* 0:host(off) 1:dev(loopback) 2:host(loopback) */
  275. #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  276. /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
  277. .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
  278. #endif
  279. .pins[1] = 3,
  280. };
  281. static struct omap_lcd_config innovator1610_lcd_config __initdata = {
  282. .ctrl_name = "internal",
  283. };
  284. #endif
  285. #if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
  286. static int mmc_set_power(struct device *dev, int slot, int power_on,
  287. int vdd)
  288. {
  289. if (power_on)
  290. fpga_write(fpga_read(OMAP1510_FPGA_POWER) | (1 << 3),
  291. OMAP1510_FPGA_POWER);
  292. else
  293. fpga_write(fpga_read(OMAP1510_FPGA_POWER) & ~(1 << 3),
  294. OMAP1510_FPGA_POWER);
  295. return 0;
  296. }
  297. /*
  298. * Innovator could use the following functions tested:
  299. * - mmc_get_wp that uses OMAP_MPUIO(3)
  300. * - mmc_get_cover_state that uses FPGA F4 UIO43
  301. */
  302. static struct omap_mmc_platform_data mmc1_data = {
  303. .nr_slots = 1,
  304. .slots[0] = {
  305. .set_power = mmc_set_power,
  306. .wires = 4,
  307. .name = "mmcblk",
  308. },
  309. };
  310. static struct omap_mmc_platform_data *mmc_data[OMAP16XX_NR_MMC];
  311. void __init innovator_mmc_init(void)
  312. {
  313. mmc_data[0] = &mmc1_data;
  314. omap1_init_mmc(mmc_data, OMAP15XX_NR_MMC);
  315. }
  316. #else
  317. static inline void innovator_mmc_init(void)
  318. {
  319. }
  320. #endif
  321. static struct omap_uart_config innovator_uart_config __initdata = {
  322. .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
  323. };
  324. static struct omap_board_config_kernel innovator_config[] = {
  325. { OMAP_TAG_LCD, NULL },
  326. { OMAP_TAG_UART, &innovator_uart_config },
  327. };
  328. static void __init innovator_init(void)
  329. {
  330. #ifdef CONFIG_ARCH_OMAP15XX
  331. if (cpu_is_omap1510()) {
  332. platform_add_devices(innovator1510_devices, ARRAY_SIZE(innovator1510_devices));
  333. spi_register_board_info(innovator1510_boardinfo,
  334. ARRAY_SIZE(innovator1510_boardinfo));
  335. }
  336. #endif
  337. #ifdef CONFIG_ARCH_OMAP16XX
  338. if (!cpu_is_omap1510()) {
  339. platform_add_devices(innovator1610_devices, ARRAY_SIZE(innovator1610_devices));
  340. }
  341. #endif
  342. #ifdef CONFIG_ARCH_OMAP15XX
  343. if (cpu_is_omap1510()) {
  344. omap_usb_init(&innovator1510_usb_config);
  345. innovator_config[1].data = &innovator1510_lcd_config;
  346. }
  347. #endif
  348. #ifdef CONFIG_ARCH_OMAP16XX
  349. if (cpu_is_omap1610()) {
  350. omap_usb_init(&h2_usb_config);
  351. innovator_config[1].data = &innovator1610_lcd_config;
  352. }
  353. #endif
  354. omap_board_config = innovator_config;
  355. omap_board_config_size = ARRAY_SIZE(innovator_config);
  356. omap_serial_init();
  357. omap_register_i2c_bus(1, 100, NULL, 0);
  358. innovator_mmc_init();
  359. }
  360. static void __init innovator_map_io(void)
  361. {
  362. omap1_map_common_io();
  363. #ifdef CONFIG_ARCH_OMAP15XX
  364. if (cpu_is_omap1510()) {
  365. iotable_init(innovator1510_io_desc, ARRAY_SIZE(innovator1510_io_desc));
  366. udelay(10); /* Delay needed for FPGA */
  367. /* Dump the Innovator FPGA rev early - useful info for support. */
  368. printk("Innovator FPGA Rev %d.%d Board Rev %d\n",
  369. fpga_read(OMAP1510_FPGA_REV_HIGH),
  370. fpga_read(OMAP1510_FPGA_REV_LOW),
  371. fpga_read(OMAP1510_FPGA_BOARD_REV));
  372. }
  373. #endif
  374. }
  375. MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
  376. /* Maintainer: MontaVista Software, Inc. */
  377. .phys_io = 0xfff00000,
  378. .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
  379. .boot_params = 0x10000100,
  380. .map_io = innovator_map_io,
  381. .init_irq = innovator_init_irq,
  382. .init_machine = innovator_init,
  383. .timer = &omap_timer,
  384. MACHINE_END