[Skiboot] [PATCH 4/5] chiptod: Synchronize timebase in both CAPP units on Naples

Philippe Bergheaud felix at linux.vnet.ibm.com
Tue Feb 9 02:30:49 AEDT 2016


Write to the scoms registers of the targeted capp.

Signed-off-by: Philippe Bergheaud <felix at linux.vnet.ibm.com>
---
 hw/chiptod.c      | 30 +++++++++++++++---------------
 hw/phb3.c         |  2 +-
 include/chiptod.h |  2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/hw/chiptod.c b/hw/chiptod.c
index f7427f1..5f6cada 100644
--- a/hw/chiptod.c
+++ b/hw/chiptod.c
@@ -1771,7 +1771,7 @@ void chiptod_init(void)
 
 /* CAPP timebase sync */
 
-static bool chiptod_capp_reset_tb_errors(uint32_t chip_id)
+static bool chiptod_capp_reset_tb_errors(uint32_t chip_id, uint32_t reg_offset)
 {
 	uint64_t tfmr;
 	unsigned long timeout = 0;
@@ -1787,12 +1787,12 @@ static bool chiptod_capp_reset_tb_errors(uint32_t chip_id)
 	tfmr |= SPR_TFMR_TFMR_CORRUPT;
 
 	/* Write CAPP TFMR */
-	xscom_write(chip_id, CAPP_TFMR, tfmr);
+	xscom_write(chip_id, CAPP_TFMR + reg_offset, tfmr);
 
 	/* We have to write "Clear TB Errors" again */
 	tfmr = base_tfmr | SPR_TFMR_CLEAR_TB_ERRORS;
 	/* Write CAPP TFMR */
-	xscom_write(chip_id, CAPP_TFMR, tfmr);
+	xscom_write(chip_id, CAPP_TFMR + reg_offset, tfmr);
 
 	do {
 		if (++timeout >= TIMEOUT_LOOPS) {
@@ -1800,7 +1800,7 @@ static bool chiptod_capp_reset_tb_errors(uint32_t chip_id)
 			return false;
 		}
 		/* Read CAPP TFMR */
-		xscom_read(chip_id, CAPP_TFMR, &tfmr);
+		xscom_read(chip_id, CAPP_TFMR + reg_offset, &tfmr);
 		if (tfmr & SPR_TFMR_TFMR_CORRUPT) {
 			prerror("CAPP: TB error reset: corrupt TFMR!\n");
 			return false;
@@ -1809,20 +1809,20 @@ static bool chiptod_capp_reset_tb_errors(uint32_t chip_id)
 	return true;
 }
 
-static bool chiptod_capp_mod_tb(uint32_t chip_id)
+static bool chiptod_capp_mod_tb(uint32_t chip_id, uint32_t reg_offset)
 {
 	uint64_t timeout = 0;
 	uint64_t tfmr;
 
 	/* Switch CAPP timebase to "Not Set" state */
 	tfmr = base_tfmr | SPR_TFMR_LOAD_TOD_MOD;
-	xscom_write(chip_id, CAPP_TFMR, tfmr);
+	xscom_write(chip_id, CAPP_TFMR + reg_offset, tfmr);
 	do {
 		if (++timeout >= (TIMEOUT_LOOPS*2)) {
 			prerror("CAPP: TB \"Not Set\" timeout\n");
 			return false;
 		}
-		xscom_read(chip_id, CAPP_TFMR, &tfmr);
+		xscom_read(chip_id, CAPP_TFMR + reg_offset, &tfmr);
 		if (tfmr & SPR_TFMR_TFMR_CORRUPT) {
 			prerror("CAPP: TB \"Not Set\" TFMR corrupt\n");
 			return false;
@@ -1857,7 +1857,7 @@ static bool chiptod_wait_for_chip_sync(void)
 	return true;
 }
 
-static bool chiptod_capp_check_tb_running(uint32_t chip_id)
+static bool chiptod_capp_check_tb_running(uint32_t chip_id, uint32_t reg_offset)
 {
 	uint64_t tfmr;
 	uint64_t timeout = 0;
@@ -1868,7 +1868,7 @@ static bool chiptod_capp_check_tb_running(uint32_t chip_id)
 			prerror("CAPP: TB Invalid!\n");
 			return false;
 		}
-		xscom_read(chip_id, CAPP_TFMR, &tfmr);
+		xscom_read(chip_id, CAPP_TFMR + reg_offset, &tfmr);
 		if (tfmr & SPR_TFMR_TFMR_CORRUPT) {
 			prerror("CAPP: TFMR corrupt!\n");
 			return false;
@@ -1877,7 +1877,7 @@ static bool chiptod_capp_check_tb_running(uint32_t chip_id)
 	return true;
 }
 
-bool chiptod_capp_timebase_sync(uint32_t chip_id)
+bool chiptod_capp_timebase_sync(int32_t chip_id, uint32_t reg_offset)
 {
 	uint64_t tfmr;
 	uint64_t capp_tb;
@@ -1885,14 +1885,14 @@ bool chiptod_capp_timebase_sync(uint32_t chip_id)
 	unsigned int retry = 0;
 
 	/* Set CAPP TFMR to base tfmr value */
-	xscom_write(chip_id, CAPP_TFMR, base_tfmr);
+	xscom_write(chip_id, CAPP_TFMR + reg_offset, base_tfmr);
 
 	/* Reset CAPP TB errors before attempting the sync */
-	if (!chiptod_capp_reset_tb_errors(chip_id))
+	if (!chiptod_capp_reset_tb_errors(chip_id, reg_offset))
 		return false;
 
 	/* Switch CAPP TB to "Not Set" state */
-	if (!chiptod_capp_mod_tb(chip_id))
+	if (!chiptod_capp_mod_tb(chip_id, reg_offset))
 		return false;
 
 	/* Sync CAPP TB with core TB, retry while difference > 16usecs */
@@ -1904,7 +1904,7 @@ bool chiptod_capp_timebase_sync(uint32_t chip_id)
 
 		/* Make CAPP ready to get the TB, wait for chip sync */
 		tfmr = base_tfmr | SPR_TFMR_MOVE_CHIP_TOD_TO_TB;
-		xscom_write(chip_id, CAPP_TFMR, tfmr);
+		xscom_write(chip_id, CAPP_TFMR + reg_offset, tfmr);
 		if (!chiptod_wait_for_chip_sync())
 			return false;
 
@@ -1912,7 +1912,7 @@ bool chiptod_capp_timebase_sync(uint32_t chip_id)
 		xscom_write(chip_id, CAPP_TB, mftb());
 
 		/* Wait for CAPP TFMR tb_valid bit */
-		if (!chiptod_capp_check_tb_running(chip_id))
+		if (!chiptod_capp_check_tb_running(chip_id, reg_offset))
 			return false;
 
 		/* Read CAPP TB, read core TB, compare */
diff --git a/hw/phb3.c b/hw/phb3.c
index 3ec14f3..150e9ba 100644
--- a/hw/phb3.c
+++ b/hw/phb3.c
@@ -3515,7 +3515,7 @@ static int64_t phb3_set_capi_mode(struct phb *phb, uint64_t mode,
 
 	phb3_init_capp_regs(p);
 
-	if (!chiptod_capp_timebase_sync(p->chip_id)) {
+	if (!chiptod_capp_timebase_sync(p->chip_id, reg_offset)) {
 		PHBERR(p, "CAPP: Failed to sync timebase\n");
 		return OPAL_HARDWARE;
 	}
diff --git a/include/chiptod.h b/include/chiptod.h
index daf37b1..b259c04 100644
--- a/include/chiptod.h
+++ b/include/chiptod.h
@@ -32,6 +32,6 @@ extern bool chiptod_wakeup_resync(void);
 extern int chiptod_recover_tb_errors(void);
 extern void chiptod_reset_tb(void);
 extern bool chiptod_adjust_topology(enum chiptod_topology topo, bool enable);
-extern bool chiptod_capp_timebase_sync(uint32_t chip_id);
+extern bool chiptod_capp_timebase_sync(int32_t chip_id, uint32_t reg_offset);
 
 #endif /* __CHIPTOD_H */
-- 
2.1.0



More information about the Skiboot mailing list