diff options
author | Paul Mundt <lethal@linux-sh.org> | 2010-01-20 04:25:19 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2010-01-20 04:25:19 -0500 |
commit | d9116d07f60383cef134c43a0ba15ec4375310fc (patch) | |
tree | 076c1698dcd4886b1f4e9c1311eb0cf8b68cdef9 /arch/sh/boards | |
parent | 920efaabcbd34e6b8dc05c5b777df3e936af5812 (diff) |
sh: mach-sdk7786: Probe system FPGA area mapping.
This implements dynamic probing for the system FPGA. The system reset
controller contains a fixed magic read word in order to identify the
FPGA. This just utilizes a simple loop that scans across all of the fixed
physical areas (area 0 through area 6) to locate the FPGA.
The FPGA also contains register information detailing the area mappings
and chip select settings for all of the other blocks, so this needs to be
done before we can set up anything else.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boards')
-rw-r--r-- | arch/sh/boards/mach-sdk7786/fpga.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/arch/sh/boards/mach-sdk7786/fpga.c b/arch/sh/boards/mach-sdk7786/fpga.c index 99f903c8b238..3e4ec66a0417 100644 --- a/arch/sh/boards/mach-sdk7786/fpga.c +++ b/arch/sh/boards/mach-sdk7786/fpga.c | |||
@@ -11,9 +11,44 @@ | |||
11 | #include <linux/io.h> | 11 | #include <linux/io.h> |
12 | #include <linux/bcd.h> | 12 | #include <linux/bcd.h> |
13 | #include <mach/fpga.h> | 13 | #include <mach/fpga.h> |
14 | #include <asm/sizes.h> | ||
14 | 15 | ||
15 | #define FPGA_REGS_BASE 0x07fff800 | 16 | #define FPGA_REGS_OFFSET 0x03fff800 |
16 | #define FPGA_REGS_SIZE 0x490 | 17 | #define FPGA_REGS_SIZE 0x490 |
18 | |||
19 | /* | ||
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. | ||
22 | * | ||
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 | ||
25 | * registers. | ||
26 | */ | ||
27 | static void __iomem *sdk7786_fpga_probe(void) | ||
28 | { | ||
29 | unsigned long area; | ||
30 | void __iomem *base; | ||
31 | |||
32 | /* | ||
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 | ||
35 | * is reserved. | ||
36 | */ | ||
37 | for (area = PA_AREA0; area < PA_AREA7; area += SZ_64M) { | ||
38 | base = ioremap_nocache(area + FPGA_REGS_OFFSET, FPGA_REGS_SIZE); | ||
39 | if (!base) { | ||
40 | /* Failed to remap this area, move along. */ | ||
41 | continue; | ||
42 | } | ||
43 | |||
44 | if (ioread16(base + SRSTR) == SRSTR_MAGIC) | ||
45 | return base; /* Found it! */ | ||
46 | |||
47 | iounmap(base); | ||
48 | } | ||
49 | |||
50 | return NULL; | ||
51 | } | ||
17 | 52 | ||
18 | void __iomem *sdk7786_fpga_base; | 53 | void __iomem *sdk7786_fpga_base; |
19 | 54 | ||
@@ -21,9 +56,9 @@ void __init sdk7786_fpga_init(void) | |||
21 | { | 56 | { |
22 | u16 version, date; | 57 | u16 version, date; |
23 | 58 | ||
24 | sdk7786_fpga_base = ioremap_nocache(FPGA_REGS_BASE, FPGA_REGS_SIZE); | 59 | sdk7786_fpga_base = sdk7786_fpga_probe(); |
25 | if (unlikely(!sdk7786_fpga_base)) { | 60 | if (unlikely(!sdk7786_fpga_base)) { |
26 | panic("FPGA remapping failed.\n"); | 61 | panic("FPGA detection failed.\n"); |
27 | return; | 62 | return; |
28 | } | 63 | } |
29 | 64 | ||