ip0x.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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 IS_ENABLED(CONFIG_USB_ISP1362_HCD)
  18. #include <linux/usb/isp1362.h>
  19. #endif
  20. #include <asm/irq.h>
  21. #include <asm/dma.h>
  22. #include <asm/bfin5xx_spi.h>
  23. #include <asm/portmux.h>
  24. /*
  25. * Name the Board for the /proc/cpuinfo
  26. */
  27. const char bfin_board_name[] = "IP04/IP08";
  28. /*
  29. * Driver needs to know address, irq and flag pin.
  30. */
  31. #if defined(CONFIG_BFIN532_IP0X)
  32. #if IS_ENABLED(CONFIG_DM9000)
  33. #include <linux/dm9000.h>
  34. static struct resource dm9000_resource1[] = {
  35. {
  36. .start = 0x20100000,
  37. .end = 0x20100000 + 1,
  38. .flags = IORESOURCE_MEM
  39. },{
  40. .start = 0x20100000 + 2,
  41. .end = 0x20100000 + 3,
  42. .flags = IORESOURCE_MEM
  43. },{
  44. .start = IRQ_PF15,
  45. .end = IRQ_PF15,
  46. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
  47. }
  48. };
  49. static struct resource dm9000_resource2[] = {
  50. {
  51. .start = 0x20200000,
  52. .end = 0x20200000 + 1,
  53. .flags = IORESOURCE_MEM
  54. },{
  55. .start = 0x20200000 + 2,
  56. .end = 0x20200000 + 3,
  57. .flags = IORESOURCE_MEM
  58. },{
  59. .start = IRQ_PF14,
  60. .end = IRQ_PF14,
  61. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
  62. }
  63. };
  64. /*
  65. * for the moment we limit ourselves to 16bit IO until some
  66. * better IO routines can be written and tested
  67. */
  68. static struct dm9000_plat_data dm9000_platdata1 = {
  69. .flags = DM9000_PLATF_16BITONLY,
  70. };
  71. static struct platform_device dm9000_device1 = {
  72. .name = "dm9000",
  73. .id = 0,
  74. .num_resources = ARRAY_SIZE(dm9000_resource1),
  75. .resource = dm9000_resource1,
  76. .dev = {
  77. .platform_data = &dm9000_platdata1,
  78. }
  79. };
  80. static struct dm9000_plat_data dm9000_platdata2 = {
  81. .flags = DM9000_PLATF_16BITONLY,
  82. };
  83. static struct platform_device dm9000_device2 = {
  84. .name = "dm9000",
  85. .id = 1,
  86. .num_resources = ARRAY_SIZE(dm9000_resource2),
  87. .resource = dm9000_resource2,
  88. .dev = {
  89. .platform_data = &dm9000_platdata2,
  90. }
  91. };
  92. #endif
  93. #endif
  94. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  95. /* all SPI peripherals info goes here */
  96. #if IS_ENABLED(CONFIG_MMC_SPI)
  97. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  98. .enable_dma = 0, /* if 1 - block!!! */
  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 IS_ENABLED(CONFIG_MMC_SPI)
  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 IS_ENABLED(CONFIG_SERIAL_BFIN)
  128. #ifdef CONFIG_SERIAL_BFIN_UART0
  129. static struct resource bfin_uart0_resources[] = {
  130. {
  131. .start = BFIN_UART_THR,
  132. .end = BFIN_UART_GCTL+2,
  133. .flags = IORESOURCE_MEM,
  134. },
  135. {
  136. .start = IRQ_UART0_TX,
  137. .end = IRQ_UART0_TX,
  138. .flags = IORESOURCE_IRQ,
  139. },
  140. {
  141. .start = IRQ_UART0_RX,
  142. .end = IRQ_UART0_RX,
  143. .flags = IORESOURCE_IRQ,
  144. },
  145. {
  146. .start = IRQ_UART0_ERROR,
  147. .end = IRQ_UART0_ERROR,
  148. .flags = IORESOURCE_IRQ,
  149. },
  150. {
  151. .start = CH_UART0_TX,
  152. .end = CH_UART0_TX,
  153. .flags = IORESOURCE_DMA,
  154. },
  155. {
  156. .start = CH_UART0_RX,
  157. .end = CH_UART0_RX,
  158. .flags = IORESOURCE_DMA,
  159. },
  160. };
  161. static unsigned short bfin_uart0_peripherals[] = {
  162. P_UART0_TX, P_UART0_RX, 0
  163. };
  164. static struct platform_device bfin_uart0_device = {
  165. .name = "bfin-uart",
  166. .id = 0,
  167. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  168. .resource = bfin_uart0_resources,
  169. .dev = {
  170. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  171. },
  172. };
  173. #endif
  174. #endif
  175. #if IS_ENABLED(CONFIG_BFIN_SIR)
  176. #ifdef CONFIG_BFIN_SIR0
  177. static struct resource bfin_sir0_resources[] = {
  178. {
  179. .start = 0xFFC00400,
  180. .end = 0xFFC004FF,
  181. .flags = IORESOURCE_MEM,
  182. },
  183. {
  184. .start = IRQ_UART0_RX,
  185. .end = IRQ_UART0_RX+1,
  186. .flags = IORESOURCE_IRQ,
  187. },
  188. {
  189. .start = CH_UART0_RX,
  190. .end = CH_UART0_RX+1,
  191. .flags = IORESOURCE_DMA,
  192. },
  193. };
  194. static struct platform_device bfin_sir0_device = {
  195. .name = "bfin_sir",
  196. .id = 0,
  197. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  198. .resource = bfin_sir0_resources,
  199. };
  200. #endif
  201. #endif
  202. #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
  203. static struct resource isp1362_hcd_resources[] = {
  204. {
  205. .start = 0x20300000,
  206. .end = 0x20300000 + 1,
  207. .flags = IORESOURCE_MEM,
  208. },{
  209. .start = 0x20300000 + 2,
  210. .end = 0x20300000 + 3,
  211. .flags = IORESOURCE_MEM,
  212. },{
  213. .start = IRQ_PF11,
  214. .end = IRQ_PF11,
  215. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  216. },
  217. };
  218. static struct isp1362_platform_data isp1362_priv = {
  219. .sel15Kres = 1,
  220. .clknotstop = 0,
  221. .oc_enable = 0, /* external OC */
  222. .int_act_high = 0,
  223. .int_edge_triggered = 0,
  224. .remote_wakeup_connected = 0,
  225. .no_power_switching = 1,
  226. .power_switching_mode = 0,
  227. };
  228. static struct platform_device isp1362_hcd_device = {
  229. .name = "isp1362-hcd",
  230. .id = 0,
  231. .dev = {
  232. .platform_data = &isp1362_priv,
  233. },
  234. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  235. .resource = isp1362_hcd_resources,
  236. };
  237. #endif
  238. static struct platform_device *ip0x_devices[] __initdata = {
  239. #if defined(CONFIG_BFIN532_IP0X)
  240. #if IS_ENABLED(CONFIG_DM9000)
  241. &dm9000_device1,
  242. &dm9000_device2,
  243. #endif
  244. #endif
  245. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  246. &spi_bfin_master_device,
  247. #endif
  248. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  249. #ifdef CONFIG_SERIAL_BFIN_UART0
  250. &bfin_uart0_device,
  251. #endif
  252. #endif
  253. #if IS_ENABLED(CONFIG_BFIN_SIR)
  254. #ifdef CONFIG_BFIN_SIR0
  255. &bfin_sir0_device,
  256. #endif
  257. #endif
  258. #if IS_ENABLED(CONFIG_USB_ISP1362_HCD)
  259. &isp1362_hcd_device,
  260. #endif
  261. };
  262. static int __init ip0x_init(void)
  263. {
  264. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  265. platform_add_devices(ip0x_devices, ARRAY_SIZE(ip0x_devices));
  266. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  267. return 0;
  268. }
  269. arch_initcall(ip0x_init);
  270. static struct platform_device *ip0x_early_devices[] __initdata = {
  271. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  272. #ifdef CONFIG_SERIAL_BFIN_UART0
  273. &bfin_uart0_device,
  274. #endif
  275. #endif
  276. };
  277. void __init native_machine_early_platform_add_devices(void)
  278. {
  279. printk(KERN_INFO "register early platform devices\n");
  280. early_platform_add_devices(ip0x_early_devices,
  281. ARRAY_SIZE(ip0x_early_devices));
  282. }