H8606.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. * 2007-2008 HV Sistemas S.L.
  4. * Javier Herrero <jherrero@hvsistemas.es>
  5. * 2005 National ICT Australia (NICTA)
  6. * Aidan Williams <aidan@nicta.com.au>
  7. *
  8. * Licensed under the GPL-2 or later.
  9. */
  10. #include <linux/device.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/spi/spi.h>
  15. #include <linux/spi/flash.h>
  16. #if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
  17. #include <linux/usb/isp1362.h>
  18. #endif
  19. #include <linux/irq.h>
  20. #include <asm/dma.h>
  21. #include <asm/bfin5xx_spi.h>
  22. #include <asm/reboot.h>
  23. #include <asm/portmux.h>
  24. /*
  25. * Name the Board for the /proc/cpuinfo
  26. */
  27. const char bfin_board_name[] = "HV Sistemas H8606";
  28. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  29. static struct platform_device rtc_device = {
  30. .name = "rtc-bfin",
  31. .id = -1,
  32. };
  33. #endif
  34. /*
  35. * Driver needs to know address, irq and flag pin.
  36. */
  37. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  38. static struct resource dm9000_resources[] = {
  39. [0] = {
  40. .start = 0x20300000,
  41. .end = 0x20300002,
  42. .flags = IORESOURCE_MEM,
  43. },
  44. [1] = {
  45. .start = 0x20300004,
  46. .end = 0x20300006,
  47. .flags = IORESOURCE_MEM,
  48. },
  49. [2] = {
  50. .start = IRQ_PF10,
  51. .end = IRQ_PF10,
  52. .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | IRQF_SHARED | IRQF_TRIGGER_HIGH),
  53. },
  54. };
  55. static struct platform_device dm9000_device = {
  56. .id = 0,
  57. .name = "dm9000",
  58. .resource = dm9000_resources,
  59. .num_resources = ARRAY_SIZE(dm9000_resources),
  60. };
  61. #endif
  62. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  63. #include <linux/smc91x.h>
  64. static struct smc91x_platdata smc91x_info = {
  65. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  66. .leda = RPC_LED_100_10,
  67. .ledb = RPC_LED_TX_RX,
  68. };
  69. static struct resource smc91x_resources[] = {
  70. {
  71. .name = "smc91x-regs",
  72. .start = 0x20300300,
  73. .end = 0x20300300 + 16,
  74. .flags = IORESOURCE_MEM,
  75. }, {
  76. .start = IRQ_PROG_INTB,
  77. .end = IRQ_PROG_INTB,
  78. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  79. }, {
  80. .start = IRQ_PF7,
  81. .end = IRQ_PF7,
  82. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  83. },
  84. };
  85. static struct platform_device smc91x_device = {
  86. .name = "smc91x",
  87. .id = 0,
  88. .num_resources = ARRAY_SIZE(smc91x_resources),
  89. .resource = smc91x_resources,
  90. .dev = {
  91. .platform_data = &smc91x_info,
  92. },
  93. };
  94. #endif
  95. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  96. static struct resource net2272_bfin_resources[] = {
  97. {
  98. .start = 0x20300000,
  99. .end = 0x20300000 + 0x100,
  100. .flags = IORESOURCE_MEM,
  101. }, {
  102. .start = IRQ_PF10,
  103. .end = IRQ_PF10,
  104. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  105. },
  106. };
  107. static struct platform_device net2272_bfin_device = {
  108. .name = "net2272",
  109. .id = -1,
  110. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  111. .resource = net2272_bfin_resources,
  112. };
  113. #endif
  114. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  115. /* all SPI peripherals info goes here */
  116. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  117. static struct mtd_partition bfin_spi_flash_partitions[] = {
  118. {
  119. .name = "bootloader (spi)",
  120. .size = 0x40000,
  121. .offset = 0,
  122. .mask_flags = MTD_CAP_ROM
  123. }, {
  124. .name = "fpga (spi)",
  125. .size = 0x30000,
  126. .offset = 0x40000
  127. }, {
  128. .name = "linux kernel (spi)",
  129. .size = 0x150000,
  130. .offset = 0x70000
  131. }, {
  132. .name = "jffs2 root file system (spi)",
  133. .size = 0x640000,
  134. .offset = 0x1c0000,
  135. }
  136. };
  137. static struct flash_platform_data bfin_spi_flash_data = {
  138. .name = "m25p80",
  139. .parts = bfin_spi_flash_partitions,
  140. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  141. .type = "m25p64",
  142. };
  143. /* SPI flash chip (m25p64) */
  144. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  145. .enable_dma = 0, /* use dma transfer with this chip*/
  146. .bits_per_word = 8,
  147. };
  148. #endif
  149. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  150. /* SPI ADC chip */
  151. static struct bfin5xx_spi_chip spi_adc_chip_info = {
  152. .enable_dma = 1, /* use dma transfer with this chip*/
  153. .bits_per_word = 16,
  154. };
  155. #endif
  156. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  157. static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
  158. .enable_dma = 0,
  159. .bits_per_word = 16,
  160. };
  161. #endif
  162. /* Notice: for blackfin, the speed_hz is the value of register
  163. * SPI_BAUD, not the real baudrate */
  164. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  165. #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
  166. {
  167. /* the modalias must be the same as spi device driver name */
  168. .modalias = "m25p80", /* Name of spi_driver for this device */
  169. /* this value is the baudrate divisor */
  170. .max_speed_hz = 50000000, /* actual baudrate is SCLK/(2xspeed_hz) */
  171. .bus_num = 0, /* Framework bus number */
  172. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
  173. .platform_data = &bfin_spi_flash_data,
  174. .controller_data = &spi_flash_chip_info,
  175. .mode = SPI_MODE_3,
  176. },
  177. #endif
  178. #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
  179. {
  180. .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
  181. .max_speed_hz = 4, /* actual baudrate is SCLK/(2xspeed_hz) */
  182. .bus_num = 1, /* Framework bus number */
  183. .chip_select = 1, /* Framework chip select. */
  184. .platform_data = NULL, /* No spi_driver specific config */
  185. .controller_data = &spi_adc_chip_info,
  186. },
  187. #endif
  188. #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
  189. {
  190. .modalias = "ad1836",
  191. .max_speed_hz = 16,
  192. .bus_num = 1,
  193. .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
  194. .controller_data = &ad1836_spi_chip_info,
  195. },
  196. #endif
  197. };
  198. /* SPI (0) */
  199. static struct resource bfin_spi0_resource[] = {
  200. [0] = {
  201. .start = SPI0_REGBASE,
  202. .end = SPI0_REGBASE + 0xFF,
  203. .flags = IORESOURCE_MEM,
  204. },
  205. [1] = {
  206. .start = CH_SPI,
  207. .end = CH_SPI,
  208. .flags = IORESOURCE_DMA,
  209. },
  210. [2] = {
  211. .start = IRQ_SPI,
  212. .end = IRQ_SPI,
  213. .flags = IORESOURCE_IRQ,
  214. }
  215. };
  216. /* SPI controller data */
  217. static struct bfin5xx_spi_master bfin_spi0_info = {
  218. .num_chipselect = 8,
  219. .enable_dma = 1, /* master has the ability to do dma transfer */
  220. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  221. };
  222. static struct platform_device bfin_spi0_device = {
  223. .name = "bfin-spi",
  224. .id = 0, /* Bus number */
  225. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  226. .resource = bfin_spi0_resource,
  227. .dev = {
  228. .platform_data = &bfin_spi0_info, /* Passed to driver */
  229. },
  230. };
  231. #endif /* spi master and devices */
  232. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  233. static struct resource bfin_uart_resources[] = {
  234. {
  235. .start = 0xFFC00400,
  236. .end = 0xFFC004FF,
  237. .flags = IORESOURCE_MEM,
  238. },
  239. };
  240. static struct platform_device bfin_uart_device = {
  241. .name = "bfin-uart",
  242. .id = 1,
  243. .num_resources = ARRAY_SIZE(bfin_uart_resources),
  244. .resource = bfin_uart_resources,
  245. };
  246. #endif
  247. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  248. #ifdef CONFIG_BFIN_SIR0
  249. static struct resource bfin_sir0_resources[] = {
  250. {
  251. .start = 0xFFC00400,
  252. .end = 0xFFC004FF,
  253. .flags = IORESOURCE_MEM,
  254. },
  255. {
  256. .start = IRQ_UART0_RX,
  257. .end = IRQ_UART0_RX+1,
  258. .flags = IORESOURCE_IRQ,
  259. },
  260. {
  261. .start = CH_UART0_RX,
  262. .end = CH_UART0_RX+1,
  263. .flags = IORESOURCE_DMA,
  264. },
  265. };
  266. static struct platform_device bfin_sir0_device = {
  267. .name = "bfin_sir",
  268. .id = 0,
  269. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  270. .resource = bfin_sir0_resources,
  271. };
  272. #endif
  273. #endif
  274. #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
  275. #include <linux/serial_8250.h>
  276. #include <linux/serial.h>
  277. /*
  278. * Configuration for two 16550 UARTS in FPGA at addresses 0x20200000 and 0x202000010.
  279. * running at half system clock, both with interrupt output or-ed to PF8. Change to
  280. * suit different FPGA configuration, or to suit real 16550 UARTS connected to the bus
  281. */
  282. static struct plat_serial8250_port serial8250_platform_data [] = {
  283. {
  284. .membase = (void *)0x20200000,
  285. .mapbase = 0x20200000,
  286. .irq = IRQ_PF8,
  287. .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE,
  288. .iotype = UPIO_MEM,
  289. .regshift = 1,
  290. .uartclk = 66666667,
  291. }, {
  292. .membase = (void *)0x20200010,
  293. .mapbase = 0x20200010,
  294. .irq = IRQ_PF8,
  295. .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE,
  296. .iotype = UPIO_MEM,
  297. .regshift = 1,
  298. .uartclk = 66666667,
  299. }, {
  300. }
  301. };
  302. static struct platform_device serial8250_device = {
  303. .id = PLAT8250_DEV_PLATFORM,
  304. .name = "serial8250",
  305. .dev = {
  306. .platform_data = serial8250_platform_data,
  307. },
  308. };
  309. #endif
  310. #if defined(CONFIG_KEYBOARD_OPENCORES) || defined(CONFIG_KEYBOARD_OPENCORES_MODULE)
  311. /*
  312. * Configuration for one OpenCores keyboard controller in FPGA at address 0x20200030,
  313. * interrupt output wired to PF9. Change to suit different FPGA configuration
  314. */
  315. static struct resource opencores_kbd_resources[] = {
  316. [0] = {
  317. .start = 0x20200030,
  318. .end = 0x20300030 + 2,
  319. .flags = IORESOURCE_MEM,
  320. },
  321. [1] = {
  322. .start = IRQ_PF9,
  323. .end = IRQ_PF9,
  324. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  325. },
  326. };
  327. static struct platform_device opencores_kbd_device = {
  328. .id = -1,
  329. .name = "opencores-kbd",
  330. .resource = opencores_kbd_resources,
  331. .num_resources = ARRAY_SIZE(opencores_kbd_resources),
  332. };
  333. #endif
  334. static struct platform_device *h8606_devices[] __initdata = {
  335. #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
  336. &rtc_device,
  337. #endif
  338. #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
  339. &dm9000_device,
  340. #endif
  341. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  342. &smc91x_device,
  343. #endif
  344. #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
  345. &net2272_bfin_device,
  346. #endif
  347. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  348. &bfin_spi0_device,
  349. #endif
  350. #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
  351. &bfin_uart_device,
  352. #endif
  353. #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
  354. &serial8250_device,
  355. #endif
  356. #if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
  357. #ifdef CONFIG_BFIN_SIR0
  358. &bfin_sir0_device,
  359. #endif
  360. #endif
  361. #if defined(CONFIG_KEYBOARD_OPENCORES) || defined(CONFIG_KEYBOARD_OPENCORES_MODULE)
  362. &opencores_kbd_device,
  363. #endif
  364. };
  365. static int __init H8606_init(void)
  366. {
  367. printk(KERN_INFO "HV Sistemas H8606 board support by http://www.hvsistemas.com\n");
  368. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  369. platform_add_devices(h8606_devices, ARRAY_SIZE(h8606_devices));
  370. #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
  371. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  372. #endif
  373. return 0;
  374. }
  375. arch_initcall(H8606_init);