Re: [PATCH v3] usb: of: add an api to get dr_mode by the phy node

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Fri, Sep 18, 2015 at 03:27:58PM -0500, Bin Liu wrote:
> Some USB phy drivers have different handling for the controller in each
> dr_mode. But the phy driver does not have visibility to the dr_mode of
> the controller.
> 
> This adds an api to return the dr_mode of the controller which
> associates the given phy node.
> 
> Signed-off-by: Bin Liu <b-liu@xxxxxx>
> ---
> v3: search controller node from dt root, as the phy and controller nodes
>     might not have the same parent.
> 
>  drivers/usb/common/common.c | 26 ++++++++++++++++++++++++++
>  include/linux/usb/of.h      |  6 ++++++
>  2 files changed, 32 insertions(+)
> 
> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> index b530fd4..fc32055 100644
> --- a/drivers/usb/common/common.c
> +++ b/drivers/usb/common/common.c
> @@ -114,6 +114,32 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
>  EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
>  
>  /**
> + * of_usb_get_dr_mode_by_phy - Get dual role mode for the controller device
> + * which is associated with the given phy device_node
> + * @np:	Pointer to the given phy device_node
> + *
> + * In dts a usb controller associates with a phy device.  The function gets
> + * the string from property 'dr_mode' of the controller associated with the
> + * given phy device node, and returns the correspondig enum usb_dr_mode.
> + */
> +enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *phy_np)
> +{
> +	struct device_node *controller = NULL;
> +	struct device_node *phy;
> +
> +	do {
> +		controller = of_find_node_with_property(controller, "phys");
> +		if (!controller)
> +			return USB_DR_MODE_UNKNOWN;
> +
> +		phy = of_parse_phandle(controller, "phys", 0);

another question: How do you know this is the USB PHY and not a SATA or
MII/GMII/RGMII, or anything else ?

-- 
balbi

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux