minotaur.c 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  122. static struct bfin5xx_spi_chip spi_mmc_chip_info = {
  123. .enable_dma = 1,
  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_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  142. {
  143. .modalias = "spi_mmc_dummy",
  144. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  145. .bus_num = 0,
  146. .chip_select = 0,
  147. .platform_data = NULL,
  148. .controller_data = &spi_mmc_chip_info,
  149. .mode = SPI_MODE_3,
  150. },
  151. {
  152. .modalias = "spi_mmc",
  153. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  154. .bus_num = 0,
  155. .chip_select = CONFIG_SPI_MMC_CS_CHAN,
  156. .platform_data = NULL,
  157. .controller_data = &spi_mmc_chip_info,
  158. .mode = SPI_MODE_3,
  159. },
  160. #endif
  161. };
  162. /* SPI controller data */
  163. static struct bfin5xx_spi_master bfin_spi0_info = {
  164. .num_chipselect = 8,
  165. .enable_dma = 1, /* master has the ability to do dma transfer */
  166. };
  167. /* SPI (0) */
  168. static struct resource bfin_spi0_resource[] = {
  169. [0] = {
  170. .start = SPI0_REGBASE,
  171. .end = SPI0_REGBASE + 0xFF,
  172. .flags = IORESOURCE_MEM,
  173. },
  174. [1] = {
  175. .start = CH_SPI,
  176. .end = CH_SPI,
  177. .flags = IORESOURCE_IRQ,
  178. },
  179. };
  180. static struct platform_device bfin_spi0_device = {
  181. .name = "bfin-spi",
  182. .id = 0, /* Bus number */
  183. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  184. .resource = bfin_spi0_resource,
  185. .dev = {
  186. .platform_data = &bfin_spi0_info, /* Passed to driver */
  187. },
  188. };
  189. #endif /* spi master and devices */
  190. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  191. static struct resource bfin_uart_resources[] = {
  192. {
  193. .start = 0xFFC00400,
  194. .end = 0xFFC004FF,
  195. .flags = IORESOURCE_MEM,
  196. }, {
  197. .start = 0xFFC02000,
  198. .end = 0xFFC020FF,
  199. .flags = IORESOURCE_MEM,
  200. },
  201. };
  202. static struct platform_device bfin_uart_device = {
  203. .name = "bfin-uart",
  204. .id = 1,
  205. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  206. .resource = bfin_uart_resources,
  207. };
  208. #endif
  209. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  210. #ifdef CONFIG_BFIN_SIR0
  211. static struct resource bfin_sir0_resources[] = {
  212. {
  213. .start = 0xFFC00400,
  214. .end = 0xFFC004FF,
  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 = CH_UART0_RX,
  224. .end = CH_UART0_RX+1,
  225. .flags = IORESOURCE_DMA,
  226. },
  227. };
  228. static struct platform_device bfin_sir0_device = {
  229. .name = "bfin_sir",
  230. .id = 0,
  231. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  232. .resource = bfin_sir0_resources,
  233. };
  234. #endif
  235. #ifdef CONFIG_BFIN_SIR1
  236. static struct resource bfin_sir1_resources[] = {
  237. {
  238. .start = 0xFFC02000,
  239. .end = 0xFFC020FF,
  240. .flags = IORESOURCE_MEM,
  241. },
  242. {
  243. .start = IRQ_UART1_RX,
  244. .end = IRQ_UART1_RX+1,
  245. .flags = IORESOURCE_IRQ,
  246. },
  247. {
  248. .start = CH_UART1_RX,
  249. .end = CH_UART1_RX+1,
  250. .flags = IORESOURCE_DMA,
  251. },
  252. };
  253. static struct platform_device bfin_sir1_device = {
  254. .name = "bfin_sir",
  255. .id = 1,
  256. .num_resources = ARRAY_SIZE(bfin_sir1_resources),
  257. .resource = bfin_sir1_resources,
  258. };
  259. #endif
  260. #endif
  261. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  262. static struct resource bfin_twi0_resource[] = {
  263. [0] = {
  264. .start = TWI0_REGBASE,
  265. .end = TWI0_REGBASE + 0xFF,
  266. .flags = IORESOURCE_MEM,
  267. },
  268. [1] = {
  269. .start = IRQ_TWI,
  270. .end = IRQ_TWI,
  271. .flags = IORESOURCE_IRQ,
  272. },
  273. };
  274. static struct platform_device i2c_bfin_twi_device = {
  275. .name = "i2c-bfin-twi",
  276. .id = 0,
  277. .num_resources = ARRAY_SIZE(bfin_twi0_resource),
  278. .resource = bfin_twi0_resource,
  279. };
  280. #endif
  281. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  282. static struct platform_device bfin_sport0_uart_device = {
  283. .name = "bfin-sport-uart",
  284. .id = 0,
  285. };
  286. static struct platform_device bfin_sport1_uart_device = {
  287. .name = "bfin-sport-uart",
  288. .id = 1,
  289. };
  290. #endif
  291. static struct platform_device *minotaur_devices[] __initdata = {
  292. #if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
  293. &bfin_pcmcia_cf_device,
  294. #endif
  295. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  296. &rtc_device,
  297. #endif
  298. #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
  299. &bfin_mii_bus,
  300. &bfin_mac_device,
  301. #endif
  302. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  303. &net2272_bfin_device,
  304. #endif
  305. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  306. &bfin_spi0_device,
  307. #endif
  308. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  309. &bfin_uart_device,
  310. #endif
  311. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  312. #ifdef CONFIG_BFIN_SIR0
  313. &bfin_sir0_device,
  314. #endif
  315. #ifdef CONFIG_BFIN_SIR1
  316. &bfin_sir1_device,
  317. #endif
  318. #endif
  319. #if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
  320. &i2c_bfin_twi_device,
  321. #endif
  322. #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
  323. &bfin_sport0_uart_device,
  324. &bfin_sport1_uart_device,
  325. #endif
  326. };
  327. static int __init minotaur_init(void)
  328. {
  329. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  330. platform_add_devices(minotaur_devices, ARRAY_SIZE(minotaur_devices));
  331. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  332. spi_register_board_info(bfin_spi_board_info,
  333. ARRAY_SIZE(bfin_spi_board_info));
  334. #endif
  335. return 0;
  336. }
  337. arch_initcall(minotaur_init);
  338. void native_machine_restart(char *cmd)
  339. {
  340. /* workaround reboot hang when booting from SPI */
  341. if ((bfin_read_SYSCR() & 0x7) == 0x3)
  342. bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
  343. }