usb: typec: tipd: Add sn201202x (ACE3) support
Subsystems (3)
v9 cover usb: typec: tipd: Add sn201202x (ACE3) support
Add support for sn201202x (a.k.a ACE3), an Apple-specific tps6598x variant that wraps the tps6598x core register set with a SPMI based regmap-like protocol, first appearing in Apple M3 devices. This series first makes the core parts bus-agnostic, and then adds the new SPMI interface as a custom regmap implementation.
To simplify the merge strategy, the device tree entries will be sent in a future patch series.
---
Changes in v9:
- Add the new no_mode_control = true
- Improve some error handling
- Link to v8: https://patch.msgid.link/[email protected]
Changes in v8:
- Rebase on latest
- Link to v7: https://patch.msgid.link/[email protected]
Changes in v7:
- Rebase on usb-testing
- Link to v6: https://patch.msgid.link/[email protected]
Changes in v6:
- Fix rebase issues
- Link to v5: https://patch.msgid.link/[email protected]
Changes in v5:
- Rebase on usb-next
- Link to v4: https://patch.msgid.link/[email protected]
Changes in v4:
- Unexport variant data
- One more debugfs-safety fix
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- Restore accidentally deleted static
- Fix building with tracepoints
- Sleep the device on failed probe
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Use a -core module instead of building everything twice
- Fix completion handling
- Make regmaps debugfs-safe
- Link to v1: https://patch.msgid.link/[email protected]
---
Alyssa Milburn (1):
usb: typec: tipd: Factor out i2c specifics
Sasha Finkelstein (2):
dt-bindings: usb: tps6598x: Add sn201202x/ACE3
usb: typec: tipd: Add sn201202x support
.../devicetree/bindings/usb/apple,sn201202x.yaml | 78 ++++++ MAINTAINERS | 2 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/tipd/Kconfig | 21 +- drivers/usb/typec/tipd/Makefile | 14 +- drivers/usb/typec/tipd/core.c | 248 ++++------------- drivers/usb/typec/tipd/i2c.c | 107 ++++++++ drivers/usb/typec/tipd/spmi.c | 303 +++++++++++++++++++++ drivers/usb/typec/tipd/tps6598x.h | 132 +++++++++ 9 files changed, 710 insertions(+), 196 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260725-tipd-ace3-090bf570ef59
Best regards,
Signature · 1 line
Sasha Finkelstein <[email protected]>
PATCH v9 1/3 dt-bindings: usb: tps6598x: Add sn201202x/ACE3
A variant of tps6598x that is attached to a SPMI bus and is found on Apple devices starting from the M3 series
--- .../devicetree/bindings/usb/apple,sn201202x.yaml | 78 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 79 insertions(+)
Documentation/devicetree/bindings/usb/apple,sn201202x.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/apple,sn201202x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments sn201202x Type-C Power Delivery controller + +maintainers: + - Sasha Finkelstein <[email protected]> + +description: | + Texas Instruments sn201202x Type-C Power Delivery controller + + A variant of tps6598x controller also known as Apple ACE3 + present on hardware with Apple SoCs starting from the M3. + +properties: + compatible: + enum: + - apple,sn201202x + + reg: + maxItems: 1 + + interrupts: + items: + - description: Primary irq used for tps6598x events + - description: Logical register selection completed + - description: Standby command completed + - description: Wakeup command completed + + interrupt-names: + items: + - const: irq + - const: select + - const: sleep + - const: wake + + connector: + $ref: /schemas/connector/usb-connector.yaml# + +required: + - compatible + - reg + - interrupts + - interrupt-names + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/spmi/spmi.h> + spmi { + #address-cells = <2>; + #size-cells = <0>; + usb-pd@c { + compatible = "apple,sn201202x"; + reg = <0xc SPMI_USID>; + interrupts = <11 IRQ_TYPE_EDGE_RISING>, + <13 IRQ_TYPE_EDGE_RISING>, + <17 IRQ_TYPE_EDGE_RISING>, + <19 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "irq", "select", "sleep", "wake"; + + connector { + compatible = "usb-c-connector"; + label = "USB-C"; + + port { + typec_ep: endpoint { + remote-endpoint = <&otg_ep>; + }; + }; + }; + }; + };
MAINTAINERS +1 -0
@@ -2736,6 +2736,7 @@ F: Documentation/devicetree/bindings/soc/apple/apple,t6000-pmgr-misc.yaml F: Documentation/devicetree/bindings/spi/apple,spi.yaml F: Documentation/devicetree/bindings/spmi/apple,spmi.yaml F: Documentation/devicetree/bindings/usb/apple,dwc3.yaml +F: Documentation/devicetree/bindings/usb/apple,sn201202x.yaml F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml F: Documentation/hwmon/macsmc-hwmon.rst F: arch/arm64/boot/dts/apple/
Signature · 1 line
2.56.1
PATCH v9 2/3 usb: typec: tipd: Factor out i2c specifics
In reply to Sasha FinkelsteinFrom: Alyssa Milburn <[email protected]>
Make the core driver more bus-agnostic to prepare for SPMI variants of the tipd chip
--- drivers/usb/typec/tipd/Kconfig | 8 +- drivers/usb/typec/tipd/Makefile | 11 +- drivers/usb/typec/tipd/core.c | 230 +++++++------------------------------- drivers/usb/typec/tipd/i2c.c | 107 ++++++++++++++++++ drivers/usb/typec/tipd/tps6598x.h | 123 ++++++++++++++++++++ 5 files changed, 281 insertions(+), 198 deletions(-)
drivers/usb/typec/tipd/Kconfig +6 -2
@@ -1,9 +1,13 @@ +config TYPEC_TPS6598X_CORE + tristate + select USB_ROLE_SWITCH + select POWER_SUPPLY + config TYPEC_TPS6598X tristate "TI TPS6598x USB Power Delivery controller driver" depends on I2C - select POWER_SUPPLY select REGMAP_I2C - select USB_ROLE_SWITCH + select TYPEC_TPS6598X_CORE help Say Y or M here if your system has TI TPS65982 or TPS65983 USB Power Delivery controller.
drivers/usb/typec/tipd/Makefile +7 -4
@@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS_trace.o := -I$(src) +CFLAGS_trace.o := -I$(src) -obj-$(CONFIG_TYPEC_TPS6598X) += tps6598x.o -tps6598x-y := core.o -tps6598x-$(CONFIG_TRACING) += trace.o +obj-$(CONFIG_TYPEC_TPS6598X_CORE) += tps6598x-core.o +tps6598x-core-y := core.o +tps6598x-core-$(CONFIG_TRACING) += trace.o + +obj-$(CONFIG_TYPEC_TPS6598X) += tps6598x.o +tps6598x-y := i2c.o
drivers/usb/typec/tipd/core.c +38 -192
381 lines not on this page · raw message
drivers/usb/typec/tipd/i2c.c new file +107 -0
107 lines not on this page · raw message
drivers/usb/typec/tipd/tps6598x.h +123 -0
133 lines not on this page · raw message
Signature · 1 line
2.56.1
Re: [PATCH v9 2/3] usb: typec: tipd: Factor out i2c specifics
Quoted 9 lines · Sasha Finkelstein
From: Alyssa Milburn <[email protected]>
Make the core driver more bus-agnostic to prepare for SPMI variants of the tipd chip
Signed-off-by Alyssa Milburn <[email protected]>Reviewed-by Heikki Krogerus <[email protected]>Signed-off-by Sasha Finkelstein <[email protected]>---
Thanks,
Sven
PATCH v9 3/3 usb: typec: tipd: Add sn201202x support
In reply to Sasha FinkelsteinAdd support for sn201202x (aka ACE3), a tipd variant that uses a very similar register map, that is exposed over a "logical register" interface on the SPMI bus.
--- MAINTAINERS | 1 + drivers/usb/typec/Makefile | 1 + drivers/usb/typec/tipd/Kconfig | 13 ++ drivers/usb/typec/tipd/Makefile | 3 + drivers/usb/typec/tipd/core.c | 22 +++ drivers/usb/typec/tipd/spmi.c | 303 ++++++++++++++++++++++++++++++++++++++ drivers/usb/typec/tipd/tps6598x.h | 9 ++ 7 files changed, 352 insertions(+)
MAINTAINERS +1 -0
@@ -2767,6 +2767,7 @@ F: drivers/soc/apple/* F: drivers/spi/spi-apple.c F: drivers/spmi/spmi-apple-controller.c F: drivers/usb/dwc3/dwc3-apple.c +F: drivers/usb/typec/tipd/spmi.c F: drivers/video/backlight/apple_dwi_bl.c F: drivers/watchdog/apple_wdt.c F: include/dt-bindings/interrupt-controller/apple-aic.h
drivers/usb/typec/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_TYPEC) += altmodes/ obj-$(CONFIG_TYPEC_TCPM) += tcpm/ obj-$(CONFIG_TYPEC_UCSI) += ucsi/ obj-$(CONFIG_TYPEC_TPS6598X) += tipd/ +obj-$(CONFIG_TYPEC_SN201202X) += tipd/ obj-$(CONFIG_TYPEC_ANX7411) += anx7411.o obj-$(CONFIG_TYPEC_HD3SS3220) += hd3ss3220.o obj-$(CONFIG_TYPEC_STUSB160X) += stusb160x.o
drivers/usb/typec/tipd/Kconfig +13 -0
@@ -14,3 +14,16 @@ config TYPEC_TPS6598X If you choose to build this driver as a dynamically linked module, the module will be called tps6598x.ko. + +config TYPEC_SN201202X + tristate "TI SN201202x USB Power Delivery controller support" + depends on SPMI + select REGMAP + select TYPEC_TPS6598X_CORE + help + Say Y here to enable support for SN201202x, a TPS6598x variant + that uses SPMI as a host bus, and is found on Apple devices starting + from the M3 series. + + If you choose to build this driver as a dynamically linked module, the + module will be called sn201202x.ko.
drivers/usb/typec/tipd/Makefile +3 -0
@@ -7,3 +7,6 @@ tps6598x-core-$(CONFIG_TRACING) += trace.o obj-$(CONFIG_TYPEC_TPS6598X) += tps6598x.o tps6598x-y := i2c.o + +obj-$(CONFIG_TYPEC_SN201202X) += sn201202x.o +sn201202x-y := spmi.o
drivers/usb/typec/tipd/core.c +22 -0
@@ -1963,11 +1963,33 @@ static const struct tipd_data tipd_tps25750_data = { .connect = tps6598x_connect, }; +static const struct tipd_data tipd_sn201202x_data = { + .irq_handler = cd321x_interrupt, + .irq_mask1 =APPLE_CD_REG_INT_POWER_STATUS_UPDATE | +APPLE_CD_REG_INT_DATA_STATUS_UPDATE | +APPLE_CD_REG_INT_PLUG_EVENT , + .tps_struct_size =sizeof (struct sn201202x ), + .no_mode_control = true, + .remove = cd321x_remove, + .register_port = cd321x_register_port, + .unregister_port = cd321x_unregister_port, + .trace_data_status = trace_cd321x_data_status, + .trace_power_status = trace_tps6598x_power_status, + .trace_status = trace_tps6598x_status, + .init = cd321x_init, + .read_data_status = cd321x_read_data_status, + .read_power_status = tps6598x_read_power_status, + .reset = cd321x_reset, + .switch_power_state = cd321x_switch_power_state, + .connect = cd321x_connect, +}; +const struct tipd_data *tipd_hw_variants[] = { [TIPD_VARIANT_CD321X ] = &tipd_cd321x_data, [TIPD_VARIANT_TPS6598X ] = &tipd_tps6598x_data, [TIPD_VARIANT_TPS66993 ] = &tipd_tps66993_data, [TIPD_VARIANT_TPS25750 ] = &tipd_tps25750_data, + [TIPD_VARIANT_SN201202X ] = &tipd_sn201202x_data, };EXPORT_SYMBOL_GPL (tipd_hw_variants);
drivers/usb/typec/tipd/spmi.c new file +303 -0
303 lines not on this page · raw message
drivers/usb/typec/tipd/tps6598x.h +9 -0
@@ -283,6 +283,7 @@ enum tipd_hw_variant {TIPD_VARIANT_TPS6598X ,TIPD_VARIANT_TPS66993 ,TIPD_VARIANT_TPS25750 , +TIPD_VARIANT_SN201202X , TIPD_VARIANT_MAX, };
@@ -388,6 +389,14 @@ struct cd321x {struct usb_pd_identity cur_partner_identity; }; +struct sn201202x { +struct cd321x cd; +struct completion select_completion; +struct completion sleep_completion; +struct completion wake_completion; +struct spmi_device *sdev; +}; +extern const struct tipd_data *tipd_hw_variants[];extern const struct regmap_config tps6598x_regmap_config;
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v9 3/3] usb: typec: tipd: Add sn201202x support
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] usb: typec: tipd: race with tps->irq in sn201202x_suspend() and resume --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] usb: typec: tipd: race with tps->irq in sn201202x_suspend() and resume
--
commit f1872e14e7db08290e3e00b97a27f328d4ac8b8d
Author: Sasha Finkelstein <[email protected]>
usb: typec: tipd: Add sn201202x support
This commit adds an SPMI driver and variant definition for the SN201202x USB Power Delivery controller.
Quoted 5 lines
drivers/usb/typec/tipd/spmi.c new file +0
-0
[ ... ]
Quoted 27 lines
drivers/usb/typec/tipd/spmi.c new file +27
-0+static int __maybe_unused sn201202x_resume (struct device *dev) +{ +struct tps6598x *tps =dev_get_drvdata (dev); +struct sn201202x *sn =tps_to_sn (tps); +int err; + +reinit_completion (&sn->wake_completion); + err =spmi_command_wakeup (sn->sdev); +if (err) +return err; +if (!wait_for_completion_timeout (&sn->wake_completion,msecs_to_jiffies (100 ))) +return -ETIMEDOUT ; +return tipd_resume (tps); +} + +static int __maybe_unused sn201202x_suspend (struct device *dev) +{ +struct tps6598x *tps =dev_get_drvdata (dev); +struct sn201202x *sn =tps_to_sn (tps); +int err; + + err =tipd_suspend (tps); +if (err) +return err; +reinit_completion (&sn->sleep_completion); + err =spmi_command_sleep (sn->sdev); +if (err)
drivers/usb/typec/tipd/spmi.c line 283
Quoted 10 lines
drivers/usb/typec/tipd/spmi.c new file +10
-0+ goto out_resume; +if (!wait_for_completion_timeout (&sn->sleep_completion,msecs_to_jiffies (100 ))) +dev_err (dev,"Waiting for sleep complete irq timed out" ); + +return 0 ; + +out_resume: +tipd_resume (tps); +return err; +}
[Severity: Medium]
Can cd321x_interrupt() race with spmi_command_sleep() and spmi_command_wakeup() when tps->wakeup is false?
tipd_suspend() only calls disable_irq(tps->irq) when tps->wakeup is set:
drivers/usb/typec/tipd/core.c:tipd_suspend() {
if (tps->wakeup) {
disable_irq(tps->irq);
enable_irq_wake(tps->irq);
} else if (tps->reset) {
gpiod_set_value_cansleep(tps->reset, 1);
}
...
}When tps->wakeup is false, tps->irq stays enabled during dpm_suspend() and is re-enabled by dpm_resume_noirq() before dpm_resume() runs sn201202x_resume():
CPU0 CPU1 (irq thread)sn201202x_suspend()
tipd_suspend(tps)
spmi_command_sleep(sn->sdev)
cd321x_interrupt()
...
regmap_sn201202x_select_reg()
<-- SPMI access while sleepingThe same race occurs on resume if a pending tps->irq fires after resume_device_irqs() but before sn201202x_resume() issues spmi_command_wakeup(), causing logical register selection timeouts and dropped Type-C status updates. Disabling tps->irq in tipd_suspend() (and re-enabling it in tipd_resume()) unconditionally when tps->irq is valid would serialize the IRQ thread against the SPMI sleep state.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v9 3/3] usb: typec: tipd: Add sn201202x support
In reply to Sasha FinkelsteinQuoted 9 lines · Sasha Finkelstein
Add support for sn201202x (aka ACE3), a tipd variant that uses a very similar register map, that is exposed over a "logical register" interface on the SPMI bus.
Reviewed-by Heikki Krogerus <[email protected]>Co-developed-by Alyssa Milburn <[email protected]>Signed-off-by Alyssa Milburn <[email protected]>Signed-off-by Sasha Finkelstein <[email protected]>---
Thanks,
Sven
[email protected]
AI reviewSashiko has finished reviewing this 3-patch series:
Sashiko has finished reviewing this 3-patch series:
- Patches 1 and 2: no issues found.
- Patch 3 ("usb: typec: tipd: Add sn201202x support"): 1 potential issue (1 Medium)
A detailed review has been sent as a separate reply to patch 3.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]