Commit Graph

36 Commits

Author SHA1 Message Date
Michał Barnaś b9ef11d4b4 usbc: add event-driven handling of CC lines changes in ps8815 driver
Add bool value that stores the CC change information received in
the interrupt of TCPC alert line. In sink role when in disconnected
state, polling the CC lines causes the chip to be awaken from sleep
mode increasing the power usage. When partner is connected, or any
other CC lines change happens, the chip informs about it with alert.
It can be cached and used instead of asking the chip directly.

Signed-off-by: Michał Barnaś <barnas@google.com>
2024-09-23 10:03:19 +02:00
Michał Barnaś 82a6e9fc66 usbc: add TCPC driver for Parade PS8815 chip
Add support for the PS8815 and used with other PS8xxx family chips.

Signed-off-by: Michał Barnaś <barnas@google.com>
2024-09-23 10:03:19 +02:00
Michał Barnaś 90c65cffdb usbc: add support for vbus measurement using TCPCI compliant device
Add support for VBUS measuring part of the TCPCI compliant device.
This device should be used as a child-node for the more specific
TCPC driver and referenced by the vbus property in the usb-c
connector node.

Signed-off-by: Michał Barnaś <barnas@google.com>
2024-09-23 10:03:19 +02:00
Michał Barnaś 198e040b4e usbc: add generic TCPCI related functions
Add generic functions that will be common to all TCPCI compliant
drivers like registers reading, writing and updating.

Signed-off-by: Michał Barnaś <barnas@google.com>
2024-09-23 10:03:19 +02:00
Erwan Gouriou d13f9d9b9b drivers: stm32: Select PINCTRL when required
Select PINCTRL subsystem by drivers which require it.
Prevent the need from enabling this symbol at board or soc level.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2024-09-03 14:40:55 +01:00
Chun-Chieh Li 9e9e409cb9 drivers: usb_c: numaker: support Nuvoton's M2L31 series
1. Support USB-C drivers TCPC, PPC, and VBUS with UTCPD H/W IP
2. UTCPD is interconnected with Timer-triggered EADC for updating
   VBUS/VCONN voltage periodically

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2024-08-01 12:38:53 +02:00
Pieter De Gendt e5a126ae0e drivers: usbc_ppc: Rename usbc_ppc_drv to usbc_ppc_driver_api
Structs with a __subsystem tag are required to have a _driver_api suffix.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-05-03 14:44:41 +01:00
Michał Barnaś 77187548ff usbc: add driver for nx20p3483 PPC chip
Add driver for NXP nx20p3483 power path controller that can be used
to control and protect sink and source path of USB-C connector.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2024-01-18 10:53:53 +01:00
Michał Barnaś 6bd26a0575 usbc: add shell commands for PPC manipulation
Add support for ppc shell command with subcommands that can print
the status of PPC (dead battery, sinking, sourcing, vbus detected),
dump registers and request the PPC to exit dead battery mode.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2024-01-18 10:53:53 +01:00
Michał Barnaś 85219ed13c usbc: add API for the Power Path Controllers
This commit adds an API to the Power Path Controllers (PPC) that
may be used with USB-C subsystem to control the current paths,
enabling and disabling sourcing and sinking VBUS and protect against
shorts, overvoltage and overcurrent.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2024-01-18 10:53:53 +01:00
Michał Barnaś 5246cea800 usbc: improve error handling in the ucpd_stm32 and vbus_adc
As noted in PR#63165 checking of result should use comparison to
success value instead of checking if result is negative. It will
allow to check if function returned invalid but positive value.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś fe0b6af337 usbc: merge the is_rx and get_rx_pending_msg functions
These two functions are used together so there is no need for
splitting them into two functions. This commit also makes this
function required to be implemented by the TCPC driver.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś 88b6fc62d5 usbc: change type for functions that may return error code
TCPC API functions should be able to inform the caller if the function
is supported and successfully executed. Bool values doesn't allow this
so it is needed to change the type to int.
For is_rx_pending_msg function the return code should conform to
existing error codes, so in case of function being not supported,
the -ENOSYS should be returned. In case of successful execution,
if there is no pending message, the -ENODATA should be returned and
in case of message pending, the value of 0.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś 2e3fcbfaa4 usbc: add "chip" subcommand for "tcpc" shell command
Add "chip" subcommand that displays the vendor, product and device
identifiers for all TCPC referenced by USB-C connectors.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:12 +02:00
Michał Barnaś 8270d0495d usbc: add "vbus" subcommand for "tcpc" shell command
Add "vbus" subcommand that displays VBUS voltages for all USB-C
connectors.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:12 +02:00
Michał Barnaś 24d152ace3 usbc: add "tcpc" shell command
Add "tcpc" shell command with "dump" subcommand used to dump
all registers of all the TCPCs.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:12 +02:00
Michał Barnaś 9608c8f667 usbc: fix conflicting Kconfigs for USB-C related init priority
There was a new Kconfig for USB-C init priority that is conflicting
with currently used Kconfig for init of VBUS and TCPC.
This commit changes the names to more specific related to the subsystem
they belong to.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-09-20 11:26:40 +01:00
Nick Ward 2bf091f8af drivers: usb-c: fix - check if adc_channel is ready before use
This will protect a user of this driver against driver initialisation
order misconfiguration.

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-07-17 10:16:22 +00:00
Sam Hurst 430990ee3f usb-c: tcpc: Disable Dead Battery after system starts
The Dead Battery resistors interfere with port partner
detection. So, Dead Battery is disabled after the system
starts and sets the Rd or Rp resistors on the CC lines.

