linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org,
	vkoul@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com,
	srinivas.kandagatla@linaro.org, Blauciak@vger.kernel.org,
	Slawomir <slawomir.blauciak@intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Sanyog Kale <sanyog.r.kale@intel.com>
Subject: [PATCH 12/17] soundwire: cadence_master: make use of mclk_freq property
Date: Mon,  5 Aug 2019 19:55:17 -0500	[thread overview]
Message-ID: <20190806005522.22642-13-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20190806005522.22642-1-pierre-louis.bossart@linux.intel.com>

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: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 drivers/soundwire/cadence_master.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
index 89c55e4bb72c..049ecfad2c00 100644
--- a/drivers/soundwire/cadence_master.c
+++ b/drivers/soundwire/cadence_master.c
@@ -175,8 +175,6 @@
 #define CDNS_PDI_CONFIG_PORT			GENMASK(4, 0)
 
 /* Driver defaults */
-
-#define CDNS_DEFAULT_CLK_DIVIDER		0
 #define CDNS_DEFAULT_SSP_INTERVAL		0x18
 #define CDNS_TX_TIMEOUT				2000
 
@@ -922,7 +920,10 @@ static u32 cdns_set_initial_frame_shape(int n_rows, int n_cols)
  */
 int sdw_cdns_init(struct sdw_cdns *cdns)
 {
+	struct sdw_bus *bus = &cdns->bus;
+	struct sdw_master_prop *prop = &bus->prop;
 	u32 val;
+	int divider;
 	int ret;
 
 	/* Exit clock stop */
@@ -934,9 +935,11 @@ int sdw_cdns_init(struct sdw_cdns *cdns)
 	}
 
 	/* Set clock divider */
+	divider	= (prop->mclk_freq / prop->max_clk_freq) - 1;
 	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_CTRL1, val);
 
 	/*
 	 * Frame shape changes after initialization have to be done
@@ -984,6 +987,7 @@ EXPORT_SYMBOL(sdw_cdns_init);
 
 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);
 	int mcp_clkctrl_off, mcp_clkctrl;
 	int divider;
@@ -993,7 +997,9 @@ int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params)
 		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)
 		mcp_clkctrl_off = CDNS_MCP_CLK_CTRL1;
-- 
2.20.1


  parent reply	other threads:[~2019-08-06  0:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06  0:55 [PATCH 00/17] soundwire: fixes for 5.4 Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 01/17] soundwire: intel: prevent possible dereference in hw_params Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 02/17] soundwire: intel: fix channel number reported by hardware Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 03/17] soundwire: cadence_master: revisit interrupt settings Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 04/17] soundwire: bus: improve dynamic debug comments for enumeration Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 05/17] soundwire: export helpers to find row and column values Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 06/17] soundwire: cadence_master: use firmware defaults for frame shape Pierre-Louis Bossart
2019-08-06 15:27   ` Cezary Rojewski
2019-08-06 15:36     ` [alsa-devel] " Pierre-Louis Bossart
2019-08-06 16:06       ` Cezary Rojewski
2019-08-14  4:31         ` Vinod Koul
2019-08-14 14:03           ` Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 07/17] soundwire: include mod_devicetable.h to avoid compiling warnings Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 08/17] soundwire: stream: fix disable sequence Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 09/17] soundwire: stream: remove unnecessary variable initializations Pierre-Louis Bossart
2019-08-06 15:31   ` Cezary Rojewski
2019-08-06 15:39     ` Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 10/17] soundwire: add new mclk_freq field for properties Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 11/17] soundwire: intel: read mclk_freq property from firmware Pierre-Louis Bossart
2019-08-06  0:55 ` Pierre-Louis Bossart [this message]
2019-08-06  0:55 ` [PATCH 13/17] soundwire: cadence_master: fix divider setting in clock register Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 14/17] soundwire: intel: handle disabled links Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 15/17] soundwire: intel_init: add kernel module parameter to filter out links Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 16/17] soundwire: cadence_master: add kernel parameter to override interrupt mask Pierre-Louis Bossart
2019-08-06  0:55 ` [PATCH 17/17] soundwire: intel: move shutdown() callback and don't export symbol Pierre-Louis Bossart
2019-08-21  9:07 ` [PATCH 00/17] soundwire: fixes for 5.4 Vinod Koul
2019-08-21 14:03   ` [alsa-devel] " Pierre-Louis Bossart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190806005522.22642-13-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=Blauciak@vger.kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jank@cadence.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sanyog.r.kale@intel.com \
    --cc=slawomir.blauciak@intel.com \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.de \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).