[[RFC PATCH] v2 11/14] discover/platform-powerpc: Determine ppc platform type

Samuel Mendoza-Jonas sam at mendozajonas.com
Thu Jan 18 16:05:14 AEDT 2018


Some platform setup for platform-powerpc depends on the whether the
platform includes an IBM FSP or a BMC used on OpenPOWER platforms.
Rather than checking each time it is needed, check once in probe() and
record the information.

Signed-off-by: Samuel Mendoza-Jonas <sam at mendozajonas.com>
---
 discover/platform-powerpc.c | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index 11b5b60..0e2f87d 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -47,6 +47,12 @@ struct platform_powerpc {
 	int 		(*set_os_boot_sensor)(
 				struct platform_powerpc *platform);
 	int		(*get_platform_versions)(struct system_info *info);
+
+	enum {
+			POWERPC_PLATFORM_FSP,
+			POWERPC_PLATFORM_BMC,
+			POWERPC_PLATFORM_UNKNOWN,
+	} type;
 };
 
 static const char *known_params[] = {
@@ -1233,11 +1239,9 @@ static void get_ipmi_network_override(struct platform_powerpc *platform,
 	}
 }
 
-static void get_active_consoles(struct config *config)
+static void get_active_consoles(struct platform_powerpc *platform,
+		struct config *config)
 {
-	struct stat sbuf;
-	char *fsp_prop = NULL;
-
 	config->n_consoles = 2;
 	config->consoles = talloc_array(config, char *, config->n_consoles);
 	if (!config->consoles)
@@ -1248,8 +1252,7 @@ static void get_active_consoles(struct config *config)
 	config->consoles[1] = talloc_asprintf(config->consoles,
 					"/dev/tty1 [VGA]");
 
-	fsp_prop = talloc_asprintf(config, "%sfsps", devtree_dir);
-	if (stat(fsp_prop, &sbuf) == 0) {
+	if (platform->type == POWERPC_PLATFORM_FSP) {
 		/* FSP based machines also have a separate serial console */
 		config->consoles = talloc_realloc(config, config->consoles,
 						char *,	config->n_consoles + 1);
@@ -1290,7 +1293,7 @@ static int load_config(struct platform *p, struct config *config)
 	if (platform->ipmi)
 		get_ipmi_network_override(platform, config);
 
-	get_active_consoles(config);
+	get_active_consoles(platform, config);
 
 	return 0;
 }
@@ -1365,7 +1368,6 @@ static bool probe(struct platform *p, void *ctx)
 {
 	struct platform_powerpc *platform;
 	struct stat statbuf;
-	bool bmc_present;
 	int rc;
 
 	/* we need a device tree */
@@ -1381,9 +1383,14 @@ static bool probe(struct platform *p, void *ctx)
 
 	p->platform_data = platform;
 
-	bmc_present = stat("/proc/device-tree/bmc", &statbuf) == 0;
+	if (stat("/proc/device-tree/fsps", &statbuf) == 0)
+		platform->type = POWERPC_PLATFORM_FSP;
+	else if (stat("/proc/device-tree/bmc", &statbuf) == 0)
+		platform->type = POWERPC_PLATFORM_BMC;
+	else
+		platform->type = POWERPC_PLATFORM_UNKNOWN;
 
-	if (ipmi_present() && bmc_present) {
+	if (ipmi_present() && platform->type == POWERPC_PLATFORM_BMC) {
 		pb_debug("platform: using direct IPMI for IPMI paramters\n");
 		platform->ipmi = ipmi_open(platform);
 		platform->get_ipmi_bootdev = get_ipmi_bootdev_ipmi;
@@ -1398,8 +1405,12 @@ static bool probe(struct platform *p, void *ctx)
 		pb_log("platform: no IPMI parameter support\n");
 	}
 
-	if (bmc_present)
-		platform->get_platform_versions = hostboot_load_versions;
+	if (platform->type == POWERPC_PLATFORM_BMC) {
+		if (!stat("/proc/device-tree/ibm,firmware-versions", &statbuf))
+			platform->get_platform_versions = device_tree_find_firmware_versions;
+		else
+			platform->get_platform_versions = hostboot_load_versions;
+	}
 
 	return true;
 }
-- 
2.15.1



More information about the Petitboot mailing list