Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F156777162
D22260.id64000.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D22260.id64000.diff
View Options
Index: head/sys/arm/allwinner/axp209.c
===================================================================
--- head/sys/arm/allwinner/axp209.c
+++ head/sys/arm/allwinner/axp209.c
@@ -753,6 +753,7 @@
REGNODEMETHOD(regnode_enable, axp2xx_regnode_enable),
REGNODEMETHOD(regnode_set_voltage, axp2xx_regnode_set_voltage),
REGNODEMETHOD(regnode_get_voltage, axp2xx_regnode_get_voltage),
+ REGNODEMETHOD(regnode_check_voltage, regnode_method_check_voltage),
REGNODEMETHOD_END
};
DEFINE_CLASS_1(axp2xx_regnode, axp2xx_regnode_class, axp2xx_regnode_methods,
Index: head/sys/arm/allwinner/axp81x.c
===================================================================
--- head/sys/arm/allwinner/axp81x.c
+++ head/sys/arm/allwinner/axp81x.c
@@ -866,6 +866,7 @@
REGNODEMETHOD(regnode_enable, axp8xx_regnode_enable),
REGNODEMETHOD(regnode_set_voltage, axp8xx_regnode_set_voltage),
REGNODEMETHOD(regnode_get_voltage, axp8xx_regnode_get_voltage),
+ REGNODEMETHOD(regnode_check_voltage, regnode_method_check_voltage),
REGNODEMETHOD_END
};
DEFINE_CLASS_1(axp8xx_regnode, axp8xx_regnode_class, axp8xx_regnode_methods,
Index: head/sys/arm64/rockchip/rk805.c
===================================================================
--- head/sys/arm64/rockchip/rk805.c
+++ head/sys/arm64/rockchip/rk805.c
@@ -362,6 +362,7 @@
REGNODEMETHOD(regnode_enable, rk805_regnode_enable),
REGNODEMETHOD(regnode_set_voltage, rk805_regnode_set_voltage),
REGNODEMETHOD(regnode_get_voltage, rk805_regnode_get_voltage),
+ REGNODEMETHOD(regnode_check_voltage, regnode_method_check_voltage),
REGNODEMETHOD_END
};
DEFINE_CLASS_1(rk805_regnode, rk805_regnode_class, rk805_regnode_methods,
Index: head/sys/dev/extres/regulator/regnode_if.m
===================================================================
--- head/sys/dev/extres/regulator/regnode_if.m
+++ head/sys/dev/extres/regulator/regnode_if.m
@@ -91,6 +91,15 @@
};
#
+# Check if a given voltage is supported by the regulator
+# Returns 0 on success or a standard errno value.
+#
+METHOD int check_voltage {
+ struct regnode *regnode;
+ int uvolt;
+};
+
+#
# Stop (shutdown) regulator
# Returns 0 on success or a standard errno value.
#
Index: head/sys/dev/extres/regulator/regulator.h
===================================================================
--- head/sys/dev/extres/regulator/regulator.h
+++ head/sys/dev/extres/regulator/regulator.h
@@ -117,6 +117,10 @@
int regnode_get_voltage(struct regnode *regnode, int *uvolt);
int regnode_set_voltage(struct regnode *regnode, int min_uvolt, int max_uvolt);
int regnode_set_constraint(struct regnode *regnode);
+
+/* Standard method that aren't default */
+int regnode_method_check_voltage(struct regnode *regnode, int uvolt);
+
#ifdef FDT
phandle_t regnode_get_ofw_node(struct regnode *regnode);
#endif
@@ -134,6 +138,7 @@
int regulator_status(regulator_t reg, int *status);
int regulator_get_voltage(regulator_t reg, int *uvolt);
int regulator_set_voltage(regulator_t reg, int min_uvolt, int max_uvolt);
+int regulator_check_voltage(regulator_t reg, int uvolt);
#ifdef FDT
int regulator_get_by_ofw_property(device_t dev, phandle_t node, char *name,
Index: head/sys/dev/extres/regulator/regulator.c
===================================================================
--- head/sys/dev/extres/regulator/regulator.c
+++ head/sys/dev/extres/regulator/regulator.c
@@ -84,6 +84,7 @@
REGNODEMETHOD(regnode_status, regnode_method_status),
REGNODEMETHOD(regnode_set_voltage, regnode_method_set_voltage),
REGNODEMETHOD(regnode_get_voltage, regnode_method_get_voltage),
+ REGNODEMETHOD(regnode_check_voltage, regnode_method_check_voltage),
REGNODEMETHOD_END
};
@@ -278,6 +279,16 @@
(regnode->std_param.max_uvolt - regnode->std_param.min_uvolt) / 2);
}
+int
+regnode_method_check_voltage(struct regnode *regnode, int uvolt)
+{
+
+ if ((uvolt > regnode->std_param.max_uvolt) ||
+ (uvolt < regnode->std_param.min_uvolt))
+ return (ERANGE);
+ return (0);
+}
+
/* ----------------------------------------------------------------------------
*
* Internal functions.
@@ -991,6 +1002,22 @@
reg->min_uvolt = min_uvolt;
reg->max_uvolt = max_uvolt;
}
+ REG_TOPO_UNLOCK();
+ return (rv);
+}
+
+int
+regulator_check_voltage(regulator_t reg, int uvolt)
+{
+ int rv;
+ struct regnode *regnode;
+
+ regnode = reg->regnode;
+ KASSERT(regnode->ref_cnt > 0,
+ ("Attempt to access unreferenced regulator: %s\n", regnode->name));
+
+ REG_TOPO_SLOCK();
+ rv = REGNODE_CHECK_VOLTAGE(regnode, uvolt);
REG_TOPO_UNLOCK();
return (rv);
}
Index: head/sys/dev/extres/regulator/regulator_fixed.c
===================================================================
--- head/sys/dev/extres/regulator/regulator_fixed.c
+++ head/sys/dev/extres/regulator/regulator_fixed.c
@@ -80,6 +80,7 @@
REGNODEMETHOD(regnode_enable, regnode_fixed_enable),
REGNODEMETHOD(regnode_status, regnode_fixed_status),
REGNODEMETHOD(regnode_stop, regnode_fixed_stop),
+ REGNODEMETHOD(regnode_check_voltage, regnode_method_check_voltage),
REGNODEMETHOD_END
};
DEFINE_CLASS_1(regnode_fixed, regnode_fixed_class, regnode_fixed_methods,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, May 17, 7:17 AM (10 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33181496
Default Alt Text
D22260.id64000.diff (5 KB)
Attached To
Mode
D22260: regulator: Add regulator_check_voltage function
Attached
Detach File
Event Timeline
Log In to Comment