devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shawn Guo <shawn.guo@linaro.org>
To: Vinod Koul <vkoul@kernel.org>
Cc: Kishon Vijay Abraham I <kishon@ti.com>,
	Rob Herring <robh+dt@kernel.org>,
	Sriharsha Allenki <sallenki@codeaurora.org>,
	Anu Ramanathan <anur@codeaurora.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] phy: qualcomm: Add Synopsys High-Speed USB PHY driver
Date: Fri, 9 Nov 2018 14:52:28 +0800	[thread overview]
Message-ID: <20181109065226.GB20049@tiger> (raw)
In-Reply-To: <20181109052217.GL12092@vkoul-mobl>

On Fri, Nov 09, 2018 at 10:52:17AM +0530, Vinod Koul wrote:
> On 08-11-18, 15:04, Shawn Guo wrote:
> > +static int qcom_snps_hsphy_config_regulators(struct hsphy_priv *priv, int high)
> > +{
> > +	int min, ret, i;
> > +
> > +	min = high ? 1 : 0; /* low or none? */
> > +
> > +	for (i = 0; i < VREG_NUM; i++) {
> > +		ret = regulator_set_voltage(priv->vregs[i].consumer,
> > +					    priv->voltages[i][min],
> > +					    priv->voltages[i][VOL_MAX]);
> > +		if (ret)
> > +			return ret;
> 
> should we not roll back the set voltages on error?

Yes.  I will get that handled in v2.  Thanks.

> 
> > +static int qcom_snps_hsphy_por_reset(struct hsphy_priv *priv)
> > +{
> > +	int ret;
> > +
> > +	ret = reset_control_assert(priv->por_reset);
> > +	if (ret)
> > +		return ret;
> > +
> > +	/*
> > +	 * The Femto PHY is POR reset in the following scenarios.
> 
> POR?

Hmm, I do not understand this comment.  The POR is commonly used as the
abbrev of power-on-reset.  What do you meat exactly?

> 
> > +static int qcom_snps_hsphy_init(struct phy *phy)
> > +{
> > +	struct hsphy_priv *priv = phy_get_drvdata(phy);
> > +	int state;
> > +	int ret;
> 
> perhaps they can be in a single line :)

I prefer to keep them on separate line, as that makes the addition and
removal of one of them relatively easier.

> 
> > +static int qcom_snps_hsphy_probe(struct platform_device *pdev)
> > +{
> > +	struct device *dev = &pdev->dev;
> > +	struct phy_provider *provider;
> > +	struct hsphy_priv *priv;
> > +	struct resource *res;
> > +	struct phy *phy;
> > +	int size;
> > +	int ret;
> > +	int i;
> > +
> > +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> > +	if (!priv)
> > +		return -ENOMEM;
> > +
> > +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	priv->base = devm_ioremap_resource(dev, res);
> > +	if (IS_ERR(priv->base))
> > +		return PTR_ERR(priv->base);
> > +
> > +	priv->num_clks = ARRAY_SIZE(qcom_snps_hsphy_clks);
> > +	priv->clks = devm_kcalloc(dev, priv->num_clks, sizeof(*priv->clks),
> > +				  GFP_KERNEL);
> > +	if (!priv->clks)
> > +		return -ENOMEM;
> > +
> > +	for (i = 0; i < priv->num_clks; i++)
> > +		priv->clks[i].id = qcom_snps_hsphy_clks[i];
> > +
> > +	ret = devm_clk_bulk_get(dev, priv->num_clks, priv->clks);
> > +	if (ret)
> > +		return ret;
> > +
> > +	priv->phy_reset = devm_reset_control_get(dev, "phy");
> > +	if (IS_ERR(priv->phy_reset))
> > +		return PTR_ERR(priv->phy_reset);
> > +
> > +	priv->por_reset = devm_reset_control_get(dev, "por");
> > +	if (IS_ERR(priv->por_reset))
> > +		return PTR_ERR(priv->por_reset);
> > +
> > +	priv->vregs[VDD].supply = "vdd";
> > +	priv->vregs[VDDA_1P8].supply = "vdda1p8";
> > +	priv->vregs[VDDA_3P3].supply = "vdda3p3";
> > +
> > +	ret = devm_regulator_bulk_get(dev, VREG_NUM, priv->vregs);
> > +	if (ret)
> > +		return ret;
> > +
> > +	priv->voltages[VDDA_1P8][VOL_NONE] = 0;
> > +	priv->voltages[VDDA_1P8][VOL_MIN] = 1800000;
> > +	priv->voltages[VDDA_1P8][VOL_MAX] = 1800000;
> > +
> > +	priv->voltages[VDDA_3P3][VOL_NONE] = 0;
> > +	priv->voltages[VDDA_3P3][VOL_MIN] = 3050000;
> > +	priv->voltages[VDDA_3P3][VOL_MAX] = 3300000;
> > +
> > +	ret = of_property_read_u32_array(dev->of_node, "qcom,vdd-voltage-level",
> > +					 priv->voltages[VDD], VOL_NUM);
> > +	if (ret) {
> > +		dev_err(dev, "failed to read qcom,vdd-voltage-level\n");
> > +		return ret;
> > +	}
> > +
> > +	size = of_property_count_u32_elems(dev->of_node, "qcom,init-seq");
> > +	if (size < 0)
> > +		size = 0;
> > +
> > +	priv->init_seq = devm_kcalloc(dev, (size / 3) + 1,
> 
> size/3? I think it would be good to add a common explaining this

The property is a sequence of <offset value delay> tuples, and we are
figuring out how many tuples are there.  Yep, I will add a comment in
there for v2.

Shawn

  reply	other threads:[~2018-11-09  6:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-08  7:04 [PATCH 0/2] Add Synopsys High-Speed USB PHY driver for Qualcomm SoCs Shawn Guo
2018-11-08  7:04 ` [PATCH 1/2] dt-bindings: phy: Add Qualcomm Synopsys High-Speed USB PHY binding Shawn Guo
2018-11-09  5:08   ` Vinod Koul
2018-11-09  6:31     ` Shawn Guo
2018-11-09 11:06       ` Vinod Koul
2018-11-12 19:24   ` Rob Herring
2018-11-13  3:42     ` Shawn Guo
2018-11-13  4:59       ` Shawn Guo
2018-11-17 15:13       ` Rob Herring
2018-11-19  6:55         ` Shawn Guo
2018-11-19  7:10           ` Vivek Gautam
2018-11-19  9:15             ` Shawn Guo
2018-11-08  7:04 ` [PATCH 2/2] phy: qualcomm: Add Synopsys High-Speed USB PHY driver Shawn Guo
2018-11-09  5:22   ` Vinod Koul
2018-11-09  6:52     ` Shawn Guo [this message]
2018-11-09 11:08       ` Vinod Koul

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=20181109065226.GB20049@tiger \
    --to=shawn.guo@linaro.org \
    --cc=anur@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kishon@ti.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sallenki@codeaurora.org \
    --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).