Skip to content

Commit 208a03e

Browse files
krzkvinodkoul
authored andcommitted
soundwire: qcom: define hardcoded version magic numbers
Use a define instead of hard-coded register values for Soundwire hardware version number, because it is a bit easier to read and allows to drop explaining comment. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Link: https://lore.kernel.org/r/20230222144412.237832-1-krzysztof.kozlowski@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent bd934f7 commit 208a03e

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

drivers/soundwire/qcom.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#define SWRM_LINK_MANAGER_EE 0x018
2929
#define SWRM_EE_CPU 1
3030
#define SWRM_FRM_GEN_ENABLED BIT(0)
31+
#define SWRM_VERSION_1_3_0 0x01030000
32+
#define SWRM_VERSION_1_5_1 0x01050001
33+
#define SWRM_VERSION_1_7_0 0x01070000
3134
#define SWRM_COMP_HW_VERSION 0x00
3235
#define SWRM_COMP_CFG_ADDR 0x04
3336
#define SWRM_COMP_CFG_IRQ_LEVEL_OR_PULSE_MSK BIT(1)
@@ -351,8 +354,7 @@ static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *swrm, u8 cmd_data,
351354
/* Its assumed that write is okay as we do not get any status back */
352355
swrm->reg_write(swrm, SWRM_CMD_FIFO_WR_CMD, val);
353356

354-
/* version 1.3 or less */
355-
if (swrm->version <= 0x01030000)
357+
if (swrm->version <= SWRM_VERSION_1_3_0)
356358
usleep_range(150, 155);
357359

358360
if (cmd_id == SWR_BROADCAST_CMD_ID) {
@@ -695,7 +697,7 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
695697
u32p_replace_bits(&val, SWRM_DEF_CMD_NO_PINGS, SWRM_MCP_CFG_MAX_NUM_OF_CMD_NO_PINGS_BMSK);
696698
ctrl->reg_write(ctrl, SWRM_MCP_CFG_ADDR, val);
697699

698-
if (ctrl->version >= 0x01070000) {
700+
if (ctrl->version >= SWRM_VERSION_1_7_0) {
699701
ctrl->reg_write(ctrl, SWRM_LINK_MANAGER_EE, SWRM_EE_CPU);
700702
ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL,
701703
SWRM_MCP_BUS_CLK_START << SWRM_EE_CPU);
@@ -704,8 +706,7 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
704706
}
705707

706708
/* Configure number of retries of a read/write cmd */
707-
if (ctrl->version >= 0x01050001) {
708-
/* Only for versions >= 1.5.1 */
709+
if (ctrl->version >= SWRM_VERSION_1_5_1) {
709710
ctrl->reg_write(ctrl, SWRM_CMD_FIFO_CFG_ADDR,
710711
SWRM_RD_WR_CMD_RETRIES |
711712
SWRM_CONTINUE_EXEC_ON_CMD_IGNORE);
@@ -1239,7 +1240,7 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl)
12391240
ret = of_property_read_u8_array(np, "qcom,ports-block-pack-mode",
12401241
bp_mode, nports);
12411242
if (ret) {
1242-
if (ctrl->version <= 0x01030000)
1243+
if (ctrl->version <= SWRM_VERSION_1_3_0)
12431244
memset(bp_mode, SWR_INVALID_PARAM, QCOM_SDW_MAX_PORTS);
12441245
else
12451246
return ret;
@@ -1442,7 +1443,7 @@ static int qcom_swrm_probe(struct platform_device *pdev)
14421443
pm_runtime_enable(dev);
14431444

14441445
/* Clk stop is not supported on WSA Soundwire masters */
1445-
if (ctrl->version <= 0x01030000) {
1446+
if (ctrl->version <= SWRM_VERSION_1_3_0) {
14461447
ctrl->clock_stop_not_supported = true;
14471448
} else {
14481449
ctrl->reg_read(ctrl, SWRM_COMP_MASTER_ID, &val);
@@ -1527,7 +1528,7 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
15271528
} else {
15281529
reset_control_reset(ctrl->audio_cgcr);
15291530

1530-
if (ctrl->version >= 0x01070000) {
1531+
if (ctrl->version >= SWRM_VERSION_1_7_0) {
15311532
ctrl->reg_write(ctrl, SWRM_LINK_MANAGER_EE, SWRM_EE_CPU);
15321533
ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL,
15331534
SWRM_MCP_BUS_CLK_START << SWRM_EE_CPU);

0 commit comments

Comments
 (0)