diff mbox series

[1/2] usb: gadget: udc: renesas_usb3: add property "renesas, ignore-id"

Message ID 1523362434-17808-2-git-send-email-yoshihiro.shimoda.uh@renesas.com
State Changes Requested, archived
Headers show
Series usb: gadet: udc: renesas_usb3: add role switch for R-Car SoCs | expand

Commit Message

Yoshihiro Shimoda April 10, 2018, 12:13 p.m. UTC
This patch adds a new property to ignore the ID signal on a board.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 Documentation/devicetree/bindings/usb/renesas_usb3.txt |  2 ++
 drivers/usb/gadget/udc/renesas_usb3.c                  | 10 ++++++++++
 2 files changed, 12 insertions(+)

Comments

Simon Horman April 11, 2018, 7:28 a.m. UTC | #1
On Tue, Apr 10, 2018 at 09:13:53PM +0900, Yoshihiro Shimoda wrote:
> This patch adds a new property to ignore the ID signal on a board.
> 
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  Documentation/devicetree/bindings/usb/renesas_usb3.txt |  2 ++
>  drivers/usb/gadget/udc/renesas_usb3.c                  | 10 ++++++++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/usb/renesas_usb3.txt b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
> index 2c071bb..53949bd 100644
> --- a/Documentation/devicetree/bindings/usb/renesas_usb3.txt
> +++ b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
> @@ -19,6 +19,8 @@ Required properties:
>  Optional properties:
>    - phys: phandle + phy specifier pair
>    - phy-names: must be "usb"
> +  - renesas,ignore-id: when a board doesn't use ID pin, you can add this
> +		       property to ignore the ID state.
>  
>  Example of R-Car H3 ES1.x:
>  	usb3_peri0: usb@ee020000 {
> diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> index 409cde4..59e1485 100644
> --- a/drivers/usb/gadget/udc/renesas_usb3.c
> +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> @@ -350,6 +350,7 @@ struct renesas_usb3 {
>  	bool extcon_host;		/* check id and set EXTCON_USB_HOST */
>  	bool extcon_usb;		/* check vbus and set EXTCON_USB */
>  	bool forced_b_device;
> +	bool ignore_id;
>  };
>  
>  #define gadget_to_renesas_usb3(_gadget)	\
> @@ -645,6 +646,9 @@ static void usb3_check_vbus(struct renesas_usb3 *usb3)
>  
>  static void usb3_set_mode(struct renesas_usb3 *usb3, bool host)
>  {
> +	if (usb3->ignore_id && !usb3->forced_b_device)
> +		return;
> +
>  	if (host)
>  		usb3_clear_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON);
>  	else
> @@ -675,6 +679,9 @@ static void usb3_mode_config(struct renesas_usb3 *usb3, bool host, bool a_dev)
>  
>  static bool usb3_is_a_device(struct renesas_usb3 *usb3)
>  {
> +	if (usb3->ignore_id)
> +		return false;
> +
>  	return !(usb3_read(usb3, USB3_USB_OTG_STA) & USB_OTG_IDMON);
>  }
>  
> @@ -2632,6 +2639,9 @@ static int renesas_usb3_probe(struct platform_device *pdev)
>  	if (ret < 0)
>  		goto err_add_udc;
>  
> +	if (of_property_read_bool(pdev->dev.of_node, "renesas,no-id"))
> +		usb3->ignore_id = true;

I wonder if this is better expressed as:

	usb3->ignore_id = of_property_read_bool(pdev->dev.of_node,
						"renesas,no-id"));

> +
>  	ret = device_create_file(&pdev->dev, &dev_attr_role);
>  	if (ret < 0)
>  		goto err_dev_create;
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yoshihiro Shimoda April 12, 2018, 5:03 a.m. UTC | #2
Hi Simon-san,

