usb: typec: add drivers for TUSB320xA and TS5USBA224
Subsystems (3)
cover usb: typec: add drivers for TUSB320xA and TS5USBA224
From: Alvin Šipraga <[email protected]>
This series adds a new typec class driver for the TUSB320xA family of Type-C port controllers and a typec_mux class driver for the TS5USBA224 switch mux.
This series was bourne out of frustration with the existing extcon driver for the TUSB320, which did not offer a convenient driver model for the Audio Accessory mode muxing offered by the TS5USBA224. I found the typec subsystem to be more suitable.
I have tested this on my i.MX8MM platform with USB OTG support and it works as desired. However I am not very familiar with this part of the kernel, so I welcome your critical feedback to this series. Thanks in advance.
Alvin Šipraga (4):
dt-bindings: usb: add TUSB320xA Type-C port controller
dt-bindings: usb: add TS5USBA224 USB/Audio switch mux
usb: typec: add TUSB320xA driver
usb: typec: mux: add TS5USBA224 driver
.../bindings/usb/ti,ts5usba224.yaml | 56 ++ .../devicetree/bindings/usb/ti,tusb320xa.yaml | 78 +++ drivers/usb/typec/Kconfig | 12 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/mux/Kconfig | 10 + drivers/usb/typec/mux/Makefile | 1 + drivers/usb/typec/mux/ts5usba224.c | 102 ++++ drivers/usb/typec/tusb320xa.c | 517 ++++++++++++++++++ 8 files changed, 777 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ti,ts5usba224.yaml create mode 100644 Documentation/devicetree/bindings/usb/ti,tusb320xa.yaml create mode 100644 drivers/usb/typec/mux/ts5usba224.c create mode 100644 drivers/usb/typec/tusb320xa.c
Signature · 1 line
2.35.1
PATCH 1/4 dt-bindings: usb: add TUSB320xA Type-C port controller
From: Alvin Šipraga <[email protected]>
The TUSB320xA is a non-PD Type-C port controller managed over I2C.
--- .../devicetree/bindings/usb/ti,tusb320xa.yaml | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ti,tusb320xa.yaml
Documentation/devicetree/bindings/usb/ti,tusb320xa.yaml new file +78 -0
@@ -0,0 +1,78 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/ti,tusb320xa.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TUSB320xA Type-C port controller DT bindings + +description: + The Texas Instruments TUSB320xA is a USB Type-C port controller which + supports role and plug orientation detection using the CC pins. It is + compatible with the USB Type-C Cable and Connector Specification v1.1. + +maintainers: + - Alvin Šipraga <[email protected]> + +properties: + compatible: + enum: + - ti,tusb320la + - ti,tusb320ha + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + patternProperties: + '^port@': + $ref: /schemas/graph.yaml#/properties/port + description: + OF graph bindings modelling any "usb-role-switch" or "accessory" mux. + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + tcpc@47 { + compatible = "ti,tusb320la"; + reg = <0x47>; + interrupt-parent = <&gpio5>; + interrupts = <2 IRQ_TYPE_LEVEL_LOW>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + typec1_mux: endpoint { + remote-endpoint = <&usb_audio_mux1>; + }; + }; + + port@1 { + reg = <1>; + typec1_dr_sw: endpoint { + remote-endpoint = <&usbotg1_drd_sw>; + }; + }; + }; + }; + };
Signature · 1 line
2.35.1
Rob Herring
maintainerRe: [PATCH 1/4] dt-bindings: usb: add TUSB320xA Type-C port controller
Quoted 39 lines · Alvin Šipraga
From: Alvin Šipraga <[email protected]>
The TUSB320xA is a non-PD Type-C port controller managed over I2C.
Signed-off-by Alvin Šipraga <[email protected]>--- .../devicetree/bindings/usb/ti,tusb320xa.yaml | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ti,tusb320xa.yamlDocumentation/devicetree/bindings/usb/ti,tusb320xa.yaml new file +23
-0@@ -0,0 +1,78 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/ti,tusb320xa.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TUSB320xA Type-C port controller DT bindings + +description: + The Texas Instruments TUSB320xA is a USB Type-C port controller which + supports role and plug orientation detection using the CC pins. It is + compatible with the USB Type-C Cable and Connector Specification v1.1. + +maintainers: + - Alvin Šipraga <[email protected]> + +properties: + compatible: + enum: + - ti,tusb320la + - ti,tusb320ha + + reg:
Documentation/devicetree/bindings/usb/ti,tusb320xa.yaml line 33
Quoted 10 lines
Documentation/devicetree/bindings/usb/ti,tusb320xa.yaml new file +10
-0+ maxItems: 1 + + interrupts: + maxItems: 1 + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + patternProperties: + '^port@':
Exact port numbers need to be defined. What does port@0 represent? port@1?
Quoted 48 lines
Documentation/devicetree/bindings/usb/ti,tusb320xa.yaml new file +45
-0+ $ref: /schemas/graph.yaml#/properties/port + description: + OF graph bindings modelling any "usb-role-switch" or "accessory" mux. + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + tcpc@47 { + compatible = "ti,tusb320la"; + reg = <0x47>; + interrupt-parent = <&gpio5>; + interrupts = <2 IRQ_TYPE_LEVEL_LOW>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + typec1_mux: endpoint { + remote-endpoint = <&usb_audio_mux1>; + }; + }; + + port@1 { + reg = <1>; + typec1_dr_sw: endpoint { + remote-endpoint = <&usbotg1_drd_sw>; + }; + }; + }; + }; + };Signature · 1 line
2.35.1
PATCH 2/4 dt-bindings: usb: add TS5USBA224 USB/Audio switch mux
In reply to Alvin ŠipragaFrom: Alvin Šipraga <[email protected]>
The TS5USBA224 is a USB High Speed/Audio switch mux IC controlled via GPIO. It is typically composed with a Type-C port controller with Audio Accessory mode detection.
--- .../bindings/usb/ti,ts5usba224.yaml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ti,ts5usba224.yaml
Documentation/devicetree/bindings/usb/ti,ts5usba224.yaml new file +56 -0
@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/ti,ts5usba224.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TS5USBA224 USB 2.0 High Speed and Audio mux DT bindings + +description: + The Texas Instruments TS5USBA224 is a double-pole, double throw + (DPDT) multiplexer that includes a low-distortion audio switch and a + USB 2.0 High Speed switch in the same package. + +maintainers: + - Alvin Šipraga <[email protected]> + +properties: + compatible: + enum: + - ti,ts5usba224 + + asel-gpio: + description: Output GPIO for A_SEL signal + maxItems: 1 + + accessory: + type: boolean + description: + Indicates that this is an Accessory Mode mux. + + port: + $ref: /schemas/graph.yaml#/properties/port + description: + OF graph bindings modelling a Type-C port controller. + +required: + - compatible + - asel-gpio + - accessory + - port + +additionalProperties: false + +examples: + - | + usbaudiomux@0 { + compatible = "ti,ts5usba224"; + asel-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>; + accessory; + + port { + usb_audio_mux1: endpoint { + remote-endpoint = <&typec1_mux>; + }; + }; + };
Signature · 1 line
2.35.1
Rob Herring
maintainerRe: [PATCH 2/4] dt-bindings: usb: add TS5USBA224 USB/Audio switch mux
Quoted 42 lines · Alvin Šipraga
From: Alvin Šipraga <[email protected]>
The TS5USBA224 is a USB High Speed/Audio switch mux IC controlled via GPIO. It is typically composed with a Type-C port controller with Audio Accessory mode detection.
Signed-off-by Alvin Šipraga <[email protected]>--- .../bindings/usb/ti,ts5usba224.yaml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ti,ts5usba224.yamlDocumentation/devicetree/bindings/usb/ti,ts5usba224.yaml new file +24
-0@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/ti,ts5usba224.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TS5USBA224 USB 2.0 High Speed and Audio mux DT bindings + +description: + The Texas Instruments TS5USBA224 is a double-pole, double throw + (DPDT) multiplexer that includes a low-distortion audio switch and a + USB 2.0 High Speed switch in the same package. + +maintainers: + - Alvin Šipraga <[email protected]> + +properties: + compatible: + enum: + - ti,ts5usba224 + + asel-gpio: + description: Output GPIO for A_SEL signal + maxItems: 1
Documentation/devicetree/bindings/usb/ti,ts5usba224.yaml line 34
Quoted 10 lines
Documentation/devicetree/bindings/usb/ti,ts5usba224.yaml new file +10
-0+ + accessory: + type: boolean + description: + Indicates that this is an Accessory Mode mux. + + port: + $ref: /schemas/graph.yaml#/properties/port + description: + OF graph bindings modelling a Type-C port controller.
What does that mean?
There's a couple of Type-C bindings on the list ATM. Without block diagrams of all the relevant components and the corresponding graph, I can't say whether any of this graph usage makes sense.
Quoted 25 lines
Documentation/devicetree/bindings/usb/ti,ts5usba224.yaml new file +22
-0+ +required: + - compatible + - asel-gpio + - accessory + - port + +additionalProperties: false + +examples: + - | + usbaudiomux@0 { + compatible = "ti,ts5usba224"; + asel-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>; + accessory; + + port { + usb_audio_mux1: endpoint { + remote-endpoint = <&typec1_mux>; + }; + }; + };Signature · 1 line
2.35.1
Re: [PATCH 2/4] dt-bindings: usb: add TS5USBA224 USB/Audio switch mux
Quoted 56 lines · Rob Herring
Quoted 42 lines · Alvin Šipraga
From: Alvin Šipraga <[email protected]>
The TS5USBA224 is a USB High Speed/Audio switch mux IC controlled via GPIO. It is typically composed with a Type-C port controller with Audio Accessory mode detection.
Signed-off-by Alvin Šipraga <[email protected]>--- .../bindings/usb/ti,ts5usba224.yaml | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ti,ts5usba224.yamlDocumentation/devicetree/bindings/usb/ti,ts5usba224.yaml new file +24
-0@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/ti,ts5usba224.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TS5USBA224 USB 2.0 High Speed and Audio mux DT bindings + +description: + The Texas Instruments TS5USBA224 is a double-pole, double throw + (DPDT) multiplexer that includes a low-distortion audio switch and a + USB 2.0 High Speed switch in the same package. + +maintainers: + - Alvin Šipraga <[email protected]> + +properties: + compatible: + enum: + - ti,ts5usba224 + + asel-gpio: + description: Output GPIO for A_SEL signal + maxItems: 1Documentation/devicetree/bindings/usb/ti,ts5usba224.yaml line 34
Quoted 10 lines
Documentation/devicetree/bindings/usb/ti,ts5usba224.yaml new file +10
-0+ + accessory: + type: boolean + description: + Indicates that this is an Accessory Mode mux. + + port: + $ref: /schemas/graph.yaml#/properties/port + description: + OF graph bindings modelling a Type-C port controller.What does that mean?
Quoted 3 lines
There's a couple of Type-C bindings on the list ATM. Without block diagrams of all the relevant components and the corresponding graph, I can't say whether any of this graph usage makes sense.
Thanks for your review. Maybe I need some help with this but I'll try and explain according to my understanding.
The series adds two drivers:
- tusb320xa - a USB Type-C port controller driver
- ts5usba224 - a USB Type-C multiplexer (for Audio Accessory mode)
These handle different classes of device: typec (the port controller) and typec_mux (the multiplexer) respectively.
The typec driver is responsible for determining what is connected on the other end of the Type-C port. It informs the typec subsystem of what role is detected (UFP or DFP), the orientation, and whether or not certain accessories (Audio or Debug) are connected.
The typec_mux driver is interested in whether an Audio Accessory has been connected to the Type-C port. Depending on whether it is or not, it will assert a GPIO controlling the TS5USBA224 mux chip.
Additionally, an OTG capable USB controller might like to be informed so that it can configure itself correctly as a host (and enable VBUS etc.) or peripheral.
Here is a simplified block diagram with my i.MX8MM SoC:
┌─────────────────────┐ ┌───────────────────┐
│ │ I2C │ │
│ ├────────────────────┤ I2C │
│ TUSB320LAI │ INT_N │ │
│ ├────────────────────┤ i.MX8MM │
│ │ │ │
│ CC1 CC2 │ ┌────────┤ GPIO │
└──┬───┬──────────────┘ │ │ │
│ │ │ │ USBOTG │
│ │ │ │ VBUS D+ D- │
│ │ │ └──────┬─────┬───┬──┘
│ │ ┌──────────────────────│───────────────┘ │ │
│ │ │ ┌───────────┴──┐ │ │
│ │ │ │ A_SEL │ │ │
│ │ │ │ │ │ │
│ │ │ │ D+ ├──────────────────┘ │
│ │ │ │ │ │
│ │ │ ┌──────┤ D+/L D- ├──────────────────────┘
│ │ │ │ │ │
│ │ │ │ ┌──┤ D-/R │ Line_L
│ │ │ │ │ │ L ├───────────────────────
┴ ┴ ┴ ┴ ┴ │ │ Line_R
USB Type-C port │ R ├───────────────────────
│ │
│ TS5USBA224 │
└──────────────┘Line_{L,R} here are handled by some alternative circuitry which is not relevant to this discussion.
Now back to the graph: I noticed while reading the generic typec code that it is walking the child nodes and looking for particular endpoints when registering a typec port. If a remote endpoint has the 'accessory' property, it will pick up the corresponding device and inform it when the port mode changes. If the new mode is TYPEC_MODE_AUDIO (as a result of an Audio Accessory being detected by the port), then the typec_mux driver will assert the A_SEL GPIO, otherwise it will deassert it.
Since this worked pretty automatically, my understanding was that this was the correct way to "connect" these two devices in the device tree.
For the USB host/peripheral role switching, I use the usb_role_switch_get() API in the probe function of the tusb320xa driver to similarly walk the device tree and find a remote endpoint with the 'usb-role-switch' property.
So it could be a misunderstanding on my part, but what I'm trying to do here with the bindings is offer the option to connect the various devices together via the graph bindings. They are strictly optional though - one might have a non-OTG capable USB controller, or perhaps not care about Audio Accessories, etc. - so I did not specify specific port numbering. I can of course do that, but it will be an arbitrary choice.
I hope that explains a bit better what I'm trying to do here. I don't claim to have got it right though. Do you have any comments? Maybe Heikki can chip in and explain if this is the right way to look at things.
Kind regards,
Alvin
Quoted 26 lines
Quoted 26 lines
Documentation/devicetree/bindings/usb/ti,ts5usba224.yaml new file +22
-0+ +required: + - compatible + - asel-gpio + - accessory + - port + +additionalProperties: false + +examples: + - | + usbaudiomux@0 { + compatible = "ti,ts5usba224"; + asel-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>; + accessory; + + port { + usb_audio_mux1: endpoint { + remote-endpoint = <&typec1_mux>; + }; + }; + };Signature · 1 line
2.35.1
PATCH 3/4 usb: typec: add TUSB320xA driver
In reply to Alvin ŠipragaFrom: Alvin Šipraga <[email protected]>
The TUSB320LA and TUSB320HA (or LAI, HAI) chips are I2C controlled non-PD Type-C port controllers. They support detection of cable orientation, port attachment state, and role, including Audio Accessory and Debug Accessory modes. Add a typec class driver for this family.
Note that there already exists an extcon driver for the TUSB320 (a slightly older revision that does not support setting role preference or disabling the CC state machine). This driver is loosely based on that one.
--- drivers/usb/typec/Kconfig | 12 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/tusb320xa.c | 517 ++++++++++++++++++++++++++++++++++ 3 files changed, 530 insertions(+) create mode 100644 drivers/usb/typec/tusb320xa.c
drivers/usb/typec/Kconfig +12 -0
@@ -75,6 +75,18 @@ config TYPEC_HD3SS3220 If you choose to build this driver as a dynamically linked module, the module will be called hd3ss3220.ko. +config TYPEC_TUSB320XA + tristate "TI TUSB320xA Type-C DRP Port controller driver" + depends on USB_ROLE_SWITCH + depends on I2C + select REGMAP_I2C + help + Say Y or M here if your system has a TUSB320xA Type-C DRP port + controller. + + If you choose to build this driver as a dynamically linked module, the + module will be called tusb320xa.ko. + config TYPEC_STUSB160X tristate "STMicroelectronics STUSB160x Type-C controller driver" depends on USB_ROLE_SWITCH || !USB_ROLE_SWITCH
drivers/usb/typec/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_TYPEC_TCPM) += tcpm/ obj-$(CONFIG_TYPEC_UCSI) += ucsi/ obj-$(CONFIG_TYPEC_TPS6598X) += tipd/ obj-$(CONFIG_TYPEC_HD3SS3220) += hd3ss3220.o +obj-$(CONFIG_TYPEC_TUSB320XA) += tusb320xa.o obj-$(CONFIG_TYPEC_QCOM_PMIC) += qcom-pmic-typec.o obj-$(CONFIG_TYPEC_STUSB160X) += stusb160x.o obj-$(CONFIG_TYPEC_RT1719) += rt1719.o
drivers/usb/typec/tusb320xa.c new file +517 -0
517 lines not on this page · raw message
Signature · 1 line
2.35.1
kernel test robot
build botRe: [PATCH 3/4] usb: typec: add TUSB320xA driver
I love your patch! Perhaps something to improve:
Hi "Alvin,
I love your patch! Perhaps something to improve:
[auto build test WARNING on usb/usb-testing]
[also build test WARNING on robh/for-next v5.17-rc6 next-20220301] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Alvin-ipraga/usb-typec-add-drivers-for-TUSB320xA-and-TS5USBA224/20220301-212251 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20220302/[email protected]/config) compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c60eb902fdeaef99cf2c10e84e0369ee6787753a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Alvin-ipraga/usb-typec-add-drivers-for-TUSB320xA-and-TS5USBA224/20220301-212251 git checkout c60eb902fdeaef99cf2c10e84e0369ee6787753a
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/usb/typec/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/usb/typec/tusb320xa.c:407:6: warning: no previous prototype for 'tusb320xa_action_role_sw_put' [-Wmissing-prototypes]
407 | void tusb320xa_action_role_sw_put(void *data)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/usb/typec/tusb320xa.c:414:6: warning: no previous prototype for 'tusb320xa_action_unregister_port' [-Wmissing-prototypes]
414 | void tusb320xa_action_unregister_port(void *data)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~vim +/tusb320xa_action_role_sw_put +407 drivers/usb/typec/tusb320xa.c
406
> 407 void tusb320xa_action_role_sw_put(void *data)
408 {
409 struct usb_role_switch *role_sw = data;
410
411 usb_role_switch_put(role_sw);
412 }
413
> 414 void tusb320xa_action_unregister_port(void *data) 415 {
416 struct typec_port *port = data;
417
418 typec_unregister_port(port);
419 }
420
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
Re: [PATCH 3/4] usb: typec: add TUSB320xA driver
Quoted 4 lines · kernel test robot
Hi "Alvin,
I love your patch! Perhaps something to improve:
<snip>
Quoted 9 lines
All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
drivers/usb/typec/tusb320xa.c:407:6: warning: no previous prototype for 'tusb320xa_action_role_sw_put' [-Wmissing-prototypes]407 | void tusb320xa_action_role_sw_put(void *data) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~Quoted 1 line
Quoted 1 line
drivers/usb/typec/tusb320xa.c:414:6: warning: no previous prototype for 'tusb320xa_action_unregister_port' [-Wmissing-prototypes]414 | void tusb320xa_action_unregister_port(void *data) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ah yes, these should be static, will fix in v2. Thank you, test robot.
Quoted 23 lines
vim +/tusb320xa_action_role_sw_put +407
drivers/usb/typec/tusb320xa.c406Quoted 1 line
407 void
tusb320xa_action_role_sw_put(void *data)408 { 409 struct usb_role_switch *role_sw = data; 410 411 usb_role_switch_put(role_sw); 412 } 413Quoted 1 line
414 void
tusb320xa_action_unregister_port(void *data)415 { 416 struct typec_port *port = data; 417 418 typec_unregister_port(port); 419 } 420---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Heikki Krogerus
maintainerRe: [PATCH 3/4] usb: typec: add TUSB320xA driver
In reply to Alvin ŠipragaHi,
Quoted 11 lines · Alvin Šipraga
From: Alvin Šipraga <[email protected]>
The TUSB320LA and TUSB320HA (or LAI, HAI) chips are I2C controlled non-PD Type-C port controllers. They support detection of cable orientation, port attachment state, and role, including Audio Accessory and Debug Accessory modes. Add a typec class driver for this family.
Note that there already exists an extcon driver for the TUSB320 (a slightly older revision that does not support setting role preference or disabling the CC state machine). This driver is loosely based on that one.
This looked mostly OK to me. There is one question below.
<snip>
Quoted 15 lines
drivers/usb/typec/tusb320xa.c new file +15
-0+static int tusb320xa_check_signature (struct tusb320xa *tusb) +{ +static const char sig[] = {'\0' ,'T' ,'U' ,'S' ,'B' ,'3' ,'2' ,'0' }; +unsigned int val; +int i, ret; + +mutex_lock (&tusb->lock); + +for (i =0 ; i <sizeof (sig); i++) { + ret =regmap_read (tusb->regmap,sizeof (sig) -1 - i, &val); +if (ret) + goto done; + +if (val != sig[i]) { +dev_err (tusb->dev,"signature mismatch!\n" );
drivers/usb/typec/tusb320xa.c line 125
Quoted 10 lines
drivers/usb/typec/tusb320xa.c new file +10
-0+ ret = -ENODEV ; + goto done; + } + } + +done: +mutex_unlock (&tusb->lock); + +return ret; +}
Couldn't that be done with a single read?
char sig[8];
u64 val;
strcpy(sig, "TUSB320")
mutex_lock(&tusb->lock);
ret = regmap_raw_read(tusb->regmap, 0, &val, sizeof(val));
...
if (val != cpu_to_le64(*(u64 *)sig)) {
...Something like that?
thanks,
Signature · 1 line
heikki
Re: [PATCH 3/4] usb: typec: add TUSB320xA driver
Hi Heikki,
Quoted 59 lines · Heikki Krogerus
Hi,
Quoted 11 lines · Alvin Šipraga
From: Alvin Šipraga <[email protected]>
The TUSB320LA and TUSB320HA (or LAI, HAI) chips are I2C controlled non-PD Type-C port controllers. They support detection of cable orientation, port attachment state, and role, including Audio Accessory and Debug Accessory modes. Add a typec class driver for this family.
Note that there already exists an extcon driver for the TUSB320 (a slightly older revision that does not support setting role preference or disabling the CC state machine). This driver is loosely based on that one.
This looked mostly OK to me. There is one question below.
<snip>
Quoted 15 lines
drivers/usb/typec/tusb320xa.c new file +15
-0+static int tusb320xa_check_signature (struct tusb320xa *tusb) +{ +static const char sig[] = {'\0' ,'T' ,'U' ,'S' ,'B' ,'3' ,'2' ,'0' }; +unsigned int val; +int i, ret; + +mutex_lock (&tusb->lock); + +for (i =0 ; i <sizeof (sig); i++) { + ret =regmap_read (tusb->regmap,sizeof (sig) -1 - i, &val); +if (ret) + goto done; + +if (val != sig[i]) { +dev_err (tusb->dev,"signature mismatch!\n" );drivers/usb/typec/tusb320xa.c line 125
Quoted 10 lines
drivers/usb/typec/tusb320xa.c new file +10
-0+ ret = -ENODEV ; + goto done; + } + } + +done: +mutex_unlock (&tusb->lock); + +return ret; +}Couldn't that be done with a single read?
char sig[8]; u64 val; strcpy(sig, "TUSB320") mutex_lock(&tusb->lock); ret = regmap_raw_read(tusb->regmap, 0, &val, sizeof(val)); ... if (val != cpu_to_le64(*(u64 *)sig)) { ...
Quoted 1 line
Something like that?
I think it's a bit cryptic - are you sure it's worth it just to save 8 one-off regmap_read()s? I could also just remove this check... I see it mostly as a courtesy to the user in case the I2C address in his device tree mistakenly points to some other unsuspecting chip.
BTW, do you have any feedback on the device tree bindings of this series? Rob had some questions and I am not sure that my proposed bindings are fully aligned with the typec subsystem expectations. Any feedback would be welcome.
I will wait for more comments and send a v2 in ~a week.
Kind regards,
Alvin
Quoted 2 lines
thanks,
Heikki Krogerus
maintainerRe: [PATCH 3/4] usb: typec: add TUSB320xA driver
Quoted 70 lines · Alvin Šipraga
Hi Heikki,
Quoted 59 lines · Heikki Krogerus
Hi,
Quoted 11 lines · Alvin Šipraga
From: Alvin Šipraga <[email protected]>
The TUSB320LA and TUSB320HA (or LAI, HAI) chips are I2C controlled non-PD Type-C port controllers. They support detection of cable orientation, port attachment state, and role, including Audio Accessory and Debug Accessory modes. Add a typec class driver for this family.
Note that there already exists an extcon driver for the TUSB320 (a slightly older revision that does not support setting role preference or disabling the CC state machine). This driver is loosely based on that one.
This looked mostly OK to me. There is one question below.
<snip>
Quoted 15 lines
drivers/usb/typec/tusb320xa.c new file +15
-0+static int tusb320xa_check_signature (struct tusb320xa *tusb) +{ +static const char sig[] = {'\0' ,'T' ,'U' ,'S' ,'B' ,'3' ,'2' ,'0' }; +unsigned int val; +int i, ret; + +mutex_lock (&tusb->lock); + +for (i =0 ; i <sizeof (sig); i++) { + ret =regmap_read (tusb->regmap,sizeof (sig) -1 - i, &val); +if (ret) + goto done; + +if (val != sig[i]) { +dev_err (tusb->dev,"signature mismatch!\n" );drivers/usb/typec/tusb320xa.c line 125
Quoted 10 lines
drivers/usb/typec/tusb320xa.c new file +10
-0+ ret = -ENODEV ; + goto done; + } + } + +done: +mutex_unlock (&tusb->lock); + +return ret; +}Couldn't that be done with a single read?
char sig[8]; u64 val; strcpy(sig, "TUSB320") mutex_lock(&tusb->lock); ret = regmap_raw_read(tusb->regmap, 0, &val, sizeof(val)); ... if (val != cpu_to_le64(*(u64 *)sig)) { ...Quoted 1 line
Something like that?
I think it's a bit cryptic - are you sure it's worth it just to save 8 one-off regmap_read()s? I could also just remove this check... I see it mostly as a courtesy to the user in case the I2C address in his device tree mistakenly points to some other unsuspecting chip.
Quoted 4 lines
BTW, do you have any feedback on the device tree bindings of this series? Rob had some questions and I am not sure that my proposed bindings are fully aligned with the typec subsystem expectations. Any feedback would be welcome.
I don't think I understand DT well enough to comment. I'm not completely sure what he's asking..
Quoted 1 line
I will wait for more comments and send a v2 in ~a week.
thanks,
Signature · 1 line
heikki
Re: [PATCH 3/4] usb: typec: add TUSB320xA driver
Quoted 71 lines · Heikki Krogerus
Quoted 70 lines · Alvin Šipraga
Hi Heikki,
Quoted 59 lines · Heikki Krogerus
Hi,
Quoted 11 lines · Alvin Šipraga
From: Alvin Šipraga <[email protected]>
The TUSB320LA and TUSB320HA (or LAI, HAI) chips are I2C controlled non-PD Type-C port controllers. They support detection of cable orientation, port attachment state, and role, including Audio Accessory and Debug Accessory modes. Add a typec class driver for this family.
Note that there already exists an extcon driver for the TUSB320 (a slightly older revision that does not support setting role preference or disabling the CC state machine). This driver is loosely based on that one.
This looked mostly OK to me. There is one question below.
<snip>
Quoted 15 lines
drivers/usb/typec/tusb320xa.c new file +15
-0+static int tusb320xa_check_signature (struct tusb320xa *tusb) +{ +static const char sig[] = {'\0' ,'T' ,'U' ,'S' ,'B' ,'3' ,'2' ,'0' }; +unsigned int val; +int i, ret; + +mutex_lock (&tusb->lock); + +for (i =0 ; i <sizeof (sig); i++) { + ret =regmap_read (tusb->regmap,sizeof (sig) -1 - i, &val); +if (ret) + goto done; + +if (val != sig[i]) { +dev_err (tusb->dev,"signature mismatch!\n" );drivers/usb/typec/tusb320xa.c line 125
Quoted 10 lines
drivers/usb/typec/tusb320xa.c new file +10
-0+ ret = -ENODEV ; + goto done; + } + } + +done: +mutex_unlock (&tusb->lock); + +return ret; +}Couldn't that be done with a single read?
char sig[8]; u64 val; strcpy(sig, "TUSB320") mutex_lock(&tusb->lock); ret = regmap_raw_read(tusb->regmap, 0, &val, sizeof(val)); ... if (val != cpu_to_le64(*(u64 *)sig)) { ...Quoted 1 line
Something like that?
I think it's a bit cryptic - are you sure it's worth it just to save 8 one-off regmap_read()s? I could also just remove this check... I see it mostly as a courtesy to the user in case the I2C address in his device tree mistakenly points to some other unsuspecting chip.
Quoted 7 lines
Quoted 4 lines
BTW, do you have any feedback on the device tree bindings of this series? Rob had some questions and I am not sure that my proposed bindings are fully aligned with the typec subsystem expectations. Any feedback would be welcome.
I don't think I understand DT well enough to comment. I'm not completely sure what he's asking..
OK, no problem! Thanks for your reply.
Kind regards,
Alvin
Quoted 4 lines
Quoted 2 lines
I will wait for more comments and send a v2 in ~a week.
thanks,
PATCH 4/4 usb: typec: mux: add TS5USBA224 driver
In reply to Alvin ŠipragaFrom: Alvin Šipraga <[email protected]>
The TS5USBA224 USB High Speed/Audio switch mux is typically used together with a Type-C port controller such as the TUSB320LAI. Below is a simplified typical application on an embedded platform:
┌─────────────────────┐ ┌───────────────────┐
│ │ I2C │ │
│ ├──────────────────────┤ I2C │
│ TUSB320LAI │ INT_N │ │
│ ├──────────────────────┤ System-on- │
│ │ │ Chip │
│ CC1 CC2 │ ┌──────────┤ GPIO │
└──┬───┬──────────────┘ │ │ │
│ │ │ │ USBOTG │
│ │ │ │ VBUS D+ D- │
│ │ │ └──────┬─────┬───┬──┘
│ │ ┌──────────────────────│─────────────────┘ │ │
│ │ │ ┌───────────┴──┐ │ │
│ │ │ │ A_SEL │ │ │
│ │ │ │ │ │ │
│ │ │ │ D+ ├────────────────────┘ │
│ │ │ │ │ │
│ │ │ ┌──────┤ D+/L D- ├────────────────────────┘
│ │ │ │ │ │
│ │ │ │ ┌──┤ D-/R │ Line_L
│ │ │ │ │ │ L ├─────────────────────────
┴ ┴ ┴ ┴ ┴ │ │ Line_R
USB Type-C port │ R ├─────────────────────────
│ │
│ TS5USBA224 │
└──────────────┘This driver controls the TS5USBA224 via the A_SEL pin. In addition, it registers itself as a Type-C mux device. In the above scenario, the driver may be notified via the port controller driver if the CC pins indicate that an Audio Accessory is connected or not.
--- drivers/usb/typec/mux/Kconfig | 10 +++ drivers/usb/typec/mux/Makefile | 1 + drivers/usb/typec/mux/ts5usba224.c | 102 +++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 drivers/usb/typec/mux/ts5usba224.c
drivers/usb/typec/mux/Kconfig +10 -0
@@ -19,4 +19,14 @@ config TYPEC_MUX_INTEL_PMC control the USB role switch and also the multiplexer/demultiplexer switches used with USB Type-C Alternate Modes. +config TYPEC_MUX_TS5USBA224 + tristate "TI TS5USBA224 USB High Speed/Audio switch mux driver" + select GPIOLIB + help + Say Y or M if your system has a TI TS5USBA224 USB High Speed/Audio + switch mux controller paired with a USB Type-C port controller. + + If you choose to build this driver as a dynamically linked module, the + module will be called ts5usba224.ko. + endmenu
drivers/usb/typec/mux/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-$(CONFIG_TYPEC_MUX_PI3USB30532) += pi3usb30532.o obj-$(CONFIG_TYPEC_MUX_INTEL_PMC) += intel_pmc_mux.o +obj-$(CONFIG_TYPEC_MUX_TS5USBA224) += ts5usba224.o
drivers/usb/typec/mux/ts5usba224.c new file +102 -0
102 lines not on this page · raw message
Signature · 1 line
2.35.1