Skip to contentSkip to conversation

Add support for TPS25750

PATCH Superseded Abdel Alkuor 3 participants 6 messages Aug 20, 2023 – Aug 29, 2023

Subsystems (3)

v4 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add support for TPS25750

TPS25750 is USB Type-C and PD controller. The device is highly configurable using App Customization online Tool developed by TI to generate loadable binary.

TPS25750 supports three modes; PTCH, APP, and BOOT. A configuration can only be applied when the controller is on PTCH mode.

The controller attempts to load a configuration from EEPROM on I2Cm bus. If no EEPROM is detected, then the driver tries to load a configuration on I2Cs bus using a firmware file defined in DT.

The driver implements the binary loading sequence which can be found on pg.53 in TPS25750 Host Interface Technical Reference Manual (Rev. A) https://tinyurl.com/y9rkhu8a

The driver only supports resume pm callback as power management is automatically controlled by the device. See pg.47 in TPS25750 datasheet https://tinyurl.com/3vfd2k43

v4:
- PATCH 1: No change
- PATCH 2: Fix comments style and drop of_match_ptr
v3:
- PATCH 1: Fix node name
- PATCH 2: Upload tps25750 driver patch
v2:
- PATCH 1: General properties clean up

Abdel Alkuor (2):
dt-bindings: usb: Add ti,tps25750
USB: typec: Add TI TPS25750 USB Type-C controller

 .../devicetree/bindings/usb/ti,tps25750.yaml  |   81 ++
 drivers/usb/typec/Kconfig                     |   13 +
 drivers/usb/typec/Makefile                    |    1 +
 drivers/usb/typec/tps25750.c                  | 1077 +++++++++++++++++
 drivers/usb/typec/tps25750.h                  |  162 +++
 5 files changed, 1334 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ti,tps25750.yaml
 create mode 100644 drivers/usb/typec/tps25750.c
 create mode 100644 drivers/usb/typec/tps25750.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/2 dt-bindings: usb: Add ti,tps25750

From: Abdel Alkuor <[email protected]>

TPS25750 provides power negotiation and capabilities management for USB Type-C applications.

---
v4:
- No change
v3:
- Drop typec label
- Use typec@21 as node name
v2:
- Remove redundant word 'binding' from Subject
- Add new line before reg property
- Remove unused description in interrupts property
- Drop interrupt-names property
- Add maxItems to firmware-name property
- Use generic node name 'typec' instead of 'tps25750'

---
 .../devicetree/bindings/usb/ti,tps25750.yaml  | 81 +++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ti,tps25750.yaml
Documentation/devicetree/bindings/usb/ti,tps25750.yaml new file +81 -0
new file mode 100644
index 000000000000..c658cb7ddec9
@@ -0,0 +1,81 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/usb/ti,tps25750.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments 25750 Type-C Port Switch and Power Delivery controller
+
+maintainers:
+  - Abdel Alkuor <[email protected]>
+
+description: |
+  Texas Instruments 25750 Type-C Port Switch and Power Delivery controller
+
+properties:
+  compatible:
+    enum:
+      - ti,tps25750
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  firmware-name:
+    description: |
+      Should contain the name of the default patch binary
+      file located on the firmware search path which is
+      used to switch the controller into APP mode
+    maxItems: 1
+
+  connector:
+    type: object
+    $ref: ../connector/usb-connector.yaml#
+    description:
+      Properties for usb c connector.
+    required:
+      - data-role
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - connector
+
+additionalProperties: true
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        typec@21 {
+            compatible = "ti,tps25750";
+            reg = <0x21>;
+
+            interrupt-parent = <&msmgpio>;
+            interrupts = <107 IRQ_TYPE_LEVEL_LOW>;
+            interrupt-names = "irq";
+
+            firmware-name = "tps25750.bin";
+
+            pinctrl-names = "default";
+            pinctrl-0 = <&typec_pins>;
+
+            typec_con: connector {
+                compatible = "usb-c-connector";
+                label = "USB-C";
+                data-role = "dual";
+                port {
+                    typec_ep: endpoint {
+                        remote-endpoint = <&otg_ep>;
+                    };
+                };
+            };
+        };
+    };
+...
Signature · 1 line
2.34.1
#2 lore raw

PATCH v4 2/2 USB: typec: Add TI TPS25750 USB Type-C controller

In reply to Abdel Alkuor

From: Abdel Alkuor <[email protected]>

TPS25750 is USB Type-C controller and Power Delivery controller.

TPS25750 needs to be configured after a cold reset. The configuration can be applied either from an external EEPROM connected to the controller or by a host using I2C. TI provides an online GUI that can be used to generate the configuration binary.
Tool link: https://tinyurl.com/2s3watcm
P.S. It requires a TI account to be able to use the tool.

Make sure to generate low region binary as using full flash binary fails when trying to apply the configuration.

In case the configuration is applied using the host, the user needs to provide the name of the binary using firmware-name property in the device tree. The process of applying a configuration can be found on pg.53 in TPS25750 Host Interface Technical Reference Manual(Rev. A).

Also, data-role property must be set as tps25750 doesn't provide a status information about the data role of the applied configuration.

