|
22 | 22 | #include <linux/mtd/partitions.h>
|
23 | 23 | #include <linux/of.h>
|
24 | 24 |
|
| 25 | +#ifdef CONFIG_MIPS |
| 26 | +#include <asm/bootinfo.h> |
| 27 | +#include <asm/fw/cfe/cfe_api.h> |
| 28 | +#endif /* CONFIG_MIPS */ |
| 29 | + |
25 | 30 | #define BCM963XX_CFE_BLOCK_SIZE SZ_64K /* always at least 64KiB */
|
26 | 31 |
|
27 | 32 | #define BCM963XX_CFE_MAGIC_OFFSET 0x4e0
|
|
32 | 37 | #define STR_NULL_TERMINATE(x) \
|
33 | 38 | do { char *_str = (x); _str[sizeof(x) - 1] = 0; } while (0)
|
34 | 39 |
|
35 |
| -static int bcm63xx_detect_cfe(struct mtd_info *master) |
| 40 | +static inline int bcm63xx_detect_cfe(void) |
36 | 41 | {
|
37 |
| - char buf[9]; |
38 |
| - int ret; |
39 |
| - size_t retlen; |
| 42 | + int ret = 0; |
40 | 43 |
|
41 |
| - ret = mtd_read(master, BCM963XX_CFE_VERSION_OFFSET, 5, &retlen, |
42 |
| - (void *)buf); |
43 |
| - buf[retlen] = 0; |
| 44 | +#ifdef CONFIG_MIPS |
| 45 | + ret = (fw_arg3 == CFE_EPTSEAL); |
| 46 | +#endif /* CONFIG_MIPS */ |
44 | 47 |
|
45 |
| - if (ret) |
46 |
| - return ret; |
47 |
| - |
48 |
| - if (strncmp("cfe-v", buf, 5) == 0) |
49 |
| - return 0; |
50 |
| - |
51 |
| - /* very old CFE's do not have the cfe-v string, so check for magic */ |
52 |
| - ret = mtd_read(master, BCM963XX_CFE_MAGIC_OFFSET, 8, &retlen, |
53 |
| - (void *)buf); |
54 |
| - buf[retlen] = 0; |
55 |
| - |
56 |
| - return strncmp("CFE1CFE1", buf, 8); |
| 48 | + return ret; |
57 | 49 | }
|
58 | 50 |
|
59 | 51 | static int bcm63xx_read_nvram(struct mtd_info *master,
|
@@ -138,7 +130,7 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
|
138 | 130 | struct bcm963xx_nvram *nvram = NULL;
|
139 | 131 | int ret;
|
140 | 132 |
|
141 |
| - if (bcm63xx_detect_cfe(master)) |
| 133 | + if (!bcm63xx_detect_cfe()) |
142 | 134 | return -EINVAL;
|
143 | 135 |
|
144 | 136 | nvram = vzalloc(sizeof(*nvram));
|
|
0 commit comments