STRUCT REGULATOR_OPS(9)

๐Ÿ“ฆ version 7.3.1, in nixpkgs unstable

๐Ÿ’– NAME ๐Ÿ’–

struct regulator_ops โ€” the regulator operations. Yes bestie, this is the manual for it, from the Kernel API Manual, and we're gonna get through it together ๐Ÿซถ


โœจ SYNOPSIS โœจ

Like, here's the whole struct, exactly as it lives. No cap, this is a big one โ€” deep breath ๐Ÿ’…

struct regulator_ops {
    int (*list_voltage) (struct regulator_dev *, unsigned selector);
    int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV,
unsigned *selector);
    int (*map_voltage)(struct regulator_dev *, int min_uV, int max_uV);
    int (*set_voltage_sel) (struct regulator_dev *, unsigned selector);
    int (*get_voltage) (struct regulator_dev *);
    int (*get_voltage_sel) (struct regulator_dev *);
    int (*set_current_limit) (struct regulator_dev *, int min_uA, int
max_uA);
    int (*get_current_limit) (struct regulator_dev *);
    int (*set_input_current_limit) (struct regulator_dev *, int lim_uA);
    int (*set_over_current_protection)(struct regulator_dev *, int
lim_uA, int severity, bool enable);
    int (*set_over_voltage_protection)(struct regulator_dev *, int
lim_uV, int severity, bool enable);
    int (*set_under_voltage_protection)(struct regulator_dev *, int
lim_uV, int severity, bool enable);
    int (*set_thermal_protection)(struct regulator_dev *, int lim, int
severity, bool enable);
    int (*set_active_discharge)(struct regulator_dev *, bool enable);
    int (*enable) (struct regulator_dev *);
    int (*disable) (struct regulator_dev *);
    int (*is_enabled) (struct regulator_dev *);
    int (*set_mode) (struct regulator_dev *, unsigned int mode);
    unsigned int (*get_mode) (struct regulator_dev *);
    int (*get_error_flags)(struct regulator_dev *, unsigned int *flags);
    int (*enable_time) (struct regulator_dev *);
    int (*set_ramp_delay) (struct regulator_dev *, int ramp_delay);
    int (*set_voltage_time) (struct regulator_dev *, int old_uV, int
new_uV);
    int (*set_voltage_time_sel) (struct regulator_dev *, unsigned int
old_selector, unsigned int new_selector);
    int (*set_soft_start) (struct regulator_dev *);
    int (*get_status)(struct regulator_dev *);
    unsigned int (*get_optimum_mode) (struct regulator_dev *, int
input_uV, int output_uV, int load_uA);
    int (*set_load)(struct regulator_dev *, int load_uA);
    int (*set_bypass)(struct regulator_dev *dev, bool enable);
    int (*get_bypass)(struct regulator_dev *dev, bool *enable);
    int (*set_suspend_voltage) (struct regulator_dev *, int uV);
    int (*set_suspend_enable) (struct regulator_dev *);
    int (*set_suspend_disable) (struct regulator_dev *);
    int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode);
    int (*resume)(struct regulator_dev *rdev);
    int (*set_pull_down) (struct regulator_dev *);
};

๐ŸŽ€ Members ๐ŸŽ€

