minotaur.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  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_BFIN) || defined(CONFIG_SPI_BFIN_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_RX,
  219. .end = IRQ_UART0_RX+1,
  220. .flags = IORESOURCE_IRQ,
  221. },
  222. {
  223. .start = IRQ_UART0_ERROR,
  224. .end = IRQ_UART0_ERROR,
  225. .flags = IORESOURCE_IRQ,
  226. },
  227. {
  228. .start = CH_UART0_TX,
  229. .end = CH_UART0_TX,
  230. .flags = IORESOURCE_DMA,
  231. },
  232. {
  233. .start = CH_UART0_RX,
  234. .end = CH_UART0_RX,
  235. .flags = IORESOURCE_DMA,
  236. },
  237. };
  238. static unsigned short bfin_uart0_peripherals[] = {
  239. P_UART0_TX, P_UART0_RX, 0
  240. };
  241. static struct platform_device bfin_uart0_device = {
  242. .name = "bfin-uart",
  243. .id = 0,
  244. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  245. .resource = bfin_uart0_resources,
  246. .dev = {
  247. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  248. },
  249. };
  250. #endif
  251. #ifdef CONFIG_SERIAL_BFIN_UART1
  252. static struct resource bfin_uart1_resources[] = {
  253. {
  254. .start = UART1_THR,
  255. .end = UART1_GCTL+2,
  256. .flags = IORESOURCE_MEM,
  257. },
  258. {
  259. .start = IRQ_UART1_RX,
  260. .end = IRQ_UART1_RX+1,
  261. .flags = IORESOURCE_IRQ,
  262. },
  263. {
  264. .start = IRQ_UART1_ERROR,
  265. .end = IRQ_UART1_ERROR,
  266. .flags = IORESOURCE_IRQ,
  267. },
  268. {
  269. .start = CH_UART1_TX,
  270. .end = CH_UART1_TX,
  271. .flags = IORESOURCE_DMA,
  272. },
  273. {
  274. .start = CH_UART1_RX,
  275. .end = CH_UART1_RX,
  276. .flags = IORESOURCE_DMA,
  277. },
  278. };
  279. static unsigned short bfin_uart1_peripherals[] = {
  280. P_UART1_TX, P_UART1_RX, 0
  281. };
  282. static struct platform_device bfin_uart1_device = {
  283. .name = "bfin-uart",
  284. .id = 1,
  285. .num_resources = ARRAY_SIZE(bfin_uart1_resources),
  286. .resource = bfin_uart1_resources,
  287. .dev = {
  288. .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
  289. },
  290. };
  291. #endif
  292. #endif
  293. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  294. #ifdef CONFIG_BFIN_SIR0
  295. static struct resource bfin_sir0_resources[] = {
  296. {
  297. .start = 0xFFC00400,
  298. .end = 0xFFC004FF,
  299. .flags = IORESOURCE_MEM,
  300. },
  301. {
  302. .start = IRQ_UART0_RX,
  303. .end = IRQ_UART0_RX+1,
  304. .flags = IORESOURCE_IRQ,
  305. },
  306. {
  307. .start = CH_UART0_RX,
  308. .end = CH_UART0_RX+1,
  309. .flags = IORESOURCE_DMA,
  310. },
  311. };
  312. static struct platform_device bfin_sir0_device = {
  313. .name = "bfin_sir",
  314. .id = 0,
  315. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  316. .resource = bfin_sir0_resources,
  317. };
  318. #endif
  319. #ifdef CONFIG_BFIN_SIR1
  320. static struct resource bfin_sir1_resources[] = {
  321. {
  322. .start = 0xFFC02000,
  323. .end = 0xFFC020FF,
  324. .flags = IORESOURCE_MEM,
  325. },
  326. {
  327. .start = IRQ_UART1_RX,
  328. .end = IRQ_UART1_RX+1,
  329. .flags = IORESOURCE_IRQ,
  330. },
  331. {
  332. .start = CH_UART1_RX,
  333. .end = CH_UART1_RX+1,
  334. .flags = IORESOURCE_DMA,
  335. },
  336. };
  337. static struct platform_device bfin_sir1_device = {
  338. .name = "bfin_sir",
  339. .id = 1,
  340. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  341. .resource = bfin_sir1_resources,
  342. };
  343. #endif
  344. #endif
  345. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  346. static struct resource bfin_twi0_resource[] = {
  347. [0] = {
  348. .start = TWI0_REGBASE,
  349. .end = TWI0_REGBASE + 0xFF,
  350. .flags = IORESOURCE_MEM,
  351. },
  352. [1] = {
  353. .start = IRQ_TWI,
  354. .end = IRQ_TWI,
  355. .flags = IORESOURCE_IRQ,
  356. },
  357. };
  358. static struct platform_device i2c_bfin_twi_device = {
  359. .name = "i2c-bfin-twi",
  360. .id = 0,
  361. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  362. .resource = bfin_twi0_resource,
  363. };
  364. #endif
  365. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  366. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  367. static struct resource bfin_sport0_uart_resources[] = {
  368. {
  369. .start = SPORT0_TCR1,
  370. .end = SPORT0_MRCS3+4,
  371. .flags = IORESOURCE_MEM,
  372. },
  373. {
  374. .start = IRQ_SPORT0_RX,
  375. .end = IRQ_SPORT0_RX+1,
  376. .flags = IORESOURCE_IRQ,
  377. },
  378. {
  379. .start = IRQ_SPORT0_ERROR,
  380. .end = IRQ_SPORT0_ERROR,
  381. .flags = IORESOURCE_IRQ,
  382. },
  383. };
  384. static unsigned short bfin_sport0_peripherals[] = {
  385. P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
  386. P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
  387. };
  388. static struct platform_device bfin_sport0_uart_device = {
  389. .name = "bfin-sport-uart",
  390. .id = 0,
  391. .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
  392. .resource = bfin_sport0_uart_resources,
  393. .dev = {
  394. .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
  395. },
  396. };
  397. #endif
  398. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  399. static struct resource bfin_sport1_uart_resources[] = {
  400. {
  401. .start = SPORT1_TCR1,
  402. .end = SPORT1_MRCS3+4,
  403. .flags = IORESOURCE_MEM,
  404. },
  405. {
  406. .start = IRQ_SPORT1_RX,
  407. .end = IRQ_SPORT1_RX+1,
  408. .flags = IORESOURCE_IRQ,
  409. },
  410. {
  411. .start = IRQ_SPORT1_ERROR,
  412. .end = IRQ_SPORT1_ERROR,
  413. .flags = IORESOURCE_IRQ,
  414. },
  415. };
  416. static unsigned short bfin_sport1_peripherals[] = {
  417. P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
  418. P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
  419. };
  420. static struct platform_device bfin_sport1_uart_device = {
  421. .name = "bfin-sport-uart",
  422. .id = 1,
  423. .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
  424. .resource = bfin_sport1_uart_resources,
  425. .dev = {
  426. .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
  427. },
  428. };
  429. #endif
  430. #endif
  431. static struct platform_device *minotaur_devices[] __initdata = {
  432. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  433. &bfin_pcmcia_cf_device,
  434. #endif
  435. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  436. &rtc_device,
  437. #endif
  438. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  439. &bfin_mii_bus,
  440. &bfin_mac_device,
  441. #endif
  442. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  443. &net2272_bfin_device,
  444. #endif
  445. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  446. &bfin_spi0_device,
  447. #endif
  448. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  449. #ifdef CONFIG_SERIAL_BFIN_UART0
  450. &bfin_uart0_device,
  451. #endif
  452. #ifdef CONFIG_SERIAL_BFIN_UART1
  453. &bfin_uart1_device,
  454. #endif
  455. #endif
  456. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  457. #ifdef CONFIG_BFIN_SIR0
  458. &bfin_sir0_device,
  459. #endif
  460. #ifdef CONFIG_BFIN_SIR1
  461. &bfin_sir1_device,
  462. #endif
  463. #endif
  464. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  465. &i2c_bfin_twi_device,
  466. #endif
  467. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  468. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  469. &bfin_sport0_uart_device,
  470. #endif
  471. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  472. &bfin_sport1_uart_device,
  473. #endif
  474. #endif
  475. };
  476. static int __init minotaur_init(void)
  477. {
  478. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  479. platform_add_devices(minotaur_devices, ARRAY_SIZE(minotaur_devices));
  480. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  481. spi_register_board_info(bfin_spi_board_info,
  482. ARRAY_SIZE(bfin_spi_board_info));
  483. #endif
  484. return 0;
  485. }
  486. arch_initcall(minotaur_init);
  487. static struct platform_device *minotaur_early_devices[] __initdata = {
  488. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  489. #ifdef CONFIG_SERIAL_BFIN_UART0
  490. &bfin_uart0_device,
  491. #endif
  492. #ifdef CONFIG_SERIAL_BFIN_UART1
  493. &bfin_uart1_device,
  494. #endif
  495. #endif
  496. #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
  497. #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
  498. &bfin_sport0_uart_device,
  499. #endif
  500. #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
  501. &bfin_sport1_uart_device,
  502. #endif
  503. #endif
  504. };
  505. void __init native_machine_early_platform_add_devices(void)
  506. {
  507. printk(KERN_INFO "register early platform devices\n");
  508. early_platform_add_devices(minotaur_early_devices,
  509. ARRAY_SIZE(minotaur_early_devices));
  510. }
  511. void native_machine_restart(char *cmd)
  512. {
  513. /* workaround reboot hang when booting from SPI */
  514. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  515. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  516. }