-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
drivers: regulator: implement active discharge api #61056
drivers: regulator: implement active discharge api #61056
Conversation
40021c2
to
d4d35f2
Compare
aac75a6
to
5ad2d4c
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.
before adding new ops to regulators:
- Is this feature present across multiple regulator devices? Is this related with e.g. ADP5360
adi,enable-output-discharge
? - Is this meant to be set/unset at runtime? For example, ADP5360 driver just takes it from DT at init time
- It may be better to introduce a more generic set/get props API. I fear more properties will pop up, and we can't keep increasing ops table for each one...
This is also present in other regulator devices. I am working on the MAX77643. This api is also implemented in the linux regulator driver which this was modeled after.
yes. the ADP5360 may want to have this api implemented as well.... but I do not have that part to test out.
I understand your concerns there...I'm not sure what you mean by a 'more generic set/get prop api`, but this active discharge setting appears to be very generic and is within a lot of regulators. Just not implemented in some of the already existing drivers. |
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.
lgtm, just a few comments, will actually migrate adp driver to this new API.
include/zephyr/drivers/regulator.h
Outdated
* @retval -errno In case of any other error. | ||
*/ | ||
static inline int regulator_set_active_discharge(const struct device *dev, | ||
uint8_t active_discharge) |
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.
uint8_t active_discharge) | |
bool enable) |
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.
my concern with making it a bool would be handle the issue of it not being defined where it just gets set to the max value of a UINT8
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 think bool would be better if we can assume that active_discharge is always disabled by default. If this is not a safe assumption I think it is OK like 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.
From an API client perspective, this function will always be called with either 0
or 1
(bool), am I wrong?
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.
yeah. I updated to be a bool
include/zephyr/drivers/regulator.h
Outdated
* @retval -errno In case of any other error. | ||
*/ | ||
static inline int regulator_get_active_discharge(const struct device *dev, | ||
uint8_t *active_discharge) |
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.
uint8_t *active_discharge) | |
bool *enabled) |
note: Linux doesn't seem to offer a getter, is it really needed?
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.
correct, but just because Linux doesn't do it doesn't mean we also shouldn't do it. I can't really think of a reason not to have it.
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.
Linux is usually right, Zephyr... not so much ;-)
@@ -611,6 +611,58 @@ ZTEST(regulator_api, test_get_mode_not_implemented) | |||
zassert_equal(ret, -ENOSYS); | |||
} | |||
|
|||
ZTEST(regulator_api, test_set_active_discharge_not_implemented) |
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 update test_common_config
test as well, to cover correct capture of dt info
thanks for this info, make sense |
1e25b52
to
6cb220b
Compare
@gmarull @aasinclair could you please take a look? |
ping |
this PR has unresolved questions, please check. |
a5c9c39
to
e9830b3
Compare
e9830b3
to
5db8039
Compare
2f0c05d
to
d6a131c
Compare
Add an active discharge api for regulators. This uses the already existing but previously unused regulator-active-discharge property. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
d6a131c
to
005eab9
Compare
Add tests for active discharge apis not being implemented. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Add the active discharge functions that can be called from the regulator shell. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
Implement the api for controlling the active discharge setting within the pca9420. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
005eab9
to
8e52da6
Compare
@gmarull This should be ready for another review. Thanks! |
Add an active discharge api for regulators. This uses the already existing but previously unused regulator-active-discharge property.
This implements it within the pca9420.
I am currently working on my own PMIC where I need this api but I do not have the pca9420 to test with and verify it... but this seems like a trivial addition
TODO: