summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/power_supply.h5
-rw-r--r--components/drivers/include/drivers/regulator.h30
-rw-r--r--components/drivers/include/rtdevice.h17
3 files changed, 44 insertions, 8 deletions
diff --git a/components/drivers/include/drivers/power_supply.h b/components/drivers/include/drivers/power_supply.h
index 15ee64e90b..8dc8f2ac03 100644
--- a/components/drivers/include/drivers/power_supply.h
+++ b/components/drivers/include/drivers/power_supply.h
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2022-11-21 GuEe-GUI first version
+ * 2026-03-27 Evlers add snapshot helpers and public name getter
*/
#ifndef __POWER_SUPPLY_H__
@@ -274,4 +275,8 @@ void rt_power_supply_changed(struct rt_power_supply *psy);
struct rt_power_supply *rt_power_supply_get(struct rt_device *dev, const char *id);
void rt_power_supply_put(struct rt_power_supply *psy);
+const char *rt_power_supply_name(struct rt_power_supply *psy);
+struct rt_power_supply **rt_power_supply_snapshot(rt_size_t *count);
+void rt_power_supply_snapshot_free(struct rt_power_supply **nodes, rt_size_t count);
+
#endif /* __POWER_SUPPLY_H__ */
diff --git a/components/drivers/include/drivers/regulator.h b/components/drivers/include/drivers/regulator.h
index 73ab7863e1..005609431f 100644
--- a/components/drivers/include/drivers/regulator.h
+++ b/components/drivers/include/drivers/regulator.h
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2023-09-23 GuEe-GUI first version
+ * 2026-03-27 Evlers add current control API and snapshot helpers
*/
#ifndef __REGULATOR_H__
@@ -18,6 +19,7 @@
#include <drivers/misc.h>
#define RT_REGULATOR_UVOLT_INVALID (((int)(RT_UINT32_MAX >> 1)))
+#define RT_REGULATOR_UAMP_INVALID (((int)(RT_UINT32_MAX >> 1)))
struct rt_regulator_param
{
@@ -86,6 +88,8 @@ struct rt_regulator_ops
rt_bool_t (*is_enabled)(struct rt_regulator_node *reg);
rt_err_t (*set_voltage)(struct rt_regulator_node *reg, int min_uvolt, int max_uvolt);
int (*get_voltage)(struct rt_regulator_node *reg);
+ rt_err_t (*set_current)(struct rt_regulator_node *reg, int min_uamp, int max_uamp);
+ int (*get_current)(struct rt_regulator_node *reg);
rt_err_t (*set_mode)(struct rt_regulator_node *reg, rt_uint32_t mode);
rt_int32_t (*get_mode)(struct rt_regulator_node *reg);
rt_err_t (*set_ramp_delay)(struct rt_regulator_node *reg, int ramp);
@@ -98,6 +102,8 @@ struct rt_regulator_notifier;
#define RT_REGULATOR_MSG_DISABLE RT_BIT(1)
#define RT_REGULATOR_MSG_VOLTAGE_CHANGE RT_BIT(2)
#define RT_REGULATOR_MSG_VOLTAGE_CHANGE_ERR RT_BIT(3)
+#define RT_REGULATOR_MSG_CURRENT_CHANGE RT_BIT(4)
+#define RT_REGULATOR_MSG_CURRENT_CHANGE_ERR RT_BIT(5)
union rt_regulator_notifier_args
{
@@ -107,6 +113,12 @@ union rt_regulator_notifier_args
int min_uvolt;
int max_uvolt;
};
+ struct
+ {
+ int old_uamp;
+ int min_uamp;
+ int max_uamp;
+ };
};
typedef rt_err_t (*rt_regulator_notifier_callback)(struct rt_regulator_notifier *notifier,
@@ -140,9 +152,16 @@ rt_bool_t rt_regulator_is_supported_voltage(struct rt_regulator *reg, int min_uv
rt_err_t rt_regulator_set_voltage(struct rt_regulator *reg, int min_uvolt, int max_uvolt);
int rt_regulator_get_voltage(struct rt_regulator *reg);
+rt_bool_t rt_regulator_is_supported_current(struct rt_regulator *reg, int min_uamp, int max_uamp);
+rt_err_t rt_regulator_set_current(struct rt_regulator *reg, int min_uamp, int max_uamp);
+int rt_regulator_get_current(struct rt_regulator *reg);
+
rt_err_t rt_regulator_set_mode(struct rt_regulator *reg, rt_uint32_t mode);
rt_int32_t rt_regulator_get_mode(struct rt_regulator *reg);
+struct rt_regulator_node **rt_regulator_nodes_snapshot(rt_size_t *count);
+void rt_regulator_nodes_snapshot_free(struct rt_regulator_node **nodes, rt_size_t count);
+
rt_inline rt_err_t rt_regulator_set_voltage_triplet(struct rt_regulator *reg,
int min_uvolt, int target_uvolt, int max_uvolt)
{
@@ -154,4 +173,15 @@ rt_inline rt_err_t rt_regulator_set_voltage_triplet(struct rt_regulator *reg,
return rt_regulator_set_voltage(reg, min_uvolt, max_uvolt);
}
+rt_inline rt_err_t rt_regulator_set_current_triplet(struct rt_regulator *reg,
+ int min_uamp, int target_uamp, int max_uamp)
+{
+ if (!rt_regulator_set_current(reg, target_uamp, max_uamp))
+ {
+ return RT_EOK;
+ }
+
+ return rt_regulator_set_current(reg, min_uamp, max_uamp);
+}
+
#endif /* __REGULATOR_H__ */
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index c3a1277449..4914fe329c 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -7,6 +7,7 @@
* Date Author Notes
* 2012-01-08 bernard first version.
* 2014-07-12 bernard Add workqueue implementation.
+ * 2026-03-27 Evlers reorder regulator/power supply headers after DM deps
*/
#ifndef __RT_DEVICE_H__
@@ -118,10 +119,6 @@ extern "C" {
#endif /* RT_PCI_ENDPOINT */
#endif /* RT_USING_PCI */
-#ifdef RT_USING_REGULATOR
-#include "drivers/regulator.h"
-#endif /* RT_USING_REGULATOR */
-
#ifdef RT_USING_RESET
#include "drivers/reset.h"
#endif /* RT_USING_RESET */
@@ -148,15 +145,19 @@ extern "C" {
#include "drivers/hwcache.h"
#endif /* RT_USING_HWCACHE */
-#ifdef RT_USING_POWER_SUPPLY
-#include "drivers/power_supply.h"
-#endif /* RT_USING_POWER_SUPPLY */
-
#ifdef RT_USING_NVMEM
#include "drivers/nvmem.h"
#endif /* RT_USING_NVMEM */
#endif /* RT_USING_DM */
+#ifdef RT_USING_REGULATOR
+#include "drivers/regulator.h"
+#endif /* RT_USING_REGULATOR */
+
+#ifdef RT_USING_POWER_SUPPLY
+#include "drivers/power_supply.h"
+#endif /* RT_USING_POWER_SUPPLY */
+
#ifdef RT_USING_RTC
#include "drivers/dev_rtc.h"
#ifdef RT_USING_ALARM