---
v4:
- Fix all multi-line comments style
- Remove of_match_ptr
v3:
- Upload tps25750 driver patch
v2:
- No change

---
 drivers/usb/typec/Kconfig    |   13 +
 drivers/usb/typec/Makefile   |    1 +
 drivers/usb/typec/tps25750.c | 1077 ++++++++++++++++++++++++++++++++++
 drivers/usb/typec/tps25750.h |  162 +++++
 4 files changed, 1253 insertions(+)
 create mode 100644 drivers/usb/typec/tps25750.c
 create mode 100644 drivers/usb/typec/tps25750.h
drivers/usb/typec/Kconfig +13 -0
index 2f80c2792dbd..fa4f73472376 100644
@@ -110,6 +110,19 @@ config TYPEC_WUSB3801
 	  If you choose to build this driver as a dynamically linked module, the
 	  module will be called wusb3801.ko.
 
+config TYPEC_TPS25750
+	tristate "TI TPS25750 USB Power Delivery controller driver"
+	depends on I2C
+	select REGMAP_I2C
+	select USB_ROLE_SWITCH
+	select POWER_SUPPLY
+	help
+	  Say Y or M here if your system has TI TPS25750 USB Power
+	  Delivery controller.
+
+	  If you choose to build this driver as a dynamically linked module, the
+	  module will be called tps25750.ko.
+
 source "drivers/usb/typec/mux/Kconfig"
 
 source "drivers/usb/typec/altmodes/Kconfig"
drivers/usb/typec/Makefile +1 -0
index 7a368fea61bc..1132a557667b 100644
@@ -12,3 +12,4 @@ obj-$(CONFIG_TYPEC_STUSB160X) 	+= stusb160x.o
 obj-$(CONFIG_TYPEC_RT1719)	+= rt1719.o
 obj-$(CONFIG_TYPEC_WUSB3801)	+= wusb3801.o
 obj-$(CONFIG_TYPEC)		+= mux/
+obj-$(CONFIG_TYPEC_TPS25750)	+= tps25750.o
drivers/usb/typec/tps25750.c new file +1077 -0

1,077 lines not on this page · raw message

drivers/usb/typec/tps25750.h new file +162 -0

162 lines not on this page · raw message

Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v4 2/2] USB: typec: Add TI TPS25750 USB Type-C controller

Hello,

drivers/usb/typec/tps25750.c line 1072

Quoted 10 lines · Abdel Alkuor
drivers/usb/typec/tps25750.c new file +10 -0
+static struct i2c_driver tps25750_i2c_driver = {
+	.driver = {
+		.name = "tps25750",
+		.pm = pm_ptr(&tps25750_pm_ops),
+		.of_match_table = tps25750_of_match,
+	},
+	.probe_new = tps25750_probe,
+	.remove = tps25750_remove,
+	.id_table = tps25750_id,
+};

Please use .probe instead of .probe_new. Apart from just dropping "_new" here, nothing is needed. .probe_new will go away soon.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
maintainer
#4 lore raw
In reply to Abdel Alkuor
Quoted 34 lines · Abdel Alkuor

TPS25750 is USB Type-C and PD controller. The device is highly configurable using App Customization online Tool developed by TI to generate loadable binary.

TPS25750 supports three modes; PTCH, APP, and BOOT. A configuration can only be applied when the controller is on PTCH mode.

The controller attempts to load a configuration from EEPROM on I2Cm bus. If no EEPROM is detected, then the driver tries to load a configuration on I2Cs bus using a firmware file defined in DT.

The driver implements the binary loading sequence which can be found on pg.53 in TPS25750 Host Interface Technical Reference Manual (Rev. A) https://tinyurl.com/y9rkhu8a

The driver only supports resume pm callback as power management is automatically controlled by the device. See pg.47 in TPS25750 datasheet https://tinyurl.com/3vfd2k43

v4:
- PATCH 1: No change
- PATCH 2: Fix comments style and drop of_match_ptr
v3:
- PATCH 1: Fix node name
- PATCH 2: Upload tps25750 driver patch
v2:
- PATCH 1: General properties clean up

Abdel Alkuor (2):
dt-bindings: usb: Add ti,tps25750
USB: typec: Add TI TPS25750 USB Type-C controller

Quoted 9 lines
 .../devicetree/bindings/usb/ti,tps25750.yaml  |   81 ++
 drivers/usb/typec/Kconfig                     |   13 +
 drivers/usb/typec/Makefile                    |    1 +
 drivers/usb/typec/tps25750.c                  | 1077 +++++++++++++++++
 drivers/usb/typec/tps25750.h                  |  162 +++
 5 files changed, 1334 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ti,tps25750.yaml
 create mode 100644 drivers/usb/typec/tps25750.c
 create mode 100644 drivers/usb/typec/tps25750.h

TPS25750 has the same host interface as TI TPS65xxx controllers, no? The register offsets at least are exactly the same.

You need to first try to incorporate support for TI25750 support into the existing tipd driver (drivers/usb/typec/tipd/).

thanks,

