From 1e9062003025bbd0ef0a8c79aeb3de6367c64359 Mon Sep 17 00:00:00 2001 From: Ramprasad Katkam Date: Wed, 30 Jan 2019 14:16:34 +0530 Subject: [PATCH] soc: swr-mstr: Avoid redunant delay for wcd934x For codecs like tavil/tasha where the soundwire register access is through codec bridge, the soundwire bus latency is absorbed in slimbus io operations, hence do not require extra delay in soundwire driver for io operations. Change-Id: If77aa02f0c3c1755916b7a57776115d12e4f08bd Signed-off-by: Ramprasad Katkam --- soc/swr-mstr-ctrl.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/soc/swr-mstr-ctrl.c b/soc/swr-mstr-ctrl.c index f9dbc24af097..8d82ff1ec775 100644 --- a/soc/swr-mstr-ctrl.c +++ b/soc/swr-mstr-ctrl.c @@ -448,11 +448,16 @@ static int swrm_cmd_fifo_rd_cmd(struct swr_mstr_ctrl *swrm, int *cmd_data, mutex_lock(&swrm->iolock); val = swrm_get_packed_reg_val(&swrm->rcmd_id, len, dev_addr, reg_addr); - /* wait for FIFO RD to complete to avoid overflow */ - usleep_range(100, 105); - swr_master_write(swrm, SWRM_CMD_FIFO_RD_CMD, val); - /* wait for FIFO RD CMD complete to avoid overflow */ - usleep_range(250, 255); + if (swrm->read) { + /* skip delay if read is handled in platform driver */ + swr_master_write(swrm, SWRM_CMD_FIFO_RD_CMD, val); + } else { + /* wait for FIFO RD to complete to avoid overflow */ + usleep_range(100, 105); + swr_master_write(swrm, SWRM_CMD_FIFO_RD_CMD, val); + /* wait for FIFO RD CMD complete to avoid overflow */ + usleep_range(250, 255); + } retry_read: *cmd_data = swr_master_read(swrm, SWRM_CMD_FIFO_RD_FIFO_ADDR); dev_dbg(swrm->dev, "%s: reg: 0x%x, cmd_id: 0x%x, rcmd_id: 0x%x, \ @@ -496,8 +501,12 @@ static int swrm_cmd_fifo_wr_cmd(struct swr_mstr_ctrl *swrm, u8 cmd_data, dev_num: 0x%x, cmd_data: 0x%x\n", __func__, reg_addr, cmd_id, swrm->wcmd_id,dev_addr, cmd_data); swr_master_write(swrm, SWRM_CMD_FIFO_WR_CMD, val); - /* wait for FIFO WR command to complete to avoid overflow */ - usleep_range(250, 255); + /* + * wait for FIFO WR command to complete to avoid overflow + * skip delay if write is handled in platform driver. + */ + if(!swrm->write) + usleep_range(250, 255); if (cmd_id == 0xF) { /* * sleep for 10ms for MSM soundwire variant to allow broadcast