board-innovator.c 11 KB

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