minotaur.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * 2008-2009 Cambridge Signal Processing
  4. * 2005 National ICT Australia (NICTA)
  5. * Aidan Williams <aidan@nicta.com.au>
  6. *
  7. * Licensed under the GPL-2 or later.
  8. */
  9. #include <linux/device.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/mtd/mtd.h>
  12. #include <linux/mtd/partitions.h>
  13. #include <linux/spi/spi.h>
  14. #include <linux/spi/flash.h>
  15. #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
  16. #include <linux/usb/isp1362.h>
  17. #endif
  18. #include <linux/ata_platform.h>
  19. #include <linux/irq.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/usb/sl811.h>
  22. #include <asm/dma.h>
  23. #include <asm/bfin5xx_spi.h>
  24. #include <asm/reboot.h>
  25. #include <asm/portmux.h>
  26. #include <linux/spi/ad7877.h>
  27. /*
  28. * Name the Board for the /proc/cpuinfo
  29. */
  30. const char bfin_board_name[] = "CamSig Minotaur BF537";
  31. #if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
  32. static struct resource bfin_pcmcia_cf_resources[] = {
  33. {
  34. .start = 0x20310000, /* IO PORT */
  35. .end = 0x20312000,
  36. .flags = IORESOURCE_MEM,
  37. }, {
  38. .start = 0x20311000, /* Attribute Memory */
  39. .end = 0x20311FFF,
  40. .flags = IORESOURCE_MEM,
  41. }, {
  42. .start = IRQ_PF4,
  43. .end = IRQ_PF4,
  44. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  45. }, {
  46. .start = IRQ_PF6, /* Card Detect PF6 */
  47. .end = IRQ_PF6,
  48. .flags = IORESOURCE_IRQ,
  49. },
  50. };
  51. static struct platform_device bfin_pcmcia_cf_device = {
  52. .name = "bfin_cf_pcmcia",
  53. .id = -1,
  54. .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
  55. .resource = bfin_pcmcia_cf_resources,
  56. };
  57. #endif
  58. #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  59. static struct platform_device rtc_device = {
  60. .name = "rtc-bfin",
  61. .id = -1,
  62. };
  63. #endif
  64. #if IS_ENABLED(CONFIG_BFIN_MAC)
  65. #include <linux/bfin_mac.h>
  66. static const unsigned short bfin_mac_peripherals[] = P_MII0;
  67. static struct bfin_phydev_platform_data bfin_phydev_data[] = {
  68. {
  69. .addr = 1,
  70. .irq = IRQ_MAC_PHYINT,
  71. },
  72. };
  73. static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
  74. .phydev_number = 1,
  75. .phydev_data = bfin_phydev_data,
  76. .phy_mode = PHY_INTERFACE_MODE_MII,
  77. .mac_peripherals = bfin_mac_peripherals,
  78. };
  79. static struct platform_device bfin_mii_bus = {
  80. .name = "bfin_mii_bus",
  81. .dev = {
  82. .platform_data = &bfin_mii_bus_data,
  83. }
  84. };
  85. static struct platform_device bfin_mac_device = {
  86. .name = "bfin_mac",
  87. .dev = {
  88. .platform_data = &bfin_mii_bus,
  89. }
  90. };
  91. #endif
  92. #if IS_ENABLED(CONFIG_USB_NET2272)
  93. static struct resource net2272_bfin_resources[] = {
  94. {
  95. .start = 0x20300000,
  96. .end = 0x20300000 + 0x100,
  97. .flags = IORESOURCE_MEM,
  98. }, {
  99. .start = IRQ_PF7,
  100. .end = IRQ_PF7,
  101. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  102. },
  103. };
  104. static struct platform_device net2272_bfin_device = {
  105. .name = "net2272",
  106. .id = -1,
  107. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  108. .resource = net2272_bfin_resources,
  109. };
  110. #endif
  111. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  112. /* all SPI peripherals info goes here */
  113. #if IS_ENABLED(CONFIG_MTD_M25P80)
  114. /* Partition sizes */
  115. #define FLASH_SIZE 0x00400000
  116. #define PSIZE_UBOOT 0x00030000
  117. #define PSIZE_INITRAMFS 0x00240000
  118. static struct mtd_partition bfin_spi_flash_partitions[] = {
  119. {
  120. .name = "bootloader(spi)",
  121. .size = PSIZE_UBOOT,
  122. .offset = 0x000000,
  123. .mask_flags = MTD_CAP_ROM
  124. }, {
  125. .name = "initramfs(spi)",
  126. .size = PSIZE_INITRAMFS,
  127. .offset = PSIZE_UBOOT
  128. }, {
  129. .name = "opt(spi)",
  130. .size = FLASH_SIZE - (PSIZE_UBOOT + PSIZE_INITRAMFS),
  131. .offset = PSIZE_UBOOT + PSIZE_INITRAMFS,
  132. }
  133. };
  134. static struct flash_platform_data bfin_spi_flash_data = {
  135. .name = "m25p80",
  136. .parts = bfin_spi_flash_partitions,
  137. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  138. .type = "m25p64",
  139. };
  140. /* SPI flash chip (m25p64) */
  141. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  142. .enable_dma = 0, /* use dma transfer with this chip*/
  143. };
  144. #endif
  145. #if IS_ENABLED(CONFIG_MMC_SPI)
  146. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  147. .enable_dma = 0,
  148. };
  149. #endif
  150. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  151. #if IS_ENABLED(CONFIG_MTD_M25P80)
  152. {
  153. /* the modalias must be the same as spi device driver name */
  154. .modalias = "m25p80", /* Name of spi_driver for this device */
  155. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  156. .bus_num = 0, /* Framework bus number */
  157. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  158. .platform_data = &bfin_spi_flash_data,
  159. .controller_data = &spi_flash_chip_info,
  160. .mode = SPI_MODE_3,
  161. },
  162. #endif
  163. #if IS_ENABLED(CONFIG_MMC_SPI)
  164. {
  165. .modalias = "mmc_spi",
  166. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  167. .bus_num = 0,
  168. .chip_select = 5,
  169. .controller_data = &mmc_spi_chip_info,
  170. .mode = SPI_MODE_3,
  171. },
  172. #endif
  173. };
  174. /* SPI controller data */
  175. static struct bfin5xx_spi_master bfin_spi0_info = {
  176. .num_chipselect = 8,
  177. .enable_dma = 1, /* master has the ability to do dma transfer */
  178. };
  179. /* SPI (0) */
  180. static struct resource bfin_spi0_resource[] = {
  181. [0] = {
  182. .start = SPI0_REGBASE,
  183. .end = SPI0_REGBASE + 0xFF,
  184. .flags = IORESOURCE_MEM,
  185. },
  186. [1] = {
  187. .start = CH_SPI,
  188. .end = CH_SPI,
  189. .flags = IORESOURCE_DMA,
  190. },
  191. [2] = {
  192. .start = IRQ_SPI,
  193. .end = IRQ_SPI,
  194. .flags = IORESOURCE_IRQ,
  195. },
  196. };
  197. static struct platform_device bfin_spi0_device = {
  198. .name = "bfin-spi",
  199. .id = 0, /* Bus number */
  200. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  201. .resource = bfin_spi0_resource,
  202. .dev = {
  203. .platform_data = &bfin_spi0_info, /* Passed to driver */
  204. },
  205. };
  206. #endif /* spi master and devices */
  207. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  208. #ifdef CONFIG_SERIAL_BFIN_UART0
  209. static struct resource bfin_uart0_resources[] = {
  210. {
  211. .start = UART0_THR,
  212. .end = UART0_GCTL+2,
  213. .flags = IORESOURCE_MEM,
  214. },
  215. {
  216. .start = IRQ_UART0_TX,
  217. .end = IRQ_UART0_TX,
  218. .flags = IORESOURCE_IRQ,
  219. },
  220. {
  221. .start = IRQ_UART0_RX,
  222. .end = IRQ_UART0_RX,
  223. .flags = IORESOURCE_IRQ,
  224. },
  225. {
  226. .start = IRQ_UART0_ERROR,
  227. .end = IRQ_UART0_ERROR,
  228. .flags = IORESOURCE_IRQ,
  229. },
  230. {
  231. .start = CH_UART0_TX,
  232. .end = CH_UART0_TX,
  233. .flags = IORESOURCE_DMA,
  234. },
  235. {
  236. .start = CH_UART0_RX,
  237. .end = CH_UART0_RX,
  238. .flags = IORESOURCE_DMA,
  239. },
  240. };
  241. static unsigned short bfin_uart0_peripherals[] = {
  242. P_UART0_TX, P_UART0_RX, 0
  243. };
  244. static struct platform_device bfin_uart0_device = {
  245. .name = "bfin-uart",
  246. .id = 0,
  247. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  248. .resource = bfin_uart0_resources,
  249. .dev = {
  250. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  251. },
  252. };
  253. #endif
  254. #ifdef CONFIG_SERIAL_BFIN_UART1
  255. static struct resource bfin_uart1_resources[] = {
  256. {
  257. .start = UART1_THR,
  258. .end = UART1_GCTL+2,
  259. .flags = IORESOURCE_MEM,
  260. },
  261. {
  262. .start = IRQ_UART1_TX,
  263. .end = IRQ_UART1_TX,
  264. .flags = IORESOURCE_IRQ,
  265. },
  266. {
  267. .start = IRQ_UART1_RX,
  268. .end = IRQ_UART1_RX,
  269. .flags = IORESOURCE_IRQ,
  270. },
  271. {
  272. .start = IRQ_UART1_ERROR,
  273. .end = IRQ_UART1_ERROR,
  274. .flags = IORESOURCE_IRQ,
  275. },
  276. {
  277. .start = CH_UART1_TX,
  278. .end = CH_UART1_TX,
  279. .flags = IORESOURCE_DMA,
  280. },
  281. {
  282. .start = CH_UART1_RX,
  283. .end = CH_UART1_RX,
  284. .flags = IORESOURCE_DMA,
  285. },
  286. };
  287. static unsigned short bfin_uart1_peripherals[] = {
  288. P_UART1_TX, P_UART1_RX, 0
  289. };
  290. static struct platform_device bfin_uart1_device = {
  291. .name = "bfin-uart",
  292. .id = 1,
  293. .num_resources = ARRAY_SIZE(bfin_uart1_resources),
  294. .resource = bfin_uart1_resources,
  295. .dev = {
  296. .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
  297. },
  298. };
  299. #endif
  300. #endif
  301. #if IS_ENABLED(CONFIG_BFIN_SIR)
  302. #ifdef CONFIG_BFIN_SIR0
  303. static struct resource bfin_sir0_resources[] = {
  304. {
  305. .start = 0xFFC00400,
  306. .end = 0xFFC004FF,
  307. .flags = IORESOURCE_MEM,
  308. },
  309. {
  310. .start = IRQ_UART0_RX,
  311. .end = IRQ_UART0_RX+1,
  312. .flags = IORESOURCE_IRQ,
  313. },
  314. {
  315. .start = CH_UART0_RX,
  316. .end = CH_UART0_RX+1,
  317. .flags = IORESOURCE_DMA,
  318. },
  319. };
  320. static struct platform_device bfin_sir0_device = {
  321. .name = "bfin_sir",
  322. .id = 0,
  323. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  324. .resource = bfin_sir0_resources,
  325. };
  326. #endif
  327. #ifdef CONFIG_BFIN_SIR1
  328. static struct resource bfin_sir1_resources[] = {
  329. {
  330. .start = 0xFFC02000,
  331. .end = 0xFFC020FF,
  332. .flags = IORESOURCE_MEM,
  333. },
  334. {
  335. .start = IRQ_UART1_RX,
  336. .end = IRQ_UART1_RX+1,
  337. .flags = IORESOURCE_IRQ,
  338. },
  339. {
  340. .start = CH_UART1_RX,
  341. .end = CH_UART1_RX+1,
  342. .flags = IORESOURCE_DMA,
  343. },
  344. };
  345. static struct platform_device bfin_sir1_device = {
  346. .name = "bfin_sir",
  347. .id = 1,
  348. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  349. .resource = bfin_sir1_resources,
  350. };
  351. #endif
  352. #endif
  353. #if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
  354. static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
  355. static struct resource bfin_twi0_resource[] = {
  356. [0] = {
  357. .start = TWI0_REGBASE,
  358. .end = TWI0_REGBASE + 0xFF,
  359. .flags = IORESOURCE_MEM,
  360. },
  361. [1] = {
  362. .start = IRQ_TWI,
  363. .end = IRQ_TWI,
  364. .flags = IORESOURCE_IRQ,
  365. },
  366. };
  367. static struct platform_device i2c_bfin_twi_device = {
  368. .name = "i2c-bfin-twi",
  369. .id = 0,
  370. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  371. .resource = bfin_twi0_resource,
  372. .dev = {
  373. .platform_data = &bfin_twi0_pins,
  374. },
  375. };
  376. #endif
  377. #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
  378. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  379. static struct resource bfin_sport0_uart_resources[] = {
  380. {
  381. .start = SPORT0_TCR1,
  382. .end = SPORT0_MRCS3+4,
  383. .flags = IORESOURCE_MEM,
  384. },
  385. {
  386. .start = IRQ_SPORT0_RX,
  387. .end = IRQ_SPORT0_RX+1,
  388. .flags = IORESOURCE_IRQ,
  389. },
  390. {
  391. .start = IRQ_SPORT0_ERROR,
  392. .end = IRQ_SPORT0_ERROR,
  393. .flags = IORESOURCE_IRQ,
  394. },
  395. };
  396. static unsigned short bfin_sport0_peripherals[] = {
  397. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  398. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  399. };
  400. static struct platform_device bfin_sport0_uart_device = {
  401. .name = "bfin-sport-uart",
  402. .id = 0,
  403. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  404. .resource = bfin_sport0_uart_resources,
  405. .dev = {
  406. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  407. },
  408. };
  409. #endif
  410. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  411. static struct resource bfin_sport1_uart_resources[] = {
  412. {
  413. .start = SPORT1_TCR1,
  414. .end = SPORT1_MRCS3+4,
  415. .flags = IORESOURCE_MEM,
  416. },
  417. {
  418. .start = IRQ_SPORT1_RX,
  419. .end = IRQ_SPORT1_RX+1,
  420. .flags = IORESOURCE_IRQ,
  421. },
  422. {
  423. .start = IRQ_SPORT1_ERROR,
  424. .end = IRQ_SPORT1_ERROR,
  425. .flags = IORESOURCE_IRQ,
  426. },
  427. };
  428. static unsigned short bfin_sport1_peripherals[] = {
  429. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  430. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  431. };
  432. static struct platform_device bfin_sport1_uart_device = {
  433. .name = "bfin-sport-uart",
  434. .id = 1,
  435. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  436. .resource = bfin_sport1_uart_resources,
  437. .dev = {
  438. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  439. },
  440. };
  441. #endif
  442. #endif
  443. static struct platform_device *minotaur_devices[] __initdata = {
  444. #if IS_ENABLED(CONFIG_BFIN_CFPCMCIA)
  445. &bfin_pcmcia_cf_device,
  446. #endif
  447. #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  448. &rtc_device,
  449. #endif
  450. #if IS_ENABLED(CONFIG_BFIN_MAC)
  451. &bfin_mii_bus,
  452. &bfin_mac_device,
  453. #endif
  454. #if IS_ENABLED(CONFIG_USB_NET2272)
  455. &net2272_bfin_device,
  456. #endif
  457. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  458. &bfin_spi0_device,
  459. #endif
  460. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  461. #ifdef CONFIG_SERIAL_BFIN_UART0
  462. &bfin_uart0_device,
  463. #endif
  464. #ifdef CONFIG_SERIAL_BFIN_UART1
  465. &bfin_uart1_device,
  466. #endif
  467. #endif
  468. #if IS_ENABLED(CONFIG_BFIN_SIR)
  469. #ifdef CONFIG_BFIN_SIR0
  470. &bfin_sir0_device,
  471. #endif
  472. #ifdef CONFIG_BFIN_SIR1
  473. &bfin_sir1_device,
  474. #endif
  475. #endif
  476. #if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
  477. &i2c_bfin_twi_device,
  478. #endif
  479. #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
  480. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  481. &bfin_sport0_uart_device,
  482. #endif
  483. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  484. &bfin_sport1_uart_device,
  485. #endif
  486. #endif
  487. };
  488. static int __init minotaur_init(void)
  489. {
  490. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  491. platform_add_devices(minotaur_devices, ARRAY_SIZE(minotaur_devices));
  492. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  493. spi_register_board_info(bfin_spi_board_info,
  494. ARRAY_SIZE(bfin_spi_board_info));
  495. #endif
  496. return 0;
  497. }
  498. arch_initcall(minotaur_init);
  499. static struct platform_device *minotaur_early_devices[] __initdata = {
  500. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  501. #ifdef CONFIG_SERIAL_BFIN_UART0
  502. &bfin_uart0_device,
  503. #endif
  504. #ifdef CONFIG_SERIAL_BFIN_UART1
  505. &bfin_uart1_device,
  506. #endif
  507. #endif
  508. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  509. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  510. &bfin_sport0_uart_device,
  511. #endif
  512. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  513. &bfin_sport1_uart_device,
  514. #endif
  515. #endif
  516. };
  517. void __init native_machine_early_platform_add_devices(void)
  518. {
  519. printk(KERN_INFO "register early platform devices\n");
  520. early_platform_add_devices(minotaur_early_devices,
  521. ARRAY_SIZE(minotaur_early_devices));
  522. }
  523. void native_machine_restart(char *cmd)
  524. {
  525. /* workaround reboot hang when booting from SPI */
  526. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  527. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  528. }