Commit 3859872f authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Vinod Koul

soundwire: cadence_master: make use of mclk_freq property

Now that the prototype and Intel implementation are enabled, use this
property to avoid hard-coded values.

For example for ICL the mclk_freq value is 38.4 MHz while on CNL/CML
it's 24 MHz. The mclk_freq should not be confused with the
max_clk_freq, which si the maximum bus clock. The mclk_freq is
typically tied to the oscillator frequency and does not change between
platforms. The max_clk_freq value is linked to the maximum bandwidth
needed and topology/trace length.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20190806005522.22642-13-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 085f4ace
...@@ -174,8 +174,6 @@ ...@@ -174,8 +174,6 @@
#define CDNS_PDI_CONFIG_PORT GENMASK(4, 0) #define CDNS_PDI_CONFIG_PORT GENMASK(4, 0)
/* Driver defaults */ /* Driver defaults */
#define CDNS_DEFAULT_CLK_DIVIDER 0
#define CDNS_DEFAULT_SSP_INTERVAL 0x18 #define CDNS_DEFAULT_SSP_INTERVAL 0x18
#define CDNS_TX_TIMEOUT 2000 #define CDNS_TX_TIMEOUT 2000
...@@ -828,7 +826,10 @@ static u32 cdns_set_initial_frame_shape(int n_rows, int n_cols) ...@@ -828,7 +826,10 @@ static u32 cdns_set_initial_frame_shape(int n_rows, int n_cols)
*/ */
int sdw_cdns_init(struct sdw_cdns *cdns) int sdw_cdns_init(struct sdw_cdns *cdns)
{ {
struct sdw_bus *bus = &cdns->bus;
struct sdw_master_prop *prop = &bus->prop;
u32 val; u32 val;
int divider;
int ret; int ret;
/* Exit clock stop */ /* Exit clock stop */
...@@ -840,9 +841,11 @@ int sdw_cdns_init(struct sdw_cdns *cdns) ...@@ -840,9 +841,11 @@ int sdw_cdns_init(struct sdw_cdns *cdns)
} }
/* Set clock divider */ /* Set clock divider */
divider = (prop->mclk_freq / prop->max_clk_freq) - 1;
val = cdns_readl(cdns, CDNS_MCP_CLK_CTRL0); val = cdns_readl(cdns, CDNS_MCP_CLK_CTRL0);
val |= CDNS_DEFAULT_CLK_DIVIDER; val |= divider;
cdns_writel(cdns, CDNS_MCP_CLK_CTRL0, val); cdns_writel(cdns, CDNS_MCP_CLK_CTRL0, val);
cdns_writel(cdns, CDNS_MCP_CLK_CTRL1, val);
/* /*
* Frame shape changes after initialization have to be done * Frame shape changes after initialization have to be done
...@@ -890,6 +893,7 @@ EXPORT_SYMBOL(sdw_cdns_init); ...@@ -890,6 +893,7 @@ EXPORT_SYMBOL(sdw_cdns_init);
int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params) int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params)
{ {
struct sdw_master_prop *prop = &bus->prop;
struct sdw_cdns *cdns = bus_to_cdns(bus); struct sdw_cdns *cdns = bus_to_cdns(bus);
int mcp_clkctrl_off, mcp_clkctrl; int mcp_clkctrl_off, mcp_clkctrl;
int divider; int divider;
...@@ -899,7 +903,9 @@ int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params) ...@@ -899,7 +903,9 @@ int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params)
return -EINVAL; return -EINVAL;
} }
divider = (params->max_dr_freq / params->curr_dr_freq) - 1; divider = prop->mclk_freq * SDW_DOUBLE_RATE_FACTOR /
params->curr_dr_freq;
divider--; /* divider is 1/(N+1) */
if (params->next_bank) if (params->next_bank)
mcp_clkctrl_off = CDNS_MCP_CLK_CTRL1; mcp_clkctrl_off = CDNS_MCP_CLK_CTRL1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment