H8606.c 11 KB

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