Skip to contentSkip to conversation

Add support for TPS25750

PATCH Superseded Abdel Alkuor 2 participants 6 messages Aug 20, 2023

Subsystems (3)

v3 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#3 lore raw

PATCH v3 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.

---
v3:
- Upload tps25750 driver patch
v2:
- No changes

---
 drivers/usb/typec/Kconfig    |   13 +
 drivers/usb/typec/Makefile   |    1 +
 drivers/usb/typec/tps25750.c | 1065 ++++++++++++++++++++++++++++++++++
 drivers/usb/typec/tps25750.h |  162 ++++++
 4 files changed, 1241 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 +1065 -0

1,065 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
#0 lore raw

v3 cover Add support for TPS25750

From: Abdel Alkuor <[email protected]>

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

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                  | 1065 +++++++++++++++++
 drivers/usb/typec/tps25750.h                  |  162 +++
 5 files changed, 1322 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 v3 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.

---
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
Reviewed-by on v3 1/2
#2 lore raw

Re: [PATCH v3 1/2] dt-bindings: usb: Add ti,tps25750

Quoted 7 lines · Abdel Alkuor

From: Abdel Alkuor <[email protected]>

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

---

---

This is an automated instruction, just in case, because many review tags are being ignored. If you know the process, you can skip it (please do not feel offended by me posting it here - no bad intentions intended). If you do not know the process, here is a short explanation:

Please add Acked-by/Reviewed-by/Tested-by tags when posting new versions, under or above your Signed-off-by tag. Tag is "received", when provided in a message replied to you on the mailing list. Tools like b4 can help here. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for tags received on the version they apply.

https://elixir.bootlin.com/linux/v6.5-rc3/source/Documentation/process/submitting-patches.rst#L577

Best regards,
Krzysztof

#4 lore raw

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

In reply to Abdel Alkuor
Quoted 11 lines · 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.

...

Quoted 15 lines
drivers/usb/typec/tps25750.c new file +15 -0
+
+static void tps25750_remove(struct i2c_client *client)
+{
+	struct tps25750 *tps = i2c_get_clientdata(client);
+
+	tps25750_disconnect(tps, 0);
+	typec_unregister_port(tps->port);
+	usb_role_switch_put(tps->role_sw);
+
+	/* clear the patch by a hard reset */
+	tps25750_exec_normal_cmd(tps, TPS_4CC_GAID);
+}
+
+static int __maybe_unused tps25750_suspend(struct device *dev)
+{

drivers/usb/typec/tps25750.c line 1029

Quoted 10 lines
drivers/usb/typec/tps25750.c new file +10 -0
+	/* TODO: should we remove the patch? */
+	return 0;
+}
+
+static int __maybe_unused tps25750_resume(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct tps25750 *tps = i2c_get_clientdata(client);
+
+	/* The controller needs to be reinitialized again

Format is:

/*
* The....

Quoted 16 lines
drivers/usb/typec/tps25750.c new file +16 -0
+	 * if it is powered off as config is not persisted
+	 */
+	return tps25750_init(tps);
+}
+
+static const struct dev_pm_ops tps25750_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(tps25750_suspend, tps25750_resume)
+};
+
+static const struct of_device_id tps25750_of_match[] = {
+	{ .compatible = "ti,tps25750", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, tps25750_of_match);
+
+static const struct i2c_device_id tps25750_id[] = {

drivers/usb/typec/tps25750.c line 1055

Quoted 10 lines
drivers/usb/typec/tps25750.c new file +10 -0
+	{ "tps25750" },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, tps25750_id);
+
+static struct i2c_driver tps25750_i2c_driver = {
+	.driver = {
+		.name = "tps25750",
+		.pm = pm_ptr(&tps25750_pm_ops),
+		.of_match_table = of_match_ptr(tps25750_of_match),

Drop of_match_ptr(). It will cause warnings.

drivers/usb/typec/tps25750.c line 1061

Quoted 6 lines
drivers/usb/typec/tps25750.c new file +6 -0
+	},
+	.probe_new = tps25750_probe,
+	.remove = tps25750_remove,
+	.id_table = tps25750_id,
+};
+module_i2c_driver(tps25750_i2c_driver);

Best regards,
Krzysztof

#5 lore raw

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

Quoted 43 lines · Krzysztof Kozlowski
Quoted 11 lines · 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.

...

Quoted 15 lines
drivers/usb/typec/tps25750.c new file +15 -0
+
+static void tps25750_remove(struct i2c_client *client)
+{
+	struct tps25750 *tps = i2c_get_clientdata(client);
+
+	tps25750_disconnect(tps, 0);
+	typec_unregister_port(tps->port);
+	usb_role_switch_put(tps->role_sw);
+
+	/* clear the patch by a hard reset */
+	tps25750_exec_normal_cmd(tps, TPS_4CC_GAID);
+}
+
+static int __maybe_unused tps25750_suspend(struct device *dev)
+{

drivers/usb/typec/tps25750.c line 1029

Quoted 10 lines
drivers/usb/typec/tps25750.c new file +10 -0
+	/* TODO: should we remove the patch? */
+	return 0;
+}
+
+static int __maybe_unused tps25750_resume(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct tps25750 *tps = i2c_get_clientdata(client);
+
+	/* The controller needs to be reinitialized again

Format is:

Quoted 3 lines

/*
* The....

Fixed all mult-line comments in v4.

Quoted 20 lines
Quoted 20 lines
drivers/usb/typec/tps25750.c new file +20 -0
+	 * if it is powered off as config is not persisted
+	 */
+	return tps25750_init(tps);
+}
+
+static const struct dev_pm_ops tps25750_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(tps25750_suspend, tps25750_resume)
+};
+
+static const struct of_device_id tps25750_of_match[] = {
+	{ .compatible = "ti,tps25750", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, tps25750_of_match);
+
+static const struct i2c_device_id tps25750_id[] = {
+	{ "tps25750" },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, tps25750_id);
Quoted 9 lines

drivers/usb/typec/tps25750.c line 1055

Quoted 6 lines
drivers/usb/typec/tps25750.c new file +6 -0
+
+static struct i2c_driver tps25750_i2c_driver = {
+	.driver = {
+		.name = "tps25750",
+		.pm = pm_ptr(&tps25750_pm_ops),
+		.of_match_table = of_match_ptr(tps25750_of_match),

Drop of_match_ptr(). It will cause warnings.

Removed in v4.

Quoted 11 lines

drivers/usb/typec/tps25750.c line 1061

Quoted 6 lines
drivers/usb/typec/tps25750.c new file +6 -0
+	},
+	.probe_new = tps25750_probe,
+	.remove = tps25750_remove,
+	.id_table = tps25750_id,
+};
+module_i2c_driver(tps25750_i2c_driver);

Best regards,
Krzysztof

Thanks,
Abdel