2 * SDK7786 FPGA Support.
4 * Copyright (C) 2010 Paul Mundt
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
10 #include <linux/init.h>
12 #include <linux/bcd.h>
13 #include <mach/fpga.h>
14 #include <asm/sizes.h>
16 #define FPGA_REGS_OFFSET 0x03fff800
17 #define FPGA_REGS_SIZE 0x490
20 * The FPGA can be mapped in any of the generally available areas,
21 * so we attempt to scan for it using the fixed SRSTR read magic.
23 * Once the FPGA is located, the rest of the mapping data for the other
24 * components can be determined dynamically from its section mapping
27 static void __iomem
*sdk7786_fpga_probe(void)
33 * Iterate over all of the areas where the FPGA could be mapped.
34 * The possible range is anywhere from area 0 through 6, area 7
37 for (area
= PA_AREA0
; area
< PA_AREA7
; area
+= SZ_64M
) {
38 base
= ioremap_nocache(area
+ FPGA_REGS_OFFSET
, FPGA_REGS_SIZE
);
40 /* Failed to remap this area, move along. */
44 if (ioread16(base
+ SRSTR
) == SRSTR_MAGIC
)
45 return base
; /* Found it! */
53 void __iomem
*sdk7786_fpga_base
;
55 void __init
sdk7786_fpga_init(void)
59 sdk7786_fpga_base
= sdk7786_fpga_probe();
60 if (unlikely(!sdk7786_fpga_base
)) {
61 panic("FPGA detection failed.\n");
65 version
= fpga_read_reg(FPGAVR
);
66 date
= fpga_read_reg(FPGADR
);
68 pr_info("\tFPGA version:\t%d.%d (built on %d/%d/%d)\n",
69 bcd2bin(version
>> 8) & 0xf, bcd2bin(version
& 0xf),
70 ((date
>> 12) & 0xf) + 2000,
71 (date
>> 8) & 0xf, bcd2bin(date
& 0xff));