Skip to content

Commit

Permalink
fixup! soundwire: cadence_master: set frame shape and divider based o…
Browse files Browse the repository at this point in the history
…n 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 <[email protected]>
  • Loading branch information
bardliao committed Jan 10, 2025
1 parent e774004 commit 4fee098
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions drivers/soundwire/cadence_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -1352,32 +1352,30 @@ static int cdns_init_clock_ctrl(struct sdw_cdns *cdns)
u32 val;
u32 ssp_interval;
int divider;
int freq;

dev_dbg(cdns->dev, "mclk %d max %d row %d col %d\n",
prop->mclk_freq,
prop->max_clk_freq,
prop->default_row,
prop->default_col);

if (!prop->default_frame_rate || !prop->default_row) {
dev_err(cdns->dev, "Default frame_rate %d or row %d is invalid\n",
prop->default_frame_rate, prop->default_row);
return -EINVAL;
}

/* Set clock divider */
divider = (prop->mclk_freq * SDW_DOUBLE_RATE_FACTOR /
bus->params.curr_dr_freq) - 1;
freq = bus->params.curr_dr_freq >> 1;

cdns_updatel(cdns, CDNS_MCP_CLK_CTRL0,
CDNS_MCP_CLK_MCLKD_MASK, divider);
cdns_updatel(cdns, CDNS_MCP_CLK_CTRL1,
CDNS_MCP_CLK_MCLKD_MASK, divider);

/* Set frame shape base on the actual bus frequency. */
if (!prop->default_frame_rate || !prop->default_row) {
dev_err(cdns->dev, "Default frame_rate %d or row %d is invalid\n",
prop->default_frame_rate, prop->default_row);
return -EINVAL;
}

prop->default_col = freq * SDW_DOUBLE_RATE_FACTOR /
prop->default_col = bus->params.curr_dr_freq /
prop->default_frame_rate / prop->default_row;

/*
Expand Down

0 comments on commit 4fee098

Please sign in to comment.