public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frank Wang <frank.wang@rock-chips.com>
To: "Heiko Stübner" <heiko@sntech.de>
Cc: dianders@chromium.org, kishon@ti.com, robh+dt@kernel.org,
	pawel.moll@arm.com, mark.rutland@arm.com,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-usb@vger.kernel.org, kever.yang@rock-chips.com,
	huangtao@rock-chips.com, william.wu@rock-chips.com,
	frank.wang@rock-chips.com
Subject: Re: [PATCH 2/2] phy: rockchip-inno-usb2: add a new driver for Rockchip usb2phy
Date: Thu, 2 Jun 2016 11:19:39 +0800	[thread overview]
Message-ID: <574FA5CB.5020402@rock-chips.com> (raw)
In-Reply-To: <1915363.WKK5oRy4Me@diego>

Hi Heiko,

On 06/02/2016 07:46 AM, Heiko Stübner wrote:
> Hi Frank,
>
> Am Dienstag, 31. Mai 2016, 14:40:11 schrieb Frank Wang:
>> The newer SoCs (rk3366, rk3399) take a different usb-phy IP block
>> than rk3288 and before, and most of phy-related registers are also
>> different from the past, so a new phy driver is required necessarily.
>>
>> Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
>> ---
>
> [...]
>
>> +static void rockchip_usb2phy_clk480m_disable(struct clk_hw *hw)
>> +{
>> +	struct rockchip_usb2phy *rphy =
>> +		container_of(hw, struct rockchip_usb2phy, clk480m_hw);
>> +	int index;
>> +
>> +	/* make sure all ports in suspended mode */
>> +	for (index = 0; index != rphy->phy_cfg->num_ports; index++)
>> +		if (!rphy->ports[index].suspended)
>> +			return;
>
> This function can only get called when all clk-references have disabled the
> clock, so you should never reach that point that one phy port is not
> suspended?
>

Yeah, you are right, I will clean them up in the next patches.

>> +
>> +	/* turn off 480m clk output */
>> +	property_enable(rphy, &rphy->phy_cfg->clkout_ctl, false);
>> +}
>> +
>
> [...]
>
> add something like:
>
> static void rockchip_usb2phy_clk480m_unregister(void *data)
> {
> 	struct rockchip_usb2phy *rphy = data;
>
> 	of_clk_del_provider(rphy->dev->of_node);
> 	clk_unregister(rphy->clk480m);
> }
>
>> +static struct clk *
>> +rockchip_usb2phy_clk480m_register(struct rockchip_usb2phy *rphy)
>> +{
>> +	struct device_node *node = rphy->dev->of_node;
>> +	struct clk *clk;
>> +	struct clk_init_data init;
> 	int ret;
>
>> +
>> +	init.name = "clk_usbphy_480m";
>> +	init.ops = &rockchip_usb2phy_clkout_ops;
>> +	init.flags = CLK_IS_ROOT;
>> +	init.parent_names = NULL;
>> +	init.num_parents = 0;
>> +	rphy->clk480m_hw.init = &init;
>> +
>> +	/* optional override of the clockname */
>> +	of_property_read_string(node, "clock-output-names", &init.name);
>> +
>> +	/* register the clock */
>> +	clk = clk_register(rphy->dev, &rphy->clk480m_hw);
> 	if (IS_ERR(clk))
> 		return clk:
>
> 	ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);
> 	if (ret < 0)
> 		goto err_clk_provider;
>
> 	ret = devm_add_action(rphy->dev, rockchip_usb2phy_clk480m_unregister,
> rphy);
> 	if (ret < 0)
> 		goto err_unreg_action;
>
> 	return clk;
>
> err_unreg_action:
> 	of_clk_del_provider(node);
> err_clk_provider:
> 	clk_unregister(clk);
> 	return ERR_PTR(ret);
>
>> +}
>

Good comments! Those codes will be included in the next.

> [...]
>
>> +/*
>> + * The function manage host-phy port state and suspend/resume phy port
>> + * to save power.
>> + *
>> + * we rely on utmi_linestate and utmi_hostdisconnect to identify whether
>> + * FS/HS is disconnect or not. Besides, we do not need care it is FS
>> + * disconnected or HS disconnected, actually, we just only need get the
>> + * device is disconnected at last through rearm the delayed work,
>> + * to suspend the phy port in _PHY_STATE_DISCONNECT_ case.
>> + *
>> + * NOTE: It will invoke some clk related APIs, so do not invoke it from
>> + * interrupt context.
>
> This does not seem to match the code, as I don't see any clk_* calls,

Sorry for not describing the comment clearly. In a fact, *_sm_work will 
invoke *phy_suspend or *phy_resume which will invoke some *clk APIs.

Anyway, I will correct it to be more clear.

>
>> + */
>> +static void rockchip_usb2phy_sm_work(struct work_struct *work)
>> +{
 >> +
>>  [...]
 >> +
>> +		/* fall through */
>> +	case PHY_STATE_HS_CONNECT:
>> +		if (rport->suspended) {
>> +			dev_dbg(&rport->phy->dev, "HS/FS connected\n");
>> +			rockchip_usb2phy_resume(rport->phy);
>> +			rport->suspended = false;
>> +		}
>> +		break;
>> +	case PHY_STATE_DISCONNECT:
>> +		if (!rport->suspended) {
>> +			dev_dbg(&rport->phy->dev, "HS/FS disconnected\n");
>> +			rockchip_usb2phy_suspend(rport->phy);
>> +			rport->suspended = true;
>> +		}
>>  [...]
 >> +
>> +	}
>> +
>> +next_schedule:
>> +	mutex_unlock(&rport->mutex);
>> +	schedule_delayed_work(&rport->sm_work, SCHEDULE_DELAY);
>> +}
>
> [...]
>
>> +static int rockchip_usb2phy_probe(struct platform_device *pdev)
>> +{
 >> +
 >>  [...]
 >> +
>> +
>> +	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
>> +	return PTR_ERR_OR_ZERO(provider);
>> +
>> +put_child:
>> +	of_node_put(child_np);
>
>> +	of_clk_del_provider(np);
>> +	clk_unregister(rphy->clk480m);
>
> these two can go away, once you have the devm_action described
> near your clk_register function.

Done

>
>> +	return ret;
>> +}

BR.
Frank

      reply	other threads:[~2016-06-02  3:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-31  6:40 [PATCH 0/2] Add a new Rockchip usb2 phy driver Frank Wang
2016-05-31  6:40 ` [PATCH 1/2] Documentation: bindings: add DT documentation for Rockchip USB2PHY Frank Wang
2016-05-31  9:02   ` Heiko Stübner
2016-06-01  8:09     ` Frank Wang
2016-06-01 22:17       ` Heiko Stübner
2016-06-02  2:53         ` Frank Wang
2016-06-01 22:02   ` Rob Herring
2016-05-31  6:40 ` [PATCH 2/2] phy: rockchip-inno-usb2: add a new driver for Rockchip usb2phy Frank Wang
2016-06-01 23:46   ` Heiko Stübner
2016-06-02  3:19     ` Frank Wang [this message]

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=574FA5CB.5020402@rock-chips.com \
    --to=frank.wang@rock-chips.com \
    --cc=dianders@chromium.org \
    --cc=galak@codeaurora.org \
    --cc=heiko@sntech.de \
    --cc=huangtao@rock-chips.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kever.yang@rock-chips.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=william.wu@rock-chips.com \
    /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