diff mbox

[05/10] hw: Create xscom_read_cfam_chipid()

Message ID 1423706279-12170-5-git-send-email-mikey@neuling.org
State Superseded
Headers show

Commit Message

Michael Neuling Feb. 12, 2015, 1:57 a.m. UTC
Create xscom_read_cfam_chipid() to read the cfam chipid().

We'll need to use this in a few places, so avoid replicating the code.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 hw/xscom.c      | 22 ++++++++++++++++------
 include/xscom.h |  2 ++
 2 files changed, 18 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/hw/xscom.c b/hw/xscom.c
index 33c04b1..bc9fff4 100644
--- a/hw/xscom.c
+++ b/hw/xscom.c
@@ -433,10 +433,10 @@  int xscom_writeme(uint64_t pcb_addr, uint64_t val)
 	return xscom_write(this_cpu()->chip_id, pcb_addr, val);
 }
 
-static void xscom_init_chip_info(struct proc_chip *chip)
+int64_t xscom_read_cfam_chipid(uint32_t partid, uint32_t *chip_id)
 {
 	uint64_t val;
-	int64_t rc = 0;
+	int64_t rc = OPAL_SUCCESS;
 
 	/* Mambo chip model lacks the f000f register, just make
 	 * something up (Murano DD2.1)
@@ -444,16 +444,26 @@  static void xscom_init_chip_info(struct proc_chip *chip)
 	if (is_mambo_chip)
 		val = 0x221EF04980000000;
 	else
-		rc = xscom_read(chip->id, 0xf000f, &val);
+		rc = xscom_read(partid, 0xf000f, &val);
+
+	/* Extract CFAM id */
+	*chip_id = (uint32_t)(val >> 44);
+
+	return rc;
+}
+
+static void xscom_init_chip_info(struct proc_chip *chip)
+{
+	uint32_t val;
+	int64_t rc;
+
+	rc = xscom_read_cfam_chipid(chip->id, &val);
 	if (rc) {
 		prerror("XSCOM: Error %lld reading 0xf000f register\n", rc);
 		/* We leave chip type to UNKNOWN */
 		return;
 	}
 
-	/* Extract CFAM id */
-	val >>= 44;
-
 	/* Identify chip */
 	switch(val & 0xff) {
 	case 0xf9:
diff --git a/include/xscom.h b/include/xscom.h
index 5eed85f..b1ecaf5 100644
--- a/include/xscom.h
+++ b/include/xscom.h
@@ -173,4 +173,6 @@  extern void xscom_init(void);
 /* Mark XSCOM lock as being in console path */
 extern void xscom_used_by_console(void);
 
+extern int64_t xscom_read_cfam_chipid(uint32_t partid, uint32_t *chip_id);
+
 #endif /* __XSCOM_H */