Merge tag 'asoc-sdw-mockup-codec' into next
authorVinod Koul <vkoul@kernel.org>
Mon, 2 Aug 2021 05:02:51 +0000 (10:32 +0530)
committerVinod Koul <vkoul@kernel.org>
Mon, 2 Aug 2021 05:02:51 +0000 (10:32 +0530)
ASoC: Add mockup SoundWire CODEC

Useful for bringup testing, not for production usage.

drivers/soundwire/bus.c
drivers/soundwire/cadence_master.c
drivers/soundwire/cadence_master.h
drivers/soundwire/dmi-quirks.c
drivers/soundwire/intel.c

index 3e6d4ad..b3ed012 100644 (file)
@@ -896,7 +896,8 @@ static int sdw_bus_wait_for_clk_prep_deprep(struct sdw_bus *bus, u16 dev_num)
        do {
                val = sdw_bread_no_pm(bus, dev_num, SDW_SCP_STAT);
                if (val < 0) {
-                       dev_err(bus->dev, "SDW_SCP_STAT bread failed:%d\n", val);
+                       if (val != -ENODATA)
+                               dev_err(bus->dev, "SDW_SCP_STAT bread failed:%d\n", val);
                        return val;
                }
                val &= SDW_SCP_STAT_CLK_STP_NF;
@@ -1853,6 +1854,7 @@ void sdw_clear_slave_status(struct sdw_bus *bus, u32 request)
                if (slave->status != SDW_SLAVE_UNATTACHED) {
                        sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
                        slave->first_interrupt_done = false;
+                       sdw_update_slave_status(slave, SDW_SLAVE_UNATTACHED);
                }
 
                /* keep track of request, used in pm_runtime resume */
index 2595042..a9bd56f 100644 (file)
@@ -822,7 +822,6 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id)
 {
        struct sdw_cdns *cdns = dev_id;
        u32 int_status;
-       int ret = IRQ_HANDLED;
 
        /* Check if the link is up */
        if (!cdns->link_up)
@@ -900,7 +899,7 @@ irqreturn_t sdw_cdns_irq(int irq, void *dev_id)
        }
 
        cdns_writel(cdns, CDNS_MCP_INTSTAT, int_status);
-       return ret;
+       return IRQ_HANDLED;
 }
 EXPORT_SYMBOL(sdw_cdns_irq);
 
@@ -936,6 +935,49 @@ static void cdns_update_slave_status_work(struct work_struct *work)
 
 }
 
+/* paranoia check to make sure self-cleared bits are indeed cleared */
+void sdw_cdns_check_self_clearing_bits(struct sdw_cdns *cdns, const char *string,
+                                      bool initial_delay, int reset_iterations)
+{
+       u32 mcp_control;
+       u32 mcp_config_update;
+       int i;
+
+       if (initial_delay)
+               usleep_range(1000, 1500);
+
+       mcp_control = cdns_readl(cdns, CDNS_MCP_CONTROL);
+
+       /* the following bits should be cleared immediately */
+       if (mcp_control & CDNS_MCP_CONTROL_CMD_RST)
+               dev_err(cdns->dev, "%s failed: MCP_CONTROL_CMD_RST is not cleared\n", string);
+       if (mcp_control & CDNS_MCP_CONTROL_SOFT_RST)
+               dev_err(cdns->dev, "%s failed: MCP_CONTROL_SOFT_RST is not cleared\n", string);
+       if (mcp_control & CDNS_MCP_CONTROL_SW_RST)
+               dev_err(cdns->dev, "%s failed: MCP_CONTROL_SW_RST is not cleared\n", string);
+       if (mcp_control & CDNS_MCP_CONTROL_CLK_STOP_CLR)
+               dev_err(cdns->dev, "%s failed: MCP_CONTROL_CLK_STOP_CLR is not cleared\n", string);
+       mcp_config_update = cdns_readl(cdns, CDNS_MCP_CONFIG_UPDATE);
+       if (mcp_config_update & CDNS_MCP_CONFIG_UPDATE_BIT)
+               dev_err(cdns->dev, "%s failed: MCP_CONFIG_UPDATE_BIT is not cleared\n", string);
+
+       i = 0;
+       while (mcp_control & CDNS_MCP_CONTROL_HW_RST) {
+               if (i == reset_iterations) {
+                       dev_err(cdns->dev, "%s failed: MCP_CONTROL_HW_RST is not cleared\n", string);
+                       break;
+               }
+
+               dev_dbg(cdns->dev, "%s: MCP_CONTROL_HW_RST is not cleared at iteration %d\n", string, i);
+               i++;
+
+               usleep_range(1000, 1500);
+               mcp_control = cdns_readl(cdns, CDNS_MCP_CONTROL);
+       }
+
+}
+EXPORT_SYMBOL(sdw_cdns_check_self_clearing_bits);
+
 /*
  * init routines
  */
@@ -1213,6 +1255,8 @@ int sdw_cdns_init(struct sdw_cdns *cdns)
 
        cdns_init_clock_ctrl(cdns);
 
+       sdw_cdns_check_self_clearing_bits(cdns, __func__, false, 0);
+
        /* reset msg_count to default value of FIFOLEVEL */
        cdns->msg_count = cdns_readl(cdns, CDNS_MCP_FIFOLEVEL);
 
