summaryrefslogtreecommitdiff
path: root/rust/helpers/regulator.c
diff options
context:
space:
mode:
authorDaniel Almeida <daniel.almeida@collabora.com>2025-07-14 15:52:04 -0300
committerMark Brown <broonie@kernel.org>2025-07-15 15:07:40 +0100
commit9b614ceada7cb846de1a1c3bb0b29b0a2726ef45 (patch)
treec566bfa7567c3f67fdca460f2031c25d36cf3643 /rust/helpers/regulator.c
parent347e9f5043c89695b01e66b3ed111755afcf1911 (diff)
rust: regulator: add a bare minimum regulator abstraction
Add a bare minimum regulator abstraction to be used by Rust drivers. This abstraction adds a small subset of the regulator API, which is thought to be sufficient for the drivers we have now. Regulators provide the power needed by many hardware blocks and thus are likely to be needed by a lot of drivers. It was tested on rk3588, where it was used to power up the "mali" regulator in order to power up the GPU. Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20250714-topics-tyr-regulator2-v8-1-c7ab3955d524@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'rust/helpers/regulator.c')
-rw-r--r--rust/helpers/regulator.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/rust/helpers/regulator.c b/rust/helpers/regulator.c
new file mode 100644
index 0000000000000..cd8b7ba648ee3
--- /dev/null
+++ b/rust/helpers/regulator.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/regulator/consumer.h>
+
+#ifndef CONFIG_REGULATOR
+
+void rust_helper_regulator_put(struct regulator *regulator)
+{
+ regulator_put(regulator);
+}
+
+int rust_helper_regulator_set_voltage(struct regulator *regulator, int min_uV,
+ int max_uV)
+{
+ return regulator_set_voltage(regulator, min_uV, max_uV);
+}
+
+int rust_helper_regulator_get_voltage(struct regulator *regulator)
+{
+ return regulator_get_voltage(regulator);
+}
+
+struct regulator *rust_helper_regulator_get(struct device *dev, const char *id)
+{
+ return regulator_get(dev, id);
+}
+
+int rust_helper_regulator_enable(struct regulator *regulator)
+{
+ return regulator_enable(regulator);
+}
+
+int rust_helper_regulator_disable(struct regulator *regulator)
+{
+ return regulator_disable(regulator);
+}
+
+int rust_helper_regulator_is_enabled(struct regulator *regulator)
+{
+ return regulator_is_enabled(regulator);
+}
+
+#endif