Tested on b_g474e_dpow1 with JP5 set to USBC.
Tested on stm32g081b_eval with JP17 set to D5V.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-03-09 09:20:35 +01:00
Sam Hurst cc416a8b9b usb-c: tcpc: Add support for Dead Battery
Add Dead Battery functionality to the TCPC drive

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-02-06 10:03:13 +01:00
Sam Hurst 6b4b7a02e7 usb-c: tcpc: Enable ISR Hard Reset sent bits
This change enables the ISR Hard Reset sent bits, so that
an interrupt is generated when a Hard Reset is sent or
the Hard Reset failed.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-24 09:43:20 +01:00
Sam Hurst 603ac13145 usb-c: tcpc: Correctly detect Hard Reset sent detection
The Hard Reset sent signal was tested twice in the same
"if else" structure but only handled in the last test. This
change removes the first detection so that Hard Reset can
be correctly detected.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-24 09:43:20 +01:00
Sam Hurst e3365e961d usb-c: tcpc: Simplify Hard Reset complete logic
This change simplifies the Hard Reset complete logic

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-24 09:43:20 +01:00
Sam Hurst 77e1638c3c drivers: usb_c: tcpc: stm32: Add VCONN functionality
Add VCONN discharge functionality to TCPC and driver

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-12-20 09:22:21 +01:00
Sam Hurst a19cf99aa3 drivers: usb_c: tcpc: stm32: Explicitly set the unconnected CC line to OPEN
Explicitly set the unconnected CC line to OPEN, so that it can be
used for VCONN.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-12-20 09:22:21 +01:00
Sam Hurst 21f28eacbc drivers: usb_c: tcpc: stm32: Add GoodCRC timer
When operating as a Source, the driver will wait indefinitely for
a GoodCRC message from a Sink. This PR adds a timer to trigger a
no response when a GoodCRC message isn't received.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-12-20 09:22:21 +01:00
Sam Hurst c659f3d8d7 drivers: usb_c: tcpc: stm32: Enable ISR after all UCPD devices initialized
Since all UCPD devices share the same ISR, the interrupt
should be enabled after all UCPD devices are initialized.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-12-20 09:22:21 +01:00
Sam Hurst 9750951dd1 drivers: usb_c: tcpc: stm32: Simplify shared ISR detection
Remove unnecessary code used during shared ISR detection

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-12-20 09:22:21 +01:00
Sam Hurst 029dc41acb drivers: usb_c: tcpc: stm32: Read UCPD Status Reg for source of IRQ
At system startup, the SYSCFG ITLINE registers might not
indicate an interrupt even though a UCPD interrupt is pending.
This cause the ISR to be called repeatedly without being serviced,
resulting in a system lockup. Reading the UCPD Status Reg instead
of the SYSCFG ITLINE register fixes the issue.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-12-20 09:22:21 +01:00
Sam Hurst 1a5e2c9c13 usb-c: Remove VBUS measurement and control
A USB-C VBUS driver will be used to measure VBUS
instead of accessing the measurement hardware
directly.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst f4b2457322 drivers: usb-c: Update TCPC driver to use devicetree Kconfig symbol
Update TCPC driver to use DT_HAS_<compat>_ENABLED Kconfig symbol
to expose the driver and enable it by default based on devicetree.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst 505892f1bb usb-c: Add USB-C VBUS ADC driver
This commit adds a VBUS driver the uses an ADC connected
to a voltage divider to measure VBUS.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst 9659819365 usb-c: tcpc: Changes the @return tag to @retval
The "@return" command should be used for the arbitrary return
description, and "@retval <return value>" for the description
of named return value

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst 050323f00f stm32: Use DT_NUM_INST_STATUS_OKAY for num IRQ sources
Use DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) to determine
number of potential interrupt sources. This mitigates
the wasting of memory on devices with mutliple UCPD ports
but only one UCPD port is used.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst 99e07709ff boards: arm: Update STM32 UCPD nodes with pin control
Assign the pins for the STM32G071b and STM32G081b STM32
UCPD peripherals so the UCPD driver can properly
configure the device.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00
Sam Hurst 3dd07aebdd usb-c: Change dir name from usbc to usb_c
For improved readability, change dir name from
usbc to usb_c

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2022-10-22 18:38:35 -04:00