Merge branch 'pwm-dmtimer-fixes' into omap-for-v5.0/fixes-v2
[sfrench/cifs-2.6.git] / drivers / bus / ti-sysc.c
index 12a0401339b8e8bded0482aa269a4eab8c554b9f..d299ec79e4c38bd4b5117b87bd75d639fe596ea1 100644 (file)
@@ -91,6 +91,9 @@ struct sysc {
        struct delayed_work idle_work;
 };
 
+static void sysc_parse_dts_quirks(struct sysc *ddata, struct device_node *np,
+                                 bool is_child);
+
 void sysc_write(struct sysc *ddata, int offset, u32 value)
 {
        writel_relaxed(value, ddata->module_va + offset);
@@ -214,8 +217,13 @@ static int sysc_get_clocks(struct sysc *ddata)
        if (!ddata->clocks)
                return -ENOMEM;
 
-       for (i = 0; i < ddata->nr_clocks; i++) {
-               error = sysc_get_one_clock(ddata, ddata->clock_roles[i]);
+       for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
+               const char *name = ddata->clock_roles[i];
+
+               if (!name)
+                       continue;
+
+               error = sysc_get_one_clock(ddata, name);
                if (error && error != -ENOENT)
                        return error;
        }
@@ -374,6 +382,7 @@ static int sysc_check_one_child(struct sysc *ddata,
                dev_warn(ddata->dev, "really a child ti,hwmods property?");
 
        sysc_check_quirk_stdout(ddata, np);
+       sysc_parse_dts_quirks(ddata, np, true);
 
        return 0;
 }
@@ -701,69 +710,7 @@ awake:
        return error;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int sysc_suspend(struct device *dev)
-{
-       struct sysc *ddata;
-       int error;
-
-       ddata = dev_get_drvdata(dev);
-
-       if (ddata->cfg.quirks & (SYSC_QUIRK_RESOURCE_PROVIDER |
-                                SYSC_QUIRK_LEGACY_IDLE))
-               return 0;
-
-       if (!ddata->enabled)
-               return 0;
-
-       dev_dbg(ddata->dev, "%s %s\n", __func__,
-               ddata->name ? ddata->name : "");
-
-       error = pm_runtime_put_sync_suspend(dev);
-       if (error < 0) {
-               dev_warn(ddata->dev, "%s not idle %i %s\n",
-                        __func__, error,
-                        ddata->name ? ddata->name : "");
-
-               return 0;
-       }
-
-       ddata->needs_resume = true;
-
-       return 0;
-}
-
-static int sysc_resume(struct device *dev)
-{
-       struct sysc *ddata;
-       int error;
-
-       ddata = dev_get_drvdata(dev);
-
-       if (ddata->cfg.quirks & (SYSC_QUIRK_RESOURCE_PROVIDER |
-                                SYSC_QUIRK_LEGACY_IDLE))
-               return 0;
-
-       if (ddata->needs_resume) {
-               dev_dbg(ddata->dev, "%s %s\n", __func__,
-                       ddata->name ? ddata->name : "");
-
-               error = pm_runtime_get_sync(dev);
-               if (error < 0) {
-                       dev_err(ddata->dev, "%s  error %i %s\n",
-                               __func__, error,
-                                ddata->name ? ddata->name : "");
-
-                       return error;
-               }
-
-               ddata->needs_resume = false;
-       }
-
-       return 0;
-}
-
-static int sysc_noirq_suspend(struct device *dev)
+static int __maybe_unused sysc_noirq_suspend(struct device *dev)
 {
        struct sysc *ddata;
 
@@ -772,21 +719,10 @@ static int sysc_noirq_suspend(struct device *dev)
        if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
                return 0;
 
-       if (!(ddata->cfg.quirks & SYSC_QUIRK_RESOURCE_PROVIDER))
-               return 0;
-
-       if (!ddata->enabled)
-               return 0;
-
-       dev_dbg(ddata->dev, "%s %s\n", __func__,
-               ddata->name ? ddata->name : "");
-
-       ddata->needs_resume = true;
-
-       return sysc_runtime_suspend(dev);
+       return pm_runtime_force_suspend(dev);
 }
 
-static int sysc_noirq_resume(struct device *dev)
+static int __maybe_unused sysc_noirq_resume(struct device *dev)
 {
        struct sysc *ddata;
 
@@ -795,24 +731,10 @@ static int sysc_noirq_resume(struct device *dev)
        if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
                return 0;
 
-       if (!(ddata->cfg.quirks & SYSC_QUIRK_RESOURCE_PROVIDER))
-               return 0;
-
-       if (ddata->needs_resume) {
-               dev_dbg(ddata->dev, "%s %s\n", __func__,
-                       ddata->name ? ddata->name : "");
-
-               ddata->needs_resume = false;
-
-               return sysc_runtime_resume(dev);
-       }
-
-       return 0;
+       return pm_runtime_force_resume(dev);
 }
-#endif
 
 static const struct dev_pm_ops sysc_pm_ops = {
-       SET_SYSTEM_SLEEP_PM_OPS(sysc_suspend, sysc_resume)
        SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_noirq_suspend, sysc_noirq_resume)
        SET_RUNTIME_PM_OPS(sysc_runtime_suspend,
                           sysc_runtime_resume,
@@ -845,28 +767,8 @@ struct sysc_revision_quirk {
        }
 
 static const struct sysc_revision_quirk sysc_revision_quirks[] = {
-       /* These need to use noirq_suspend */
-       SYSC_QUIRK("control", 0, 0, 0x10, -1, 0x40000900, 0xffffffff,
-                  SYSC_QUIRK_RESOURCE_PROVIDER),
-       SYSC_QUIRK("i2c", 0, 0, 0x10, 0x90, 0x5040000a, 0xffffffff,
-                  SYSC_QUIRK_RESOURCE_PROVIDER),
-       SYSC_QUIRK("mcspi", 0, 0, 0x10, -1, 0x40300a0b, 0xffffffff,
-                  SYSC_QUIRK_RESOURCE_PROVIDER),
-       SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000100, 0xffffffff,
-                  SYSC_QUIRK_RESOURCE_PROVIDER),
-       SYSC_QUIRK("ocp2scp", 0, 0, 0x10, 0x14, 0x50060005, 0xffffffff,
-                  SYSC_QUIRK_RESOURCE_PROVIDER),
-       SYSC_QUIRK("padconf", 0, 0, 0x10, -1, 0x4fff0800, 0xffffffff,
-                  SYSC_QUIRK_RESOURCE_PROVIDER),
-       SYSC_QUIRK("scm", 0, 0, 0x10, -1, 0x40000900, 0xffffffff,
-                  SYSC_QUIRK_RESOURCE_PROVIDER),
-       SYSC_QUIRK("scrm", 0, 0, -1, -1, 0x00000010, 0xffffffff,
-                  SYSC_QUIRK_RESOURCE_PROVIDER),
-       SYSC_QUIRK("sdma", 0, 0, 0x2c, 0x28, 0x00010900, 0xffffffff,
-                  SYSC_QUIRK_RESOURCE_PROVIDER),
-
        /* These drivers need to be fixed to not use pm_runtime_irq_safe() */
-       SYSC_QUIRK("gpio", 0, 0, 0x10, 0x114, 0x50600801, 0xffffffff,
+       SYSC_QUIRK("gpio", 0, 0, 0x10, 0x114, 0x50600801, 0xffff00ff,
                   SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_OPT_CLKS_IN_RESET),
        SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000020, 0xffffffff,
                   SYSC_QUIRK_LEGACY_IDLE),
@@ -881,38 +783,73 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
        SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff,
                   0),
        /* Some timers on omap4 and later */
-       SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x4fff1301, 0xffffffff,
+       SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x50002100, 0xffffffff,
+                  0),
+       SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x4fff1301, 0xffff00ff,
                   0),
        SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff,
                   SYSC_QUIRK_LEGACY_IDLE),
        /* Uarts on omap4 and later */
