From: Peter Chen <hzpeterchen@gmail.com>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: stern@rowland.harvard.edu, gregkh@linuxfoundation.org,
robh+dt@kernel.org, mark.rutland@arm.com,
linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH v2 1/2] usb: of: add functions to bind a companion controller
Date: Tue, 28 Feb 2017 09:03:42 +0800 [thread overview]
Message-ID: <20170228010341.GA1235@b29397-desktop> (raw)
In-Reply-To: <1487674788-12599-2-git-send-email-yoshihiro.shimoda.uh@renesas.com>
On Tue, Feb 21, 2017 at 07:59:47PM +0900, Yoshihiro Shimoda wrote:
> EHCI controllers will have a companion controller. However, on platform
> bus, there was difficult to bind them in previous code. So, this
> patch adds helper functions to bind them using a "companion" property.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
> Documentation/devicetree/bindings/usb/generic.txt | 1 +
> drivers/usb/core/of.c | 23 +++++++++++++++++++++++
> include/linux/usb/of.h | 5 +++++
> 3 files changed, 29 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt
> index bfadeb1..0a74ab8 100644
> --- a/Documentation/devicetree/bindings/usb/generic.txt
> +++ b/Documentation/devicetree/bindings/usb/generic.txt
> @@ -22,6 +22,7 @@ Optional properties:
> property is used if any real OTG features(HNP/SRP/ADP)
> is enabled, if ADP is required, otg-rev should be
> 0x0200 or above.
> + - companion: phandle of a companion
> - hnp-disable: tells OTG controllers we want to disable OTG HNP, normally HNP
> is the basic function of real OTG except you want it
> to be a srp-capable only B device.
> diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c
> index 3de4f88..d787f19 100644
> --- a/drivers/usb/core/of.c
> +++ b/drivers/usb/core/of.c
> @@ -18,6 +18,7 @@
> */
>
> #include <linux/of.h>
> +#include <linux/of_platform.h>
> #include <linux/usb/of.h>
>
> /**
> @@ -46,3 +47,25 @@ struct device_node *usb_of_get_child_node(struct device_node *parent,
> }
> EXPORT_SYMBOL_GPL(usb_of_get_child_node);
>
> +/**
> + * usb_of_get_companion_dev - Find the companion device
> + * @dev: the device pointer to find a companion
> + *
> + * Find the companion device from platform bus.
> + *
> + * Return: On success, a pointer to the companion device, %NULL on failure.
> + */
> +struct device *usb_of_get_companion_dev(struct device *dev)
> +{
> + struct device_node *node;
> + struct platform_device *pdev = NULL;
> +
> + node = of_parse_phandle(dev->of_node, "companion", 0);
> + if (node)
> + pdev = of_find_device_by_node(node);
> +
> + of_node_put(node);
> +
> + return pdev ? &pdev->dev : NULL;
> +}
> +EXPORT_SYMBOL_GPL(usb_of_get_companion_dev);
> diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
> index 5ff9032..4031f47 100644
> --- a/include/linux/usb/of.h
> +++ b/include/linux/usb/of.h
> @@ -18,6 +18,7 @@ int of_usb_update_otg_caps(struct device_node *np,
> struct usb_otg_caps *otg_caps);
> struct device_node *usb_of_get_child_node(struct device_node *parent,
> int portnum);
> +struct device *usb_of_get_companion_dev(struct device *dev);
> #else
> static inline enum usb_dr_mode
> of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0)
> @@ -38,6 +39,10 @@ static inline int of_usb_update_otg_caps(struct device_node *np,
> {
> return NULL;
> }
> +static inline struct device *usb_of_get_companion_dev(struct device *dev)
> +{
> + return NULL;
> +}
> #endif
>
> #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT)
Acked-by: Peter Chen <peter.chen@nxp.com>
--
Best Regards,
Peter Chen
next prev parent reply other threads:[~2017-02-28 1:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-21 10:59 [PATCH v2 0/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume Yoshihiro Shimoda
2017-02-21 10:59 ` [PATCH v2 1/2] usb: of: add functions to bind a companion controller Yoshihiro Shimoda
2017-02-27 20:50 ` Rob Herring
2017-02-28 1:03 ` Peter Chen [this message]
[not found] ` <1487674788-12599-1-git-send-email-yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2017-02-21 10:59 ` [PATCH v2 2/2] usb: host: ehci-platform: fix usb 1.1 device is not connected in system resume Yoshihiro Shimoda
2017-02-28 1:04 ` Peter Chen
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=20170228010341.GA1235@b29397-desktop \
--to=hzpeterchen@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=yoshihiro.shimoda.uh@renesas.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).