LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon@ti.com>
To: Swapnil Jakhade <sjakhade@cadence.com>, <vkoul@kernel.org>,
	<robh+dt@kernel.org>, <linux-phy@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>
Cc: <mparab@cadence.com>, <lokeshvutla@ti.com>, <a-govindraju@ti.com>
Subject: Re: [PATCH 3/5] phy: cadence-torrent: Add support for derived reference clock output
Date: Wed, 15 Sep 2021 09:25:47 +0530	[thread overview]
Message-ID: <48b7b8c0-5550-623f-ae28-caf99b17cee3@ti.com> (raw)
In-Reply-To: <20210908182628.28364-4-sjakhade@cadence.com>

Hi Swapnil,

On 08/09/21 11:56 pm, Swapnil Jakhade wrote:
> Update the reference clock driver implementation where cmn_refclk_<p/m>
> is configured to output the reference clock. cmn_refclk_p/m will output
> either derived or received reference clock based on the selection. So,
> all these clocks should be modelled separately. Model the derived
> reference clock here as a first step to support reference clock driver.
> 

Will AM64 work after this patch? Since you are removing bunch of configurations
here, would it affect git bisectability?

Thanks
Kishon

> Signed-off-by: Swapnil Jakhade <sjakhade@cadence.com>
> ---
>  drivers/phy/cadence/phy-cadence-torrent.c | 78 +++++++++--------------
>  1 file changed, 31 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c
> index ecb1aa883c05..6dceb12e88c4 100644
> --- a/drivers/phy/cadence/phy-cadence-torrent.c
> +++ b/drivers/phy/cadence/phy-cadence-torrent.c
> @@ -235,10 +235,11 @@
>  #define PHY_PMA_CMN_CTRL2		0x0001U
>  #define PHY_PMA_PLL_RAW_CTRL		0x0003U
>  
> -#define CDNS_TORRENT_OUTPUT_CLOCKS	1
> +#define CDNS_TORRENT_OUTPUT_CLOCKS	2
>  
>  static const char * const clk_names[] = {
>  	[CDNS_TORRENT_REFCLK_DRIVER] = "refclk-driver",
> +	[CDNS_TORRENT_DERIVED_REFCLK] = "refclk-der",
>  };
>  
>  static const struct reg_field phy_pll_cfg =
> @@ -261,23 +262,8 @@ static const struct reg_field phy_pcs_iso_link_ctrl_1 =
>  
>  static const struct reg_field phy_pipe_cmn_ctrl1_0 = REG_FIELD(PHY_PIPE_CMN_CTRL1, 0, 0);
>  
> -#define REFCLK_OUT_NUM_CMN_CONFIG	5
> -
> -enum cdns_torrent_refclk_out_cmn {
> -	CMN_CDIAG_REFCLK_OVRD_4,
> -	CMN_CDIAG_REFCLK_DRV0_CTRL_1,
> -	CMN_CDIAG_REFCLK_DRV0_CTRL_4,
> -	CMN_CDIAG_REFCLK_DRV0_CTRL_5,
> -	CMN_CDIAG_REFCLK_DRV0_CTRL_6,
> -};
> -
> -static const struct reg_field refclk_out_cmn_cfg[] = {
> -	[CMN_CDIAG_REFCLK_OVRD_4]	= REG_FIELD(CMN_CDIAG_REFCLK_OVRD, 4, 4),
> -	[CMN_CDIAG_REFCLK_DRV0_CTRL_1]	= REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 1, 1),
> -	[CMN_CDIAG_REFCLK_DRV0_CTRL_4]	= REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 4, 4),
> -	[CMN_CDIAG_REFCLK_DRV0_CTRL_5]  = REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 5, 5),
> -	[CMN_CDIAG_REFCLK_DRV0_CTRL_6]	= REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 6, 6),
> -};
> +static const struct reg_field cmn_cdiag_refclk_ovrd_4 =
> +				REG_FIELD(CMN_CDIAG_REFCLK_OVRD, 4, 4);
>  
>  enum cdns_torrent_phy_type {
>  	TYPE_NONE,
> @@ -330,6 +316,8 @@ struct cdns_torrent_phy {
>  	struct regmap *regmap_phy_pcs_lane_cdb[MAX_NUM_LANES];
>  	struct regmap *regmap_dptx_phy_reg;
>  	struct regmap_field *phy_pll_cfg;
> +	struct regmap_field *phy_pipe_cmn_ctrl1_0;
> +	struct regmap_field *cmn_cdiag_refclk_ovrd_4;
>  	struct regmap_field *phy_pma_cmn_ctrl_1;
>  	struct regmap_field *phy_pma_cmn_ctrl_2;
>  	struct regmap_field *phy_pma_pll_raw_ctrl;
> @@ -348,7 +336,7 @@ enum phy_powerstate {
>  struct cdns_torrent_derived_refclk {
>  	struct clk_hw		hw;
>  	struct regmap_field	*phy_pipe_cmn_ctrl1_0;
> -	struct regmap_field	*cmn_fields[REFCLK_OUT_NUM_CMN_CONFIG];
> +	struct regmap_field	*cmn_cdiag_refclk_ovrd_4;
>  	struct clk_init_data	clk_data;
>  };
>  
> @@ -1618,11 +1606,7 @@ static int cdns_torrent_derived_refclk_enable(struct clk_hw *hw)
>  {
>  	struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
>  
> -	regmap_field_write(derived_refclk->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_6], 0);
> -	regmap_field_write(derived_refclk->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], 1);
> -	regmap_field_write(derived_refclk->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_5], 1);
> -	regmap_field_write(derived_refclk->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 0);
> -	regmap_field_write(derived_refclk->cmn_fields[CMN_CDIAG_REFCLK_OVRD_4], 1);
> +	regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 1);
>  	regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 1);
>  
>  	return 0;
> @@ -1633,6 +1617,7 @@ static void cdns_torrent_derived_refclk_disable(struct clk_hw *hw)
>  	struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
>  
>  	regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 0);
> +	regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 0);
>  }
>  
>  static int cdns_torrent_derived_refclk_is_enabled(struct clk_hw *hw)
> @@ -1640,7 +1625,7 @@ static int cdns_torrent_derived_refclk_is_enabled(struct clk_hw *hw)
>  	struct cdns_torrent_derived_refclk *derived_refclk = to_cdns_torrent_derived_refclk(hw);
>  	int val;
>  
> -	regmap_field_read(derived_refclk->phy_pipe_cmn_ctrl1_0, &val);
> +	regmap_field_read(derived_refclk->cmn_cdiag_refclk_ovrd_4, &val);
>  
>  	return !!val;
>  }
> @@ -1655,21 +1640,19 @@ static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_ph
>  {
>  	struct cdns_torrent_derived_refclk *derived_refclk;
>  	struct device *dev = cdns_phy->dev;
> -	struct regmap_field *field;
>  	struct clk_init_data *init;
>  	const char *parent_name;
> -	struct regmap *regmap;
>  	char clk_name[100];
>  	struct clk_hw *hw;
>  	struct clk *clk;
> -	int i, ret;
> +	int ret;
>  
>  	derived_refclk = devm_kzalloc(dev, sizeof(*derived_refclk), GFP_KERNEL);
>  	if (!derived_refclk)
>  		return -ENOMEM;
>  
>  	snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev),
> -		 clk_names[CDNS_TORRENT_REFCLK_DRIVER]);
> +		 clk_names[CDNS_TORRENT_DERIVED_REFCLK]);
>  
>  	clk = devm_clk_get_optional(dev, "phy_en_refclk");
>  	if (IS_ERR(clk)) {
> @@ -1688,23 +1671,8 @@ static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_ph
>  	init->flags = 0;
>  	init->name = clk_name;
>  
> -	regmap = cdns_phy->regmap_phy_pcs_common_cdb;
> -	field = devm_regmap_field_alloc(dev, regmap, phy_pipe_cmn_ctrl1_0);
> -	if (IS_ERR(field)) {
> -		dev_err(dev, "phy_pipe_cmn_ctrl1_0 reg field init failed\n");
> -		return PTR_ERR(field);
> -	}
> -	derived_refclk->phy_pipe_cmn_ctrl1_0 = field;
> -
> -	regmap = cdns_phy->regmap_common_cdb;
> -	for (i = 0; i < REFCLK_OUT_NUM_CMN_CONFIG; i++) {
> -		field = devm_regmap_field_alloc(dev, regmap, refclk_out_cmn_cfg[i]);
> -		if (IS_ERR(field)) {
> -			dev_err(dev, "CMN reg field init failed\n");
> -			return PTR_ERR(field);
> -		}
> -		derived_refclk->cmn_fields[i] = field;
> -	}
> +	derived_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0;
> +	derived_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4;
>  
>  	derived_refclk->hw.init = init;
>  
> @@ -1713,7 +1681,7 @@ static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_ph
>  	if (ret)
>  		return ret;
>  
> -	cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER] = hw;
> +	cdns_phy->clk_hw_data->hws[CDNS_TORRENT_DERIVED_REFCLK] = hw;
>  
>  	return 0;
>  }
> @@ -1768,6 +1736,22 @@ static int cdns_torrent_regfield_init(struct cdns_torrent_phy *cdns_phy)
>  	}
>  	cdns_phy->phy_pll_cfg = field;
>  
> +	regmap = cdns_phy->regmap_phy_pcs_common_cdb;
> +	field = devm_regmap_field_alloc(dev, regmap, phy_pipe_cmn_ctrl1_0);
> +	if (IS_ERR(field)) {
> +		dev_err(dev, "phy_pipe_cmn_ctrl1_0 reg field init failed\n");
> +		return PTR_ERR(field);
> +	}
> +	cdns_phy->phy_pipe_cmn_ctrl1_0 = field;
> +
> +	regmap = cdns_phy->regmap_common_cdb;
> +	field = devm_regmap_field_alloc(dev, regmap, cmn_cdiag_refclk_ovrd_4);
> +	if (IS_ERR(field)) {
> +		dev_err(dev, "cmn_cdiag_refclk_ovrd_4 reg field init failed\n");
> +		return PTR_ERR(field);
> +	}
> +	cdns_phy->cmn_cdiag_refclk_ovrd_4 = field;
> +
>  	regmap = cdns_phy->regmap_phy_pma_common_cdb;
>  	field = devm_regmap_field_alloc(dev, regmap, phy_pma_cmn_ctrl_1);
>  	if (IS_ERR(field)) {
> 

  reply	other threads:[~2021-09-15  3:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 18:26 [PATCH 0/5] PHY: Add support to output derived and received reference clock from Torrent Swapnil Jakhade
2021-09-08 18:26 ` [PATCH 1/5] phy: cadence-torrent: Migrate to clk_hw based registration and OF APIs Swapnil Jakhade
2021-09-15  3:51   ` Kishon Vijay Abraham I
2021-09-08 18:26 ` [PATCH 2/5] dt-bindings: phy: cadence-torrent: Add clock IDs for derived and received refclk Swapnil Jakhade
2021-09-21 17:10   ` Rob Herring
2021-09-08 18:26 ` [PATCH 3/5] phy: cadence-torrent: Add support for derived reference clock output Swapnil Jakhade
2021-09-15  3:55   ` Kishon Vijay Abraham I [this message]
2021-09-08 18:26 ` [PATCH 4/5] phy: cadence-torrent: Add support for received " Swapnil Jakhade
2021-09-08 18:26 ` [PATCH 5/5] phy: cadence-torrent: Model reference clock driver as a gate and mux clock Swapnil Jakhade

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=48b7b8c0-5550-623f-ae28-caf99b17cee3@ti.com \
    --to=kishon@ti.com \
    --cc=a-govindraju@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=lokeshvutla@ti.com \
    --cc=mparab@cadence.com \
    --cc=robh+dt@kernel.org \
    --cc=sjakhade@cadence.com \
    --cc=vkoul@kernel.org \
    --subject='Re: [PATCH 3/5] phy: cadence-torrent: Add support for derived reference clock output' \
    /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

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).