bus: ti-sysc: Add support for early quirks based on register address
authorTony Lindgren <tony@atomide.com>
Thu, 21 Mar 2019 18:00:21 +0000 (11:00 -0700)
committerTony Lindgren <tony@atomide.com>
Wed, 3 Apr 2019 16:32:35 +0000 (09:32 -0700)
At least mcpdm needs an optional external clock enabled to function and
this clock typically comes from the PMIC. We can detect mcpdm based on
the interconnect target module address and set a quirk flag early.

To do this, let's initialize the clocks a bit later and add a new
function for sysc_init_early_quirks(). Note that we cannot yet enable
the early quirks for mcpdm until the optional external clocks are
handled in the in the following patch.

Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/bus/ti-sysc.c

index 8bf153d821381101afe5d18f510538c541e13a00..c7e0896929bbde3b23bd2fdd1ad3ff0306ce91db 100644 (file)
@@ -959,6 +959,42 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
 #endif
 };
 
+/*
+ * Early quirks based on module base and register offsets only that are
+ * needed before the module revision can be read
+ */
+static void sysc_init_early_quirks(struct sysc *ddata)
+{
+       const struct sysc_revision_quirk *q;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(sysc_revision_quirks); i++) {
+               q = &sysc_revision_quirks[i];
+
+               if (!q->base)
+                       continue;
+
+               if (q->base != ddata->module_pa)
+                       continue;
+
+               if (q->rev_offset >= 0 &&
+                   q->rev_offset != ddata->offsets[SYSC_REVISION])
+                       continue;
+
+               if (q->sysc_offset >= 0 &&
+                   q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG])
+                       continue;
+
+               if (q->syss_offset >= 0 &&
+                   q->syss_offset != ddata->offsets[SYSC_SYSSTATUS])
+                       continue;
+
+               ddata->name = q->name;
+               ddata->cfg.quirks |= q->quirks;
+       }
+}
+
+/* Quirks that also consider the revision register value */
 static void sysc_init_revision_quirks(struct sysc *ddata)
 {
        const struct sysc_revision_quirk *q;
@@ -1829,10 +1865,6 @@ static int sysc_probe(struct platform_device *pdev)
        if (error)
                goto unprepare;
 
-       error = sysc_get_clocks(ddata);
-       if (error)
-               return error;
-
        error = sysc_map_and_check_registers(ddata);
        if (error)
                goto unprepare;
@@ -1853,6 +1885,12 @@ static int sysc_probe(struct platform_device *pdev)
        if (error)
                goto unprepare;
 
+       sysc_init_early_quirks(ddata);
+
+       error = sysc_get_clocks(ddata);
+       if (error)
+               return error;
+
        error = sysc_init_resets(ddata);
        if (error)
                return error;