H8606.c 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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 IS_ENABLED(CONFIG_USB_ISP1362_HCD)
  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 IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  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 IS_ENABLED(CONFIG_DM9000)
  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 |
  53. IORESOURCE_IRQ_SHAREABLE),
  54. },
  55. };
  56. static struct platform_device dm9000_device = {
  57. .id = 0,
  58. .name = "dm9000",
  59. .resource = dm9000_resources,
  60. .num_resources = ARRAY_SIZE(dm9000_resources),
  61. };
  62. #endif
  63. #if IS_ENABLED(CONFIG_SMC91X)
  64. #include <linux/smc91x.h>
  65. static struct smc91x_platdata smc91x_info = {
  66. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  67. .leda = RPC_LED_100_10,
  68. .ledb = RPC_LED_TX_RX,
  69. };
  70. static struct resource smc91x_resources[] = {
  71. {
  72. .name = "smc91x-regs",
  73. .start = 0x20300300,
  74. .end = 0x20300300 + 16,
  75. .flags = IORESOURCE_MEM,
  76. }, {
  77. .start = IRQ_PROG_INTB,
  78. .end = IRQ_PROG_INTB,
  79. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  80. }, {
  81. .start = IRQ_PF7,
  82. .end = IRQ_PF7,
  83. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  84. },
  85. };
  86. static struct platform_device smc91x_device = {
  87. .name = "smc91x",
  88. .id = 0,
  89. .num_resources = ARRAY_SIZE(smc91x_resources),
  90. .resource = smc91x_resources,
  91. .dev = {
  92. .platform_data = &smc91x_info,
  93. },
  94. };
  95. #endif
  96. #if IS_ENABLED(CONFIG_USB_NET2272)
  97. static struct resource net2272_bfin_resources[] = {
  98. {
  99. .start = 0x20300000,
  100. .end = 0x20300000 + 0x100,
  101. .flags = IORESOURCE_MEM,
  102. }, {
  103. .start = IRQ_PF10,
  104. .end = IRQ_PF10,
  105. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  106. },
  107. };
  108. static struct platform_device net2272_bfin_device = {
  109. .name = "net2272",
  110. .id = -1,
  111. .num_resources = ARRAY_SIZE(net2272_bfin_resources),
  112. .resource = net2272_bfin_resources,
  113. };
  114. #endif
  115. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  116. /* all SPI peripherals info goes here */
  117. #if IS_ENABLED(CONFIG_MTD_M25P80)
  118. static struct mtd_partition bfin_spi_flash_partitions[] = {
  119. {
  120. .name = "bootloader (spi)",
  121. .size = 0x40000,
  122. .offset = 0,
  123. .mask_flags = MTD_CAP_ROM
  124. }, {
  125. .name = "fpga (spi)",
  126. .size = 0x30000,
  127. .offset = 0x40000
  128. }, {
  129. .name = "linux kernel (spi)",
  130. .size = 0x150000,
  131. .offset = 0x70000
  132. }, {
  133. .name = "jffs2 root file system (spi)",
  134. .size = 0x640000,
  135. .offset = 0x1c0000,
  136. }
  137. };
  138. static struct flash_platform_data bfin_spi_flash_data = {
  139. .name = "m25p80",
  140. .parts = bfin_spi_flash_partitions,
  141. .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
  142. .type = "m25p64",
  143. };
  144. /* SPI flash chip (m25p64) */
  145. static struct bfin5xx_spi_chip spi_flash_chip_info = {
  146. .enable_dma = 0, /* use dma transfer with this chip*/
  147. };
  148. #endif
  149. /* Notice: for blackfin, the speed_hz is the value of register
  150. * SPI_BAUD, not the real baudrate */
  151. static struct spi_board_info bfin_spi_board_info[] __initdata = {
  152. #if IS_ENABLED(CONFIG_MTD_M25P80)
  153. {
  154. /* the modalias must be the same as spi device driver name */
  155. .modalias = "m25p80", /* Name of spi_driver for this device */
  156. /* this value is the baudrate divisor */
  157. .max_speed_hz = 50000000, /* actual baudrate is SCLK/(2xspeed_hz) */
  158. .bus_num = 0, /* Framework bus number */
  159. .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
  160. .platform_data = &bfin_spi_flash_data,
  161. .controller_data = &spi_flash_chip_info,
  162. .mode = SPI_MODE_3,
  163. },
  164. #endif
  165. #if IS_ENABLED(CONFIG_SND_BF5XX_SOC_AD183X)
  166. {
  167. .modalias = "ad183x",
  168. .max_speed_hz = 16,
  169. .bus_num = 1,
  170. .chip_select = 4,
  171. },
  172. #endif
  173. };
  174. /* SPI (0) */
  175. static struct resource bfin_spi0_resource[] = {
  176. [0] = {
  177. .start = SPI0_REGBASE,
  178. .end = SPI0_REGBASE + 0xFF,
  179. .flags = IORESOURCE_MEM,
  180. },
  181. [1] = {
  182. .start = CH_SPI,
  183. .end = CH_SPI,
  184. .flags = IORESOURCE_DMA,
  185. },
  186. [2] = {
  187. .start = IRQ_SPI,
  188. .end = IRQ_SPI,
  189. .flags = IORESOURCE_IRQ,
  190. }
  191. };
  192. /* SPI controller data */
  193. static struct bfin5xx_spi_master bfin_spi0_info = {
  194. .num_chipselect = 8,
  195. .enable_dma = 1, /* master has the ability to do dma transfer */
  196. .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
  197. };
  198. static struct platform_device bfin_spi0_device = {
  199. .name = "bfin-spi",
  200. .id = 0, /* Bus number */
  201. .num_resources = ARRAY_SIZE(bfin_spi0_resource),
  202. .resource = bfin_spi0_resource,
  203. .dev = {
  204. .platform_data = &bfin_spi0_info, /* Passed to driver */
  205. },
  206. };
  207. #endif /* spi master and devices */
  208. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  209. #ifdef CONFIG_SERIAL_BFIN_UART0
  210. static struct resource bfin_uart0_resources[] = {
  211. {
  212. .start = BFIN_UART_THR,
  213. .end = BFIN_UART_GCTL+2,
  214. .flags = IORESOURCE_MEM,
  215. },
  216. {
  217. .start = IRQ_UART0_TX,
  218. .end = IRQ_UART0_TX,
  219. .flags = IORESOURCE_IRQ,
  220. },
  221. {
  222. .start = IRQ_UART0_RX,
  223. .end = IRQ_UART0_RX,
  224. .flags = IORESOURCE_IRQ,
  225. },
  226. {
  227. .start = IRQ_UART0_ERROR,
  228. .end = IRQ_UART0_ERROR,
  229. .flags = IORESOURCE_IRQ,
  230. },
  231. {
  232. .start = CH_UART0_TX,
  233. .end = CH_UART0_TX,
  234. .flags = IORESOURCE_DMA,
  235. },
  236. {
  237. .start = CH_UART0_RX,
  238. .end = CH_UART0_RX,
  239. .flags = IORESOURCE_DMA,
  240. },
  241. };
  242. static unsigned short bfin_uart0_peripherals[] = {
  243. P_UART0_TX, P_UART0_RX, 0
  244. };
  245. static struct platform_device bfin_uart0_device = {
  246. .name = "bfin-uart",
  247. .id = 0,
  248. .num_resources = ARRAY_SIZE(bfin_uart0_resources),
  249. .resource = bfin_uart0_resources,
  250. .dev = {
  251. .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
  252. },
  253. };
  254. #endif
  255. #endif
  256. #if IS_ENABLED(CONFIG_BFIN_SIR)
  257. #ifdef CONFIG_BFIN_SIR0
  258. static struct resource bfin_sir0_resources[] = {
  259. {
  260. .start = 0xFFC00400,
  261. .end = 0xFFC004FF,
  262. .flags = IORESOURCE_MEM,
  263. },
  264. {
  265. .start = IRQ_UART0_RX,
  266. .end = IRQ_UART0_RX+1,
  267. .flags = IORESOURCE_IRQ,
  268. },
  269. {
  270. .start = CH_UART0_RX,
  271. .end = CH_UART0_RX+1,
  272. .flags = IORESOURCE_DMA,
  273. },
  274. };
  275. static struct platform_device bfin_sir0_device = {
  276. .name = "bfin_sir",
  277. .id = 0,
  278. .num_resources = ARRAY_SIZE(bfin_sir0_resources),
  279. .resource = bfin_sir0_resources,
  280. };
  281. #endif
  282. #endif
  283. #if IS_ENABLED(CONFIG_SERIAL_8250)
  284. #include <linux/serial_8250.h>
  285. #include <linux/serial.h>
  286. /*
  287. * Configuration for two 16550 UARTS in FPGA at addresses 0x20200000 and 0x202000010.
  288. * running at half system clock, both with interrupt output or-ed to PF8. Change to
  289. * suit different FPGA configuration, or to suit real 16550 UARTS connected to the bus
  290. */
  291. static struct plat_serial8250_port serial8250_platform_data [] = {
  292. {
  293. .membase = (void *)0x20200000,
  294. .mapbase = 0x20200000,
  295. .irq = IRQ_PF8,
  296. .irqflags = IRQF_TRIGGER_HIGH,
  297. .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE,
  298. .iotype = UPIO_MEM,
  299. .regshift = 1,
  300. .uartclk = 66666667,
  301. }, {
  302. .membase = (void *)0x20200010,
  303. .mapbase = 0x20200010,
  304. .irq = IRQ_PF8,
  305. .irqflags = IRQF_TRIGGER_HIGH,
  306. .flags = UPF_BOOT_AUTOCONF | UART_CONFIG_TYPE,
  307. .iotype = UPIO_MEM,
  308. .regshift = 1,
  309. .uartclk = 66666667,
  310. }, {
  311. }
  312. };
  313. static struct platform_device serial8250_device = {
  314. .id = PLAT8250_DEV_PLATFORM,
  315. .name = "serial8250",
  316. .dev = {
  317. .platform_data = serial8250_platform_data,
  318. },
  319. };
  320. #endif
  321. #if IS_ENABLED(CONFIG_KEYBOARD_OPENCORES)
  322. /*
  323. * Configuration for one OpenCores keyboard controller in FPGA at address 0x20200030,
  324. * interrupt output wired to PF9. Change to suit different FPGA configuration
  325. */
  326. static struct resource opencores_kbd_resources[] = {
  327. [0] = {
  328. .start = 0x20200030,
  329. .end = 0x20300030 + 2,
  330. .flags = IORESOURCE_MEM,
  331. },
  332. [1] = {
  333. .start = IRQ_PF9,
  334. .end = IRQ_PF9,
  335. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  336. },
  337. };
  338. static struct platform_device opencores_kbd_device = {
  339. .id = -1,
  340. .name = "opencores-kbd",
  341. .resource = opencores_kbd_resources,
  342. .num_resources = ARRAY_SIZE(opencores_kbd_resources),
  343. };
  344. #endif
  345. static struct platform_device *h8606_devices[] __initdata = {
  346. #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
  347. &rtc_device,
  348. #endif
  349. #if IS_ENABLED(CONFIG_DM9000)
  350. &dm9000_device,
  351. #endif
  352. #if IS_ENABLED(CONFIG_SMC91X)
  353. &smc91x_device,
  354. #endif
  355. #if IS_ENABLED(CONFIG_USB_NET2272)
  356. &net2272_bfin_device,
  357. #endif
  358. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  359. &bfin_spi0_device,
  360. #endif
  361. #if IS_ENABLED(CONFIG_SERIAL_BFIN)
  362. #ifdef CONFIG_SERIAL_BFIN_UART0
  363. &bfin_uart0_device,
  364. #endif
  365. #endif
  366. #if IS_ENABLED(CONFIG_SERIAL_8250)
  367. &serial8250_device,
  368. #endif
  369. #if IS_ENABLED(CONFIG_BFIN_SIR)
  370. #ifdef CONFIG_BFIN_SIR0
  371. &bfin_sir0_device,
  372. #endif
  373. #endif
  374. #if IS_ENABLED(CONFIG_KEYBOARD_OPENCORES)
  375. &opencores_kbd_device,
  376. #endif
  377. };
  378. static int __init H8606_init(void)
  379. {
  380. printk(KERN_INFO "HV Sistemas H8606 board support by http://www.hvsistemas.com\n");
  381. printk(KERN_INFO "%s(): registering device resources\n", __func__);
  382. platform_add_devices(h8606_devices, ARRAY_SIZE(h8606_devices));
  383. #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
  384. spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
  385. #endif
  386. return 0;
  387. }
  388. arch_initcall(H8606_init);
  389. static struct platform_device *H8606_early_devices[] __initdata = {
  390. #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
  391. #ifdef CONFIG_SERIAL_BFIN_UART0
  392. &bfin_uart0_device,
  393. #endif
  394. #endif
  395. };
  396. void __init native_machine_early_platform_add_devices(void)
  397. {
  398. printk(KERN_INFO "register early platform devices\n");
  399. early_platform_add_devices(H8606_early_devices,
  400. ARRAY_SIZE(H8606_early_devices));
  401. }