Commit graph

12 commits

Author SHA1 Message Date
Michał Barnaś 0b4365ef29 usbc: add support for TCPC control of vbus sourcing
Adds calls to the set_src_ctrl of TCPC driver to enable and disable
the VBUS sourcing. If the TCPC doesn't support these functions,
no errors should be printed.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2024-06-12 18:17:17 -04:00
Fin Maaß 7d83a8a68a lib: smf: constant number of arguments for SMF_CREATE_STATE()
This sets the number of arguments for SMF_CREATE_STATE() to always
be the same, independent of the selected Kconfig options.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-07 17:46:21 +02:00
Michał Barnaś 551c7654f5 usbc: integrate the PPC with the USB-C stack
Add calls to the PPC API that enables and disables the sink and source
paths in the appropriate USB-C stack states.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2024-01-18 10:53:53 +01:00
Michał Barnaś 3848e4c023 usbc: add checks for results of TCPC functions
This commit adds checks for results and in case of error, handles it.
The failed initialization of the TCPC can postpone initialization in
case the TCPC needs more time after powering up. Otherwise if other
error happened, the Type-C Layer will be disabled.
Errors in other places of the USB-C stack, like communication errors,
moves the state machine to the error recovery, restarting the
communication with parner.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś 793d29d23f usbc: check if setting the CC and VCONN was successful
This commit adds check in cc_open entry state and logs if setting
either of the values were unsuccessful.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś cff8bb2687 usbc: check if sampling CC lines were successful
When the get_cc function returns error, the CC lines should be
considered as open. It may happen either due to some chip malfunction
or chip going into sleep mode and needing time to reinitialize.
TCPC should only go to sleep if there is no partner attaches, so
in case of this error, the lines should be considered as disconnected.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Michał Barnaś 216bc4db73 usbc: add check if tcpc initialization was successful
The TCPC driver initialization can be unsuccessful and it should be
checked and logged if that's the case.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-10-20 14:57:32 +02:00
Sam Hurst 0056249a13 usb-c: Add USB-C Subsystem Source PD Support
Add USB-C Power Delivery Source Support to USB-C
Subsystem

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-04-28 10:06:01 +02:00
Michał Barnaś e0fbd35fc0 usbc: explicitly declare sizes of state machines arrays
The asserts in the USB-C stack functions were causing compilation
errors when asserts were enabled in Kconfig.
This was caused because the asserts checked if the functions
parameters were within limits specified by the state machine arrays.
At the position of these asserts, these arrays were only declared
without specifying the size of them, what prohibited the asserts from
knowing the size of arrays and checking if specified value is within
limit of it.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2023-03-03 09:17:11 +01:00
Sam Hurst f04da7f7ab usb_c: Check state machine array of states
Build time check that the number of states initialized
in the state machine array matches the number of enums
used to index said array.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst 914fed36d5 usb_c: run clang-format
Run clang-format

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00
Sam Hurst 7910c617be usb-c: Refactor USB-C Subsystem Sink
Refactor USB-C Subsystem Sink so that Power Delivery
Source support and be easily added.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-05 10:34:06 +01:00