Skip to content

Commit 5376d68

Browse files
committed
fixup! soundwire: cadence_master: set frame shape and divider based on actual clk freq
Address comments from Pierre. 1. Mave the check before writing the divider registers 2. Remove the 'freq' intermediate variable which is multiplied by two after divided by two. Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
1 parent e774004 commit 5376d68

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

drivers/soundwire/cadence_master.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,32 +1352,30 @@ static int cdns_init_clock_ctrl(struct sdw_cdns *cdns)
13521352
u32 val;
13531353
u32 ssp_interval;
13541354
int divider;
1355-
int freq;
13561355

13571356
dev_dbg(cdns->dev, "mclk %d max %d row %d col %d\n",
13581357
prop->mclk_freq,
13591358
prop->max_clk_freq,
13601359
prop->default_row,
13611360
prop->default_col);
13621361

1362+
if (!prop->default_frame_rate || !prop->default_row) {
1363+
dev_err(cdns->dev, "Default frame_rate %d or row %d is invalid\n",
1364+
prop->default_frame_rate, prop->default_row);
1365+
return -EINVAL;
1366+
}
1367+
13631368
/* Set clock divider */
13641369
divider = (prop->mclk_freq * SDW_DOUBLE_RATE_FACTOR /
13651370
bus->params.curr_dr_freq) - 1;
1366-
freq = bus->params.curr_dr_freq >> 1;
13671371

13681372
cdns_updatel(cdns, CDNS_MCP_CLK_CTRL0,
13691373
CDNS_MCP_CLK_MCLKD_MASK, divider);
13701374
cdns_updatel(cdns, CDNS_MCP_CLK_CTRL1,
13711375
CDNS_MCP_CLK_MCLKD_MASK, divider);
13721376

13731377
/* Set frame shape base on the actual bus frequency. */
1374-
if (!prop->default_frame_rate || !prop->default_row) {
1375-
dev_err(cdns->dev, "Default frame_rate %d or row %d is invalid\n",
1376-
prop->default_frame_rate, prop->default_row);
1377-
return -EINVAL;
1378-
}
1379-
1380-
prop->default_col = freq * SDW_DOUBLE_RATE_FACTOR /
1378+
prop->default_col = bus->params.curr_dr_freq /
13811379
prop->default_frame_rate / prop->default_row;
13821380

13831381
/*

0 commit comments

Comments
 (0)