-       SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x50411e03, 0xffffffff,
-                  SYSC_QUIRK_LEGACY_IDLE),
-
-       /* These devices don't yet suspend properly without legacy setting */
-       SYSC_QUIRK("sdio", 0, 0, 0x10, -1, 0x40202301, 0xffffffff,
-                  SYSC_QUIRK_LEGACY_IDLE),
-       SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xffffffff,
+       SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x50411e03, 0xffff00ff,
                   SYSC_QUIRK_LEGACY_IDLE),
-       SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0d00, 0xffffffff,
+       SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x47422e03, 0xffffffff,
                   SYSC_QUIRK_LEGACY_IDLE),
 
 #ifdef DEBUG
+       SYSC_QUIRK("adc", 0, 0, 0x10, -1, 0x47300001, 0xffffffff, 0),
+       SYSC_QUIRK("atl", 0, 0, -1, -1, 0x0a070100, 0xffffffff, 0),
        SYSC_QUIRK("aess", 0, 0, 0x10, -1, 0x40000000, 0xffffffff, 0),
+       SYSC_QUIRK("cm", 0, 0, -1, -1, 0x40000301, 0xffffffff, 0),
+       SYSC_QUIRK("control", 0, 0, 0x10, -1, 0x40000900, 0xffffffff, 0),
+       SYSC_QUIRK("cpgmac", 0, 0x1200, 0x1208, 0x1204, 0x4edb1902,
+                  0xffff00f0, 0),
+       SYSC_QUIRK("dcan", 0, 0, -1, -1, 0xffffffff, 0xffffffff, 0),
+       SYSC_QUIRK("dcan", 0, 0, -1, -1, 0x00001401, 0xffffffff, 0),
+       SYSC_QUIRK("dwc3", 0, 0, 0x10, -1, 0x500a0200, 0xffffffff, 0),
+       SYSC_QUIRK("epwmss", 0, 0, 0x4, -1, 0x47400001, 0xffffffff, 0),
        SYSC_QUIRK("gpu", 0, 0x1fc00, 0x1fc10, -1, 0, 0, 0),
        SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x00000006, 0xffffffff, 0),
