minotaur.c 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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_IRQ,
  168. },
  169. };
  170. static struct platform_device bfin_spi0_device = {
  171. .name = "bfin-spi",
  172. .id = 0, /* Bus number */
  173. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  174. .resource = bfin_spi0_resource,
  175. .dev = {
  176. .platform_data = &bfin_spi0_info, /* Passed to driver */
  177. },
  178. };
  179. #endif /* spi master and devices */
  180. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  181. static struct resource bfin_uart_resources[] = {
  182. {
  183. .start = 0xFFC00400,
  184. .end = 0xFFC004FF,
  185. .flags = IORESOURCE_MEM,
  186. }, {
  187. .start = 0xFFC02000,
  188. .end = 0xFFC020FF,
  189. .flags = IORESOURCE_MEM,
  190. },
  191. };
  192. static struct platform_device bfin_uart_device = {
  193. .name = "bfin-uart",
  194. .id = 1,
  195. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  196. .resource = bfin_uart_resources,
  197. };
  198. #endif
  199. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  200. #ifdef CONFIG_BFIN_SIR0
  201. static struct resource bfin_sir0_resources[] = {
  202. {
  203. .start = 0xFFC00400,
  204. .end = 0xFFC004FF,
  205. .flags = IORESOURCE_MEM,
  206. },
  207. {
  208. .start = IRQ_UART0_RX,
  209. .end = IRQ_UART0_RX+1,
  210. .flags = IORESOURCE_IRQ,
  211. },
  212. {
  213. .start = CH_UART0_RX,
  214. .end = CH_UART0_RX+1,
  215. .flags = IORESOURCE_DMA,
  216. },
  217. };
  218. static struct platform_device bfin_sir0_device = {
  219. .name = "bfin_sir",
  220. .id = 0,
  221. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  222. .resource = bfin_sir0_resources,
  223. };
  224. #endif
  225. #ifdef CONFIG_BFIN_SIR1
  226. static struct resource bfin_sir1_resources[] = {
  227. {
  228. .start = 0xFFC02000,
  229. .end = 0xFFC020FF,
  230. .flags = IORESOURCE_MEM,
  231. },
  232. {
  233. .start = IRQ_UART1_RX,
  234. .end = IRQ_UART1_RX+1,
  235. .flags = IORESOURCE_IRQ,
  236. },
  237. {
  238. .start = CH_UART1_RX,
  239. .end = CH_UART1_RX+1,
  240. .flags = IORESOURCE_DMA,
  241. },
  242. };
  243. static struct platform_device bfin_sir1_device = {
  244. .name = "bfin_sir",
  245. .id = 1,
  246. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  247. .resource = bfin_sir1_resources,
  248. };
  249. #endif
  250. #endif
  251. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  252. static struct resource bfin_twi0_resource[] = {
  253. [0] = {
  254. .start = TWI0_REGBASE,
  255. .end = TWI0_REGBASE + 0xFF,
  256. .flags = IORESOURCE_MEM,
  257. },
  258. [1] = {
  259. .start = IRQ_TWI,
  260. .end = IRQ_TWI,
  261. .flags = IORESOURCE_IRQ,
  262. },
  263. };
  264. static struct platform_device i2c_bfin_twi_device = {
  265. .name = "i2c-bfin-twi",
  266. .id = 0,
  267. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  268. .resource = bfin_twi0_resource,
  269. };
  270. #endif
  271. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  272. static struct platform_device bfin_sport0_uart_device = {
  273. .name = "bfin-sport-uart",
  274. .id = 0,
  275. };
  276. static struct platform_device bfin_sport1_uart_device = {
  277. .name = "bfin-sport-uart",
  278. .id = 1,
  279. };
  280. #endif
  281. static struct platform_device *minotaur_devices[] __initdata = {
  282. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  283. &bfin_pcmcia_cf_device,
  284. #endif
  285. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  286. &rtc_device,
  287. #endif
  288. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  289. &bfin_mii_bus,
  290. &bfin_mac_device,
  291. #endif
  292. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  293. &net2272_bfin_device,
  294. #endif
  295. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  296. &bfin_spi0_device,
  297. #endif
  298. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  299. &bfin_uart_device,
  300. #endif
  301. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  302. #ifdef CONFIG_BFIN_SIR0
  303. &bfin_sir0_device,
  304. #endif
  305. #ifdef CONFIG_BFIN_SIR1
  306. &bfin_sir1_device,
  307. #endif
  308. #endif
  309. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  310. &i2c_bfin_twi_device,
  311. #endif
  312. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  313. &bfin_sport0_uart_device,
  314. &bfin_sport1_uart_device,
  315. #endif
  316. };
  317. static int __init minotaur_init(void)
  318. {
  319. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  320. platform_add_devices(minotaur_devices, ARRAY_SIZE(minotaur_devices));
  321. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  322. spi_register_board_info(bfin_spi_board_info,
  323. ARRAY_SIZE(bfin_spi_board_info));
  324. #endif
  325. return 0;
  326. }
  327. arch_initcall(minotaur_init);
  328. void native_machine_restart(char *cmd)
  329. {
  330. /* workaround reboot hang when booting from SPI */
  331. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  332. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  333. }