linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: b-liu@ti.com (Bin Liu)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 6/7] phy-sun4i-usb: Add "allwinner,usb0-usb-a-connector" dt property
Date: Fri, 19 Aug 2016 16:33:12 -0500	[thread overview]
Message-ID: <20160819213312.GD1853@uda0271908> (raw)
In-Reply-To: <1471288892-21702-7-git-send-email-hdegoede@redhat.com>

Hi,

On Mon, Aug 15, 2016 at 09:21:31PM +0200, Hans de Goede wrote:
> On some devices the musb otg controller can be used in both device and
> host mode, but requires software mode switching since there is no id pin
> connected. The usb0 phy code will default to device mode in this case.
> 
> On some systems usb0 is connected to a female USB-A port. It can still
> be used in device mode when using software mode switching and a USB
> A to A cable. To configure the controller to support both modes we must
> set its "dr_mode" dt property to "otg" (*). For these setups the device
> mode default is wrong, for a female USB-A port the default should be
> host mode.
> 
> This commit adds support to the sun4i phy code for a new
> "allwinner,usb0-usb-a-connector" dt property which can be used in dt
> files to indicate this scenario and when present it changes the default
> mode to host mode.

As I commented in patch 0/7, this dt prop is unneccesary.

Regards,
-Bin.

> 
> *) dr_mode = "host" is used when device mode is _never_ used. E.g.
> a wifi module soldered onto the PCB is connected to the musb controller.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v2:
> -New patch in v2 of this patchset
> ---
>  Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt | 2 ++
>  drivers/phy/phy-sun4i-usb.c                             | 9 ++++++++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt b/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
> index 287150d..8646b53 100644
> --- a/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
> +++ b/Documentation/devicetree/bindings/phy/sun4i-usb-phy.txt
> @@ -35,6 +35,8 @@ Optional properties:
>  - usb0_vbus-supply : regulator phandle for controller usb0 vbus
>  - usb1_vbus-supply : regulator phandle for controller usb1 vbus
>  - usb2_vbus-supply : regulator phandle for controller usb2 vbus
> +- allwinner,usb0-usb-a-connector: usb0 is connected to an USB-A connector,
> +                     rather then an USB-B connector as one would expect (bool)
>  
>  Example:
>  	usbphy: phy at 0x01c13400 {
> diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
> index c17b099..82fb46a 100644
> --- a/drivers/phy/phy-sun4i-usb.c
> +++ b/drivers/phy/phy-sun4i-usb.c
> @@ -137,6 +137,7 @@ struct sun4i_usb_phy_data {
>  	int vbus_det_irq;
>  	int id_det;
>  	int vbus_det;
> +	int id_det_default;
>  	struct delayed_work detect;
>  };
>  
> @@ -328,7 +329,7 @@ static int sun4i_usb_phy0_get_id_det(struct sun4i_usb_phy_data *data)
>  		if (data->id_det_gpio)
>  			return gpiod_get_value_cansleep(data->id_det_gpio);
>  		else
> -			return 1; /* Fallback to peripheral mode */
> +			return data->id_det_default;
>  	case USB_DR_MODE_HOST:
>  		return 0;
>  	case USB_DR_MODE_PERIPHERAL:
> @@ -621,6 +622,12 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
>  	if (IS_ERR(data->base))
>  		return PTR_ERR(data->base);
>  
> +	/* Set id-det default for when there is no id-det gpio */
> +	if (of_property_read_bool(np, "allwinner,usb0-usb-a-connector"))
> +		data->id_det_default = 0; /* Host (USB-A connector) */
> +	else
> +		data->id_det_default = 1; /* Device (USB-B connector) */
> +
>  	data->id_det_gpio = devm_gpiod_get_optional(dev, "usb0_id_det",
>  						    GPIOD_IN);
>  	if (IS_ERR(data->id_det_gpio))
> -- 
> 2.7.4
> 

  reply	other threads:[~2016-08-19 21:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-15 19:21 [PATCH v2 0/7] musb: sunxi: Add support for run-time changing dr-mode through sysfs Hans de Goede
2016-08-15 19:21 ` [PATCH v2 1/7] phy-sun4i-usb: Use bool where appropriate Hans de Goede
2016-08-15 19:21 ` [PATCH v2 2/7] phy-sun4i-usb: Refactor forced session ending Hans de Goede
2016-08-15 19:21 ` [PATCH v2 3/7] phy-sun4i-usb: Simplify missing dr_mode handling Hans de Goede
2016-08-15 19:21 ` [PATCH v2 4/7] phy-sun4i-usb: Add support for phy_set_mode Hans de Goede
2016-08-16 13:48   ` Sergei Shtylyov
2016-08-16 20:01     ` Hans de Goede
2016-08-18  7:40       ` Felipe Balbi
2016-08-18  9:05         ` Hans de Goede
2016-08-18 10:17           ` Felipe Balbi
2016-08-19 13:27             ` Kishon Vijay Abraham I
2016-08-15 19:21 ` [PATCH v2 5/7] phy-sun4i-usb: Warn when external vbus is detected Hans de Goede
2016-08-15 19:21 ` [PATCH v2 6/7] phy-sun4i-usb: Add "allwinner, usb0-usb-a-connector" dt property Hans de Goede
2016-08-19 21:33   ` Bin Liu [this message]
2016-08-15 19:21 ` [PATCH v2 7/7] musb: sunxi: Add support for platform_set_mode Hans de Goede
2016-08-19 21:30   ` Bin Liu
2016-08-21 10:10     ` Hans de Goede
2016-08-22 14:11       ` Bin Liu
2016-08-22 15:08         ` Hans de Goede
2016-08-22 15:24           ` Bin Liu
2016-08-22 15:32             ` Hans de Goede
2016-08-22 15:38               ` Bin Liu
2016-08-22 15:55                 ` Hans de Goede
2016-08-22 16:10                   ` Bin Liu
2016-08-25 17:59                     ` Hans de Goede
2016-08-19 21:25 ` [PATCH v2 0/7] musb: sunxi: Add support for run-time changing dr-mode through sysfs Bin Liu
2016-08-21  9:29   ` Hans de Goede
2016-08-22 14:08     ` Bin Liu
2016-08-22 14:16       ` Bin Liu
2016-08-22 15:50       ` Hans de Goede
2016-08-22 16:03         ` Bin Liu
2016-08-22 19:16   ` Rask Ingemann Lambertsen

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=20160819213312.GD1853@uda0271908 \
    --to=b-liu@ti.com \
    --cc=linux-arm-kernel@lists.infradead.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).