+       SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x0000000a, 0xffffffff, 0),
        SYSC_QUIRK("hsi", 0, 0, 0x10, 0x14, 0x50043101, 0xffffffff, 0),
        SYSC_QUIRK("iss", 0, 0, 0x10, -1, 0x40000101, 0xffffffff, 0),
+       SYSC_QUIRK("i2c", 0, 0, 0x10, 0x90, 0x5040000a, 0xfffff0f0, 0),
+       SYSC_QUIRK("lcdc", 0, 0, 0x54, -1, 0x4f201000, 0xffffffff, 0),
        SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44306302, 0xffffffff, 0),
+       SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44307b02, 0xffffffff, 0),
        SYSC_QUIRK("mcbsp", 0, -1, 0x8c, -1, 0, 0, 0),
+       SYSC_QUIRK("mcspi", 0, 0, 0x10, -1, 0x40300a0b, 0xffff00ff, 0),
+       SYSC_QUIRK("mcspi", 0, 0, 0x110, 0x114, 0x40300a0b, 0xffffffff, 0),
        SYSC_QUIRK("mailbox", 0, 0, 0x10, -1, 0x00000400, 0xffffffff, 0),
+       SYSC_QUIRK("m3", 0, 0, -1, -1, 0x5f580105, 0x0fff0f00, 0),
+       SYSC_QUIRK("ocp2scp", 0, 0, 0x10, 0x14, 0x50060005, 0xfffffff0, 0),
+       SYSC_QUIRK("ocp2scp", 0, 0, -1, -1, 0x50060007, 0xffffffff, 0),
+       SYSC_QUIRK("padconf", 0, 0, 0x10, -1, 0x4fff0800, 0xffffffff, 0),
+       SYSC_QUIRK("padconf", 0, 0, -1, -1, 0x40001100, 0xffffffff, 0),
+       SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000100, 0xffffffff, 0),
+       SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x00004102, 0xffffffff, 0),
+       SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000400, 0xffffffff, 0),
+       SYSC_QUIRK("scm", 0, 0, 0x10, -1, 0x40000900, 0xffffffff, 0),
+       SYSC_QUIRK("scm", 0, 0, -1, -1, 0x4e8b0100, 0xffffffff, 0),
+       SYSC_QUIRK("scm", 0, 0, -1, -1, 0x4f000100, 0xffffffff, 0),
+       SYSC_QUIRK("scm", 0, 0, -1, -1, 0x40000900, 0xffffffff, 0),
+       SYSC_QUIRK("scrm", 0, 0, -1, -1, 0x00000010, 0xffffffff, 0),
+       SYSC_QUIRK("sdio", 0, 0, 0x10, -1, 0x40202301, 0xffff0ff0, 0),
+       SYSC_QUIRK("sdio", 0, 0x2fc, 0x110, 0x114, 0x31010000, 0xffffffff, 0),
+       SYSC_QUIRK("sdma", 0, 0, 0x2c, 0x28, 0x00010900, 0xffffffff, 0),
        SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40000902, 0xffffffff, 0),
        SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40002903, 0xffffffff, 0),
        SYSC_QUIRK("spinlock", 0, 0, 0x10, -1, 0x50020000, 0xffffffff, 0),
+       SYSC_QUIRK("rng", 0, 0x1fe0, 0x1fe4, -1, 0x00000020, 0xffffffff, 0),
+       SYSC_QUIRK("rtc", 0, 0x74, 0x78, -1, 0x4eb01908, 0xffff00f0, 0),
+       SYSC_QUIRK("timer32k", 0, 0, 0x4, -1, 0x00000060, 0xffffffff, 0),
        SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000004, 0xffffffff, 0),
+       SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000008, 0xffffffff, 0),
        SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, 0x14, 0x50700100, 0xffffffff, 0),
+       SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, -1, 0x50700101, 0xffffffff, 0),
        SYSC_QUIRK("usb_otg_hs", 0, 0x400, 0x404, 0x408, 0x00000050,
                   0xffffffff, 0),
+       SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xfffff0f0, 0),
+       SYSC_QUIRK("vfpe", 0, 0, 0x104, -1, 0x4d001200, 0xffffffff, 0),
 #endif
 };
 
@@ -1221,8 +1158,8 @@ static int sysc_child_suspend_noirq(struct device *dev)
        if (!pm_runtime_status_suspended(dev)) {
                error = pm_generic_runtime_suspend(dev);
                if (error) {
-                       dev_warn(dev, "%s busy at %i: %i\n",
-                                __func__, __LINE__, error);
+                       dev_dbg(dev, "%s busy at %i: %i\n",
+                               __func__, __LINE__, error);
 
                        return 0;
                }
@@ -1346,23 +1283,37 @@ static const struct sysc_dts_quirk sysc_dts_quirks[] = {
          .mask = SYSC_QUIRK_NO_RESET_ON_INIT, },
 };
 
-static int sysc_init_dts_quirks(struct sysc *ddata)
+static void sysc_parse_dts_quirks(struct sysc *ddata, struct device_node *np,
+                                 bool is_child)
 {
-       struct device_node *np = ddata->dev->of_node;
        const struct property *prop;
-       int i, len, error;
-       u32 val;
-
-       ddata->legacy_mode = of_get_property(np, "ti,hwmods", NULL);
+       int i, len;
 
        for (i = 0; i < ARRAY_SIZE(sysc_dts_quirks); i++) {
-               prop = of_get_property(np, sysc_dts_quirks[i].name, &len);
+               const char *name = sysc_dts_quirks[i].name;
+
+               prop = of_get_property(np, name, &len);
                if (!prop)
                        continue;
 
                ddata->cfg.quirks |= sysc_dts_quirks[i].mask;
+               if (is_child) {
+                       dev_warn(ddata->dev,
+                                "dts flag should be at module level for %s\n",
+                                name);
+               }
        }
+}
 
+static int sysc_init_dts_quirks(struct sysc *ddata)
+{
+       struct device_node *np = ddata->dev->of_node;
+       int error;
+       u32 val;
+
+       ddata->legacy_mode = of_get_property(np, "ti,hwmods", NULL);
+
+       sysc_parse_dts_quirks(ddata, np, false);
        error = of_property_read_u32(np, "ti,sysc-delay-us", &val);
        if (!error) {
                if (val > 255) {
@@ -1573,6 +1524,16 @@ static const struct sysc_regbits sysc_regbits_omap4_mcasp = {
 static const struct sysc_capabilities sysc_omap4_mcasp = {
        .type = TI_SYSC_OMAP4_MCASP,
        .regbits = &sysc_regbits_omap4_mcasp,
+       .mod_quirks = SYSC_QUIRK_OPT_CLKS_NEEDED,
+};
+
+/*
+ * McASP found on dra7 and later
+ */
+static const struct sysc_capabilities sysc_dra7_mcasp = {
+       .type = TI_SYSC_OMAP4_SIMPLE,
+       .regbits = &sysc_regbits_omap4_simple,
+       .mod_quirks = SYSC_QUIRK_OPT_CLKS_NEEDED,
 };
 
 /*
@@ -1801,6 +1762,7 @@ static const struct of_device_id sysc_match[] = {
        { .compatible = "ti,sysc-omap3-sham", .data = &sysc_omap3_sham, },
        { .compatible = "ti,sysc-omap-aes", .data = &sysc_omap3_aes, },
        { .compatible = "ti,sysc-mcasp", .data = &sysc_omap4_mcasp, },
+       { .compatible = "ti,sysc-dra7-mcasp", .data = &sysc_dra7_mcasp, },
        { .compatible = "ti,sysc-usb-host-fs",
          .data = &sysc_omap4_usb_host_fs, },
        { .compatible = "ti,sysc-dra7-mcan", .data = &sysc_dra7_mcan, },