Lines Matching defs:regulator
6 //! The intention is to allow systems to dynamically control regulator power
11 //! C header: [`include/linux/regulator/consumer.h`](srctree/include/linux/regulator/consumer.h)
16 //! See [Voltage and current regulator API](https://docs.kernel.org/driver-api/regulator.html)
37 /// Whether the regulator should be disabled when dropped.
48 /// underlying regulator to be enabled. This means that this reference does not
49 /// own an `enable` reference count, but the regulator may still be on.
69 /// The regulator that caused the error, so that the operation may be retried.
70 pub regulator: Regulator<State>,
72 /// Obtains and enables a [`devres`]-managed regulator for a device.
79 /// cares about the regulator being enabled.
82 /// [`regulator_disable()`]: https://docs.kernel.org/driver-api/regulator.html#c.regulator_disable
83 /// [`regulator_put()`]: https://docs.kernel.org/driver-api/regulator.html#c.regulator_put
93 /// This obtains and enables a [`devres`]-managed regulator for a device, but
94 /// does not print a message nor provides a dummy if the regulator is not found.
100 /// [`regulator_disable()`]: https://docs.kernel.org/driver-api/regulator.html#c.regulator_disable
101 /// [`regulator_put()`]: https://docs.kernel.org/driver-api/regulator.html#c.regulator_put
108 /// A `struct regulator` abstraction.
112 /// ## Enabling a regulator
115 /// enable a regulator at probe time and leave them on until the device is
125 /// # use kernel::regulator::{Voltage, Regulator, Disabled, Enabled};
127 /// // Obtain a reference to a (fictitious) regulator.
128 /// let regulator: Regulator<Disabled> = Regulator::<Disabled>::get(dev, c_str!("vcc"))?;
130 /// // The voltage can be set before enabling the regulator if needed, e.g.:
131 /// regulator.set_voltage(min_voltage, max_voltage)?;
134 /// let voltage: Voltage = regulator.get_voltage()?;
136 /// // Enables the regulator, consuming the previous value.
138 /// // From now on, the regulator is known to be enabled because of the type
141 /// // If this operation fails, the `Error` will contain the regulator
143 /// let regulator: Regulator<Enabled> =
144 /// regulator.try_into_enabled().map_err(|error| error.error)?;
146 /// // The voltage can also be set after enabling the regulator, e.g.:
147 /// regulator.set_voltage(min_voltage, max_voltage)?;
150 /// let voltage: Voltage = regulator.get_voltage()?;
152 /// // Dropping an enabled regulator will disable it. The refcount will be
154 /// drop(regulator);
162 /// A more concise shortcut is available for enabling a regulator. This is
169 /// # use kernel::regulator::{Voltage, Regulator, Enabled};
171 /// // Obtain a reference to a (fictitious) regulator and enable it.
172 /// let regulator: Regulator<Enabled> = Regulator::<Enabled>::get(dev, c_str!("vcc"))?;
174 /// // Dropping an enabled regulator will disable it. The refcount will be
176 /// drop(regulator);
184 /// If a driver only cares about the regulator being on for as long it is bound
187 /// the regulator's state is required.
189 /// [`devm_enable`]: crate::regulator::devm_enable
190 /// [`devm_optional`]: crate::regulator::devm_enable_optional
196 /// # use kernel::regulator;
198 /// // Obtain a reference to a (fictitious) regulator and enable it. This
200 /// regulator::devm_enable(dev, c_str!("vcc"))?;
202 /// // The regulator will be disabled and put when `dev` is unbound.
207 /// ## Disabling a regulator
212 /// # use kernel::regulator::{Regulator, Enabled, Disabled};
213 /// fn disable(dev: &Device, regulator: Regulator<Enabled>) -> Result {
214 /// // We can also disable an enabled regulator without reliquinshing our
217 /// // If this operation fails, the `Error` will contain the regulator
219 /// let regulator: Regulator<Disabled> =
220 /// regulator.try_into_disabled().map_err(|error| error.error)?;
222 /// // The refcount will be decremented when `regulator` is dropped.
223 /// drop(regulator);
234 /// regulator` obtained from [`regulator_get()`].
236 /// [`regulator_get()`]: https://docs.kernel.org/driver-api/regulator.html#c.regulator_get
241 inner: NonNull<bindings::regulator>,
246 /// Sets the voltage for the regulator.
260 /// Gets the current voltage of the regulator.
274 // regulator if `ERR_PTR` was not returned.
300 /// Attempts to convert the regulator to an enabled state.
304 let regulator = ManuallyDrop::new(self);
306 regulator
309 inner: regulator.inner,
314 regulator: ManuallyDrop::into_inner(regulator),
329 /// Attempts to convert the regulator to a disabled state.
333 let regulator = ManuallyDrop::new(self);
335 regulator
338 inner: regulator.inner,
343 regulator: ManuallyDrop::into_inner(regulator),
349 /// Checks if the regulator is enabled.