minotaur.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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 const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
  357. static struct resource bfin_twi0_resource[] = {
  358. [0] = {
  359. .start = TWI0_REGBASE,
  360. .end = TWI0_REGBASE + 0xFF,
  361. .flags = IORESOURCE_MEM,
  362. },
  363. [1] = {
  364. .start = IRQ_TWI,
  365. .end = IRQ_TWI,
  366. .flags = IORESOURCE_IRQ,
  367. },
  368. };
  369. static struct platform_device i2c_bfin_twi_device = {
  370. .name = "i2c-bfin-twi",
  371. .id = 0,
  372. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  373. .resource = bfin_twi0_resource,
  374. .dev = {
  375. .platform_data = &bfin_twi0_pins,
  376. },
  377. };
  378. #endif
  379. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  380. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  381. static struct resource bfin_sport0_uart_resources[] = {
  382. {
  383. .start = SPORT0_TCR1,
  384. .end = SPORT0_MRCS3+4,
  385. .flags = IORESOURCE_MEM,
  386. },
  387. {
  388. .start = IRQ_SPORT0_RX,
  389. .end = IRQ_SPORT0_RX+1,
  390. .flags = IORESOURCE_IRQ,
  391. },
  392. {
  393. .start = IRQ_SPORT0_ERROR,
  394. .end = IRQ_SPORT0_ERROR,
  395. .flags = IORESOURCE_IRQ,
  396. },
  397. };
  398. static unsigned short bfin_sport0_peripherals[] = {
  399. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  400. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  401. };
  402. static struct platform_device bfin_sport0_uart_device = {
  403. .name = "bfin-sport-uart",
  404. .id = 0,
  405. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  406. .resource = bfin_sport0_uart_resources,
  407. .dev = {
  408. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  409. },
  410. };
  411. #endif
  412. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  413. static struct resource bfin_sport1_uart_resources[] = {
  414. {
  415. .start = SPORT1_TCR1,
  416. .end = SPORT1_MRCS3+4,
  417. .flags = IORESOURCE_MEM,
  418. },
  419. {
  420. .start = IRQ_SPORT1_RX,
  421. .end = IRQ_SPORT1_RX+1,
  422. .flags = IORESOURCE_IRQ,
  423. },
  424. {
  425. .start = IRQ_SPORT1_ERROR,
  426. .end = IRQ_SPORT1_ERROR,
  427. .flags = IORESOURCE_IRQ,
  428. },
  429. };
  430. static unsigned short bfin_sport1_peripherals[] = {
  431. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  432. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  433. };
  434. static struct platform_device bfin_sport1_uart_device = {
  435. .name = "bfin-sport-uart",
  436. .id = 1,
  437. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  438. .resource = bfin_sport1_uart_resources,
  439. .dev = {
  440. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  441. },
  442. };
  443. #endif
  444. #endif
  445. static struct platform_device *minotaur_devices[] __initdata = {
  446. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  447. &bfin_pcmcia_cf_device,
  448. #endif
  449. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  450. &rtc_device,
  451. #endif
  452. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  453. &bfin_mii_bus,
  454. &bfin_mac_device,
  455. #endif
  456. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  457. &net2272_bfin_device,
  458. #endif
  459. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  460. &bfin_spi0_device,
  461. #endif
  462. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  463. #ifdef CONFIG_SERIAL_BFIN_UART0
  464. &bfin_uart0_device,
  465. #endif
  466. #ifdef CONFIG_SERIAL_BFIN_UART1
  467. &bfin_uart1_device,
  468. #endif
  469. #endif
  470. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  471. #ifdef CONFIG_BFIN_SIR0
  472. &bfin_sir0_device,
  473. #endif
  474. #ifdef CONFIG_BFIN_SIR1
  475. &bfin_sir1_device,
  476. #endif
  477. #endif
  478. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  479. &i2c_bfin_twi_device,
  480. #endif
  481. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  482. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  483. &bfin_sport0_uart_device,
  484. #endif
  485. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  486. &bfin_sport1_uart_device,
  487. #endif
  488. #endif
  489. };
  490. static int __init minotaur_init(void)
  491. {
  492. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  493. platform_add_devices(minotaur_devices, ARRAY_SIZE(minotaur_devices));
  494. #if defined(CONFIG_SPI_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_MODULE)
  495. spi_register_board_info(bfin_spi_board_info,
  496. ARRAY_SIZE(bfin_spi_board_info));
  497. #endif
  498. return 0;
  499. }
  500. arch_initcall(minotaur_init);
  501. static struct platform_device *minotaur_early_devices[] __initdata = {
  502. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  503. #ifdef CONFIG_SERIAL_BFIN_UART0
  504. &bfin_uart0_device,
  505. #endif
  506. #ifdef CONFIG_SERIAL_BFIN_UART1
  507. &bfin_uart1_device,
  508. #endif
  509. #endif
  510. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  511. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  512. &bfin_sport0_uart_device,
  513. #endif
  514. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  515. &bfin_sport1_uart_device,
  516. #endif
  517. #endif
  518. };
  519. void __init native_machine_early_platform_add_devices(void)
  520. {
  521. printk(KERN_INFO "register early platform devices\n");
  522. early_platform_add_devices(minotaur_early_devices,
  523. ARRAY_SIZE(minotaur_early_devices));
  524. }
  525. void native_machine_restart(char *cmd)
  526. {
  527. /* workaround reboot hang when booting from SPI */
  528. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  529. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  530. }