-
Notifications
You must be signed in to change notification settings - Fork 1.4k
drivers/power/supply/husb238: Add support for HUSB238 USB-PD Sink Controller #16963
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
base: master
Are you sure you want to change the base?
Conversation
…troller Add support for the Hynetek HUSB238 USB Type-C Power Delivery Sink Controller. Also add a new defconfig that includes support for a HUSB238 IC connected via I2C and extend the existing documentation to include its description. Signed-off-by: Niccolò Maggioni <nicco.maggioni+nuttx@gmail.com>
|
|
||
| /* Write the contents of the SRC_PDO register */ | ||
|
|
||
| case PWRIOC_HUSB238_SET_SELECTED_PDO: |
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.
should we define and implement. USB P Dofficially in nuttx?
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'm not sure what you mean, these commands only interact with the internal state machine of the IC (see registries definitions and datasheet).
If you are suggesting to define PDOs globally for future implementations, I'd say that it's not worth the trouble as they are a constantly moving target due to each manufacurer's different implementation - both at the sink and source levels.
|
"Since this is, if I'm not mistaken, the first USB-PD driver implemented in NuttX" Actually you are mistaken! hehehe NuttX already supports it (yes, NuttX is full of hidden features and resources). Please take a look at drivers/usbmisc/stusb4500.c, it was implemented by @SimonFilgis This is why all new PR that introduces a new feature or API ask people to include a Documentation. @nmaggioni @xiaoxiang781216 @SimonFilgis please align it to avoid spreading similar drivers to different places. I'm not sure which place (drivers/usbmisc or drivers/power/supply) |
|
Ah, it indeed seemed strange to me that nobody else dabbled with this before! Hence the conditional :) Thanks for pointing me in the right direction, I'll take a look at the STUSB4500 driver. With USB-PD being a relatively new standard, I'm often having difficulties finding existing sources because it can be referred to in a few subtly different ways. |
|
@nmaggioni maybe your application could become a standard for control USB PD device, maybe renaming it to usbpdctl or something similar. Please take a look how it is done on Linux, that should be our reference ;-) |
Summary
This PR adds support for the I2C interface of the Hynetek HUSB238 USB Type-C Power Delivery Sink Controller.
Since this is, if I'm not mistaken, the first USB-PD driver implemented in NuttX, I tried to apply the conventions used in other types of drivers while extending the power-related headers, IOCTL definitions, and Kconfig keys. I reckon that
drivers/power/supplyis the right place for this driver and the prefix of its config keys should beUSBPD_HUSB238, but let me know if things should be organized/named differently.I also have an example app ready, I'll open a PR on the apps repo once this one gets out of draft status. As before, CI will complain that the relative config key does not exist (yet) and will try to remove it during the normalization step.
This PR should also be updated in case #16869 gets merged: for now I used the old style of bus initialization to avoid merge conflicts.
Impact
Users will be able to query the controller for the currently active USB-PD PDO (combined specification of voltage and current), and interactively request different PDOs from the power supply.
Testing
These changes were tested on a Linux host, targeting a custom Cortex-M0+ (RP2040) board using NuttX v12.8.0 as the baseline. They were then manually ported to the current master branch.
Note: All the read commands have been tested, but I did not fully test the write commands (change active USB-PD voltage range, reset the power supply) as my current hardware is not designed for being exposed to wildly different voltage ranges and I do not have a dedicated breakout/evaluation board for this IC at hand.