ip0x.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /*
  2. * File: arch/blackfin/mach-bf533/ip0x.c
  3. * Based on: arch/blackfin/mach-bf533/bf1.c
  4. * Based on: arch/blackfin/mach-bf533/stamp.c
  5. * Author: Ivan Danov <idanov@gmail.com>
  6. * Modified for IP0X David Rowe
  7. *
  8. * Created: 2007
  9. * Description: Board info file for the IP04/IP08 boards, which
  10. * are derived from the BlackfinOne V2.0 boards.
  11. *
  12. * Modified:
  13. * COpyright 2007 David Rowe
  14. * Copyright 2006 Intratrade Ltd.
  15. * Copyright 2005 National ICT Australia (NICTA)
  16. * Copyright 2004-2006 Analog Devices Inc.
  17. *
  18. * This program is free software; you can redistribute it and/or modify
  19. * it under the terms of the GNU General Public License as published by
  20. * the Free Software Foundation; either version 2 of the License, or
  21. * (at your option) any later version.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU General Public License
  29. * along with this program; if not, see the file COPYING, or write
  30. * to the Free Software Foundation, Inc.,
  31. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  32. */
  33. #include <linux/device.h>
  34. #include <linux/platform_device.h>
  35. #include <linux/mtd/mtd.h>
  36. #include <linux/mtd/partitions.h>
  37. #include <linux/spi/spi.h>
  38. #include <linux/spi/flash.h>
  39. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  40. #include <linux/usb/isp1362.h>
  41. #endif
  42. #include <asm/irq.h>
  43. #include <asm/bfin5xx_spi.h>
  44. /*
  45. * Name the Board for the /proc/cpuinfo
  46. */
  47. const char bfin_board_name[] = "IP04/IP08";
  48. /*
  49. * Driver needs to know address, irq and flag pin.
  50. */
  51. #if defined(CONFIG_BFIN532_IP0X)
  52. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  53. #include <linux/dm9000.h>
  54. static struct resource dm9000_resource1[] = {
  55. {
  56. .start = 0x20100000,
  57. .end = 0x20100000 + 1,
  58. .flags = IORESOURCE_MEM
  59. },{
  60. .start = 0x20100000 + 2,
  61. .end = 0x20100000 + 3,
  62. .flags = IORESOURCE_MEM
  63. },{
  64. .start = IRQ_PF15,
  65. .end = IRQ_PF15,
  66. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
  67. }
  68. };
  69. static struct resource dm9000_resource2[] = {
  70. {
  71. .start = 0x20200000,
  72. .end = 0x20200000 + 1,
  73. .flags = IORESOURCE_MEM
  74. },{
  75. .start = 0x20200000 + 2,
  76. .end = 0x20200000 + 3,
  77. .flags = IORESOURCE_MEM
  78. },{
  79. .start = IRQ_PF14,
  80. .end = IRQ_PF14,
  81. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
  82. }
  83. };
  84. /*
  85. * for the moment we limit ourselves to 16bit IO until some
  86. * better IO routines can be written and tested
  87. */
  88. static struct dm9000_plat_data dm9000_platdata1 = {
  89. .flags = DM9000_PLATF_16BITONLY,
  90. };
  91. static struct platform_device dm9000_device1 = {
  92. .name = "dm9000",
  93. .id = 0,
  94. .num_resources = ARRAY_SIZE(dm9000_resource1),
  95. .resource = dm9000_resource1,
  96. .dev = {
  97. .platform_data = &dm9000_platdata1,
  98. }
  99. };
  100. static struct dm9000_plat_data dm9000_platdata2 = {
  101. .flags = DM9000_PLATF_16BITONLY,
  102. };
  103. static struct platform_device dm9000_device2 = {
  104. .name = "dm9000",
  105. .id = 1,
  106. .num_resources = ARRAY_SIZE(dm9000_resource2),
  107. .resource = dm9000_resource2,
  108. .dev = {
  109. .platform_data = &dm9000_platdata2,
  110. }
  111. };
  112. #endif
  113. #endif
  114. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  115. /* all SPI peripherals info goes here */
  116. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  117. static struct bfin5xx_spi_chip spi_mmc_chip_info = {
  118. /*
  119. * CPOL (Clock Polarity)
  120. * 0 - Active high SCK
  121. * 1 - Active low SCK
  122. * CPHA (Clock Phase) Selects transfer format and operation mode
  123. * 0 - SCLK toggles from middle of the first data bit, slave select
  124. * pins controlled by hardware.
  125. * 1 - SCLK toggles from beginning of first data bit, slave select
  126. * pins controller by user software.
  127. * .ctl_reg = 0x1c00, * CPOL=1,CPHA=1,Sandisk 1G work
  128. * NO NO .ctl_reg = 0x1800, * CPOL=1,CPHA=0
  129. * NO NO .ctl_reg = 0x1400, * CPOL=0,CPHA=1
  130. */
  131. .ctl_reg = 0x1000, /* CPOL=0,CPHA=0,Sandisk 1G work */
  132. .enable_dma = 0, /* if 1 - block!!! */
  133. .bits_per_word = 8,
  134. .cs_change_per_word = 0,
  135. };
  136. #endif
  137. /* Notice: for blackfin, the speed_hz is the value of register
  138. * SPI_BAUD, not the real baudrate */
  139. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  140. #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
  141. {
  142. .modalias = "spi_mmc",
  143. .max_speed_hz = 2,
  144. .bus_num = 1,
  145. .chip_select = CONFIG_SPI_MMC_CS_CHAN,
  146. .platform_data = NULL,
  147. .controller_data = &spi_mmc_chip_info,
  148. },
  149. #endif
  150. };
  151. /* SPI controller data */
  152. static struct bfin5xx_spi_master spi_bfin_master_info = {
  153. .num_chipselect = 8,
  154. .enable_dma = 1, /* master has the ability to do dma transfer */
  155. };
  156. static struct platform_device spi_bfin_master_device = {
  157. .name = "bfin-spi-master",
  158. .id = 1, /* Bus number */
  159. .dev = {
  160. .platform_data = &spi_bfin_master_info, /* Passed to driver */
  161. },
  162. };
  163. #endif /* spi master and devices */
  164. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  165. static struct resource bfin_uart_resources[] = {
  166. {
  167. .start = 0xFFC00400,
  168. .end = 0xFFC004FF,
  169. .flags = IORESOURCE_MEM,
  170. },
  171. };
  172. static struct platform_device bfin_uart_device = {
  173. .name = "bfin-uart",
  174. .id = 1,
  175. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  176. .resource = bfin_uart_resources,
  177. };
  178. #endif
  179. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  180. static struct resource bfin_sir_resources[] = {
  181. #ifdef CONFIG_BFIN_SIR0
  182. {
  183. .start = 0xFFC00400,
  184. .end = 0xFFC004FF,
  185. .flags = IORESOURCE_MEM,
  186. },
  187. #endif
  188. };
  189. static struct platform_device bfin_sir_device = {
  190. .name = "bfin_sir",
  191. .id = 0,
  192. .num_resources = ARRAY_SIZE(bfin_sir_resources),
  193. .resource = bfin_sir_resources,
  194. };
  195. #endif
  196. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  197. static struct resource isp1362_hcd_resources[] = {
  198. {
  199. .start = 0x20300000,
  200. .end = 0x20300000 + 1,
  201. .flags = IORESOURCE_MEM,
  202. },{
  203. .start = 0x20300000 + 2,
  204. .end = 0x20300000 + 3,
  205. .flags = IORESOURCE_MEM,
  206. },{
  207. .start = IRQ_PF11,
  208. .end = IRQ_PF11,
  209. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  210. },
  211. };
  212. static struct isp1362_platform_data isp1362_priv = {
  213. .sel15Kres = 1,
  214. .clknotstop = 0,
  215. .oc_enable = 0, /* external OC */
  216. .int_act_high = 0,
  217. .int_edge_triggered = 0,
  218. .remote_wakeup_connected = 0,
  219. .no_power_switching = 1,
  220. .power_switching_mode = 0,
  221. };
  222. static struct platform_device isp1362_hcd_device = {
  223. .name = "isp1362-hcd",
  224. .id = 0,
  225. .dev = {
  226. .platform_data = &isp1362_priv,
  227. },
  228. .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
  229. .resource = isp1362_hcd_resources,
  230. };
  231. #endif
  232. static struct platform_device *ip0x_devices[] __initdata = {
  233. #if defined(CONFIG_BFIN532_IP0X)
  234. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  235. &dm9000_device1,
  236. &dm9000_device2,
  237. #endif
  238. #endif
  239. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  240. &spi_bfin_master_device,
  241. #endif
  242. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  243. &bfin_uart_device,
  244. #endif
  245. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  246. &bfin_sir_device,
  247. #endif
  248. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  249. &isp1362_hcd_device,
  250. #endif
  251. };
  252. static int __init ip0x_init(void)
  253. {
  254. int i;
  255. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  256. platform_add_devices(ip0x_devices, ARRAY_SIZE(ip0x_devices));
  257. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  258. for (i = 0; i < ARRAY_SIZE(bfin_spi_board_info); ++i) {
  259. int j = 1 << bfin_spi_board_info[i].chip_select;
  260. /* set spi cs to 1 */
  261. bfin_write_FIO_DIR(bfin_read_FIO_DIR() | j);
  262. bfin_write_FIO_FLAG_S(j);
  263. }
  264. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  265. #endif
  266. return 0;
  267. }
  268. arch_initcall(ip0x_init);