aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorOliver O'Halloran <oohall@gmail.com>2017-11-30 16:31:23 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-12-01 00:54:47 -0600
commit95a0f5d9db9897af212af66b6b87ccd09db26048 (patch)
tree96215a7391a87dc6448d1b88e9f0ccb2133c7464 /external
parentaee9b0218454b09e6e2e0f4c0b7045326299264c (diff)
downloadskiboot-95a0f5d9db9897af212af66b6b87ccd09db26048.zip
skiboot-95a0f5d9db9897af212af66b6b87ccd09db26048.tar.gz
skiboot-95a0f5d9db9897af212af66b6b87ccd09db26048.tar.bz2
gard: Set chip generation based on PVR
Currently we assume that this tool is being used on a P8 system by default and allow the user to override this behaviour using the -8 and -9 command line arguments. When running on the host we can use the PVR to guess what chip generation so do that. This also changes the default behaviour to assume that the host is a P9 when running on an ARM system. This tool didn't even work when compiled for ARM until recently and the OpenBMC vPNOR hack that we have currently is broken for P9 systems that don't use vPNOR (Zaius and Romulus). Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r--external/gard/gard.c52
1 files changed, 42 insertions, 10 deletions
diff --git a/external/gard/gard.c b/external/gard/gard.c
index c280bbf..c70fa2a 100644
--- a/external/gard/gard.c
+++ b/external/gard/gard.c
@@ -159,6 +159,45 @@ static void set_chip_gen(const struct chip_unit_desc *c)
}
}
+#ifdef __powerpc64__
+static void guess_chip_gen(void)
+{
+ /*
+ * Guesstimate what chip generation based on the PVR if we're running
+ * on ppc64.
+ */
+ uint32_t pvr;
+
+ /* grab the chip type from the PVR SPR */
+ asm ("mfspr %0,0x11f" : "=r" (pvr));
+
+ switch (pvr >> 16) {
+ case 0x004b: /* murano */
+ case 0x004c: /* naples */
+ case 0x004d: /* venice */
+ set_chip_gen(p8_chip_units);
+ return;
+
+ case 0x004e: /* nimbus */
+ set_chip_gen(p9_chip_units);
+ return;
+
+ default:
+ fprintf(stderr, "Unsupported processor (pvr %#x)! Set the processor generation manually with -8 or -9\n", pvr);
+ exit(1);
+ }
+}
+#else
+static void guess_chip_gen(void)
+{
+#ifdef ASSUME_P8
+ set_chip_gen(p8_chip_units);
+#else
+ set_chip_gen(p9_chip_units);
+#endif
+}
+#endif
+
static const char *target_type_to_str(int type)
{
int i;
@@ -874,15 +913,6 @@ int main(int argc, char **argv)
argv += optind;
action = argv[0];
- /* assume a P8 if we haven't been given any */
- if (!chip_units) {
-#ifdef ASSUME_P9
- set_chip_gen(p9_chip_units);
-#else
- set_chip_gen(p8_chip_units);
-#endif
- }
-
#ifdef __arm__
/*
* HACK: Look for a vPNOR GUARD file if we haven't been given anything
@@ -903,7 +933,6 @@ int main(int argc, char **argv)
/* BUG: This ignores the command line settings */
part = true;
ecc = true;
- set_chip_gen(p9_chip_units);
} else if (!stat(VPNOR_GARD_DIR, &buf)) {
printf(VPNOR_GARD_FILE" is missing. Nothing to do\n");
return 0;
@@ -911,6 +940,9 @@ int main(int argc, char **argv)
}
#endif
+ if (!chip_units)
+ guess_chip_gen();
+
/*
* Force libflash to do flash accesses via the MTD. Direct mode is
* generally unsafe since it fiddles with the flash controller state