From: jckuo <jckuo@nvidia.com>
To: Thierry Reding <thierry.reding@gmail.com>,
Kishon Vijay Abraham I <kishon@ti.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>,
<linux-tegra@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/5] phy: tegra: xusb: Parse dual-role mode property
Date: Mon, 28 Jan 2019 15:08:59 +0800 [thread overview]
Message-ID: <339edd93-6e6f-d30b-ea6e-aa1af7a1409e@nvidia.com> (raw)
In-Reply-To: <20190125112525.10697-3-thierry.reding@gmail.com>
Reviewed-by: JC Kuo <jckuo@nvidia.com>
On 1/25/19 7:25 PM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> The device tree bindings document the "mode" property of "ports"
> subnodes, but the driver was not parsing the property. In preparation
> for adding role switching, parse the property at probe time.
>
> Based on work by JC Kuo <jckuo@nvidia.com>.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> drivers/phy/tegra/xusb.c | 21 +++++++++++++++++++++
> drivers/phy/tegra/xusb.h | 3 +++
> 2 files changed, 24 insertions(+)
>
> diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
> index e3bc60cfe6a1..57a2d08ef6da 100644
> --- a/drivers/phy/tegra/xusb.c
> +++ b/drivers/phy/tegra/xusb.c
> @@ -546,13 +546,34 @@ static void tegra_xusb_port_unregister(struct tegra_xusb_port *port)
> device_unregister(&port->dev);
> }
>
> +static const char *const modes[] = {
> + [USB_DR_MODE_UNKNOWN] = "",
> + [USB_DR_MODE_HOST] = "host",
> + [USB_DR_MODE_PERIPHERAL] = "peripheral",
> + [USB_DR_MODE_OTG] = "otg",
> +};
> +
> static int tegra_xusb_usb2_port_parse_dt(struct tegra_xusb_usb2_port *usb2)
> {
> struct tegra_xusb_port *port = &usb2->base;
> struct device_node *np = port->dev.of_node;
> + const char *mode;
>
> usb2->internal = of_property_read_bool(np, "nvidia,internal");
>
> + if (!of_property_read_string(np, "mode", &mode)) {
> + int err = match_string(modes, ARRAY_SIZE(modes), mode);
> + if (err < 0) {
> + dev_err(&port->dev, "invalid value %s for \"mode\"\n",
> + mode);
> + usb2->mode = USB_DR_MODE_UNKNOWN;
> + } else {
> + usb2->mode = err;
> + }
> + } else {
> + usb2->mode = USB_DR_MODE_HOST;
> + }
> +
> usb2->supply = devm_regulator_get(&port->dev, "vbus");
> return PTR_ERR_OR_ZERO(usb2->supply);
> }
> diff --git a/drivers/phy/tegra/xusb.h b/drivers/phy/tegra/xusb.h
> index b49dbc36efa3..bb60fc09c752 100644
> --- a/drivers/phy/tegra/xusb.h
> +++ b/drivers/phy/tegra/xusb.h
> @@ -19,6 +19,8 @@
> #include <linux/mutex.h>
> #include <linux/workqueue.h>
>
> +#include <linux/usb/otg.h>
> +
> /* legacy entry points for backwards-compatibility */
> int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev);
> int tegra_xusb_padctl_legacy_remove(struct platform_device *pdev);
> @@ -271,6 +273,7 @@ struct tegra_xusb_usb2_port {
> struct tegra_xusb_port base;
>
> struct regulator *supply;
> + enum usb_dr_mode mode;
> bool internal;
> };
>
next prev parent reply other threads:[~2019-01-28 7:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-25 11:25 [PATCH 1/5] dt-bindings: phy: tegra: Add Tegra186 support Thierry Reding
2019-01-25 11:25 ` [PATCH 2/5] phy: tegra: xusb: Skip single function lane programming Thierry Reding
2019-01-28 7:06 ` jckuo
2019-01-25 11:25 ` [PATCH 3/5] phy: tegra: xusb: Parse dual-role mode property Thierry Reding
2019-01-28 7:08 ` jckuo [this message]
2019-01-25 11:25 ` [PATCH 4/5] phy: tegra: xusb: Add support for power supplies Thierry Reding
2019-01-28 7:22 ` jckuo
2019-01-28 8:00 ` Thierry Reding
2019-01-29 6:50 ` jckuo
2019-02-05 12:55 ` Kishon Vijay Abraham I
2019-02-07 11:11 ` Thierry Reding
2019-01-25 11:25 ` [PATCH 5/5] phy: tegra: xusb: Add Tegra186 support Thierry Reding
2019-01-28 7:45 ` jckuo
2019-02-07 11:47 ` Kishon Vijay Abraham I
2019-02-07 12:17 ` Thierry Reding
2019-01-28 7:04 ` [PATCH 1/5] dt-bindings: phy: tegra: " jckuo
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=339edd93-6e6f-d30b-ea6e-aa1af7a1409e@nvidia.com \
--to=jckuo@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).