From: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
To: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>,
tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org,
t-kristo-l0cyMroinI0@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: balbi-l0cyMroinI0@public.gmane.org, nsekhar-l0cyMroinI0@public.gmane.org
Subject: Re: [PATCH 7/7] phy: omap-usb2: use *syscon* framework API to power on/off the PHY
Date: Wed, 5 Aug 2015 19:51:56 +0530 [thread overview]
Message-ID: <55C21C04.9000704@ti.com> (raw)
In-Reply-To: <55C1CAE1.3060901-l0cyMroinI0@public.gmane.org>
Hi,
On Wednesday 05 August 2015 02:05 PM, Roger Quadros wrote:
> On 04/08/15 18:20, Kishon Vijay Abraham I wrote:
>> Deprecate using phy-omap-control driver to power on/off the PHY,
>> and use *syscon* framework to do the same. This handles
>> powering on/off the PHY for the USB2 PHYs used in various TI SoCs.
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>
>> ---
>> Documentation/devicetree/bindings/phy/ti-phy.txt | 6 +-
>> drivers/phy/phy-omap-usb2.c | 85 +++++++++++++++++-----
>> include/linux/phy/omap_usb.h | 23 ++++++
>> 3 files changed, 96 insertions(+), 18 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/phy/ti-phy.txt b/Documentation/devicetree/bindings/phy/ti-phy.txt
>> index a061077..a3b3945 100644
>> --- a/Documentation/devicetree/bindings/phy/ti-phy.txt
>> +++ b/Documentation/devicetree/bindings/phy/ti-phy.txt
>> @@ -42,10 +42,14 @@ Required properties:
>> * "wkupclk" - wakeup clock.
>> * "refclk" - reference clock (optional).
>>
>> -Optional properties:
>> +Deprecated properties:
>> - ctrl-module : phandle of the control module used by PHY driver to power on
>> the PHY.
>>
>> +Recommended properies:
>> +- syscon-phy-power : phandle/offset pair. Phandle to the system control
>> + module and the register offset to power on/off the PHY.
>> +
>> This is usually a subnode of ocp2scp to which it is connected.
>>
>> usb2phy@4a0ad080 {
>> diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
>> index 2f7220f..531fe04 100644
>> --- a/drivers/phy/phy-omap-usb2.c
>> +++ b/drivers/phy/phy-omap-usb2.c
>> @@ -29,6 +29,8 @@
>> #include <linux/delay.h>
>> #include <linux/phy/omap_control_phy.h>
>> #include <linux/phy/phy.h>
>> +#include <linux/mfd/syscon.h>
>> +#include <linux/regmap.h>
>> #include <linux/of_platform.h>
>>
>> #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
>> @@ -97,22 +99,40 @@ static int omap_usb_set_peripheral(struct usb_otg *otg,
>> return 0;
>> }
>>
>> -static int omap_usb_power_off(struct phy *x)
>> +static int omap_usb_phy_power(struct omap_usb *phy, int on)
>> {
>> - struct omap_usb *phy = phy_get_drvdata(x);
>> + u32 val = 0;
>
> No need to initialize val.
indeed.
>
>> + int ret;
>>
>> - omap_control_phy_power(phy->control_dev, 0);
>> + if (phy->syscon_phy_power) {
>> + if (on)
>> + val = phy->power_on;
>> + else
>> + val = phy->power_off;
>> +
>> + ret = regmap_update_bits(phy->syscon_phy_power, phy->power_reg,
>> + phy->mask, val);
>> + if (ret < 0)
>> + return ret;
>> + } else {
>> + omap_control_phy_power(phy->control_dev, on);
>> + }
>>
>> return 0;
>> }
>>
>> -static int omap_usb_power_on(struct phy *x)
>> +static int omap_usb_power_off(struct phy *x)
>> {
>> struct omap_usb *phy = phy_get_drvdata(x);
>>
>> - omap_control_phy_power(phy->control_dev, 1);
>> + return omap_usb_phy_power(phy, false);
>> +}
>>
>> - return 0;
>> +static int omap_usb_power_on(struct phy *x)
>> +{
>> + struct omap_usb *phy = phy_get_drvdata(x);
>> +
>> + return omap_usb_phy_power(phy, true);
>> }
>>
>> static int omap_usb_init(struct phy *x)
>> @@ -147,26 +167,38 @@ static struct phy_ops ops = {
>> static const struct usb_phy_data omap_usb2_data = {
>> .label = "omap_usb2",
>> .flags = OMAP_USB2_HAS_START_SRP | OMAP_USB2_HAS_SET_VBUS,
>> + .mask = OMAP_DEV_PHY_PD,
>> + .power_off = OMAP_DEV_PHY_PD,
>> };
>>
>> static const struct usb_phy_data omap5_usb2_data = {
>> .label = "omap5_usb2",
>> .flags = 0,
>> + .mask = OMAP_DEV_PHY_PD,
>> + .power_off = OMAP_DEV_PHY_PD,
>> };
>>
>> static const struct usb_phy_data dra7x_usb2_data = {
>> .label = "dra7x_usb2",
>> .flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
>> + .mask = OMAP_DEV_PHY_PD,
>> + .power_off = OMAP_DEV_PHY_PD,
>> };
>>
>> static const struct usb_phy_data dra7x_usb2_phy2_data = {
>> .label = "dra7x_usb2_phy2",
>> .flags = OMAP_USB2_CALIBRATE_FALSE_DISCONNECT,
>> + .mask = OMAP_USB2_PHY_PD,
>> + .power_off = OMAP_USB2_PHY_PD,
>> };
>>
>> static const struct usb_phy_data am437x_usb2_data = {
>> .label = "am437x_usb2",
>> .flags = 0,
>> + .mask = AM437X_USB2_PHY_PD | AM437X_USB2_OTG_PD |
>> + AM437X_USB2_OTGVDET_EN | AM437X_USB2_OTGSESSEND_EN,
>> + .power_on = AM437X_USB2_OTGVDET_EN | AM437X_USB2_OTGSESSEND_EN,
>> + .power_off = AM437X_USB2_PHY_PD | AM437X_USB2_OTG_PD,
>
> We're combining some OTG operations with PHY on/off. This is probably OK
> for now but looks like we need a OTG phy driver for this?
Yes. Once we have that we can stop using the USB PHY library from this driver.
>
>> };
>>
>> static const struct of_device_id omap_usb2_id_table[] = {
>> @@ -228,6 +260,9 @@ static int omap_usb2_probe(struct platform_device *pdev)
>> phy->phy.label = phy_data->label;
>> phy->phy.otg = otg;
>> phy->phy.type = USB_PHY_TYPE_USB2;
>> + phy->mask = phy_data->mask;
>> + phy->power_on = phy_data->power_on;
>> + phy->power_off = phy_data->power_off;
>>
>> if (phy_data->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT) {
>> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> @@ -237,20 +272,36 @@ static int omap_usb2_probe(struct platform_device *pdev)
>> phy->flags |= OMAP_USB2_CALIBRATE_FALSE_DISCONNECT;
>> }
>>
>> - control_node = of_parse_phandle(node, "ctrl-module", 0);
>> - if (!control_node) {
>> - dev_err(&pdev->dev, "Failed to get control device phandle\n");
>> - return -EINVAL;
>> - }
>> + phy->syscon_phy_power = syscon_regmap_lookup_by_phandle(node,
>> + "syscon-phy-power");
>> + if (IS_ERR(phy->syscon_phy_power)) {
>> + dev_info(&pdev->dev,
>> + "can't get syscon-phy-power, using control device\n");
>
> dev_dbg()?
okay.
>
>> + phy->syscon_phy_power = NULL;
>> +
>> + control_node = of_parse_phandle(node, "ctrl-module", 0);
>> + if (!control_node) {
>> + dev_err(&pdev->dev,
>> + "Failed to get control device phandle\n");
>> + return -EINVAL;
>> + }
>>
>> - control_pdev = of_find_device_by_node(control_node);
>> - if (!control_pdev) {
>> - dev_err(&pdev->dev, "Failed to get control device\n");
>> - return -EINVAL;
>> + control_pdev = of_find_device_by_node(control_node);
>> + if (!control_pdev) {
>> + dev_err(&pdev->dev, "Failed to get control device\n");
>> + return -EINVAL;
>> + }
>> + phy->control_dev = &control_pdev->dev;
>> + } else {
>> + if (of_property_read_u32_index(node,
>> + "syscon-phy-power", 1,
>> + &phy->power_reg)) {
>> + dev_err(&pdev->dev,
>> + "couldn't get power reg. offset\n");
>> + return -EINVAL;
>> + }
>> }
>>
>> - phy->control_dev = &control_pdev->dev;
>> -
>> otg->set_host = omap_usb_set_host;
>> otg->set_peripheral = omap_usb_set_peripheral;
>> if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
>> diff --git a/include/linux/phy/omap_usb.h b/include/linux/phy/omap_usb.h
>> index dc2c541..2e5fb87 100644
>> --- a/include/linux/phy/omap_usb.h
>> +++ b/include/linux/phy/omap_usb.h
>> @@ -30,6 +30,12 @@ struct usb_dpll_params {
>> u32 mf;
>> };
>>
>> +enum omap_usb_phy_type {
>> + TYPE_USB2, /* USB2_PHY, power down in CONTROL_DEV_CONF */
>> + TYPE_DRA7USB2, /* USB2 PHY, power and power_aux e.g. DRA7 */
>> + TYPE_AM437USB2, /* USB2 PHY, power e.g. AM437x */
>> +};
>> +
>> struct omap_usb {
>> struct usb_phy phy;
>> struct phy_companion *comparator;
>> @@ -40,11 +46,20 @@ struct omap_usb {
>> struct clk *wkupclk;
>> struct clk *optclk;
>> u8 flags;
>> + enum omap_usb_phy_type type;
>> + struct regmap *syscon_phy_power; /* ctrl. reg. acces */
>> + unsigned int power_reg; /* power reg. index within syscon */
>> + u32 mask;
>> + u32 power_on;
>> + u32 power_off;
>> };
>>
>> struct usb_phy_data {
>> const char *label;
>> u8 flags;
>> + u32 mask;
>> + u32 power_on;
>> + u32 power_off;
>> };
>>
>> /* Driver Flags */
>> @@ -52,6 +67,14 @@ struct usb_phy_data {
>> #define OMAP_USB2_HAS_SET_VBUS (1 << 1)
>> #define OMAP_USB2_CALIBRATE_FALSE_DISCONNECT (1 << 2)
>>
>> +#define OMAP_DEV_PHY_PD BIT(0)
>> +#define OMAP_USB2_PHY_PD BIT(28)
>> +
>> +#define AM437X_USB2_PHY_PD BIT(0)
>> +#define AM437X_USB2_OTG_PD BIT(1)
>> +#define AM437X_USB2_OTGVDET_EN BIT(19)
>> +#define AM437X_USB2_OTGSESSEND_EN BIT(20)
>> +
>
> Is all this used by anyone other than the phy driver?
> If not we should move whatever possible into the .c file.
>
> Could be a separate patch of course.
sure.
Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2015-08-05 14:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 15:20 [PATCH 0/7] phy: use syscon framework APIs to set ctrl mod reg Kishon Vijay Abraham I
2015-08-04 15:20 ` [PATCH 1/7] phy: ti-pipe3: cleanup ti_pipe3_probe() Kishon Vijay Abraham I
[not found] ` <1438701646-7876-2-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-08-04 16:00 ` Felipe Balbi
[not found] ` <20150804160028.GG23659-HgARHv6XitJaoMGHk7MhZQC/G2K4zDHf@public.gmane.org>
2015-08-05 14:08 ` Kishon Vijay Abraham I
2015-08-04 15:20 ` [PATCH 2/7] phy: ti-pipe3: use ti_pipe3_power_off to power off the PHY during probe Kishon Vijay Abraham I
2015-08-04 16:06 ` Felipe Balbi
[not found] ` <20150804160631.GH23659-HgARHv6XitJaoMGHk7MhZQC/G2K4zDHf@public.gmane.org>
2015-08-05 14:12 ` Kishon Vijay Abraham I
2015-08-05 15:35 ` Felipe Balbi
2015-08-04 15:20 ` [PATCH 3/7] phy: ti-pipe3: use *syscon* framework API to power on/off the PHY Kishon Vijay Abraham I
[not found] ` <1438701646-7876-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-08-04 15:20 ` [PATCH 4/7] phy: ti-pipe3: use *syscon* framework API to set PCS value of " Kishon Vijay Abraham I
2015-08-04 15:20 ` [PATCH 5/7] phy: omap-usb2: use omap_usb_power_off to power off the PHY during probe Kishon Vijay Abraham I
2015-08-04 16:07 ` Felipe Balbi
2015-08-04 15:20 ` [PATCH 6/7] phy: omap-usb2: Add a new compatible string for USB2 PHY2 Kishon Vijay Abraham I
[not found] ` <1438701646-7876-7-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2015-08-05 8:23 ` Roger Quadros
2015-08-05 8:25 ` Roger Quadros
2015-08-05 14:18 ` Kishon Vijay Abraham I
2015-08-07 8:27 ` Roger Quadros
2015-08-04 15:20 ` [PATCH 7/7] phy: omap-usb2: use *syscon* framework API to power on/off the PHY Kishon Vijay Abraham I
2015-08-05 8:35 ` Roger Quadros
[not found] ` <55C1CAE1.3060901-l0cyMroinI0@public.gmane.org>
2015-08-05 14:21 ` Kishon Vijay Abraham I [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=55C21C04.9000704@ti.com \
--to=kishon-l0cymroini0@public.gmane.org \
--cc=balbi-l0cyMroinI0@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nsekhar-l0cyMroinI0@public.gmane.org \
--cc=rogerq-l0cyMroinI0@public.gmane.org \
--cc=t-kristo-l0cyMroinI0@public.gmane.org \
--cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.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).