* [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree binding document
2019-09-04 8:15 [PATCH RESEND v7 0/3] Add USB3.0 and TI HD3SS3220 driver support Biju Das
@ 2019-09-04 8:15 ` Biju Das
2020-07-15 8:43 ` Geert Uytterhoeven
2019-09-04 8:15 ` [PATCH RESEND v7 2/3] usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller Biju Das
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Biju Das @ 2019-09-04 8:15 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, Yoshihiro Shimoda, Greg Kroah-Hartman
Cc: Biju Das, Heikki Krogerus, Felipe Balbi, linux-usb, devicetree,
Simon Horman, Geert Uytterhoeven, Chris Paterson,
Fabrizio Castro, linux-renesas-soc
Add device tree binding document for TI HD3SS3220 Type-C DRP port
controller driver.
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
V7--> V7 RESEND
* Added Rob's Reviewed by tag.
v6-->V7
* Removed Rob's reviewed by tag, since there is a rework
* Incorporated Sergie and Shimoda-San's review comment
(https://patchwork.kernel.org/patch/10944629/)
V5-->V6
* No change.
V4-->V5
* No Change.
V3-->V4
* No Change.
V2-->V3
* Added Rob's Reviewed by tag.
V1-->V2
* Added connector node.
* updated the example with connector node.
---
.../devicetree/bindings/usb/ti,hd3ss3220.txt | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 Documentation/devicetree/bindings/usb/ti,hd3ss3220.txt
diff --git a/Documentation/devicetree/bindings/usb/ti,hd3ss3220.txt b/Documentation/devicetree/bindings/usb/ti,hd3ss3220.txt
new file mode 100644
index 0000000..25780e9
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ti,hd3ss3220.txt
@@ -0,0 +1,38 @@
+TI HD3SS3220 TypeC DRP Port Controller.
+
+Required properties:
+ - compatible: Must be "ti,hd3ss3220".
+ - reg: I2C slave address, must be 0x47 or 0x67 based on ADDR pin.
+ - interrupts: An interrupt specifier.
+
+Required sub-node:
+ - connector: The "usb-c-connector" attached to the hd3ss3220 chip. The
+ bindings of the connector node are specified in:
+
+ Documentation/devicetree/bindings/connector/usb-connector.txt
+
+Example:
+hd3ss3220@47 {
+ compatible = "ti,hd3ss3220";
+ reg = <0x47>;
+ interrupt-parent = <&gpio6>;
+ interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+
+ connector {
+ compatible = "usb-c-connector";
+ label = "USB-C";
+ data-role = "dual";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@1 {
+ reg = <1>;
+ hd3ss3220_ep: endpoint {
+ remote-endpoint = <&usb3_role_switch>;
+ };
+ };
+ };
+ };
+};
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree binding document
2019-09-04 8:15 ` [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree binding document Biju Das
@ 2020-07-15 8:43 ` Geert Uytterhoeven
2020-07-15 9:04 ` Prabhakar Mahadev Lad
2020-07-15 11:42 ` Biju Das
0 siblings, 2 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2020-07-15 8:43 UTC (permalink / raw)
To: Biju Das
Cc: Rob Herring, Mark Rutland, Yoshihiro Shimoda, Greg Kroah-Hartman,
Heikki Krogerus, Felipe Balbi, USB list,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Simon Horman, Geert Uytterhoeven, Chris Paterson,
Fabrizio Castro, Linux-Renesas, Lad, Prabhakar
Hi Biju,
On Wed, Sep 4, 2019 at 10:22 AM Biju Das <biju.das@bp.renesas.com> wrote:
> Add device tree binding document for TI HD3SS3220 Type-C DRP port
> controller driver.
>
> Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> Reviewed-by: Rob Herring <robh@kernel.org>
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/ti,hd3ss3220.txt
> @@ -0,0 +1,38 @@
> +TI HD3SS3220 TypeC DRP Port Controller.
> +
> +Required properties:
> + - compatible: Must be "ti,hd3ss3220".
> + - reg: I2C slave address, must be 0x47 or 0x67 based on ADDR pin.
> + - interrupts: An interrupt specifier.
> +
> +Required sub-node:
> + - connector: The "usb-c-connector" attached to the hd3ss3220 chip. The
> + bindings of the connector node are specified in:
> +
> + Documentation/devicetree/bindings/connector/usb-connector.txt
> +
> +Example:
> +hd3ss3220@47 {
> + compatible = "ti,hd3ss3220";
> + reg = <0x47>;
> + interrupt-parent = <&gpio6>;
> + interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
> +
> + connector {
> + compatible = "usb-c-connector";
> + label = "USB-C";
> + data-role = "dual";
> +
> + ports {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + port@1 {
This does not comply with
Documentation/devicetree/bindings/connector/usb-connector.yaml:
connector: ports: 'port@0' is a required property
> + reg = <1>;
> + hd3ss3220_ep: endpoint {
> + remote-endpoint = <&usb3_role_switch>;
> + };
> + };
> + };
> + };
> +};
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree binding document
2020-07-15 8:43 ` Geert Uytterhoeven
@ 2020-07-15 9:04 ` Prabhakar Mahadev Lad
2020-07-15 11:42 ` Biju Das
1 sibling, 0 replies; 10+ messages in thread
From: Prabhakar Mahadev Lad @ 2020-07-15 9:04 UTC (permalink / raw)
To: Biju Das, Geert Uytterhoeven
Cc: Rob Herring, Mark Rutland, Yoshihiro Shimoda, Greg Kroah-Hartman,
Heikki Krogerus, Felipe Balbi, USB list,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Simon Horman, Geert Uytterhoeven, Chris Paterson,
Fabrizio Castro, Linux-Renesas
+Biju.
> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: 15 July 2020 09:44
> To: Biju Das <biju.das@bp.renesas.com>
> Cc: Rob Herring <robh+dt@kernel.org>; Mark Rutland <mark.rutland@arm.com>; Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com>; Greg Kroah-Hartman <gregkh@linuxfoundation.org>; Heikki Krogerus
> <heikki.krogerus@linux.intel.com>; Felipe Balbi <balbi@kernel.org>; USB list <linux-usb@vger.kernel.org>; open list:OPEN FIRMWARE AND
> FLATTENED DEVICE TREE BINDINGS <devicetree@vger.kernel.org>; Simon Horman <horms@verge.net.au>; Geert Uytterhoeven
> <geert+renesas@glider.be>; Chris Paterson <Chris.Paterson2@renesas.com>; Fabrizio Castro <fabrizio.castro@bp.renesas.com>; Linux-
> Renesas <linux-renesas-soc@vger.kernel.org>; Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Subject: Re: [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree binding document
>
> Hi Biju,
>
> On Wed, Sep 4, 2019 at 10:22 AM Biju Das <biju.das@bp.renesas.com> wrote:
> > Add device tree binding document for TI HD3SS3220 Type-C DRP port
> > controller driver.
> >
> > Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> > Reviewed-by: Rob Herring <robh@kernel.org>
>
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/usb/ti,hd3ss3220.txt
> > @@ -0,0 +1,38 @@
> > +TI HD3SS3220 TypeC DRP Port Controller.
> > +
> > +Required properties:
> > + - compatible: Must be "ti,hd3ss3220".
> > + - reg: I2C slave address, must be 0x47 or 0x67 based on ADDR pin.
> > + - interrupts: An interrupt specifier.
> > +
> > +Required sub-node:
> > + - connector: The "usb-c-connector" attached to the hd3ss3220 chip. The
> > + bindings of the connector node are specified in:
> > +
> > + Documentation/devicetree/bindings/connector/usb-connector.txt
> > +
> > +Example:
> > +hd3ss3220@47 {
> > + compatible = "ti,hd3ss3220";
> > + reg = <0x47>;
> > + interrupt-parent = <&gpio6>;
> > + interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
> > +
> > + connector {
> > + compatible = "usb-c-connector";
> > + label = "USB-C";
> > + data-role = "dual";
> > +
> > + ports {
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + port@1 {
>
> This does not comply with
> Documentation/devicetree/bindings/connector/usb-connector.yaml:
>
> connector: ports: 'port@0' is a required property
>
> > + reg = <1>;
> > + hd3ss3220_ep: endpoint {
> > + remote-endpoint = <&usb3_role_switch>;
> > + };
> > + };
> > + };
> > + };
> > +};
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree binding document
2020-07-15 8:43 ` Geert Uytterhoeven
2020-07-15 9:04 ` Prabhakar Mahadev Lad
@ 2020-07-15 11:42 ` Biju Das
2020-07-15 15:37 ` Geert Uytterhoeven
1 sibling, 1 reply; 10+ messages in thread
From: Biju Das @ 2020-07-15 11:42 UTC (permalink / raw)
To: Geert Uytterhoeven, Biju Das, Biju Das, Prabhakar Mahadev Lad
Cc: Rob Herring, Mark Rutland, Yoshihiro Shimoda, Greg Kroah-Hartman,
Heikki Krogerus, Felipe Balbi, USB list,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Simon Horman, Geert Uytterhoeven, Chris Paterson,
Fabrizio Castro, Linux-Renesas, Prabhakar Mahadev Lad
Hi Geert,
Thanks for the feedback.
> Subject: Re: [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree
> binding document
>
> Hi Biju,
>
> On Wed, Sep 4, 2019 at 10:22 AM Biju Das <biju.das@bp.renesas.com>
> wrote:
> > Add device tree binding document for TI HD3SS3220 Type-C DRP port
> > controller driver.
> >
> > Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> > Reviewed-by: Rob Herring <robh@kernel.org>
>
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/usb/ti,hd3ss3220.txt
> > @@ -0,0 +1,38 @@
> > +TI HD3SS3220 TypeC DRP Port Controller.
> > +
> > +Required properties:
> > + - compatible: Must be "ti,hd3ss3220".
> > + - reg: I2C slave address, must be 0x47 or 0x67 based on ADDR pin.
> > + - interrupts: An interrupt specifier.
> > +
> > +Required sub-node:
> > + - connector: The "usb-c-connector" attached to the hd3ss3220 chip. The
> > + bindings of the connector node are specified in:
> > +
> > + Documentation/devicetree/bindings/connector/usb-connector.txt
> > +
> > +Example:
> > +hd3ss3220@47 {
> > + compatible = "ti,hd3ss3220";
> > + reg = <0x47>;
> > + interrupt-parent = <&gpio6>;
> > + interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
> > +
> > + connector {
> > + compatible = "usb-c-connector";
> > + label = "USB-C";
> > + data-role = "dual";
> > +
> > + ports {
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + port@1 {
>
> This does not comply with
> Documentation/devicetree/bindings/connector/usb-connector.yaml:
>
> connector: ports: 'port@0' is a required property
But in RZ/G2E case, the connector is a SS capable connector. May be we need to update required property
as port@0 or port@1? Please let me know
- required:
- - port@0
+ anyOf:
+ - required:
+ - port@0
+ - required:
+ - port@1
Regards,
Biju
> > + reg = <1>;
> > + hd3ss3220_ep: endpoint {
> > + remote-endpoint = <&usb3_role_switch>;
> > + };
> > + };
> > + };
> > + };
> > +};
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-
> m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree binding document
2020-07-15 11:42 ` Biju Das
@ 2020-07-15 15:37 ` Geert Uytterhoeven
0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2020-07-15 15:37 UTC (permalink / raw)
To: Biju Das
Cc: Biju Das, Prabhakar Mahadev Lad, Rob Herring, Mark Rutland,
Yoshihiro Shimoda, Greg Kroah-Hartman, Heikki Krogerus,
Felipe Balbi, USB list,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Simon Horman, Geert Uytterhoeven, Chris Paterson,
Fabrizio Castro, Linux-Renesas
Hi Biju,
On Wed, Jul 15, 2020 at 1:42 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> > Subject: Re: [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree
> > binding document
> >
> > On Wed, Sep 4, 2019 at 10:22 AM Biju Das <biju.das@bp.renesas.com>
> > wrote:
> > > Add device tree binding document for TI HD3SS3220 Type-C DRP port
> > > controller driver.
> > >
> > > Signed-off-by: Biju Das <biju.das@bp.renesas.com>
> > > Reviewed-by: Rob Herring <robh@kernel.org>
> >
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/usb/ti,hd3ss3220.txt
> > > @@ -0,0 +1,38 @@
> > > +TI HD3SS3220 TypeC DRP Port Controller.
> > > +
> > > +Required properties:
> > > + - compatible: Must be "ti,hd3ss3220".
> > > + - reg: I2C slave address, must be 0x47 or 0x67 based on ADDR pin.
> > > + - interrupts: An interrupt specifier.
> > > +
> > > +Required sub-node:
> > > + - connector: The "usb-c-connector" attached to the hd3ss3220 chip. The
> > > + bindings of the connector node are specified in:
> > > +
> > > + Documentation/devicetree/bindings/connector/usb-connector.txt
> > > +
> > > +Example:
> > > +hd3ss3220@47 {
> > > + compatible = "ti,hd3ss3220";
> > > + reg = <0x47>;
> > > + interrupt-parent = <&gpio6>;
> > > + interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
> > > +
> > > + connector {
> > > + compatible = "usb-c-connector";
> > > + label = "USB-C";
> > > + data-role = "dual";
> > > +
> > > + ports {
> > > + #address-cells = <1>;
> > > + #size-cells = <0>;
> > > +
> > > + port@1 {
> >
> > This does not comply with
> > Documentation/devicetree/bindings/connector/usb-connector.yaml:
> >
> > connector: ports: 'port@0' is a required property
>
> But in RZ/G2E case, the connector is a SS capable connector. May be we need to update required property
> as port@0 or port@1? Please let me know
>
> - required:
> - - port@0
> + anyOf:
> + - required:
> + - port@0
> + - required:
> + - port@1
May make sense.
I'd like to defer to the USB experts, though.
> > > + reg = <1>;
> > > + hd3ss3220_ep: endpoint {
> > > + remote-endpoint = <&usb3_role_switch>;
> > > + };
> > > + };
> > > + };
> > > + };
> > > +};
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH RESEND v7 2/3] usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller
2019-09-04 8:15 [PATCH RESEND v7 0/3] Add USB3.0 and TI HD3SS3220 driver support Biju Das
2019-09-04 8:15 ` [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree binding document Biju Das
@ 2019-09-04 8:15 ` Biju Das
2019-09-04 8:15 ` [PATCH RESEND v7 3/3] dt-bindings: usb: renesas_usb3: Document usb role switch support Biju Das
2019-10-03 13:06 ` [PATCH RESEND v7 0/3] Add USB3.0 and TI HD3SS3220 driver support Biju Das
3 siblings, 0 replies; 10+ messages in thread
From: Biju Das @ 2019-09-04 8:15 UTC (permalink / raw)
To: Heikki Krogerus, Matthias Brugger, Greg Kroah-Hartman, Rob Herring
Cc: Biju Das, Felipe Balbi, Chunfeng Yun, linux-usb, Simon Horman,
Yoshihiro Shimoda, Geert Uytterhoeven, Chris Paterson,
Fabrizio Castro, linux-renesas-soc
Driver for TI HD3SS3220 USB Type-C DRP port controller.
The driver currently registers the port and supports data role swapping.
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
V7 --> V7 RESEND
* Added Heikki's Acked-by tag
(https://patchwork.kernel.org/patch/10969911/)
V6-->V7
* Rebased on below patch
(https://patchwork.kernel.org/patch/10966313/)
* Removed Heikki's reviewed by tag,since there is a rework.
V5-->V6
* No change
V4-->V5
* Incorporated Heikki's review comment
(https://patchwork.kernel.org/patch/10902531/)
* Added Heikki's Reviewed-by tag
V3-->V4
* Incorporated Chunfeng Yun's review comment
* Used fwnode API's to get usb role switch handle.
V2-->V3
* Used the new api "usb_role_switch by node" for getting
remote endpoint associated with Type-C USB DRP port
controller devices.
V1-->V2
* Driver uses usb role class instead of extcon for dual role switch
and also handles connect/disconnect events.
---
drivers/usb/typec/Kconfig | 10 ++
drivers/usb/typec/Makefile | 1 +
drivers/usb/typec/hd3ss3220.c | 259 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 270 insertions(+)
create mode 100644 drivers/usb/typec/hd3ss3220.c
diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
index 895e241..aceb2af 100644
--- a/drivers/usb/typec/Kconfig
+++ b/drivers/usb/typec/Kconfig
@@ -50,6 +50,16 @@ source "drivers/usb/typec/tcpm/Kconfig"
source "drivers/usb/typec/ucsi/Kconfig"
+config TYPEC_HD3SS3220
+ tristate "TI HD3SS3220 Type-C DRP Port controller driver"
+ depends on I2C
+ help
+ Say Y or M here if your system has TI HD3SS3220 Type-C DRP Port
+ controller driver.
+
+ If you choose to build this driver as a dynamically linked module, the
+ module will be called hd3ss3220.ko.
+
config TYPEC_TPS6598X
tristate "TI TPS6598x USB Power Delivery controller driver"
depends on I2C
diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
index 6696b72..7753a5c3 100644
--- a/drivers/usb/typec/Makefile
+++ b/drivers/usb/typec/Makefile
@@ -4,5 +4,6 @@ typec-y := class.o mux.o bus.o
obj-$(CONFIG_TYPEC) += altmodes/
obj-$(CONFIG_TYPEC_TCPM) += tcpm/
obj-$(CONFIG_TYPEC_UCSI) += ucsi/
+obj-$(CONFIG_TYPEC_HD3SS3220) += hd3ss3220.o
obj-$(CONFIG_TYPEC_TPS6598X) += tps6598x.o
obj-$(CONFIG_TYPEC) += mux/
diff --git a/drivers/usb/typec/hd3ss3220.c b/drivers/usb/typec/hd3ss3220.c
new file mode 100644
index 0000000..b8f247e
--- /dev/null
+++ b/drivers/usb/typec/hd3ss3220.c
@@ -0,0 +1,259 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * TI HD3SS3220 Type-C DRP Port Controller Driver
+ *
+ * Copyright (C) 2019 Renesas Electronics Corp.
+ */
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/usb/role.h>
+#include <linux/irqreturn.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/usb/typec.h>
+#include <linux/delay.h>
+
+#define HD3SS3220_REG_CN_STAT_CTRL 0x09
+#define HD3SS3220_REG_GEN_CTRL 0x0A
+#define HD3SS3220_REG_DEV_REV 0xA0
+
+/* Register HD3SS3220_REG_CN_STAT_CTRL*/
+#define HD3SS3220_REG_CN_STAT_CTRL_ATTACHED_STATE_MASK (BIT(7) | BIT(6))
+#define HD3SS3220_REG_CN_STAT_CTRL_AS_DFP BIT(6)
+#define HD3SS3220_REG_CN_STAT_CTRL_AS_UFP BIT(7)
+#define HD3SS3220_REG_CN_STAT_CTRL_TO_ACCESSORY (BIT(7) | BIT(6))
+#define HD3SS3220_REG_CN_STAT_CTRL_INT_STATUS BIT(4)
+
+/* Register HD3SS3220_REG_GEN_CTRL*/
+#define HD3SS3220_REG_GEN_CTRL_SRC_PREF_MASK (BIT(2) | BIT(1))
+#define HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_DEFAULT 0x00
+#define HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_TRY_SNK BIT(1)
+#define HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_TRY_SRC (BIT(2) | BIT(1))
+
+struct hd3ss3220 {
+ struct device *dev;
+ struct regmap *regmap;
+ struct usb_role_switch *role_sw;
+ struct typec_port *port;
+ struct typec_capability typec_cap;
+};
+
+static int hd3ss3220_set_source_pref(struct hd3ss3220 *hd3ss3220, int src_pref)
+{
+ return regmap_update_bits(hd3ss3220->regmap, HD3SS3220_REG_GEN_CTRL,
+ HD3SS3220_REG_GEN_CTRL_SRC_PREF_MASK,
+ src_pref);
+}
+
+static enum usb_role hd3ss3220_get_attached_state(struct hd3ss3220 *hd3ss3220)
+{
+ unsigned int reg_val;
+ enum usb_role attached_state;
+ int ret;
+
+ ret = regmap_read(hd3ss3220->regmap, HD3SS3220_REG_CN_STAT_CTRL,
+ ®_val);
+ if (ret < 0)
+ return ret;
+
+ switch (reg_val & HD3SS3220_REG_CN_STAT_CTRL_ATTACHED_STATE_MASK) {
+ case HD3SS3220_REG_CN_STAT_CTRL_AS_DFP:
+ attached_state = USB_ROLE_HOST;
+ break;
+ case HD3SS3220_REG_CN_STAT_CTRL_AS_UFP:
+ attached_state = USB_ROLE_DEVICE;
+ break;
+ default:
+ attached_state = USB_ROLE_NONE;
+ break;
+ }
+
+ return attached_state;
+}
+
+static int hd3ss3220_dr_set(const struct typec_capability *cap,
+ enum typec_data_role role)
+{
+ struct hd3ss3220 *hd3ss3220 = container_of(cap, struct hd3ss3220,
+ typec_cap);
+ enum usb_role role_val;
+ int pref, ret = 0;
+
+ if (role == TYPEC_HOST) {
+ role_val = USB_ROLE_HOST;
+ pref = HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_TRY_SRC;
+ } else {
+ role_val = USB_ROLE_DEVICE;
+ pref = HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_TRY_SNK;
+ }
+
+ ret = hd3ss3220_set_source_pref(hd3ss3220, pref);
+ usleep_range(10, 100);
+
+ usb_role_switch_set_role(hd3ss3220->role_sw, role_val);
+ typec_set_data_role(hd3ss3220->port, role);
+
+ return ret;
+}
+
+static void hd3ss3220_set_role(struct hd3ss3220 *hd3ss3220)
+{
+ enum usb_role role_state = hd3ss3220_get_attached_state(hd3ss3220);
+
+ usb_role_switch_set_role(hd3ss3220->role_sw, role_state);
+ if (role_state == USB_ROLE_NONE)
+ hd3ss3220_set_source_pref(hd3ss3220,
+ HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_DEFAULT);
+
+ switch (role_state) {
+ case USB_ROLE_HOST:
+ typec_set_data_role(hd3ss3220->port, TYPEC_HOST);
+ break;
+ case USB_ROLE_DEVICE:
+ typec_set_data_role(hd3ss3220->port, TYPEC_DEVICE);
+ break;
+ default:
+ break;
+ }
+}
+
+irqreturn_t hd3ss3220_irq(struct hd3ss3220 *hd3ss3220)
+{
+ int err;
+
+ hd3ss3220_set_role(hd3ss3220);
+ err = regmap_update_bits_base(hd3ss3220->regmap,
+ HD3SS3220_REG_CN_STAT_CTRL,
+ HD3SS3220_REG_CN_STAT_CTRL_INT_STATUS,
+ HD3SS3220_REG_CN_STAT_CTRL_INT_STATUS,
+ NULL, false, true);
+ if (err < 0)
+ return IRQ_NONE;
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t hd3ss3220_irq_handler(int irq, void *data)
+{
+ struct i2c_client *client = to_i2c_client(data);
+ struct hd3ss3220 *hd3ss3220 = i2c_get_clientdata(client);
+
+ return hd3ss3220_irq(hd3ss3220);
+}
+
+static const struct regmap_config config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = 0x0A,
+};
+
+static int hd3ss3220_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct hd3ss3220 *hd3ss3220;
+ struct fwnode_handle *connector;
+ int ret;
+ unsigned int data;
+
+ hd3ss3220 = devm_kzalloc(&client->dev, sizeof(struct hd3ss3220),
+ GFP_KERNEL);
+ if (!hd3ss3220)
+ return -ENOMEM;
+
+ i2c_set_clientdata(client, hd3ss3220);
+
+ hd3ss3220->dev = &client->dev;
+ hd3ss3220->regmap = devm_regmap_init_i2c(client, &config);
+ if (IS_ERR(hd3ss3220->regmap))
+ return PTR_ERR(hd3ss3220->regmap);
+
+ hd3ss3220_set_source_pref(hd3ss3220,
+ HD3SS3220_REG_GEN_CTRL_SRC_PREF_DRP_DEFAULT);
+ connector = device_get_named_child_node(hd3ss3220->dev, "connector");
+ if (IS_ERR(connector))
+ return PTR_ERR(connector);
+
+ hd3ss3220->role_sw = fwnode_usb_role_switch_get(connector);
+ fwnode_handle_put(connector);
+ if (IS_ERR_OR_NULL(hd3ss3220->role_sw))
+ return PTR_ERR(hd3ss3220->role_sw);
+
+ hd3ss3220->typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE;
+ hd3ss3220->typec_cap.dr_set = hd3ss3220_dr_set;
+ hd3ss3220->typec_cap.type = TYPEC_PORT_DRP;
+ hd3ss3220->typec_cap.data = TYPEC_PORT_DRD;
+
+ hd3ss3220->port = typec_register_port(&client->dev,
+ &hd3ss3220->typec_cap);
+ if (IS_ERR(hd3ss3220->port))
+ return PTR_ERR(hd3ss3220->port);
+
+ hd3ss3220_set_role(hd3ss3220);
+ ret = regmap_read(hd3ss3220->regmap, HD3SS3220_REG_CN_STAT_CTRL, &data);
+ if (ret < 0)
+ goto error;
+
+ if (data & HD3SS3220_REG_CN_STAT_CTRL_INT_STATUS) {
+ ret = regmap_write(hd3ss3220->regmap,
+ HD3SS3220_REG_CN_STAT_CTRL,
+ data | HD3SS3220_REG_CN_STAT_CTRL_INT_STATUS);
+ if (ret < 0)
+ goto error;
+ }
+
+ if (client->irq > 0) {
+ ret = devm_request_threaded_irq(&client->dev, client->irq, NULL,
+ hd3ss3220_irq_handler,
+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ "hd3ss3220", &client->dev);
+ if (ret)
+ goto error;
+ }
+
+ ret = i2c_smbus_read_byte_data(client, HD3SS3220_REG_DEV_REV);
+ if (ret < 0)
+ goto error;
+
+ dev_info(&client->dev, "probed revision=0x%x\n", ret);
+
+ return 0;
+error:
+ typec_unregister_port(hd3ss3220->port);
+ usb_role_switch_put(hd3ss3220->role_sw);
+
+ return ret;
+}
+
+static int hd3ss3220_remove(struct i2c_client *client)
+{
+ struct hd3ss3220 *hd3ss3220 = i2c_get_clientdata(client);
+
+ typec_unregister_port(hd3ss3220->port);
+ usb_role_switch_put(hd3ss3220->role_sw);
+
+ return 0;
+}
+
+static const struct of_device_id dev_ids[] = {
+ { .compatible = "ti,hd3ss3220"},
+ {}
+};
+MODULE_DEVICE_TABLE(of, dev_ids);
+
+static struct i2c_driver hd3ss3220_driver = {
+ .driver = {
+ .name = "hd3ss3220",
+ .of_match_table = of_match_ptr(dev_ids),
+ },
+ .probe = hd3ss3220_probe,
+ .remove = hd3ss3220_remove,
+};
+
+module_i2c_driver(hd3ss3220_driver);
+
+MODULE_AUTHOR("Biju Das <biju.das@bp.renesas.com>");
+MODULE_DESCRIPTION("TI HD3SS3220 DRP Port Controller Driver");
+MODULE_LICENSE("GPL");
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH RESEND v7 3/3] dt-bindings: usb: renesas_usb3: Document usb role switch support
2019-09-04 8:15 [PATCH RESEND v7 0/3] Add USB3.0 and TI HD3SS3220 driver support Biju Das
2019-09-04 8:15 ` [PATCH RESEND v7 1/3] dt-bindings: usb: hd3ss3220 device tree binding document Biju Das
2019-09-04 8:15 ` [PATCH RESEND v7 2/3] usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller Biju Das
@ 2019-09-04 8:15 ` Biju Das
2019-10-03 13:06 ` [PATCH RESEND v7 0/3] Add USB3.0 and TI HD3SS3220 driver support Biju Das
3 siblings, 0 replies; 10+ messages in thread
From: Biju Das @ 2019-09-04 8:15 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, Yoshihiro Shimoda, Greg Kroah-Hartman
Cc: Biju Das, Heikki Krogerus, Felipe Balbi, linux-usb, devicetree,
Simon Horman, Geert Uytterhoeven, Chris Paterson,
Fabrizio Castro, linux-renesas-soc
Update the DT bindings documentation to support usb role switch
for USB Type-C connector using USB role switch class framework.
Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
V7--> V7 RESEND
* Rebased to the new file name renesas,usb3-peri.txt.
* Added Reviewed-by tags of Rob and Shimoda-San.
V6-->V7
* Incorporated shimoda-san's review comments.
(https://patchwork.kernel.org/patch/10944631/)
V5-->V6
* Updated description
* Added usb-role-switch-property
V4-->V5
* No Change
V3-->V4
* No Change
V2-->V3
* Added optional renesas,usb-role-switch property.
V1-->V2
* Added usb-role-switch-property
* Updated the example with usb-role-switch property.
---
.../devicetree/bindings/usb/renesas,usb3-peri.txt | 23 ++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/Documentation/devicetree/bindings/usb/renesas,usb3-peri.txt b/Documentation/devicetree/bindings/usb/renesas,usb3-peri.txt
index 35039e7..5eecfbc 100644
--- a/Documentation/devicetree/bindings/usb/renesas,usb3-peri.txt
+++ b/Documentation/devicetree/bindings/usb/renesas,usb3-peri.txt
@@ -22,6 +22,12 @@ Required properties:
Optional properties:
- phys: phandle + phy specifier pair
- phy-names: must be "usb"
+ - usb-role-switch: support role switch. see usb/generic.txt
+
+Sub-nodes:
+- any connector to the data bus of this controller should be modelled using the
+ OF graph bindings specified in bindings/graph.txt, if the "usb-role-switch"
+ property is used.
Example of R-Car H3 ES1.x:
usb3_peri0: usb@ee020000 {
@@ -39,3 +45,20 @@ Example of R-Car H3 ES1.x:
interrupts = <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&cpg CPG_MOD 327>;
};
+
+Example of RZ/G2E:
+ usb3_peri0: usb@ee020000 {
+ compatible = "renesas,r8a774c0-usb3-peri",
+ "renesas,rcar-gen3-usb3-peri";
+ reg = <0 0xee020000 0 0x400>;
+ interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 328>;
+ companion = <&xhci0>;
+ usb-role-switch;
+
+ port {
+ usb3_role_switch: endpoint {
+ remote-endpoint = <&hd3ss3220_ep>;
+ };
+ };
+ };
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* RE: [PATCH RESEND v7 0/3] Add USB3.0 and TI HD3SS3220 driver support
2019-09-04 8:15 [PATCH RESEND v7 0/3] Add USB3.0 and TI HD3SS3220 driver support Biju Das
` (2 preceding siblings ...)
2019-09-04 8:15 ` [PATCH RESEND v7 3/3] dt-bindings: usb: renesas_usb3: Document usb role switch support Biju Das
@ 2019-10-03 13:06 ` Biju Das
2019-10-04 12:19 ` Greg Kroah-Hartman
3 siblings, 1 reply; 10+ messages in thread
From: Biju Das @ 2019-10-03 13:06 UTC (permalink / raw)
To: Rob Herring, Greg Kroah-Hartman, Heikki Krogerus, Felipe Balbi,
Mark Rutland
Cc: linux-usb, devicetree, Simon Horman, Yoshihiro Shimoda,
Geert Uytterhoeven, Chris Paterson, Fabrizio Castro,
linux-renesas-soc
Hi Greg,
Polite reminder.
Are happy with the below patch series, since the dependency patches hit on mainline 5.4-rc1?
https://patchwork.kernel.org/project/linux-usb/list/?series=169305
regards,
Biju
> -----Original Message-----
> From: Biju Das <biju.das@bp.renesas.com>
> Sent: Wednesday, September 4, 2019 9:16 AM
> To: Rob Herring <robh+dt@kernel.org>; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>; Heikki Krogerus
> <heikki.krogerus@linux.intel.com>; Felipe Balbi <balbi@kernel.org>; Mark
> Rutland <mark.rutland@arm.com>
> Cc: Biju Das <biju.das@bp.renesas.com>; linux-usb@vger.kernel.org;
> devicetree@vger.kernel.org; Simon Horman <horms@verge.net.au>;
> Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>; Geert
> Uytterhoeven <geert+renesas@glider.be>; Chris Paterson
> <Chris.Paterson2@renesas.com>; Fabrizio Castro
> <fabrizio.castro@bp.renesas.com>; linux-renesas-soc@vger.kernel.org
> Subject: [PATCH RESEND v7 0/3] Add USB3.0 and TI HD3SS3220 driver support
>
> This series adds USB 3.0 support for the CAT874 platform, including a new
> driver for the TI HD3SS3220 USB Type-C DRP port controller.
>
> Patch4-7 on the v7 series been accepted and is in linux-rc tree.
> Resending patch 1-3 of v7 series, since the dependency patches [1],
> [2],[3],[4] is accpted for usb-next.
>
> This patchset is based on usb-next tree.
>
> [1] commit 451d15a1731c7db9d4868 ("dt-binding: usb: add usb-role-switch
> property") [2] commit 977607653cdd06a2c4d1d ("usb: roles: Introduce stubs
> for the exiting functions in role.h") [3] commit 44493062abc38e5895e0c
> ("device connection: Add fwnode_connection_find_match()") [4] commit
> a31f01777bc54a0a9d576 ("usb: roles: Add fwnode_usb_role_switch_get()
> function")
>
> V7-->V7 RESEND
> * No change
> (https://patchwork.kernel.org/patch/10969911/)
> V6-->V7
> * Rebased on the below patch series
> (https://patchwork.kernel.org/project/linux-usb/list/?series=124223)
> * Updted the hd3ss3220 binding documentation
> -> Removed Rob's reviewed by tag, since there is a rework.
> -> Incorporated Sergie and Shimoda-San's review comment.
> (https://patchwork.kernel.org/patch/10944629/)
> * Rebased hd3ss3220 driver based on the new API
> --> Removed Heikki's review comment, since there is a rework
> (https://patchwork.kernel.org/patch/10942499/)
> * Incorporated shimoda-san's review comments for renesas usb3 binding
> (https://patchwork.kernel.org/patch/10944631/)
> * Incorporated shimoda-san's review comments for renesas usb3 driver
> (https://patchwork.kernel.org/patch/10944643/)
> V5-->V6
> * Updated bindings patch by using usb-role-switch property
> * Used graph api's to get role switch supported by the usb-c-connector
> V4-->V5
> * Incorporated Heikki's review comment.
> (https://patchwork.kernel.org/patch/10902531/)
> * Patch 1 is a dependency patch to make the compilation successful.
> (https://patchwork.kernel.org/patch/10909971/)
> * Patch 2 is also dependency patch to make the compilation successful.
> Rebased on top of Patch1 and fixed Heikki's review comments
> (https://patchwork.kernel.org/patch/10882555/)
> * Incorporated Shimoda-San's review comment.
> (https://patchwork.kernel.org/patch/10902535/)
> V3-->V4
> * Incorporated Chunfeng Yun's review comment
> (https://patchwork.kernel.org/project/linux-usb/list/?submitter=133171)
> * Used fwnode API's to get roleswitch handle
>
> V2-->V3
> * Used the new API to usb_role_switch by node to find the remote
> endpoint
> (https://patchwork.kernel.org/patch/10882555/)
> * Added renesas,usb-role-switch property
> * Incorporated shimoda-san's review comment
> (https://patchwork.kernel.org/patch/10852507/)
>
> V1-->V2
> * Use USB role class instead of extcon to receive connect and disconnect
> events and also for the dual role switch.
> * Dropped patch 6
> * Squashed patch 8 and patch 9
> * https://patchwork.kernel.org/cover/10840641/
>
>
> Biju Das (3):
> dt-bindings: usb: hd3ss3220 device tree binding document
> usb: typec: driver for TI HD3SS3220 USB Type-C DRP port controller
> dt-bindings: usb: renesas_usb3: Document usb role switch support
>
> .../devicetree/bindings/usb/renesas,usb3-peri.txt | 23 ++
> .../devicetree/bindings/usb/ti,hd3ss3220.txt | 38 +++
> drivers/usb/typec/Kconfig | 10 +
> drivers/usb/typec/Makefile | 1 +
> drivers/usb/typec/hd3ss3220.c | 259 +++++++++++++++++++++
> 5 files changed, 331 insertions(+)
> create mode 100644
> Documentation/devicetree/bindings/usb/ti,hd3ss3220.txt
> create mode 100644 drivers/usb/typec/hd3ss3220.c
>
> --
> 2.7.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH RESEND v7 0/3] Add USB3.0 and TI HD3SS3220 driver support
2019-10-03 13:06 ` [PATCH RESEND v7 0/3] Add USB3.0 and TI HD3SS3220 driver support Biju Das
@ 2019-10-04 12:19 ` Greg Kroah-Hartman
0 siblings, 0 replies; 10+ messages in thread
From: Greg Kroah-Hartman @ 2019-10-04 12:19 UTC (permalink / raw)
To: Biju Das
Cc: Rob Herring, Heikki Krogerus, Felipe Balbi, Mark Rutland,
linux-usb, devicetree, Simon Horman, Yoshihiro Shimoda,
Geert Uytterhoeven, Chris Paterson, Fabrizio Castro,
linux-renesas-soc
On Thu, Oct 03, 2019 at 01:06:31PM +0000, Biju Das wrote:
> Hi Greg,
>
> Polite reminder.
>
> Are happy with the below patch series, since the dependency patches hit on mainline 5.4-rc1?
>
> https://patchwork.kernel.org/project/linux-usb/list/?series=169305
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread