H8606.c 12 KB

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