ip0x.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * 2007 David Rowe
  4. * 2006 Intratrade Ltd.
  5. * Ivan Danov <idanov@gmail.com>
  6. * 2005 National ICT Australia (NICTA)
  7. * Aidan Williams <aidan@nicta.com.au>
  8. *
  9. * Licensed under the GPL-2 or later.
  10. */
  11. #include <linux/device.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/partitions.h>
  15. #include <linux/spi/spi.h>
  16. #include <linux/spi/flash.h>
  17. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  18. #include <linux/usb/isp1362.h>
  19. #endif
  20. #include <asm/irq.h>
  21. #include <asm/bfin5xx_spi.h>
  22. #include <asm/portmux.h>
  23. /*
  24. * Name the Board for the /proc/cpuinfo
  25. */
  26. const char bfin_board_name[] = "IP04/IP08";
  27. /*
  28. * Driver needs to know address, irq and flag pin.
  29. */
  30. #if defined(CONFIG_BFIN532_IP0X)
  31. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  32. #include <linux/dm9000.h>
  33. static struct resource dm9000_resource1[] = {
  34. {
  35. .start = 0x20100000,
  36. .end = 0x20100000 + 1,
  37. .flags = IORESOURCE_MEM
  38. },{
  39. .start = 0x20100000 + 2,
  40. .end = 0x20100000 + 3,
  41. .flags = IORESOURCE_MEM
  42. },{
  43. .start = IRQ_PF15,
  44. .end = IRQ_PF15,
  45. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
  46. }
  47. };
  48. static struct resource dm9000_resource2[] = {
  49. {
  50. .start = 0x20200000,
  51. .end = 0x20200000 + 1,
  52. .flags = IORESOURCE_MEM
  53. },{
  54. .start = 0x20200000 + 2,
  55. .end = 0x20200000 + 3,
  56. .flags = IORESOURCE_MEM
  57. },{
  58. .start = IRQ_PF14,
  59. .end = IRQ_PF14,
  60. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
  61. }
  62. };
  63. /*
  64. * for the moment we limit ourselves to 16bit IO until some
  65. * better IO routines can be written and tested
  66. */
  67. static struct dm9000_plat_data dm9000_platdata1 = {
  68. .flags = DM9000_PLATF_16BITONLY,
  69. };
  70. static struct platform_device dm9000_device1 = {
  71. .name = "dm9000",
  72. .id = 0,
  73. .num_resources = ARRAY_SIZE(dm9000_resource1),
  74. .resource = dm9000_resource1,
  75. .dev = {
  76. .platform_data = &dm9000_platdata1,
  77. }
  78. };
  79. static struct dm9000_plat_data dm9000_platdata2 = {
  80. .flags = DM9000_PLATF_16BITONLY,
  81. };
  82. static struct platform_device dm9000_device2 = {
  83. .name = "dm9000",
  84. .id = 1,
  85. .num_resources = ARRAY_SIZE(dm9000_resource2),
  86. .resource = dm9000_resource2,
  87. .dev = {
  88. .platform_data = &dm9000_platdata2,
  89. }
  90. };
  91. #endif
  92. #endif
  93. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  94. /* all SPI peripherals info goes here */
  95. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  96. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  97. .enable_dma = 0, /* if 1 - block!!! */
  98. .bits_per_word = 8,
  99. };
  100. #endif
  101. /* Notice: for blackfin, the speed_hz is the value of register
  102. * SPI_BAUD, not the real baudrate */
  103. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  104. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  105. {
  106. .modalias = "mmc_spi",
  107. .max_speed_hz = 2,
  108. .bus_num = 1,
  109. .chip_select = 5,
  110. .controller_data = &mmc_spi_chip_info,
  111. },
  112. #endif
  113. };
  114. /* SPI controller data */
  115. static struct bfin5xx_spi_master spi_bfin_master_info = {
  116. .num_chipselect = 8,
  117. .enable_dma = 1, /* master has the ability to do dma transfer */
  118. };
  119. static struct platform_device spi_bfin_master_device = {
  120. .name = "bfin-spi-master",
  121. .id = 1, /* Bus number */
  122. .dev = {
  123. .platform_data = &spi_bfin_master_info, /* Passed to driver */
  124. },
  125. };
  126. #endif /* spi master and devices */
  127. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  128. static struct resource bfin_uart_resources[] = {
  129. {
  130. .start = 0xFFC00400,
  131. .end = 0xFFC004FF,
  132. .flags = IORESOURCE_MEM,
  133. },
  134. };
  135. static struct platform_device bfin_uart_device = {
  136. .name = "bfin-uart",
  137. .id = 1,
  138. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  139. .resource = bfin_uart_resources,
  140. };
  141. #endif
  142. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  143. #ifdef CONFIG_BFIN_SIR0
  144. static struct resource bfin_sir0_resources[] = {
  145. {
  146. .start = 0xFFC00400,
  147. .end = 0xFFC004FF,
  148. .flags = IORESOURCE_MEM,
  149. },
  150. {
  151. .start = IRQ_UART0_RX,
  152. .end = IRQ_UART0_RX+1,
  153. .flags = IORESOURCE_IRQ,
  154. },
  155. {
  156. .start = CH_UART0_RX,
  157. .end = CH_UART0_RX+1,
  158. .flags = IORESOURCE_DMA,
  159. },
  160. };
  161. static struct platform_device bfin_sir0_device = {
  162. .name = "bfin_sir",
  163. .id = 0,
  164. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  165. .resource = bfin_sir0_resources,
  166. };
  167. #endif
  168. #endif
  169. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  170. static struct resource isp1362_hcd_resources[] = {
  171. {
  172. .start = 0x20300000,
  173. .end = 0x20300000 + 1,
  174. .flags = IORESOURCE_MEM,
  175. },{
  176. .start = 0x20300000 + 2,
  177. .end = 0x20300000 + 3,
  178. .flags = IORESOURCE_MEM,
  179. },{
  180. .start = IRQ_PF11,
  181. .end = IRQ_PF11,
  182. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  183. },
  184. };
  185. static struct isp1362_platform_data isp1362_priv = {
  186. .sel15Kres = 1,
  187. .clknotstop = 0,
  188. .oc_enable = 0, /* external OC */
  189. .int_act_high = 0,
  190. .int_edge_triggered = 0,
  191. .remote_wakeup_connected = 0,
  192. .no_power_switching = 1,
  193. .power_switching_mode = 0,
  194. };
  195. static struct platform_device isp1362_hcd_device = {
  196. .name = "isp1362-hcd",
  197. .id = 0,
  198. .dev = {
  199. .platform_data = &isp1362_priv,
  200. },
  201. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  202. .resource = isp1362_hcd_resources,
  203. };
  204. #endif
  205. static struct platform_device *ip0x_devices[] __initdata = {
  206. #if defined(CONFIG_BFIN532_IP0X)
  207. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  208. &dm9000_device1,
  209. &dm9000_device2,
  210. #endif
  211. #endif
  212. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  213. &spi_bfin_master_device,
  214. #endif
  215. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  216. &bfin_uart_device,
  217. #endif
  218. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  219. #ifdef CONFIG_BFIN_SIR0
  220. &bfin_sir0_device,
  221. #endif
  222. #endif
  223. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  224. &isp1362_hcd_device,
  225. #endif
  226. };
  227. static int __init ip0x_init(void)
  228. {
  229. int i;
  230. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  231. platform_add_devices(ip0x_devices, ARRAY_SIZE(ip0x_devices));
  232. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  233. for (i = 0; i < ARRAY_SIZE(bfin_spi_board_info); ++i) {
  234. int j = 1 << bfin_spi_board_info[i].chip_select;
  235. /* set spi cs to 1 */
  236. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | j);
  237. bfin_write_FIO_FLAG_S(j);
  238. }
  239. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  240. #endif
  241. return 0;
  242. }
  243. arch_initcall(ip0x_init);