public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <niklas.cassel@linaro.org>
To: Matthias Kaehlcke <mka@chromium.org>
Cc: Rob Clark <robdclark@gmail.com>, David Airlie <airlied@linux.ie>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Andy Gross <andy.gross@linaro.org>,
	David Brown <david.brown@linaro.org>,
	Archit Taneja <architt@codeaurora.org>,
	Sean Paul <seanpaul@chromium.org>,
	Rajesh Yadav <ryadav@codeaurora.org>,
	Douglas Anderson <dianders@chromium.org>,
	Stephen Boyd <swboyd@chromium.org>,
	Jeykumar Sankaran <jsanka@codeaurora.org>,
	linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
	freedreno@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 3/8] drm/msm/dsi: 28nm PHY: Get ref clock from the DT
Date: Wed, 12 Dec 2018 23:07:17 +0100	[thread overview]
Message-ID: <20181212220717.GA16710@centauri.lan> (raw)
In-Reply-To: <20181204224234.62619-4-mka@chromium.org>

On Tue, Dec 04, 2018 at 02:42:29PM -0800, Matthias Kaehlcke wrote:
> Get the ref clock of the PHY from the device tree instead of
> hardcoding its name and rate.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
> Changes in v4:
> - always use parent rate in dsi_pll_28nm_clk_set_rate() and
>    dsi_pll_28nm_clk_recalc_rate()
> - pass name of VCO ref clock to pll_28nm_register() instead of
>   storing it in a struct field
> - updated commit message
> 
> Changes in v3:
> - use default name and rate if the ref clock is not specified
>   in the DT
> - store vco_ref_clk_name instead of vco_ref_clk
> - dsi_pll_28nm_clk_set_rate: changed data type of ref_clk_rate to
>   unsigned long
> - fixed check for EPROBE_DEFER
> - renamed VCO_REF_CLK_RATE to VCO_REF_CLK_DEFAULT_RATE
> 
> Changes in v2:
> - patch added to the series
> ---
>  drivers/gpu/drm/msm/dsi/pll/dsi_pll_28nm.c | 36 +++++++++++++++-------
>  1 file changed, 25 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_28nm.c b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_28nm.c
> index 26e3a01a99c2b..7777340b03e8d 100644
> --- a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_28nm.c
> +++ b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_28nm.c
> @@ -40,7 +40,6 @@
>  
>  #define NUM_PROVIDED_CLKS		2
>  
> -#define VCO_REF_CLK_RATE		19200000
>  #define VCO_MIN_RATE			350000000
>  #define VCO_MAX_RATE			750000000
>  
> @@ -166,17 +165,17 @@ static int dsi_pll_28nm_clk_set_rate(struct clk_hw *hw, unsigned long rate,
>  	pll_write(base + REG_DSI_28nm_PHY_PLL_LPFC1_CFG, 0x70);
>  	pll_write(base + REG_DSI_28nm_PHY_PLL_LPFC2_CFG, 0x15);
>  
> -	rem = rate % VCO_REF_CLK_RATE;
> +	rem = rate % parent_rate;
>  	if (rem) {
>  		refclk_cfg = DSI_28nm_PHY_PLL_REFCLK_CFG_DBLR;
>  		frac_n_mode = 1;
> -		div_fbx1000 = rate / (VCO_REF_CLK_RATE / 500);
> -		gen_vco_clk = div_fbx1000 * (VCO_REF_CLK_RATE / 500);
> +		div_fbx1000 = rate / (parent_rate / 500);
> +		gen_vco_clk = div_fbx1000 * (parent_rate / 500);
>  	} else {
>  		refclk_cfg = 0x0;
>  		frac_n_mode = 0;
> -		div_fbx1000 = rate / (VCO_REF_CLK_RATE / 1000);
> -		gen_vco_clk = div_fbx1000 * (VCO_REF_CLK_RATE / 1000);
> +		div_fbx1000 = rate / (parent_rate / 1000);
> +		gen_vco_clk = div_fbx1000 * (parent_rate / 1000);
>  	}
>  
>  	DBG("refclk_cfg = %d", refclk_cfg);
> @@ -265,7 +264,7 @@ static unsigned long dsi_pll_28nm_clk_recalc_rate(struct clk_hw *hw,
>  	void __iomem *base = pll_28nm->mmio;
>  	u32 sdm0, doubler, sdm_byp_div;
>  	u32 sdm_dc_off, sdm_freq_seed, sdm2, sdm3;
> -	u32 ref_clk = VCO_REF_CLK_RATE;
> +	u32 ref_clk = parent_rate;
>  	unsigned long vco_rate;
>  
>  	VERB("parent_rate=%lu", parent_rate);
> @@ -273,7 +272,7 @@ static unsigned long dsi_pll_28nm_clk_recalc_rate(struct clk_hw *hw,
>  	/* Check to see if the ref clk doubler is enabled */
>  	doubler = pll_read(base + REG_DSI_28nm_PHY_PLL_REFCLK_CFG) &
>  			DSI_28nm_PHY_PLL_REFCLK_CFG_DBLR;
> -	ref_clk += (doubler * VCO_REF_CLK_RATE);
> +	ref_clk += (doubler * ref_clk);
>  
>  	/* see if it is integer mode or sdm mode */
>  	sdm0 = pll_read(base + REG_DSI_28nm_PHY_PLL_SDM_CFG0);
> @@ -514,11 +513,12 @@ static void dsi_pll_28nm_destroy(struct msm_dsi_pll *pll)
>  	pll_28nm->clk_data.clk_num = 0;
>  }
>  
> -static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm)
> +static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm,
> +			     const char *ref_clk_name)
>  {
>  	char clk_name[32], parent1[32], parent2[32], vco_name[32];
>  	struct clk_init_data vco_init = {
> -		.parent_names = (const char *[]){ "xo" },
> +		.parent_names = &ref_clk_name,
>  		.num_parents = 1,
>  		.name = vco_name,
>  		.flags = CLK_IGNORE_UNUSED,
> @@ -593,6 +593,8 @@ struct msm_dsi_pll *msm_dsi_pll_28nm_init(struct platform_device *pdev,
>  {
>  	struct dsi_pll_28nm *pll_28nm;
>  	struct msm_dsi_pll *pll;
> +	struct clk *vco_ref_clk;
> +	const char *vco_ref_clk_name;
>  	int ret;
>  
>  	if (!pdev)
> @@ -605,6 +607,18 @@ struct msm_dsi_pll *msm_dsi_pll_28nm_init(struct platform_device *pdev,
>  	pll_28nm->pdev = pdev;
>  	pll_28nm->id = id;
>  
> +	vco_ref_clk = devm_clk_get(&pdev->dev, "ref");
> +	if (!IS_ERR(vco_ref_clk)) {
> +		vco_ref_clk_name = __clk_get_name(vco_ref_clk);
> +	} else {
> +		ret = PTR_ERR(vco_ref_clk);
> +		if (ret == -EPROBE_DEFER)
> +			ERR_PTR(ret);

It looks like you are missing the return keyword here.

> +
> +		dev_warn(&pdev->dev, "'ref' clock is not specified, using default name\n");
> +		vco_ref_clk_name = "xo";
> +	}
> +
>  	pll_28nm->mmio = msm_ioremap(pdev, "dsi_pll", "DSI_PLL");
>  	if (IS_ERR_OR_NULL(pll_28nm->mmio)) {
>  		dev_err(&pdev->dev, "%s: failed to map pll base\n", __func__);
> @@ -637,7 +651,7 @@ struct msm_dsi_pll *msm_dsi_pll_28nm_init(struct platform_device *pdev,
>  		return ERR_PTR(-EINVAL);
>  	}
>  
> -	ret = pll_28nm_register(pll_28nm);
> +	ret = pll_28nm_register(pll_28nm, vco_ref_clk_name);
>  	if (ret) {
>  		dev_err(&pdev->dev, "failed to register PLL: %d\n", ret);
>  		return ERR_PTR(ret);
> -- 
> 2.20.0.rc1.387.gf8505762e3-goog
> 

  parent reply	other threads:[~2018-12-12 22:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04 22:42 [PATCH v4 0/8] drm/msm/dsi: Get PHY ref clocks from the DT Matthias Kaehlcke
2018-12-04 22:42 ` [PATCH v4 1/8] dt-bindings: msm/dsi: Add ref clock for PHYs Matthias Kaehlcke
2018-12-07 23:18   ` Rob Herring
2018-12-04 22:42 ` [PATCH v4 2/8] drm/msm/dsi: 28nm 8960 PHY: Get ref clock from the DT Matthias Kaehlcke
2018-12-10 15:47   ` Stephen Boyd
2018-12-04 22:42 ` [PATCH v4 3/8] drm/msm/dsi: 28nm " Matthias Kaehlcke
2018-12-10 15:48   ` Stephen Boyd
2018-12-12 22:07   ` Niklas Cassel [this message]
2018-12-19 20:57     ` Matthias Kaehlcke
2018-12-04 22:42 ` [PATCH v4 4/8] drm/msm/dsi: 14nm " Matthias Kaehlcke
2018-12-10 15:51   ` Stephen Boyd
2018-12-19 22:22     ` Matthias Kaehlcke
2018-12-19 22:32       ` Stephen Boyd
2018-12-04 22:42 ` [PATCH v4 5/8] drm/msm/dsi: 10nm " Matthias Kaehlcke
2018-12-10 15:52   ` Stephen Boyd
2018-12-04 22:42 ` [PATCH v4 6/8] arm64: dts: qcom: msm8916: Set 'xo_board' as ref clock of the DSI PHY Matthias Kaehlcke
2018-12-04 22:42 ` [PATCH v4 7/8] arm64: dts: sdm845: Set 'bi_tcxo' as ref clock of the DSI PHYs Matthias Kaehlcke
2018-12-04 22:42 ` [PATCH v4 8/8] ARM: dts: qcom-apq8064: Set 'xo_board' as ref clock of the DSI PHY Matthias Kaehlcke

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=20181212220717.GA16710@centauri.lan \
    --to=niklas.cassel@linaro.org \
    --cc=airlied@linux.ie \
    --cc=andy.gross@linaro.org \
    --cc=architt@codeaurora.org \
    --cc=david.brown@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jsanka@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mka@chromium.org \
    --cc=robdclark@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=ryadav@codeaurora.org \
    --cc=seanpaul@chromium.org \
    --cc=swboyd@chromium.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