basicAlgorithmEncapsulation.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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_BFIN5XX) || defined(CONFIG_SPI_BFIN5XX_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. };
  145. #endif
  146. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  147. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  148. .enable_dma = 0,
  149. };
  150. #endif
  151. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  152. #if defined(CONFIG_MTD_M25P80) \
  153. || defined(CONFIG_MTD_M25P80_MODULE)
  154. {
  155. /* the modalias must be the same as spi device driver name */
  156. .modalias = "m25p80", /* Name of spi_driver for this device */
  157. .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
  158. .bus_num = 0, /* Framework bus number */
  159. .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
  160. .platform_data = &bfin_spi_flash_data,
  161. .controller_data = &spi_flash_chip_info,
  162. .mode = SPI_MODE_3,
  163. },
  164. #endif
  165. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  166. {
  167. .modalias = "mmc_spi",
  168. .max_speed_hz = 5000000, /* max spi clock (SCK) speed in HZ */
  169. .bus_num = 0,
  170. .chip_select = 5,
  171. .controller_data = &mmc_spi_chip_info,
  172. .mode = SPI_MODE_3,
  173. },
  174. #endif
  175. };
  176. /* SPI controller data */
  177. static struct bfin5xx_spi_master bfin_spi0_info = {
  178. .num_chipselect = 8,
  179. .enable_dma = 1, /* master has the ability to do dma transfer */
  180. };
  181. /* SPI (0) */
  182. static struct resource bfin_spi0_resource[] = {
  183. [0] = {
  184. .start = SPI0_REGBASE,
  185. .end = SPI0_REGBASE + 0xFF,
  186. .flags = IORESOURCE_MEM,
  187. },
  188. [1] = {
  189. .start = CH_SPI,
  190. .end = CH_SPI,
  191. .flags = IORESOURCE_DMA,
  192. },
  193. [2] = {
  194. .start = IRQ_SPI,
  195. .end = IRQ_SPI,
  196. .flags = IORESOURCE_IRQ,
  197. },
  198. };
  199. static struct platform_device bfin_spi0_device = {
  200. .name = "bfin-spi",
  201. .id = 0, /* Bus number */
  202. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  203. .resource = bfin_spi0_resource,
  204. .dev = {
  205. .platform_data = &bfin_spi0_info, /* Passed to driver */
  206. },
  207. };
  208. #endif /* spi master and devices */
  209. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  210. #ifdef CONFIG_SERIAL_BFIN_UART0
  211. static struct resource bfin_uart0_resources[] = {
  212. {
  213. .start = UART0_THR,
  214. .end = UART0_GCTL+2,
  215. .flags = IORESOURCE_MEM,
  216. },
  217. {
  218. .start = IRQ_UART0_TX,
  219. .end = IRQ_UART0_TX,
  220. .flags = IORESOURCE_IRQ,
  221. },
  222. {
  223. .start = IRQ_UART0_RX,
  224. .end = IRQ_UART0_RX,
  225. .flags = IORESOURCE_IRQ,
  226. },
  227. {
  228. .start = IRQ_UART0_ERROR,
  229. .end = IRQ_UART0_ERROR,
  230. .flags = IORESOURCE_IRQ,
  231. },
  232. {
  233. .start = CH_UART0_TX,
  234. .end = CH_UART0_TX,
  235. .flags = IORESOURCE_DMA,
  236. },
  237. {
  238. .start = CH_UART0_RX,
  239. .end = CH_UART0_RX,
  240. .flags = IORESOURCE_DMA,
  241. },
  242. };
  243. static unsigned short bfin_uart0_peripherals[] = {
  244. P_UART0_TX, P_UART0_RX, 0
  245. };
  246. static struct platform_device bfin_uart0_device = {
  247. .name = "bfin-uart",
  248. .id = 0,