-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usbc source #52993
Usbc source #52993
Conversation
578889e
to
7893733
Compare
7893733
to
d85f317
Compare
d85f317
to
160d0f8
Compare
Hey @sambhurst, do you think it would make sense to regroup the commints in smaller PRs? Looks like there's a mix of refactoring/preparation, board specific changes, bug fixes and then the main feature. Thinking having more small PRs may make it easier to review and hopefully get it merged faster, and also make it easier to maintain the stack through the reviews. |
include/zephyr/usb_c/usbc.h
Outdated
* @brief Callback type used to get the Sink Capabilities | ||
* | ||
* @param dev dev Runtime device structure | ||
* @param pdos pointer where pdos are stored | ||
* @param num_pdos pointer where number of pdos is stored | ||
* @return 0 on success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit- put the callback descriptions for the SNK into a separate commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please put the src/snk/common callbacks into their own doxygen groups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add this group to the API reference section of ucds.rst.
doc/connectivity/usb_c/ucds.rst
Outdated
@@ -14,7 +14,7 @@ It provides the following functionalities: | |||
The APIs is described in | |||
:zephyr_file:`include/zephyr/usb_c/usbc.h` | |||
|
|||
Currently the device stack only support implementation of Sink devices. | |||
Currently the device stack supports implementation of Sink and Source devices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the device stack supports implementation of Sink and Source devices. | |
Currently the device stack supports implementation of Sink only and Source only devices. Dual Role Power (DRP) devices are not yet supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Transmit errors must be treated differently than Protocol Errors. This change sets a flag that informs the stack of a Message Transmit error. Signed-off-by: Sam Hurst <[email protected]>
e0c9c30
to
e2e3a4e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have some comments open from my March 27 and 28 reviews. Mostly LGTM.
include/zephyr/usb_c/usbc.h
Outdated
* @brief Callback type used to get the Sink Capabilities | ||
* | ||
* @param dev dev Runtime device structure | ||
* @param pdos pointer where pdos are stored | ||
* @param num_pdos pointer where number of pdos is stored | ||
* @return 0 on success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add this group to the API reference section of ucds.rst.
include/zephyr/usb_c/usbc.h
Outdated
/** | ||
* @brief Callback type used to get the Sink Capabilities | ||
* | ||
* @param dev dev Runtime device structure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please specify the type of device passed in for all these prototypes.
* @param dev dev Runtime device structure | |
* @param dev USB-C Connector Instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
include/zephyr/usb_c/usbc.h
Outdated
typedef enum usbc_snk_req_reply_t (*policy_cb_check_sink_request_t)( | ||
const struct device *dev, | ||
const uint32_t request_msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this file needs clang-format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
include/zephyr/usb_c/usbc.h
Outdated
* @param dev dev Runtime device structure | ||
* @return true if power supply is ready, else false | ||
*/ | ||
typedef bool (*policy_cb_check_if_ps_ready_t)(const struct device *dev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - you could name this policy_cb_is_ps_ready_t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
include/zephyr/usb_c/usbc.h
Outdated
* @param present_contract present contract | ||
* @return true if present contract is still valid | ||
*/ | ||
typedef bool (*policy_cb_check_present_contract_t)(const struct device *dev, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit - policy_cb_present_contract_is_valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
include/zephyr/usb_c/usbc.h
Outdated
typedef bool (*policy_cb_change_src_caps_t)(const struct device *dev); | ||
|
||
/** | ||
* @brief Callback type used to store the Capabilities received from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @brief Callback type used to store the Capabilities received from | |
* @brief Callback type used to report the Capabilities received from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
include/zephyr/usb_c/usbc.h
Outdated
/** | ||
* @brief Callback type used to check a policy | ||
* | ||
* @param dev dev Runtime device structure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param dev dev Runtime device structure | |
* @param dev USB-C Connector Instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
include/zephyr/usb_c/usbc.h
Outdated
* @brief Callback type used to get the Rp value that should be placed on | ||
* the CC lines | ||
* | ||
* @param dev dev Runtime device structure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param dev dev Runtime device structure | |
* @param dev USB-C Connector Instance |
Replace all instances for the APIs your are introducing in this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Document the sink callbacks Signed-off-by: Sam Hurst <[email protected]>
Detect and flag the reception of the first AMS mesage Signed-off-by: Sam Hurst <[email protected]>
Refactor soft reset code Signed-off-by: Sam Hurst <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last nit on the documentation from me.
include/zephyr/usb_c/usbc.h
Outdated
* the CC lines | ||
* | ||
* @param dev USB-C Connector Instance | ||
* @param rp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing description for the rp
parameter. I thought the CI had checks for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Add USB-C Power Delivery Source Support to USB-C Subsystem Signed-off-by: Sam Hurst <[email protected]>
Implementing USB-C Source functionality can be difficult. This sample application serves as an example of how to create an application with Power Delivery Source functionality. Signed-off-by: Sam Hurst <[email protected]>
Documents the USB-C Source Subsystem API. Signed-off-by: Sam Hurst <[email protected]>
* @brief Callback type used to get the Rp value that should be placed on | ||
* the CC lines | ||
* | ||
* @param dev USB-C Connector Instance | ||
* @param rp Rp value | ||
* @return 0 on success | ||
*/ | ||
typedef int (*policy_cb_get_src_rp_t)(const struct device *dev, enum tc_rp_value *rp); | ||
|
||
/** | ||
* @brief Callback type used to enable VBUS | ||
* | ||
* @param dev USB-C Connector Instance | ||
* @param en true to enable VBUS, else disable it | ||
* @return 0 on success | ||
*/ | ||
typedef int (*policy_cb_src_en_t)(const struct device *dev, bool en); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sambhurst this is defined again in in L324-340. I am not sure why this wasn't caught by Doxygen (although I just had Doxygen 1.9.4 spit out a warning). I will submit a fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds Power Delivery Source Support to the USB-C Stack. See Issue 38371 for details