minotaur.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  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 defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  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 defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  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 defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  59. static struct platform_device rtc_device = {
  60. .name = "rtc-bfin",
  61. .id = -1,
  62. };
  63. #endif
  64. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  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 defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  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 defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  112. /* all SPI peripherals info goes here */
  113. #if defined(CONFIG_MTD_M25P80) \
  114. || defined(CONFIG_MTD_M25P80_MODULE)
  115. /* Partition sizes */
  116. #define FLASH_SIZE 0x00400000
  117. #define PSIZE_UBOOT 0x00030000
  118. #define PSIZE_INITRAMFS 0x00240000
  119. static struct mtd_partition bfin_spi_flash_partitions[] = {
  120. {
  121. .name = "bootloader(spi)",
  122. .size = PSIZE_UBOOT,
  123. .offset = 0x000000,
  124. .mask_flags = MTD_CAP_ROM
  125. }, {
  126. .name = "initramfs(spi)",
  127. .size = PSIZE_INITRAMFS,
  128. .offset = PSIZE_UBOOT
  129. }, {
  130. .name = "opt(spi)",
  131. .size = FLASH_SIZE - (PSIZE_UBOOT + PSIZE_INITRAMFS),
  132. .offset = PSIZE_UBOOT + PSIZE_INITRAMFS,
  133. }
  134. };
  135. static struct flash_platform_data bfin_spi_flash_data = {
  136. .name = "m25p80",
  137. .parts = bfin_spi_flash_partitions,
  138. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  139. .type = "m25p64",
  140. };
  141. /* SPI flash chip (m25p64) */
  142. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  143. .enable_dma = 0, /* use dma transfer with this chip*/
  144. };
  145. #endif
  146. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  147. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  148. .enable_dma = 0,
  149. };
  150. #endif
  151. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  152. #if defined(CONFIG_MTD_M25P80) \
  153. || defined(CONFIG_MTD_M25P80_MODULE)
  154. {
  155. /* the modalias must be the same as spi device driver name */
  156. .modalias = "m25p80", /* Name of spi_driver for this device */
  157. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  158. .bus_num = 0, /* Framework bus number */
  159. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  160. .platform_data = &bfin_spi_flash_data,
  161. .controller_data = &spi_flash_chip_info,
  162. .mode = SPI_MODE_3,
  163. },
  164. #endif
  165. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  166. {
  167. .modalias = "mmc_spi",
  168. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  169. .bus_num = 0,
  170. .chip_select = 5,
  171. .controller_data = &mmc_spi_chip_info,
  172. .mode = SPI_MODE_3,
  173. },
  174. #endif
  175. };
  176. /* SPI controller data */
  177. static struct bfin5xx_spi_master bfin_spi0_info = {
  178. .num_chipselect = 8,
  179. .enable_dma = 1, /* master has the ability to do dma transfer */
  180. };
  181. /* SPI (0) */
  182. static struct resource bfin_spi0_resource[] = {
  183. [0] = {
  184. .start = SPI0_REGBASE,
  185. .end = SPI0_REGBASE + 0xFF,
  186. .flags = IORESOURCE_MEM,
  187. },
  188. [1] = {
  189. .start = CH_SPI,
  190. .end = CH_SPI,
  191. .flags = IORESOURCE_DMA,
  192. },
  193. [2] = {
  194. .start = IRQ_SPI,
  195. .end = IRQ_SPI,
  196. .flags = IORESOURCE_IRQ,
  197. },
  198. };
  199. static struct platform_device bfin_spi0_device = {
  200. .name = "bfin-spi",
  201. .id = 0, /* Bus number */
  202. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  203. .resource = bfin_spi0_resource,
  204. .dev = {
  205. .platform_data = &bfin_spi0_info, /* Passed to driver */
  206. },
  207. };
  208. #endif /* spi master and devices */
  209. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  210. #ifdef CONFIG_SERIAL_BFIN_UART0
  211. static struct resource bfin_uart0_resources[] = {
  212. {
  213. .start = UART0_THR,
  214. .end = UART0_GCTL+2,
  215. .flags = IORESOURCE_MEM,
  216. },
  217. {
  218. .start = IRQ_UART0_TX,
  219. .end = IRQ_UART0_TX,
  220. .flags = IORESOURCE_IRQ,
  221. },
  222. {
  223. .start = IRQ_UART0_RX,
  224. .end = IRQ_UART0_RX,
  225. .flags = IORESOURCE_IRQ,
  226. },
  227. {
  228. .start = IRQ_UART0_ERROR,
  229. .end = IRQ_UART0_ERROR,
  230. .flags = IORESOURCE_IRQ,
  231. },
  232. {
  233. .start = CH_UART0_TX,
  234. .end = CH_UART0_TX,
  235. .flags = IORESOURCE_DMA,
  236. },
  237. {
  238. .start = CH_UART0_RX,
  239. .end = CH_UART0_RX,
  240. .flags = IORESOURCE_DMA,
  241. },
  242. };
  243. static unsigned short bfin_uart0_peripherals[] = {
  244. P_UART0_TX, P_UART0_RX, 0
  245. };
  246. static struct platform_device bfin_uart0_device = {
  247. .name = "bfin-uart",
  248. .id = 0,
  249. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  250. .resource = bfin_uart0_resources,
  251. .dev = {
  252. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  253. },
  254. };
  255. #endif
  256. #ifdef CONFIG_SERIAL_BFIN_UART1
  257. static struct resource bfin_uart1_resources[] = {
  258. {
  259. .start = UART1_THR,
  260. .end = UART1_GCTL+2,
  261. .flags = IORESOURCE_MEM,
  262. },
  263. {
  264. .start = IRQ_UART1_TX,
  265. .end = IRQ_UART1_TX,
  266. .flags = IORESOURCE_IRQ,
  267. },
  268. {
  269. .start = IRQ_UART1_RX,
  270. .end = IRQ_UART1_RX,
  271. .flags = IORESOURCE_IRQ,
  272. },
  273. {
  274. .start = IRQ_UART1_ERROR,
  275. .end = IRQ_UART1_ERROR,
  276. .flags = IORESOURCE_IRQ,
  277. },
  278. {
  279. .start = CH_UART1_TX,
  280. .end = CH_UART1_TX,
  281. .flags = IORESOURCE_DMA,
  282. },
  283. {
  284. .start = CH_UART1_RX,
  285. .end = CH_UART1_RX,
  286. .flags = IORESOURCE_DMA,
  287. },
  288. };
  289. static unsigned short bfin_uart1_peripherals[] = {
  290. P_UART1_TX, P_UART1_RX, 0
  291. };
  292. static struct platform_device bfin_uart1_device = {
  293. .name = "bfin-uart",
  294. .id = 1,
  295. .num_resources = ARRAY_SIZE(bfin_uart1_resources),
  296. .resource = bfin_uart1_resources,
  297. .dev = {
  298. .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
  299. },
  300. };
  301. #endif
  302. #endif
  303. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  304. #ifdef CONFIG_BFIN_SIR0
  305. static struct resource bfin_sir0_resources[] = {
  306. {
  307. .start = 0xFFC00400,
  308. .end = 0xFFC004FF,
  309. .flags = IORESOURCE_MEM,
  310. },
  311. {
  312. .start = IRQ_UART0_RX,
  313. .end = IRQ_UART0_RX+1,
  314. .flags = IORESOURCE_IRQ,
  315. },
  316. {
  317. .start = CH_UART0_RX,
  318. .end = CH_UART0_RX+1,
  319. .flags = IORESOURCE_DMA,
  320. },
  321. };
  322. static struct platform_device bfin_sir0_device = {
  323. .name = "bfin_sir",
  324. .id = 0,
  325. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  326. .resource = bfin_sir0_resources,
  327. };
  328. #endif
  329. #ifdef CONFIG_BFIN_SIR1
  330. static struct resource bfin_sir1_resources[] = {
  331. {
  332. .start = 0xFFC02000,
  333. .end = 0xFFC020FF,
  334. .flags = IORESOURCE_MEM,
  335. },
  336. {
  337. .start = IRQ_UART1_RX,
  338. .end = IRQ_UART1_RX+1,
  339. .flags = IORESOURCE_IRQ,
  340. },
  341. {
  342. .start = CH_UART1_RX,
  343. .end = CH_UART1_RX+1,
  344. .flags = IORESOURCE_DMA,
  345. },
  346. };
  347. static struct platform_device bfin_sir1_device = {
  348. .name = "bfin_sir",
  349. .id = 1,
  350. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  351. .resource = bfin_sir1_resources,
  352. };
  353. #endif
  354. #endif
  355. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  356. static struct resource bfin_twi0_resource[] = {
  357. [0] = {
  358. .start = TWI0_REGBASE,
  359. .end = TWI0_REGBASE + 0xFF,
  360. .flags = IORESOURCE_MEM,
  361. },
  362. [1] = {
  363. .start = IRQ_TWI,
  364. .end = IRQ_TWI,
  365. .flags = IORESOURCE_IRQ,
  366. },
  367. };
  368. static struct platform_device i2c_bfin_twi_device = {
  369. .name = "i2c-bfin-twi",
  370. .id = 0,
  371. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  372. .resource = bfin_twi0_resource,
  373. };
  374. #endif
  375. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  376. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  377. static struct resource bfin_sport0_uart_resources[] = {
  378. {
  379. .start = SPORT0_TCR1,
  380. .end = SPORT0_MRCS3+4,
  381. .flags = IORESOURCE_MEM,
  382. },
  383. {
  384. .start = IRQ_SPORT0_RX,
  385. .end = IRQ_SPORT0_RX+1,
  386. .flags = IORESOURCE_IRQ,
  387. },
  388. {
  389. .start = IRQ_SPORT0_ERROR,
  390. .end = IRQ_SPORT0_ERROR,
  391. .flags = IORESOURCE_IRQ,
  392. },
  393. };
  394. static unsigned short bfin_sport0_peripherals[] = {
  395. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  396. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  397. };
  398. static struct platform_device bfin_sport0_uart_device = {
  399. .name = "bfin-sport-uart",
  400. .id = 0,
  401. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  402. .resource = bfin_sport0_uart_resources,
  403. .dev = {
  404. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  405. },
  406. };
  407. #endif
  408. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  409. static struct resource bfin_sport1_uart_resources[] = {
  410. {
  411. .start = SPORT1_TCR1,
  412. .end = SPORT1_MRCS3+4,
  413. .flags = IORESOURCE_MEM,
  414. },
  415. {
  416. .start = IRQ_SPORT1_RX,
  417. .end = IRQ_SPORT1_RX+1,
  418. .flags = IORESOURCE_IRQ,
  419. },
  420. {
  421. .start = IRQ_SPORT1_ERROR,
  422. .end = IRQ_SPORT1_ERROR,
  423. .flags = IORESOURCE_IRQ,
  424. },
  425. };
  426. static unsigned short bfin_sport1_peripherals[] = {
  427. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  428. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  429. };
  430. static struct platform_device bfin_sport1_uart_device = {
  431. .name = "bfin-sport-uart",
  432. .id = 1,
  433. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  434. .resource = bfin_sport1_uart_resources,
  435. .dev = {
  436. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  437. },
  438. };
  439. #endif
  440. #endif
  441. static struct platform_device *minotaur_devices[] __initdata = {
  442. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  443. &bfin_pcmcia_cf_device,
  444. #endif
  445. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  446. &rtc_device,
  447. #endif
  448. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  449. &bfin_mii_bus,
  450. &bfin_mac_device,
  451. #endif
  452. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  453. &net2272_bfin_device,
  454. #endif
  455. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  456. &bfin_spi0_device,
  457. #endif
  458. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  459. #ifdef CONFIG_SERIAL_BFIN_UART0
  460. &bfin_uart0_device,
  461. #endif
  462. #ifdef CONFIG_SERIAL_BFIN_UART1
  463. &bfin_uart1_device,
  464. #endif
  465. #endif
  466. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  467. #ifdef CONFIG_BFIN_SIR0
  468. &bfin_sir0_device,
  469. #endif
  470. #ifdef CONFIG_BFIN_SIR1
  471. &bfin_sir1_device,
  472. #endif
  473. #endif
  474. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  475. &i2c_bfin_twi_device,
  476. #endif
  477. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  478. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  479. &bfin_sport0_uart_device,
  480. #endif
  481. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  482. &bfin_sport1_uart_device,
  483. #endif
  484. #endif
  485. };
  486. static int __init minotaur_init(void)
  487. {
  488. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  489. platform_add_devices(minotaur_devices, ARRAY_SIZE(minotaur_devices));
  490. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  491. spi_register_board_info(bfin_spi_board_info,
  492. ARRAY_SIZE(bfin_spi_board_info));
  493. #endif
  494. return 0;
  495. }
  496. arch_initcall(minotaur_init);
  497. static struct platform_device *minotaur_early_devices[] __initdata = {
  498. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  499. #ifdef CONFIG_SERIAL_BFIN_UART0
  500. &bfin_uart0_device,
  501. #endif
  502. #ifdef CONFIG_SERIAL_BFIN_UART1
  503. &bfin_uart1_device,
  504. #endif
  505. #endif
  506. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  507. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  508. &bfin_sport0_uart_device,
  509. #endif
  510. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  511. &bfin_sport1_uart_device,
  512. #endif
  513. #endif
  514. };
  515. void __init native_machine_early_platform_add_devices(void)
  516. {
  517. printk(KERN_INFO "register early platform devices\n");
  518. early_platform_add_devices(minotaur_early_devices,
  519. ARRAY_SIZE(minotaur_early_devices));
  520. }
  521. void native_machine_restart(char *cmd)
  522. {
  523. /* workaround reboot hang when booting from SPI */
  524. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  525. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  526. }