On Wed, Sep 7, 2022 at 1:03 PM Tim Hardisty <t...@jti.uk.com.invalid> wrote:
    >>
    >>
    >>     >>> Please correct me if I'm still missing something, as there are 
zero
    >>     >>> clues I can find as to what each ops function (for example) is
    >>     >>> actually supposed to do.
    >>     >>
    >>     >>
    >>     >>
    >>     >>Here is two examples:
    >>     >>https://github.com/apache/incubator-
    >>     >>nuttx/blob/master/drivers/power/supply/regulator_gpio.c
    >>     >>https://github.com/apache/incubator-
    >>     >>nuttx/blob/master/drivers/power/supply/regulator_rpmsg.c
    >>
    >>     >thank you for these, I will take a look and hopefully they will 
point me
    >>     >in the right direction.
    >>
    > Please: what are the purpose of:
    >>
    >> set_voltage_sel
    >> get_voltage_sel


    >This really should be documented in the definition of struct
    >regulator_ops_s in include/nuttx/power/regulator.h, particularly what
    >is the difference between set_voltage and set_voltage_sel.

I agree - this should be there as comments. I will eventually submit a PR for 
my driver and, if it's not done by then, I will add these in the same PR 

    >That said, based on reading the code at _regulator_do_set_voltage() in
    >drivers/power/supply/regulator.c, it appears that:

    >1) set_voltage() is given a minimum and maximum desired voltage in
    >microvolts and sets (if possible) the regulator's voltage selector to
    >generate something between those bounds. It is up to the lower-half
    >driver to look at the desired min and max voltage and figure out what
    >the selector should be, whereas:

    >2) set_voltage_sel() is given the selector value itself and sets that.
    >The lower-half driver doesn't make decisions in this case; the
    >upper-half driver iterates through all available voltages to decide
    >which one is the "best" and then calls the lower-half driver with that
    >selector value.

    >The logic in _regulator_do_set_voltage() is such that if the
    >lower-half driver provides set_voltage(), it prefers to call that; if
    >not, then I assume it's a more "primitive" driver and therefore the
    >upper-half decides the selector value.

This is a great help, Nathan: thank you. The ACT8945A only allows discrete 
voltages to be set (64 values) so the set_voltage_sel may one way to sort this, 
although I already have code to select the right register value by some 
mathematical shenigans so could put that in the lower half and make use of the 
min and max values.

It is all making sense now: lack of comments, and no examples in 10.3, are what 
done me in.


Reply via email to