Merge tag 'drm-misc-next-fixes-2023-01-03' of git://anongit.freedesktop.org/drm/drm...
[linux-block.git] / drivers / soundwire / qcom.c
index cee2b22231410345e9373b5968b1f9b9c977623b..33542487029005a91f59dc15acb4b76f69ebeb3b 100644 (file)
@@ -25,6 +25,8 @@
 
 #define SWRM_COMP_SW_RESET                                     0x008
 #define SWRM_COMP_STATUS                                       0x014
+#define SWRM_LINK_MANAGER_EE                                   0x018
+#define SWRM_EE_CPU                                            1
 #define SWRM_FRM_GEN_ENABLED                                   BIT(0)
 #define SWRM_COMP_HW_VERSION                                   0x00
 #define SWRM_COMP_CFG_ADDR                                     0x04
 #define SWRM_REG_VAL_PACK(data, dev, id, reg)  \
                        ((reg) | ((id) << 16) | ((dev) << 20) | ((data) << 24))
 
-#define SWRM_SPECIAL_CMD_ID    0xF
 #define MAX_FREQ_NUM           1
 #define TIMEOUT_MS             100
 #define QCOM_SWRM_MAX_RD_LEN   0x1
@@ -694,7 +695,14 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
        u32p_replace_bits(&val, SWRM_DEF_CMD_NO_PINGS, SWRM_MCP_CFG_MAX_NUM_OF_CMD_NO_PINGS_BMSK);
        ctrl->reg_write(ctrl, SWRM_MCP_CFG_ADDR, val);
 
-       ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL, SWRM_MCP_BUS_CLK_START);
+       if (ctrl->version >= 0x01070000) {
+               ctrl->reg_write(ctrl, SWRM_LINK_MANAGER_EE, SWRM_EE_CPU);
+               ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL,
+                               SWRM_MCP_BUS_CLK_START << SWRM_EE_CPU);
+       } else {
+               ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL, SWRM_MCP_BUS_CLK_START);
+       }
+
        /* Configure number of retries of a read/write cmd */
        if (ctrl->version > 0x01050001) {
                /* Only for versions >= 1.5.1 */
@@ -1331,8 +1339,8 @@ static int qcom_swrm_probe(struct platform_device *pdev)
        }
 
        if (data->sw_clk_gate_required) {
-               ctrl->audio_cgcr = devm_reset_control_get_exclusive(dev, "swr_audio_cgcr");
-               if (IS_ERR_OR_NULL(ctrl->audio_cgcr)) {
+               ctrl->audio_cgcr = devm_reset_control_get_optional_exclusive(dev, "swr_audio_cgcr");
+               if (IS_ERR(ctrl->audio_cgcr)) {
                        dev_err(dev, "Failed to get cgcr reset ctrl required for SW gating\n");
                        ret = PTR_ERR(ctrl->audio_cgcr);
                        goto err_init;
@@ -1519,7 +1527,13 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
        } else {
                reset_control_reset(ctrl->audio_cgcr);
 
-               ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL, SWRM_MCP_BUS_CLK_START);
+               if (ctrl->version >= 0x01070000) {
+                       ctrl->reg_write(ctrl, SWRM_LINK_MANAGER_EE, SWRM_EE_CPU);
+                       ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL,
+                                       SWRM_MCP_BUS_CLK_START << SWRM_EE_CPU);
+               } else {
+                       ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL, SWRM_MCP_BUS_CLK_START);
+               }
                ctrl->reg_write(ctrl, SWRM_INTERRUPT_CLEAR,
                        SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET);
 
@@ -1583,6 +1597,7 @@ static const struct of_device_id qcom_swrm_of_match[] = {
        { .compatible = "qcom,soundwire-v1.3.0", .data = &swrm_v1_3_data },
        { .compatible = "qcom,soundwire-v1.5.1", .data = &swrm_v1_5_data },
        { .compatible = "qcom,soundwire-v1.6.0", .data = &swrm_v1_6_data },
+       { .compatible = "qcom,soundwire-v1.7.0", .data = &swrm_v1_5_data },
        {/* sentinel */},
 };