minotaur.c 9.2 KB

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