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. 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. If any of this is incorrect, then hopefully someone will correct me. I'm reading this code for the first time. Cheers, Nathan