Okay so this is the part where we go one by one. Grab a snack ๐Ÿ“

  • list_voltage โ€” returns one of the supported voltages, in microvolts ๐ŸŒธ If the selector points at a voltage that's literally unusable on this system, it returns zero. Or, you know, a negative errno if things went sideways. Selectors go from zero up to one less than regulator_desc.n_voltages. And the voltages? They can be reported in any order โ€” no rules, main character energy ๐Ÿ”ฅ
  • set_voltage โ€” sets the regulator's voltage inside the range you specified. The driver should pick the voltage closest to min_uV.
  • map_voltage โ€” converts a voltage into a selector โœจ
  • set_voltage_sel โ€” sets the regulator's voltage using the exact selector you handed it ๐Ÿ’…
  • get_voltage โ€” returns the voltage the regulator is currently configured to. But heads up: it returns -ENOTRECOVERABLE if the regulator can't be read at bootup and hasn't been set yet ๐Ÿ˜ญ
  • get_voltage_sel โ€” returns the currently configured voltage selector for the regulator. Same caveat, same energy: -ENOTRECOVERABLE if it can't be read at bootup and hasn't been set yet ๐Ÿ™ˆ
  • set_current_limit โ€” sets up a limit for a current-limited regulator. The driver should pick the current closest to max_uA.
  • get_current_limit โ€” gets the limit that's configured for a current-limited regulator.
  • set_input_current_limit โ€” configures an input limit.
  • set_over_current_protection โ€” supports enabling and setting limits for over-current detection ๐Ÿšจ The detection can be configured for three levels of severity.
  • set_over_voltage_protection โ€” supports enabling and setting limits for over-voltage detection. Detection can be configured for the same severities as over-current protection. Units are uV.
  • set_under_voltage_protection โ€” supports enabling and setting limits for under-voltage detection. Detection can be configured for the same severities as over-current protection. Units are uV.
  • set_thermal_protection โ€” supports enabling and setting limits for over-temperature detection. Detection can be configured for the same severities as over-current protection. Units are degree Kelvin ๐Ÿ”ฅ
  • set_active_discharge โ€” sets active discharge enable/disable on the regulator.
  • enable โ€” configures the regulator as enabled โญ
  • disable โ€” configures the regulator as disabled ๐Ÿ’€
  • is_enabled โ€” returns 1 if the regulator is enabled, 0 if it's not. It may also return a negative errno, because of course it can.
  • set_mode โ€” sets the configured operating mode for the regulator.
  • get_mode โ€” gets the configured operating mode for the regulator.
  • get_error_flags โ€” gets the current error(s) for the regulator ๐Ÿšจ
  • enable_time โ€” the time it takes for the regulator's voltage output to stabilise after being enabled, in microseconds.
  • set_ramp_delay โ€” sets the ramp delay for the regulator. The driver should pick a ramp delay equal to or less than (closest to) ramp_delay.
  • set_voltage_time โ€” time taken for the regulator's voltage output to stabilise after being set to a new value, in microseconds. The function takes the from and to voltage as input, and it should return the worst case ๐Ÿ˜ฎโ€๐Ÿ’จ
  • set_voltage_time_sel โ€” same deal: time taken for the output voltage to stabilise after being set to a new value, in microseconds. This one takes the from and to voltage selector as input, and it should return the worst case.
  • set_soft_start โ€” enables soft start for the regulator ๐ŸŒˆ
  • get_status โ€” returns the actual (not as-configured!) status of the regulator, as a REGULATOR_STATUS value โ€” or a negative errno.
  • get_optimum_mode โ€” gets the most efficient operating mode for the regulator when it's running with the parameters you specify ๐Ÿ‘‘
  • set_load โ€” sets the load for the regulator.
  • set_bypass โ€” puts the regulator in bypass mode.
  • get_bypass โ€” gets the regulator's bypass mode state.
  • set_suspend_voltage โ€” sets the voltage for the regulator while the system is suspended ๐Ÿ˜ด
  • set_suspend_enable โ€” marks the regulator as enabled while the system is suspended.
  • set_suspend_disable โ€” marks the regulator as disabled while the system is suspended.
  • set_suspend_mode โ€” sets the operating mode for the regulator while the system is suspended.
  • resume โ€” resumes operation of a suspended regulator ๐Ÿฆ‹
  • set_pull_down โ€” configures the regulator to pull down when the regulator is disabled.

๐ŸŒธ Description ๐ŸŒธ

The severity levels, because these matter, bestie:

  • REGULATOR_SEVERITY_PROT should automatically shut down the regulator(s) ๐Ÿ›‘
  • REGULATOR_SEVERITY_ERR should indicate that the over-current situation is caused by an unrecoverable error, but the HW does not perform an automatic shut down.
  • REGULATOR_SEVERITY_WARN should indicate a situation where the hardware is still believed to not be damaged, but a board specific recovery action is needed. If lim_uA is 0, the limit should not be changed โ€” the detection should just be enabled/disabled as requested.

And the whole vibe of the thing: this struct describes the regulator operations which can be implemented by regulator chip drivers ๐Ÿงš


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

Kernel file ./include/linux/regulator/driver.h โ€” struct regulator_desc(9), struct regulator_config(9), struct regulator_err_state(9), struct regulator_irq_data(9), struct regulator_irq_desc(9)


๐Ÿ’œ And that's the whole page! Sourced from ./include/linux/regulator, dated October 2026, and it's the struct regulator_ops(9) manual โ€” literally iconic, you're welcome, go forth and regulate ๐Ÿ’…โœจ
๐Ÿ“ฆ where this page comes from