minotaur.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. /*
  2. */
  3. #include <linux/device.h>
  4. #include <linux/platform_device.h>
  5. #include <linux/mtd/mtd.h>
  6. #include <linux/mtd/partitions.h>
  7. #include <linux/spi/spi.h>
  8. #include <linux/spi/flash.h>
  9. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  10. #include <linux/usb/isp1362.h>
  11. #endif
  12. #include <linux/ata_platform.h>
  13. #include <linux/irq.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/usb/sl811.h>
  16. #include <asm/dma.h>
  17. #include <asm/bfin5xx_spi.h>
  18. #include <asm/reboot.h>
  19. #include <linux/spi/ad7877.h>
  20. /*
  21. * Name the Board for the /proc/cpuinfo
  22. */
  23. char *bfin_board_name = "CamSig Minotaur BF537";
  24. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  25. static struct resource bfin_pcmcia_cf_resources[] = {
  26. {
  27. .start = 0x20310000, /* IO PORT */
  28. .end = 0x20312000,
  29. .flags = IORESOURCE_MEM,
  30. }, {
  31. .start = 0x20311000, /* Attribute Memory */
  32. .end = 0x20311FFF,
  33. .flags = IORESOURCE_MEM,
  34. }, {
  35. .start = IRQ_PF4,
  36. .end = IRQ_PF4,
  37. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  38. }, {
  39. .start = IRQ_PF6, /* Card Detect PF6 */
  40. .end = IRQ_PF6,
  41. .flags = IORESOURCE_IRQ,
  42. },
  43. };
  44. static struct platform_device bfin_pcmcia_cf_device = {
  45. .name = "bfin_cf_pcmcia",
  46. .id = -1,
  47. .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
  48. .resource = bfin_pcmcia_cf_resources,
  49. };
  50. #endif
  51. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  52. static struct platform_device rtc_device = {
  53. .name = "rtc-bfin",
  54. .id = -1,
  55. };
  56. #endif
  57. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  58. static struct platform_device bfin_mii_bus = {
  59. .name = "bfin_mii_bus",
  60. };
  61. static struct platform_device bfin_mac_device = {
  62. .name = "bfin_mac",
  63. .dev.platform_data = &bfin_mii_bus,
  64. };
  65. #endif
  66. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  67. static struct resource net2272_bfin_resources[] = {
  68. {
  69. .start = 0x20300000,
  70. .end = 0x20300000 + 0x100,
  71. .flags = IORESOURCE_MEM,
  72. }, {
  73. .start = IRQ_PF7,
  74. .end = IRQ_PF7,
  75. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  76. },
  77. };
  78. static struct platform_device net2272_bfin_device = {
  79. .name = "net2272",
  80. .id = -1,
  81. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  82. .resource = net2272_bfin_resources,
  83. };
  84. #endif
  85. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  86. /* all SPI peripherals info goes here */
  87. #if defined(CONFIG_MTD_M25P80) \
  88. || defined(CONFIG_MTD_M25P80_MODULE)
  89. /* Partition sizes */
  90. #define FLASH_SIZE 0x00400000
  91. #define PSIZE_UBOOT 0x00030000
  92. #define PSIZE_INITRAMFS 0x00240000
  93. static struct mtd_partition bfin_spi_flash_partitions[] = {
  94. {
  95. .name = "bootloader(spi)",
  96. .size = PSIZE_UBOOT,
  97. .offset = 0x000000,
  98. .mask_flags = MTD_CAP_ROM
  99. }, {
  100. .name = "initramfs(spi)",
  101. .size = PSIZE_INITRAMFS,
  102. .offset = PSIZE_UBOOT
  103. }, {
  104. .name = "opt(spi)",
  105. .size = FLASH_SIZE - (PSIZE_UBOOT + PSIZE_INITRAMFS),
  106. .offset = PSIZE_UBOOT + PSIZE_INITRAMFS,
  107. }
  108. };
  109. static struct flash_platform_data bfin_spi_flash_data = {
  110. .name = "m25p80",
  111. .parts = bfin_spi_flash_partitions,
  112. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  113. .type = "m25p64",
  114. };
  115. /* SPI flash chip (m25p64) */
  116. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  117. .enable_dma = 0, /* use dma transfer with this chip*/
  118. .bits_per_word = 8,
  119. };
  120. #endif
  121. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  122. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  123. .enable_dma = 0,
  124. .bits_per_word = 8,
  125. };
  126. #endif
  127. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  128. #if defined(CONFIG_MTD_M25P80) \
  129. || defined(CONFIG_MTD_M25P80_MODULE)
  130. {
  131. /* the modalias must be the same as spi device driver name */
  132. .modalias = "m25p80", /* Name of spi_driver for this device */
  133. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  134. .bus_num = 0, /* Framework bus number */
  135. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  136. .platform_data = &bfin_spi_flash_data,
  137. .controller_data = &spi_flash_chip_info,
  138. .mode = SPI_MODE_3,
  139. },
  140. #endif
  141. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  142. {
  143. .modalias = "mmc_spi",
  144. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  145. .bus_num = 0,
  146. .chip_select = 5,
  147. .controller_data = &mmc_spi_chip_info,
  148. .mode = SPI_MODE_3,
  149. },
  150. #endif
  151. };
  152. /* SPI controller data */
  153. static struct bfin5xx_spi_master bfin_spi0_info = {
  154. .num_chipselect = 8,
  155. .enable_dma = 1, /* master has the ability to do dma transfer */
  156. };
  157. /* SPI (0) */
  158. static struct resource bfin_spi0_resource[] = {
  159. [0] = {
  160. .start = SPI0_REGBASE,
  161. .end = SPI0_REGBASE + 0xFF,
  162. .flags = IORESOURCE_MEM,
  163. },
  164. [1] = {
  165. .start = CH_SPI,
  166. .end = CH_SPI,
  167. .flags = IORESOURCE_DMA,
  168. },
  169. [2] = {
  170. .start = IRQ_SPI,
  171. .end = IRQ_SPI,
  172. .flags = IORESOURCE_IRQ,
  173. },
  174. };
  175. static struct platform_device bfin_spi0_device = {
  176. .name = "bfin-spi",
  177. .id = 0, /* Bus number */
  178. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  179. .resource = bfin_spi0_resource,
  180. .dev = {
  181. .platform_data = &bfin_spi0_info, /* Passed to driver */
  182. },
  183. };
  184. #endif /* spi master and devices */
  185. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  186. static struct resource bfin_uart_resources[] = {
  187. {
  188. .start = 0xFFC00400,
  189. .end = 0xFFC004FF,
  190. .flags = IORESOURCE_MEM,
  191. }, {
  192. .start = 0xFFC02000,
  193. .end = 0xFFC020FF,
  194. .flags = IORESOURCE_MEM,
  195. },
  196. };
  197. static struct platform_device bfin_uart_device = {
  198. .name = "bfin-uart",
  199. .id = 1,
  200. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  201. .resource = bfin_uart_resources,
  202. };
  203. #endif
  204. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  205. #ifdef CONFIG_BFIN_SIR0
  206. static struct resource bfin_sir0_resources[] = {
  207. {
  208. .start = 0xFFC00400,
  209. .end = 0xFFC004FF,
  210. .flags = IORESOURCE_MEM,
  211. },
  212. {
  213. .start = IRQ_UART0_RX,
  214. .end = IRQ_UART0_RX+1,
  215. .flags = IORESOURCE_IRQ,
  216. },
  217. {
  218. .start = CH_UART0_RX,
  219. .end = CH_UART0_RX+1,
  220. .flags = IORESOURCE_DMA,
  221. },
  222. };
  223. static struct platform_device bfin_sir0_device = {
  224. .name = "bfin_sir",
  225. .id = 0,
  226. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  227. .resource = bfin_sir0_resources,
  228. };
  229. #endif
  230. #ifdef CONFIG_BFIN_SIR1
  231. static struct resource bfin_sir1_resources[] = {
  232. {
  233. .start = 0xFFC02000,
  234. .end = 0xFFC020FF,
  235. .flags = IORESOURCE_MEM,
  236. },
  237. {
  238. .start = IRQ_UART1_RX,
  239. .end = IRQ_UART1_RX+1,
  240. .flags = IORESOURCE_IRQ,
  241. },
  242. {
  243. .start = CH_UART1_RX,
  244. .end = CH_UART1_RX+1,
  245. .flags = IORESOURCE_DMA,
  246. },
  247. };
  248. static struct platform_device bfin_sir1_device = {
  249. .name = "bfin_sir",
  250. .id = 1,
  251. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  252. .resource = bfin_sir1_resources,
  253. };
  254. #endif
  255. #endif
  256. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  257. static struct resource bfin_twi0_resource[] = {
  258. [0] = {
  259. .start = TWI0_REGBASE,
  260. .end = TWI0_REGBASE + 0xFF,
  261. .flags = IORESOURCE_MEM,
  262. },
  263. [1] = {
  264. .start = IRQ_TWI,
  265. .end = IRQ_TWI,
  266. .flags = IORESOURCE_IRQ,
  267. },
  268. };
  269. static struct platform_device i2c_bfin_twi_device = {
  270. .name = "i2c-bfin-twi",
  271. .id = 0,
  272. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  273. .resource = bfin_twi0_resource,
  274. };
  275. #endif
  276. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  277. static struct platform_device bfin_sport0_uart_device = {
  278. .name = "bfin-sport-uart",
  279. .id = 0,
  280. };
  281. static struct platform_device bfin_sport1_uart_device = {
  282. .name = "bfin-sport-uart",
  283. .id = 1,
  284. };
  285. #endif
  286. static struct platform_device *minotaur_devices[] __initdata = {
  287. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  288. &bfin_pcmcia_cf_device,
  289. #endif
  290. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  291. &rtc_device,
  292. #endif
  293. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  294. &bfin_mii_bus,
  295. &bfin_mac_device,
  296. #endif
  297. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  298. &net2272_bfin_device,
  299. #endif
  300. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  301. &bfin_spi0_device,
  302. #endif
  303. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  304. &bfin_uart_device,
  305. #endif
  306. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  307. #ifdef CONFIG_BFIN_SIR0
  308. &bfin_sir0_device,
  309. #endif
  310. #ifdef CONFIG_BFIN_SIR1
  311. &bfin_sir1_device,
  312. #endif
  313. #endif
  314. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  315. &i2c_bfin_twi_device,
  316. #endif
  317. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  318. &bfin_sport0_uart_device,
  319. &bfin_sport1_uart_device,
  320. #endif
  321. };
  322. static int __init minotaur_init(void)
  323. {
  324. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  325. platform_add_devices(minotaur_devices, ARRAY_SIZE(minotaur_devices));
  326. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  327. spi_register_board_info(bfin_spi_board_info,
  328. ARRAY_SIZE(bfin_spi_board_info));
  329. #endif
  330. return 0;
  331. }
  332. arch_initcall(minotaur_init);
  333. void native_machine_restart(char *cmd)
  334. {
  335. /* workaround reboot hang when booting from SPI */
  336. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  337. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  338. }