H8606.c 11 KB

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