Page MenuHomeFreeBSD

regulator: Add a regnode_set_constraint function
ClosedPublic

Authored by manu on Oct 22 2019, 1:56 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 10, 8:53 PM
Unknown Object (File)
Tue, Nov 26, 8:29 AM
Unknown Object (File)
Nov 10 2024, 9:48 PM
Unknown Object (File)
Sep 20 2024, 8:45 PM
Unknown Object (File)
Sep 20 2024, 8:45 PM
Unknown Object (File)
Sep 19 2024, 12:53 PM
Unknown Object (File)
Sep 19 2024, 8:58 AM
Unknown Object (File)
Sep 19 2024, 4:49 AM
Subscribers

Details

Summary

This method check that boot_on or always_on is set to 1 and if it is it will try to enable the regulator.
The binding docs aren't clear on what to do but Linux enable the regulator if any of those properties
is set so we want to do the same.
The function first check the status to see if the regulator is already enabled, it then get the voltage
to check if it is in a acceptable range and then enables it.
This will be either called from the regnode_init method (if it's needed by the platform)
or by a SYSINIT at SI_SUB_LAST

Test Plan

Tested on Pine64-LTS and checked that regulator that are boot_on/always_on will be enabled.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

The code itself looks OK for me. But I have problem with using its usage as default regulator init method, because:

  • it cannot be used by regulators with its own init
  • it expect that regulator is accessible early, at registration time. I'm not sure if this is possible in all cases (like I2C and interrupts ..)

But we can declare renamed regnode_method_init() as public (regnode_set_constrains() ????)
and call it from eqivalent of regulator_shutdown() .

For me, this looks like most flexible solution to me. Individual regulators will be able to use this, and we already expect that regulators are accessible at time when regulator_shutdown() is called.

sys/dev/extres/regulator/regulator.c
243

.boot_on and .always on are booleans

Move the code to regnode_set_constraint.
The function can either be called from the regnode init method if the platform allow this or
it will be called in a sysinit so we're sure that all the regulator that needs to be enabled will be.

I'll split the patch in three commits :

  • One that adds the regnode_constraint
  • One that add the regnode_method_init (useful for regulator that don't need a dedicated init method)
  • One for axp81x.
manu retitled this revision from regulator: Add a default regnode_init method to regulator: Add a regnode_set_constraint function.Oct 23 2019, 9:10 AM
manu edited the test plan for this revision. (Show Details)

rest is OK for me.

sys/dev/extres/regulator/regulator.c
838

this comment is now outdated.

843

Now, we can return real error here.

856

Ditto.

This revision is now accepted and ready to land.Oct 23 2019, 9:24 AM
manu edited the summary of this revision. (Show Details)
This revision now requires review to proceed.Oct 23 2019, 9:49 AM
manu marked 4 inline comments as done.

Remove obsolete comments.

This revision is now accepted and ready to land.Oct 23 2019, 9:51 AM
This revision was automatically updated to reflect the committed changes.