Skip to content

Commit b2bfe0f

Browse files
Srinivas Kandagatlavinodkoul
authored andcommitted
soundwire: qcom: adding support for v3.1.0
Add support for controller version v3.1.0, which has changes in register layout and some register fields compared to v2.0. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> Tested-by: Alexey Klimov <alexey.klimov@linaro.org> # sm8550 Link: https://patch.msgid.link/20250912083225.228778-8-srinivas.kandagatla@oss.qualcomm.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 66eca4b commit b2bfe0f

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

drivers/soundwire/qcom.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define SWRM_VERSION_1_5_1 0x01050001
3232
#define SWRM_VERSION_1_7_0 0x01070000
3333
#define SWRM_VERSION_2_0_0 0x02000000
34+
#define SWRM_VERSION_3_1_0 0x03010000
3435
#define SWRM_COMP_HW_VERSION 0x00
3536
#define SWRM_COMP_CFG_ADDR 0x04
3637
#define SWRM_COMP_CFG_IRQ_LEVEL_OR_PULSE_MSK BIT(1)
@@ -40,6 +41,9 @@
4041
#define SWRM_COMP_PARAMS_RD_FIFO_DEPTH GENMASK(19, 15)
4142
#define SWRM_COMP_PARAMS_DOUT_PORTS_MASK GENMASK(4, 0)
4243
#define SWRM_COMP_PARAMS_DIN_PORTS_MASK GENMASK(9, 5)
44+
#define SWRM_V3_COMP_PARAMS_WR_FIFO_DEPTH GENMASK(17, 10)
45+
#define SWRM_V3_COMP_PARAMS_RD_FIFO_DEPTH GENMASK(23, 18)
46+
4347
#define SWRM_COMP_MASTER_ID 0x104
4448
#define SWRM_V1_3_INTERRUPT_STATUS 0x200
4549
#define SWRM_V2_0_INTERRUPT_STATUS 0x5000
@@ -296,6 +300,32 @@ static const struct qcom_swrm_data swrm_v2_0_data = {
296300
.reg_layout = swrm_v2_0_reg_layout,
297301
};
298302

303+
static const unsigned int swrm_v3_0_reg_layout[] = {
304+
[SWRM_REG_FRAME_GEN_ENABLED] = SWRM_V2_0_LINK_STATUS,
305+
[SWRM_REG_INTERRUPT_STATUS] = SWRM_V2_0_INTERRUPT_STATUS,
306+
[SWRM_REG_INTERRUPT_MASK_ADDR] = 0, /* Not present */
307+
[SWRM_REG_INTERRUPT_CLEAR] = SWRM_V2_0_INTERRUPT_CLEAR,
308+
[SWRM_REG_INTERRUPT_CPU_EN] = SWRM_V2_0_INTERRUPT_CPU_EN,
309+
[SWRM_REG_CMD_FIFO_WR_CMD] = SWRM_V2_0_CMD_FIFO_WR_CMD,
310+
[SWRM_REG_CMD_FIFO_RD_CMD] = SWRM_V2_0_CMD_FIFO_RD_CMD,
311+
[SWRM_REG_CMD_FIFO_STATUS] = SWRM_V2_0_CMD_FIFO_STATUS,
312+
[SWRM_REG_CMD_FIFO_RD_FIFO_ADDR] = SWRM_V2_0_CMD_FIFO_RD_FIFO_ADDR,
313+
[SWRM_OFFSET_DP_PORT_CTRL_BANK] = 0x1224,
314+
[SWRM_OFFSET_DP_PORT_CTRL_2_BANK] = 0x1228,
315+
[SWRM_OFFSET_DP_BLOCK_CTRL_1] = 0x122c,
316+
[SWRM_OFFSET_DP_BLOCK_CTRL2_BANK] = 0x1230,
317+
[SWRM_OFFSET_DP_PORT_HCTRL_BANK] = 0x1234,
318+
[SWRM_OFFSET_DP_BLOCK_CTRL3_BANK] = 0x1238,
319+
[SWRM_OFFSET_DP_SAMPLECTRL2_BANK] = 0x123c,
320+
};
321+
322+
static const struct qcom_swrm_data swrm_v3_0_data = {
323+
.default_rows = 50,
324+
.default_cols = 16,
325+
.sw_clk_gate_required = true,
326+
.max_reg = SWR_V2_0_MSTR_MAX_REG_ADDR,
327+
.reg_layout = swrm_v3_0_reg_layout,
328+
};
299329
#define to_qcom_sdw(b) container_of(b, struct qcom_swrm_ctrl, bus)
300330

301331
static int qcom_swrm_ahb_reg_read(struct qcom_swrm_ctrl *ctrl, int reg,
@@ -919,7 +949,11 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
919949
swrm_wait_for_frame_gen_enabled(ctrl);
920950
ctrl->slave_status = 0;
921951
ctrl->reg_read(ctrl, SWRM_COMP_PARAMS, &val);
922-
ctrl->wr_fifo_depth = FIELD_GET(SWRM_COMP_PARAMS_WR_FIFO_DEPTH, val);
952+
953+
if (ctrl->version >= SWRM_VERSION_3_1_0)
954+
ctrl->wr_fifo_depth = FIELD_GET(SWRM_V3_COMP_PARAMS_WR_FIFO_DEPTH, val);
955+
else
956+
ctrl->wr_fifo_depth = FIELD_GET(SWRM_COMP_PARAMS_WR_FIFO_DEPTH, val);
923957

924958
return 0;
925959
}
@@ -1785,6 +1819,7 @@ static const struct of_device_id qcom_swrm_of_match[] = {
17851819
{ .compatible = "qcom,soundwire-v1.6.0", .data = &swrm_v1_6_data },
17861820
{ .compatible = "qcom,soundwire-v1.7.0", .data = &swrm_v1_5_data },
17871821
{ .compatible = "qcom,soundwire-v2.0.0", .data = &swrm_v2_0_data },
1822+
{ .compatible = "qcom,soundwire-v3.1.0", .data = &swrm_v3_0_data },
17881823
{/* sentinel */},
17891824
};
17901825

0 commit comments

Comments
 (0)