board-innovator.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-omap1/board-innovator.c
  4. *
  5. * Board specific inits for OMAP-1510 and OMAP-1610 Innovator
  6. *
  7. * Copyright (C) 2001 RidgeRun, Inc.
  8. * Author: Greg Lonnon <[email protected]>
  9. *
  10. * Copyright (C) 2002 MontaVista Software, Inc.
  11. *
  12. * Separated FPGA interrupts from innovator1510.c and cleaned up for 2.6
  13. * Copyright (C) 2004 Nokia Corporation by Tony Lindrgen <[email protected]>
  14. */
  15. #include <linux/gpio.h>
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/delay.h>
  20. #include <linux/mtd/mtd.h>
  21. #include <linux/mtd/partitions.h>
  22. #include <linux/mtd/physmap.h>
  23. #include <linux/input.h>
  24. #include <linux/smc91x.h>
  25. #include <linux/omapfb.h>
  26. #include <linux/platform_data/keypad-omap.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include "tc.h"
  31. #include "mux.h"
  32. #include "flash.h"
  33. #include "hardware.h"
  34. #include "usb.h"
  35. #include "iomap.h"
  36. #include "common.h"
  37. #include "mmc.h"
  38. /* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
  39. #define INNOVATOR1610_ETHR_START 0x04000300
  40. static const unsigned int innovator_keymap[] = {
  41. KEY(0, 0, KEY_F1),
  42. KEY(3, 0, KEY_DOWN),
  43. KEY(1, 1, KEY_F2),
  44. KEY(2, 1, KEY_RIGHT),
  45. KEY(0, 2, KEY_F3),
  46. KEY(1, 2, KEY_F4),
  47. KEY(2, 2, KEY_UP),
  48. KEY(2, 3, KEY_ENTER),
  49. KEY(3, 3, KEY_LEFT),
  50. };
  51. static struct mtd_partition innovator_partitions[] = {
  52. /* bootloader (U-Boot, etc) in first sector */
  53. {
  54. .name = "bootloader",
  55. .offset = 0,
  56. .size = SZ_128K,
  57. .mask_flags = MTD_WRITEABLE, /* force read-only */
  58. },
  59. /* bootloader params in the next sector */
  60. {
  61. .name = "params",
  62. .offset = MTDPART_OFS_APPEND,
  63. .size = SZ_128K,
  64. .mask_flags = 0,
  65. },
  66. /* kernel */
  67. {
  68. .name = "kernel",
  69. .offset = MTDPART_OFS_APPEND,
  70. .size = SZ_2M,
  71. .mask_flags = 0
  72. },
  73. /* rest of flash1 is a file system */
  74. {
  75. .name = "rootfs",
  76. .offset = MTDPART_OFS_APPEND,
  77. .size = SZ_16M - SZ_2M - 2 * SZ_128K,
  78. .mask_flags = 0
  79. },
  80. /* file system */
  81. {
  82. .name = "filesystem",
  83. .offset = MTDPART_OFS_APPEND,
  84. .size = MTDPART_SIZ_FULL,
  85. .mask_flags = 0
  86. }
  87. };
  88. static struct physmap_flash_data innovator_flash_data = {
  89. .width = 2,
  90. .set_vpp = omap1_set_vpp,
  91. .parts = innovator_partitions,
  92. .nr_parts = ARRAY_SIZE(innovator_partitions),
  93. };
  94. static struct resource innovator_flash_resource = {
  95. .start = OMAP_CS0_PHYS,
  96. .end = OMAP_CS0_PHYS + SZ_32M - 1,
  97. .flags = IORESOURCE_MEM,
  98. };
  99. static struct platform_device innovator_flash_device = {
  100. .name = "physmap-flash",
  101. .id = 0,
  102. .dev = {
  103. .platform_data = &innovator_flash_data,
  104. },
  105. .num_resources = 1,
  106. .resource = &innovator_flash_resource,
  107. };
  108. static struct resource innovator_kp_resources[] = {
  109. [0] = {
  110. .start = INT_KEYBOARD,
  111. .end = INT_KEYBOARD,
  112. .flags = IORESOURCE_IRQ,
  113. },
  114. };
  115. static const struct matrix_keymap_data innovator_keymap_data = {
  116. .keymap = innovator_keymap,
  117. .keymap_size = ARRAY_SIZE(innovator_keymap),
  118. };
  119. static struct omap_kp_platform_data innovator_kp_data = {
  120. .rows = 8,
  121. .cols = 8,
  122. .keymap_data = &innovator_keymap_data,
  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. .dev = {
  176. .platform_data = (void __force *)OMAP1510_FPGA_LCD_PANEL_CONTROL,
  177. }
  178. };
  179. static struct platform_device innovator1510_spi_device = {
  180. .name = "spi_inn1510",
  181. .id = -1,
  182. };
  183. static struct platform_device *innovator1510_devices[] __initdata = {
  184. &innovator_flash_device,
  185. &innovator1510_smc91x_device,
  186. &innovator_kp_device,
  187. &innovator1510_lcd_device,
  188. &innovator1510_spi_device,
  189. };
  190. static int innovator_get_pendown_state(void)
  191. {
  192. return !(__raw_readb(OMAP1510_FPGA_TOUCHSCREEN) & (1 << 5));
  193. }
  194. static const struct ads7846_platform_data innovator1510_ts_info = {
  195. .model = 7846,
  196. .vref_delay_usecs = 100, /* internal, no capacitor */
  197. .x_plate_ohms = 419,
  198. .y_plate_ohms = 486,
  199. .get_pendown_state = innovator_get_pendown_state,
  200. };
  201. static struct spi_board_info __initdata innovator1510_boardinfo[] = { {
  202. /* FPGA (bus "10") CS0 has an ads7846e */
  203. .modalias = "ads7846",
  204. .platform_data = &innovator1510_ts_info,
  205. .irq = OMAP1510_INT_FPGA_TS,
  206. .max_speed_hz = 120000 /* max sample rate at 3V */
  207. * 26 /* command + data + overhead */,
  208. .bus_num = 10,
  209. .chip_select = 0,
  210. } };
  211. #endif /* CONFIG_ARCH_OMAP15XX */
  212. #ifdef CONFIG_ARCH_OMAP16XX
  213. static struct resource innovator1610_smc91x_resources[] = {
  214. [0] = {
  215. .start = INNOVATOR1610_ETHR_START, /* Physical */
  216. .end = INNOVATOR1610_ETHR_START + 0xf,
  217. .flags = IORESOURCE_MEM,
  218. },
  219. [1] = {
  220. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  221. },
  222. };
  223. static struct platform_device innovator1610_smc91x_device = {
  224. .name = "smc91x",
  225. .id = 0,
  226. .dev = {
  227. .platform_data = &innovator_smc91x_info,
  228. },
  229. .num_resources = ARRAY_SIZE(innovator1610_smc91x_resources),
  230. .resource = innovator1610_smc91x_resources,
  231. };
  232. static struct platform_device innovator1610_lcd_device = {
  233. .name = "inn1610_lcd",
  234. .id = -1,
  235. };
  236. static struct platform_device *innovator1610_devices[] __initdata = {
  237. &innovator_flash_device,
  238. &innovator1610_smc91x_device,
  239. &innovator_kp_device,
  240. &innovator1610_lcd_device,
  241. };
  242. #endif /* CONFIG_ARCH_OMAP16XX */
  243. static void __init innovator_init_smc91x(void)
  244. {
  245. if (cpu_is_omap1510()) {
  246. __raw_writeb(__raw_readb(OMAP1510_FPGA_RST) & ~1,
  247. OMAP1510_FPGA_RST);
  248. udelay(750);
  249. } else {
  250. if (gpio_request(0, "SMC91x irq") < 0) {
  251. printk("Error requesting gpio 0 for smc91x irq\n");
  252. return;
  253. }
  254. }
  255. }
  256. #ifdef CONFIG_ARCH_OMAP15XX
  257. /*
  258. * Board specific gang-switched transceiver power on/off.
  259. */
  260. static int innovator_omap_ohci_transceiver_power(int on)
  261. {
  262. if (on)
  263. __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL)
  264. | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)),
  265. INNOVATOR_FPGA_CAM_USB_CONTROL);
  266. else
  267. __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL)
  268. & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)),
  269. INNOVATOR_FPGA_CAM_USB_CONTROL);
  270. return 0;
  271. }
  272. static struct omap_usb_config innovator1510_usb_config __initdata = {
  273. /* for bundled non-standard host and peripheral cables */
  274. .hmc_mode = 4,
  275. .register_host = 1,
  276. .pins[1] = 6,
  277. .pins[2] = 6, /* Conflicts with UART2 */
  278. .register_dev = 1,
  279. .pins[0] = 2,
  280. .transceiver_power = innovator_omap_ohci_transceiver_power,
  281. };
  282. static const struct omap_lcd_config innovator1510_lcd_config __initconst = {
  283. .ctrl_name = "internal",
  284. };
  285. #endif
  286. #ifdef CONFIG_ARCH_OMAP16XX
  287. static struct omap_usb_config h2_usb_config __initdata = {
  288. /* usb1 has a Mini-AB port and external isp1301 transceiver */
  289. .otg = 2,
  290. #if IS_ENABLED(CONFIG_USB_OMAP)
  291. .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
  292. /* .hmc_mode = 21,*/ /* 0:host(off) 1:dev(loopback) 2:host(loopback) */
  293. #elif IS_ENABLED(CONFIG_USB_OHCI_HCD)
  294. /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
  295. .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
  296. #endif
  297. .pins[1] = 3,
  298. };
  299. static const struct omap_lcd_config innovator1610_lcd_config __initconst = {
  300. .ctrl_name = "internal",
  301. };
  302. #endif
  303. #if IS_ENABLED(CONFIG_MMC_OMAP)
  304. static int mmc_set_power(struct device *dev, int slot, int power_on,
  305. int vdd)
  306. {
  307. if (power_on)
  308. __raw_writeb(__raw_readb(OMAP1510_FPGA_POWER) | (1 << 3),
  309. OMAP1510_FPGA_POWER);
  310. else
  311. __raw_writeb(__raw_readb(OMAP1510_FPGA_POWER) & ~(1 << 3),
  312. OMAP1510_FPGA_POWER);
  313. return 0;
  314. }
  315. /*
  316. * Innovator could use the following functions tested:
  317. * - mmc_get_wp that uses OMAP_MPUIO(3)
  318. * - mmc_get_cover_state that uses FPGA F4 UIO43
  319. */
  320. static struct omap_mmc_platform_data mmc1_data = {
  321. .nr_slots = 1,
  322. .slots[0] = {
  323. .set_power = mmc_set_power,
  324. .wires = 4,
  325. .name = "mmcblk",
  326. },
  327. };
  328. static struct omap_mmc_platform_data *mmc_data[OMAP16XX_NR_MMC];
  329. static void __init innovator_mmc_init(void)
  330. {
  331. mmc_data[0] = &mmc1_data;
  332. omap1_init_mmc(mmc_data, OMAP15XX_NR_MMC);
  333. }
  334. #else
  335. static inline void innovator_mmc_init(void)
  336. {
  337. }
  338. #endif
  339. static void __init innovator_init(void)
  340. {
  341. if (cpu_is_omap1510())
  342. omap1510_fpga_init_irq();
  343. innovator_init_smc91x();
  344. #ifdef CONFIG_ARCH_OMAP15XX
  345. if (cpu_is_omap1510()) {
  346. unsigned char reg;
  347. /* mux pins for uarts */
  348. omap_cfg_reg(UART1_TX);
  349. omap_cfg_reg(UART1_RTS);
  350. omap_cfg_reg(UART2_TX);
  351. omap_cfg_reg(UART2_RTS);
  352. omap_cfg_reg(UART3_TX);
  353. omap_cfg_reg(UART3_RX);
  354. reg = __raw_readb(OMAP1510_FPGA_POWER);
  355. reg |= OMAP1510_FPGA_PCR_COM1_EN;
  356. __raw_writeb(reg, OMAP1510_FPGA_POWER);
  357. udelay(10);
  358. reg = __raw_readb(OMAP1510_FPGA_POWER);
  359. reg |= OMAP1510_FPGA_PCR_COM2_EN;
  360. __raw_writeb(reg, OMAP1510_FPGA_POWER);
  361. udelay(10);
  362. platform_add_devices(innovator1510_devices, ARRAY_SIZE(innovator1510_devices));
  363. spi_register_board_info(innovator1510_boardinfo,
  364. ARRAY_SIZE(innovator1510_boardinfo));
  365. }
  366. #endif
  367. #ifdef CONFIG_ARCH_OMAP16XX
  368. if (!cpu_is_omap1510()) {
  369. innovator1610_smc91x_resources[1].start = gpio_to_irq(0);
  370. innovator1610_smc91x_resources[1].end = gpio_to_irq(0);
  371. platform_add_devices(innovator1610_devices, ARRAY_SIZE(innovator1610_devices));
  372. }
  373. #endif
  374. #ifdef CONFIG_ARCH_OMAP15XX
  375. if (cpu_is_omap1510()) {
  376. omap1_usb_init(&innovator1510_usb_config);
  377. omapfb_set_lcd_config(&innovator1510_lcd_config);
  378. }
  379. #endif
  380. #ifdef CONFIG_ARCH_OMAP16XX
  381. if (cpu_is_omap1610()) {
  382. omap1_usb_init(&h2_usb_config);
  383. omapfb_set_lcd_config(&innovator1610_lcd_config);
  384. }
  385. #endif
  386. omap_serial_init();
  387. omap_register_i2c_bus(1, 100, NULL, 0);
  388. innovator_mmc_init();
  389. }
  390. /*
  391. * REVISIT: Assume 15xx for now, we don't want to do revision check
  392. * until later on. The right way to fix this is to set up a different
  393. * machine_id for 16xx Innovator, or use device tree.
  394. */
  395. static void __init innovator_map_io(void)
  396. {
  397. #ifdef CONFIG_ARCH_OMAP15XX
  398. omap15xx_map_io();
  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. pr_debug("Innovator FPGA Rev %d.%d Board Rev %d\n",
  403. __raw_readb(OMAP1510_FPGA_REV_HIGH),
  404. __raw_readb(OMAP1510_FPGA_REV_LOW),
  405. __raw_readb(OMAP1510_FPGA_BOARD_REV));
  406. #endif
  407. }
  408. MACHINE_START(OMAP_INNOVATOR, "TI-Innovator")
  409. /* Maintainer: MontaVista Software, Inc. */
  410. .atag_offset = 0x100,
  411. .map_io = innovator_map_io,
  412. .init_early = omap1_init_early,
  413. .init_irq = omap1_init_irq,
  414. .handle_irq = omap1_handle_irq,
  415. .init_machine = innovator_init,
  416. .init_late = omap1_init_late,
  417. .init_time = omap1_timer_init,
  418. .restart = omap1_restart,
  419. MACHINE_END