> From: Simon Horman, Sent: Wednesday, April 11, 2018 4:28 PM
> 
> On Tue, Apr 10, 2018 at 09:13:53PM +0900, Yoshihiro Shimoda wrote:
<snip>
> > This patch adds a new property to ignore the ID signal on a board.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >  Documentation/devicetree/bindings/usb/renesas_usb3.txt |  2 ++
> >  drivers/usb/gadget/udc/renesas_usb3.c                  | 10 ++++++++++
> >  2 files changed, 12 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/usb/renesas_usb3.txt
> b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
> > index 2c071bb..53949bd 100644
> > --- a/Documentation/devicetree/bindings/usb/renesas_usb3.txt
> > +++ b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
> > @@ -19,6 +19,8 @@ Required properties:
> >  Optional properties:
> >    - phys: phandle + phy specifier pair
> >    - phy-names: must be "usb"
> > +  - renesas,ignore-id: when a board doesn't use ID pin, you can add this
> > +		       property to ignore the ID state.
> >
> >  Example of R-Car H3 ES1.x:
> >  	usb3_peri0: usb@ee020000 {
> > diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
> > index 409cde4..59e1485 100644
> > --- a/drivers/usb/gadget/udc/renesas_usb3.c
> > +++ b/drivers/usb/gadget/udc/renesas_usb3.c
> > @@ -350,6 +350,7 @@ struct renesas_usb3 {
> >  	bool extcon_host;		/* check id and set EXTCON_USB_HOST */
> >  	bool extcon_usb;		/* check vbus and set EXTCON_USB */
> >  	bool forced_b_device;
> > +	bool ignore_id;
> >  };
> >
> >  #define gadget_to_renesas_usb3(_gadget)	\
> > @@ -645,6 +646,9 @@ static void usb3_check_vbus(struct renesas_usb3 *usb3)
> >
> >  static void usb3_set_mode(struct renesas_usb3 *usb3, bool host)
> >  {
> > +	if (usb3->ignore_id && !usb3->forced_b_device)
> > +		return;
> > +
> >  	if (host)
> >  		usb3_clear_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON);
> >  	else
> > @@ -675,6 +679,9 @@ static void usb3_mode_config(struct renesas_usb3 *usb3, bool host, bool a_dev)
> >
> >  static bool usb3_is_a_device(struct renesas_usb3 *usb3)
> >  {
> > +	if (usb3->ignore_id)
> > +		return false;
> > +
> >  	return !(usb3_read(usb3, USB3_USB_OTG_STA) & USB_OTG_IDMON);
> >  }
> >
> > @@ -2632,6 +2639,9 @@ static int renesas_usb3_probe(struct platform_device *pdev)
> >  	if (ret < 0)
> >  		goto err_add_udc;
> >
> > +	if (of_property_read_bool(pdev->dev.of_node, "renesas,no-id"))
> > +		usb3->ignore_id = true;
> 
> I wonder if this is better expressed as:
> 
> 	usb3->ignore_id = of_property_read_bool(pdev->dev.of_node,
> 						"renesas,no-id"));

Thank you for the pointed out! I agree with you.
However, I would like to recall this adding property for now because
I'm thinking that the OF graph of usb-connector can assume this via connector-type
instead of such a local property. So, I'll try to use the usb-connector bindings on
this driver.

Best regards,
Yoshihiro Shimoda

> > +
> >  	ret = device_create_file(&pdev->dev, &dev_attr_role);
> >  	if (ret < 0)
> >  		goto err_dev_create;
> > --
> > 1.9.1
> >
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/usb/renesas_usb3.txt b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
index 2c071bb..53949bd 100644
--- a/Documentation/devicetree/bindings/usb/renesas_usb3.txt
+++ b/Documentation/devicetree/bindings/usb/renesas_usb3.txt
@@ -19,6 +19,8 @@  Required properties:
 Optional properties:
   - phys: phandle + phy specifier pair
   - phy-names: must be "usb"
+  - renesas,ignore-id: when a board doesn't use ID pin, you can add this
+		       property to ignore the ID state.
 
 Example of R-Car H3 ES1.x:
 	usb3_peri0: usb@ee020000 {
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
index 409cde4..59e1485 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -350,6 +350,7 @@  struct renesas_usb3 {
 	bool extcon_host;		/* check id and set EXTCON_USB_HOST */
 	bool extcon_usb;		/* check vbus and set EXTCON_USB */
 	bool forced_b_device;
+	bool ignore_id;
 };
 
 #define gadget_to_renesas_usb3(_gadget)	\
@@ -645,6 +646,9 @@  static void usb3_check_vbus(struct renesas_usb3 *usb3)
 
 static void usb3_set_mode(struct renesas_usb3 *usb3, bool host)
 {
+	if (usb3->ignore_id && !usb3->forced_b_device)
+		return;
+
 	if (host)
 		usb3_clear_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON);
 	else
@@ -675,6 +679,9 @@  static void usb3_mode_config(struct renesas_usb3 *usb3, bool host, bool a_dev)
 
 static bool usb3_is_a_device(struct renesas_usb3 *usb3)
 {
+	if (usb3->ignore_id)
+		return false;
+
 	return !(usb3_read(usb3, USB3_USB_OTG_STA) & USB_OTG_IDMON);
 }
 
@@ -2632,6 +2639,9 @@  static int renesas_usb3_probe(struct platform_device *pdev)
 	if (ret < 0)
 		goto err_add_udc;
 
+	if (of_property_read_bool(pdev->dev.of_node, "renesas,no-id"))
+		usb3->ignore_id = true;
+
 	ret = device_create_file(&pdev->dev, &dev_attr_role);
 	if (ret < 0)
 		goto err_dev_create;