@@ -1397,6 +1441,8 @@ int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake)
        struct sdw_slave *slave;
        int ret;
 
+       sdw_cdns_check_self_clearing_bits(cdns, __func__, false, 0);
+
        /* Check suspend status */
        if (sdw_cdns_is_clock_stop(cdns)) {
                dev_dbg(cdns->dev, "Clock is already stopped\n");
index 0e7f8b3..b54c161 100644 (file)
@@ -184,4 +184,8 @@ int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params);
 
 int cdns_set_sdw_stream(struct snd_soc_dai *dai,
                        void *stream, bool pcm, int direction);
+
+void sdw_cdns_check_self_clearing_bits(struct sdw_cdns *cdns, const char *string,
+                                      bool initial_delay, int reset_iterations);
+
 #endif /* __SDW_CADENCE_H */
index 5db0a24..0ca2a3e 100644 (file)
@@ -16,18 +16,18 @@ struct adr_remap {
 };
 
 /*
- * HP Spectre 360 Convertible devices do not expose the correct _ADR
- * in the DSDT.
+ * Some TigerLake devices based on an initial Intel BIOS do not expose
+ * the correct _ADR in the DSDT.
  * Remap the bad _ADR values to the ones reported by hardware
  */
-static const struct adr_remap hp_spectre_360[] = {
+static const struct adr_remap intel_tgl_bios[] = {
        {
-               0x000010025D070100,
-               0x000020025D071100
+               0x000010025D070100ull,
+               0x000020025D071100ull
        },
        {
-               0x000110025d070100,
-               0x000120025D130800
+               0x000110025d070100ull,
+               0x000120025D130800ull
        },
        {}
 };
@@ -39,18 +39,18 @@ static const struct adr_remap hp_spectre_360[] = {
 static const struct adr_remap dell_sku_0A3E[] = {
        /* rt715 on link0 */
        {
-               0x00020025d071100,
-               0x00021025d071500
+               0x00020025d071100ull,
+               0x00021025d071500ull
        },
        /* rt711 on link1 */
        {
-               0x000120025d130800,
-               0x000120025d071100,
+               0x000120025d130800ull,
+               0x000120025d071100ull,
        },
        /* rt1308 on link2 */
        {
-               0x000220025d071500,
-               0x000220025d130800
+               0x000220025d071500ull,
+               0x000220025d130800ull
        },
        {}
 };
@@ -61,7 +61,15 @@ static const struct dmi_system_id adr_remap_quirk_table[] = {
                        DMI_MATCH(DMI_SYS_VENDOR, "HP"),
                        DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Convertible"),
                },
-               .driver_data = (void *)hp_spectre_360,
+               .driver_data = (void *)intel_tgl_bios,
+       },
+       {
+               /* quirk used for NUC15 'Bishop County' LAPBC510 and LAPBC710 skews */
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Intel(R) Client Systems"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "LAPBC"),
+               },
+               .driver_data = (void *)intel_tgl_bios,
        },
        {
                .matches = {
index c11e3d8..9794bc2 100644 (file)
@@ -23,6 +23,7 @@
 #include "intel.h"
 
 #define INTEL_MASTER_SUSPEND_DELAY_MS  3000
+#define INTEL_MASTER_RESET_ITERATIONS  10
 
 /*
  * debug/config flags for the Intel SoundWire Master.
@@ -1467,6 +1468,8 @@ int intel_link_startup(struct auxiliary_device *auxdev)
                        goto err_interrupt;
                }
        }
+       sdw_cdns_check_self_clearing_bits(cdns, __func__,
+                                         true, INTEL_MASTER_RESET_ITERATIONS);
 
        /* Register DAIs */
        ret = intel_register_dai(sdw);
@@ -1783,6 +1786,8 @@ static int __maybe_unused intel_resume(struct device *dev)
                        return ret;
                }
        }
+       sdw_cdns_check_self_clearing_bits(cdns, __func__,
+                                         true, INTEL_MASTER_RESET_ITERATIONS);
 
        /*
         * after system resume, the pm_runtime suspend() may kick in
@@ -1867,6 +1872,9 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
                                return ret;
                        }
                }
+               sdw_cdns_check_self_clearing_bits(cdns, "intel_resume_runtime TEARDOWN",
+                                                 true, INTEL_MASTER_RESET_ITERATIONS);
+
        } else if (clock_stop_quirks & SDW_INTEL_CLK_STOP_BUS_RESET) {
                ret = intel_init(sdw);
                if (ret) {
@@ -1940,6 +1948,9 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
                                }
                        }
                }
+               sdw_cdns_check_self_clearing_bits(cdns, "intel_resume_runtime BUS_RESET",
+                                                 true, INTEL_MASTER_RESET_ITERATIONS);
+
        } else if (!clock_stop_quirks) {
 
                clock_stop0 = sdw_cdns_is_clock_stop(&sdw->cdns);
@@ -1963,6 +1974,9 @@ static int __maybe_unused intel_resume_runtime(struct device *dev)
                        dev_err(dev, "unable to resume master during resume\n");
                        return ret;
                }
+
+               sdw_cdns_check_self_clearing_bits(cdns, "intel_resume_runtime no_quirks",
+                                                 true, INTEL_MASTER_RESET_ITERATIONS);
        } else {
                dev_err(dev, "%s clock_stop_quirks %x unsupported\n",
                        __func__, clock_stop_quirks);