[Skiboot] [PATCH] hdata/i2c: log unknown i2c devices

Claudio Carvalho cclaudio at linux.vnet.ibm.com
Thu Oct 12 16:03:56 AEDT 2017


An i2c device is unknown if either the i2c device list is outdated or
the device is marked as unknown (0xFF) in the hdat.

This log both cases.

Signed-off-by: Claudio Carvalho <cclaudio at linux.vnet.ibm.com>
Reviewed-by: Oliver O'Halloran <oohall at gmail.com>
Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 hdata/i2c.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/hdata/i2c.c b/hdata/i2c.c
index 2e14212..9fb8513 100644
--- a/hdata/i2c.c
+++ b/hdata/i2c.c
@@ -165,6 +165,7 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
 	uint32_t i2c_addr;
 	uint32_t version;
 	uint32_t size;
+	uint32_t purpose;
 	int i, count;
 
 	/*
@@ -226,11 +227,9 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
 		 */
 		i2c_addr = dev->i2c_addr >> 1;
 
-		prlog(PR_TRACE, "HDAT I2C: found e%dp%d - %x\n",
-			dev->i2cm_engine, dev->i2cm_port, i2c_addr);
-
+		purpose = be32_to_cpu(dev->purpose);
 		type = map_type(dev->type);
-		label = map_label(be32_to_cpu(dev->purpose));
+		label = map_label(purpose);
 		if (type) {
 			compat = type->compat;
 			name = type->name;
@@ -239,6 +238,20 @@ int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
 			compat = NULL;
 		}
 
+		/*
+		 * An i2c device is unknown if either the i2c device list is
+		 * outdated or the device is marked as unknown (0xFF) in the
+		 * hdat. Log both cases to see what/where/why.
+		 */
+		if (!type || dev->type == 0xFF)
+			prlog(PR_WARNING, "HDAT I2C: found e%dp%d - %s@%x (%#x:%s)\n",
+			      dev->i2cm_engine, dev->i2cm_port, name, i2c_addr,
+			      purpose, label);
+		else
+			prlog(PR_TRACE, "HDAT I2C: found e%dp%d - %s@%x (%#x:%s)\n",
+			      dev->i2cm_engine, dev->i2cm_port, name, i2c_addr,
+			      purpose, label);
+
 		node = dt_new_addr(bus, name, i2c_addr);
 		if (!node)
 			continue;
-- 
2.7.4



More information about the Skiboot mailing list