Signature · 1 line
heikki
#5 lore raw
Quoted 35 lines · Heikki Krogerus
Quoted 34 lines · Abdel Alkuor

TPS25750 is USB Type-C and PD controller. The device is highly configurable using App Customization online Tool developed by TI to generate loadable binary.

TPS25750 supports three modes; PTCH, APP, and BOOT. A configuration can only be applied when the controller is on PTCH mode.

The controller attempts to load a configuration from EEPROM on I2Cm bus. If no EEPROM is detected, then the driver tries to load a configuration on I2Cs bus using a firmware file defined in DT.

The driver implements the binary loading sequence which can be found on pg.53 in TPS25750 Host Interface Technical Reference Manual (Rev. A) https://tinyurl.com/y9rkhu8a

The driver only supports resume pm callback as power management is automatically controlled by the device. See pg.47 in TPS25750 datasheet https://tinyurl.com/3vfd2k43

v4:
- PATCH 1: No change
- PATCH 2: Fix comments style and drop of_match_ptr
v3:
- PATCH 1: Fix node name
- PATCH 2: Upload tps25750 driver patch
v2:
- PATCH 1: General properties clean up

Abdel Alkuor (2):
dt-bindings: usb: Add ti,tps25750
USB: typec: Add TI TPS25750 USB Type-C controller

Quoted 9 lines
Quoted 9 lines
 .../devicetree/bindings/usb/ti,tps25750.yaml  |   81 ++
 drivers/usb/typec/Kconfig                     |   13 +
 drivers/usb/typec/Makefile                    |    1 +
 drivers/usb/typec/tps25750.c                  | 1077 +++++++++++++++++
 drivers/usb/typec/tps25750.h                  |  162 +++
 5 files changed, 1334 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ti,tps25750.yaml
 create mode 100644 drivers/usb/typec/tps25750.c
 create mode 100644 drivers/usb/typec/tps25750.h

Hi Heikki,

Quoted 3 lines

TPS25750 has the same host interface as TI TPS65xxx controllers, no? The register offsets at least are exactly the same.

Correct, the register offsets are the same. That being said, TPS25750 is a subset of TPS6598x where some registers are structured differently, and even some registers are not supported. Hence, Each has its own host interface manual.

Quoted 4 lines

You need to first try to incorporate support for TI25750 support into the existing tipd driver (drivers/usb/typec/tipd/).

Incorporating TPS25750 into TPS6598x driver is doable which requires the following changes:

- Only Check VID register (0x00) for TPS6598x and cd321x, as TPS25750 doesn't have VID register.

- TypeC port registration will be registered differently for each PD controller. TPS6598x uses system configuration register (0x28) to get pr/dr capabilities. On the other hand, TPS25750 will use data role property and PD status register (0x40) to get pr/dr capabilities as TPS25750 doesn't have register 0x28 supported.

- TPS25750 requires writing a binary configuration to switch PD controller from PTCH mode to APP mode which needs the following changes:
- Add PTCH mode to the modes list.
- Add an argument to tps6598x_check_mode to return the current mode.
- Currently, tps6598x_exec_cmd has cmd timeout hardcoded to 1 second, and doesn't wait before checking DATA_OUT response. In TPS25750, patch 4CCs take longer than 1 second to execute and some requires a delay before checking DATA_OUT. To accommodate that, cmd_timeout and response_delay will be added as arguments to tps6598x_exec_cmd.
- Implement applying patch sequence for TPS25750.

- In pm suspend callback, patch mode needs to be checked and the binary configuration should be applied if needed.

- For interrupt, TPS25750 has only one event register (0x14) and one mask register (0x16) of 11 bytes each, where TPS6598x has two event and two mask registers of 8 bytes each. Both TPS25750 and TPS65986x shares the same bit field offsets for events/masks/clear but many of there fields are reserved in TPS25750, the followings need to be done in tps6598x_interrupt:
- Read EVENT1 register as a block of 11 bytes when tps25750 is present
- Write CLEAR1 register as a block of 11 bytes when tps25750 is present
- Add trace_tps25750_irq
- During testing, I noticed that when a cable is plugged into the PD controller and before PD controller switches to APP mode, there is a lag between dr/pr updates and PlugInsertOrRemoval Event, so a check for dr/pr change needs to be added along TPS_REG_INT_PLUG_EVENT check

- Add TPS25750 traces for status and power status registers. Trace for data register won't be added as it doesn't exist in the device.

- Configure sleep mode for TPS25750.

Before writing the binary configuration, PBMs command is used to set up the patch bundle which consists of binary length, timeout, and slave address. The slave address is not the device I2C address, the bundle slave address can be any value except the ones that are listed for possible device addresses which are 0x20, 0x21, 0x22, and 0x23 based on pg.44 in https://www.ti.com/lit/ds/symlink/tps25750.pdf.
Currently, I'm using 0x0F for the bundle slave address which I think is not the right way of assigning such address as a conflict may arise when there is another device with 0x0F address is present on the same I2C bus.

Should the bundle address be set as property in the device node? Or should we use i2c_probe_func_quick_read to scan the bus and find an available address that is not used?

Thanks,
Abdel