ip0x.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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/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 defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  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 defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  95. /* all SPI peripherals info goes here */
  96. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  97. static struct bfin5xx_spi_chip mmc_spi_chip_info = {
  98. .enable_dma = 0, /* if 1 - block!!! */
  99. .bits_per_word = 8,
  100. };
  101. #endif
  102. /* Notice: for blackfin, the speed_hz is the value of register
  103. * SPI_BAUD, not the real baudrate */
  104. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  105. #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
  106. {
  107. .modalias = "mmc_spi",
  108. .max_speed_hz = 2,
  109. .bus_num = 1,
  110. .chip_select = 5,
  111. .controller_data = &mmc_spi_chip_info,
  112. },
  113. #endif
  114. };
  115. /* SPI controller data */
  116. static struct bfin5xx_spi_master spi_bfin_master_info = {
  117. .num_chipselect = 8,
  118. .enable_dma = 1, /* master has the ability to do dma transfer */
  119. };
  120. static struct platform_device spi_bfin_master_device = {
  121. .name = "bfin-spi-master",
  122. .id = 1, /* Bus number */
  123. .dev = {
  124. .platform_data = &spi_bfin_master_info, /* Passed to driver */
  125. },
  126. };
  127. #endif /* spi master and devices */
  128. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  129. #ifdef CONFIG_SERIAL_BFIN_UART0
  130. static struct resource bfin_uart0_resources[] = {
  131. {
  132. .start = BFIN_UART_THR,
  133. .end = BFIN_UART_GCTL+2,
  134. .flags = IORESOURCE_MEM,
  135. },
  136. {
  137. .start = IRQ_UART0_RX,
  138. .end = IRQ_UART0_RX + 1,
  139. .flags = IORESOURCE_IRQ,
  140. },
  141. {
  142. .start = IRQ_UART0_ERROR,
  143. .end = IRQ_UART0_ERROR,
  144. .flags = IORESOURCE_IRQ,
  145. },
  146. {
  147. .start = CH_UART0_TX,
  148. .end = CH_UART0_TX,
  149. .flags = IORESOURCE_DMA,
  150. },
  151. {
  152. .start = CH_UART0_RX,
  153. .end = CH_UART0_RX,
  154. .flags = IORESOURCE_DMA,
  155. },
  156. };
  157. static unsigned short bfin_uart0_peripherals[] = {
  158. P_UART0_TX, P_UART0_RX, 0
  159. };
  160. static struct platform_device bfin_uart0_device = {
  161. .name = "bfin-uart",
  162. .id = 0,
  163. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  164. .resource = bfin_uart0_resources,
  165. .dev = {
  166. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  167. },
  168. };
  169. #endif
  170. #endif
  171. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  172. #ifdef CONFIG_BFIN_SIR0
  173. static struct resource bfin_sir0_resources[] = {
  174. {
  175. .start = 0xFFC00400,
  176. .end = 0xFFC004FF,
  177. .flags = IORESOURCE_MEM,
  178. },
  179. {
  180. .start = IRQ_UART0_RX,
  181. .end = IRQ_UART0_RX+1,
  182. .flags = IORESOURCE_IRQ,
  183. },
  184. {
  185. .start = CH_UART0_RX,
  186. .end = CH_UART0_RX+1,
  187. .flags = IORESOURCE_DMA,
  188. },
  189. };
  190. static struct platform_device bfin_sir0_device = {
  191. .name = "bfin_sir",
  192. .id = 0,
  193. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  194. .resource = bfin_sir0_resources,
  195. };
  196. #endif
  197. #endif
  198. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  199. static struct resource isp1362_hcd_resources[] = {
  200. {
  201. .start = 0x20300000,
  202. .end = 0x20300000 + 1,
  203. .flags = IORESOURCE_MEM,
  204. },{
  205. .start = 0x20300000 + 2,
  206. .end = 0x20300000 + 3,
  207. .flags = IORESOURCE_MEM,
  208. },{
  209. .start = IRQ_PF11,
  210. .end = IRQ_PF11,
  211. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  212. },
  213. };
  214. static struct isp1362_platform_data isp1362_priv = {
  215. .sel15Kres = 1,
  216. .clknotstop = 0,
  217. .oc_enable = 0, /* external OC */
  218. .int_act_high = 0,
  219. .int_edge_triggered = 0,
  220. .remote_wakeup_connected = 0,
  221. .no_power_switching = 1,
  222. .power_switching_mode = 0,
  223. };
  224. static struct platform_device isp1362_hcd_device = {
  225. .name = "isp1362-hcd",
  226. .id = 0,
  227. .dev = {
  228. .platform_data = &isp1362_priv,
  229. },
  230. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  231. .resource = isp1362_hcd_resources,
  232. };
  233. #endif
  234. static struct platform_device *ip0x_devices[] __initdata = {
  235. #if defined(CONFIG_BFIN532_IP0X)
  236. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  237. &dm9000_device1,
  238. &dm9000_device2,
  239. #endif
  240. #endif
  241. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  242. &spi_bfin_master_device,
  243. #endif
  244. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  245. #ifdef CONFIG_SERIAL_BFIN_UART0
  246. &bfin_uart0_device,
  247. #endif
  248. #endif
  249. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  250. #ifdef CONFIG_BFIN_SIR0
  251. &bfin_sir0_device,
  252. #endif
  253. #endif
  254. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  255. &isp1362_hcd_device,
  256. #endif
  257. };
  258. static int __init ip0x_init(void)
  259. {
  260. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  261. platform_add_devices(ip0x_devices, ARRAY_SIZE(ip0x_devices));
  262. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  263. return 0;
  264. }
  265. arch_initcall(ip0x_init);
  266. static struct platform_device *ip0x_early_devices[] __initdata = {
  267. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  268. #ifdef CONFIG_SERIAL_BFIN_UART0
  269. &bfin_uart0_device,
  270. #endif
  271. #endif
  272. };
  273. void __init native_machine_early_platform_add_devices(void)
  274. {
  275. printk(KERN_INFO "register early platform devices\n");
  276. early_platform_add_devices(ip0x_early_devices,
  277. ARRAY_SIZE(ip0x_early_devices));
  278. }