minotaur.c 13 KB

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