aboutsummaryrefslogtreecommitdiff
path: root/hw/chiptod.c
diff options
context:
space:
mode:
authorMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>2015-06-05 23:35:22 +0530
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-07-09 16:00:17 +1000
commitbcc5709f41413ca2823033b48587286888cd5efe (patch)
treecf9298f420def87993df6cead0d2bd7598ae56be /hw/chiptod.c
parentf395bd9c5c3bdfb241928c51beb548d5a905d46f (diff)
downloadskiboot-bcc5709f41413ca2823033b48587286888cd5efe.zip
skiboot-bcc5709f41413ca2823033b48587286888cd5efe.tar.gz
skiboot-bcc5709f41413ca2823033b48587286888cd5efe.tar.bz2
opal: Query current TOD topology during chiptod init.
Query for TOD topology currently in use during opal initialization. The first 3 bits of TOD status register (0x08) tells the topology that is active and in use currently. TOD status(0x00040008)[0-2]: 0b000 = primary, 0b111 = secondary Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> [stewart@linux.vnet.ibm.com: also add support for printing Unknown topology] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/chiptod.c')
-rw-r--r--hw/chiptod.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/hw/chiptod.c b/hw/chiptod.c
index 18c4847..b452398 100644
--- a/hw/chiptod.c
+++ b/hw/chiptod.c
@@ -26,6 +26,10 @@
#include <timebase.h>
#include <opal-api.h>
+/* -- TOD primary/secondary master/slave status register -- */
+#define TOD_STATUS 0x00040008
+#define TOD_ST_TOPOLOGY_SELECT PPC_BITMASK(0, 2)
+
/* TOD chip XSCOM addresses */
#define TOD_TTYPE_0 0x00040011
#define TOD_TTYPE_1 0x00040012 /* PSS switch */
@@ -73,6 +77,10 @@
/* Number of iterations for the various timeouts */
#define TIMEOUT_LOOPS 20000000
+/* TOD active Primary/secondary configuration */
+#define TOD_PRI_CONF_IN_USE 0 /* Tod using primary topology*/
+#define TOD_SEC_CONF_IN_USE 7 /* Tod using secondary topo */
+
/* Timebase State Machine error state */
#define TBST_STATE_ERROR 9
@@ -82,8 +90,15 @@ static enum chiptod_type {
chiptod_p8
} chiptod_type;
+enum chiptod_topology {
+ chiptod_topo_unknown = -1,
+ chiptod_topo_primary = 0,
+ chiptod_topo_secondary = 1,
+};
+
static int32_t chiptod_primary = -1;
static int32_t chiptod_secondary = -1;
+static enum chiptod_topology current_topology = chiptod_topo_unknown;
/* The base TFMR value is the same for the whole machine
* for now as far as I can tell
@@ -97,6 +112,37 @@ static uint64_t base_tfmr;
*/
static struct lock chiptod_lock = LOCK_UNLOCKED;
+static void print_topology_info(void)
+{
+ const char *topo[] = { "Unknown", "Primary", "Secondary" };
+
+ if (current_topology < 0)
+ return;
+
+ prlog(PR_DEBUG, "CHIPTOD: TOD Topology in Use: %s\n",
+ topo[current_topology+1]);
+}
+
+static enum chiptod_topology query_current_topology(void)
+{
+ uint64_t tod_status;
+
+ if (xscom_readme(TOD_STATUS, &tod_status) != 0) {
+ prerror("CHIPTOD: XSCOM error reading TOD_STATUS reg\n");
+ return chiptod_topo_unknown;
+ }
+
+ /*
+ * Tod status register bit [0-2] tells configuration in use.
+ * 000 <= primary configuration in use
+ * 111 <= secondary configuration in use
+ */
+ if ((tod_status & TOD_ST_TOPOLOGY_SELECT) == TOD_PRI_CONF_IN_USE)
+ return chiptod_topo_primary;
+ else
+ return chiptod_topo_secondary;
+}
+
static void chiptod_setup_base_tfmr(void)
{
struct dt_node *cpu = this_cpu()->node;
@@ -941,6 +987,14 @@ static bool chiptod_probe(void)
return true;
}
+static void chiptod_init_topology_info(void)
+{
+ /* Find and update current topology in use. */
+ current_topology = query_current_topology();
+
+ print_topology_info();
+}
+
void chiptod_init(void)
{
struct cpu_thread *cpu0, *cpu;
@@ -1008,5 +1062,6 @@ void chiptod_init(void)
chiptod_print_tb, NULL), true);
}
+ chiptod_init_topology_info();
op_display(OP_LOG, OP_MOD_CHIPTOD, 4);
}