@@ -984,6 +984,24 @@ static bool is_topology_switch_required(void)
return false;
}
+static bool chiptod_backup_valid(void)
+{
+ enum chiptod_topology backup_topo;
+
+ if (current_topology < 0)
+ return false;
+
+ if (current_topology == chiptod_topo_primary)
+ backup_topo = chiptod_topo_secondary;
+ else
+ backup_topo = chiptod_topo_primary;
+
+ if (chiptod_topology_info[backup_topo].status == chiptod_backup_master)
+ return chiptod_sync_step_check_running(backup_topo);
+
+ return false;
+}
+
/*
* Sync up TOD with other chips and get TOD in running state.
* Check if current topology is active and running. If not, then
@@ -1008,7 +1026,16 @@ static int chiptod_start_tod(void)
* topology we can then request TOD value from new active
* master. But make sure we move local chiptod to Not Set
* before requesting TOD value.
+ *
+ * Before triggering a topology switch, check if backup
+ * is valid.
*/
+ if (!chiptod_backup_valid()) {
+ prerror("CHIPTOD: Backup master is not enabled.\n");
+ prerror("CHIPTOD: Can not do a topology switch.\n");
+ return 0;
+ }
+
if (xscom_write(mchip, TOD_TTYPE_1, (1UL << 63)) != 0) {
prerror("CHIPTOD: XSCOM error switching primary/secondary\n");
return 0;