regulator: qpnp: Add property to override type registers
On some regulator hardware, the values read on SPMI offset 0x4 (type)
and 0x5 (subtype) are incorrect. Add a new optional property called
qcom,force-type that allows a user to override the hardware values
with values supplied in the Device Tree.
Change-Id: Id73fe69873f5dc9d0f2623771872aa2eaddd66f1
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
diff --git a/drivers/regulator/qpnp-regulator.c b/drivers/regulator/qpnp-regulator.c
index f8176b9..0e836c7 100644
--- a/drivers/regulator/qpnp-regulator.c
+++ b/drivers/regulator/qpnp-regulator.c
@@ -982,16 +982,26 @@
static int qpnp_regulator_match(struct qpnp_regulator *vreg)
{
const struct qpnp_regulator_mapping *mapping;
+ struct device_node *node = vreg->spmi_dev->dev.of_node;
int rc, i;
u8 raw_type[2], type, subtype;
+ u32 type_reg[2];
- rc = qpnp_vreg_read(vreg, QPNP_COMMON_REG_TYPE, raw_type, 2);
- if (rc) {
- vreg_err(vreg, "could not read type register, rc=%d\n", rc);
- return rc;
+ rc = of_property_read_u32_array(node, "qcom,force-type",
+ type_reg, 2);
+ if (!rc) {
+ type = type_reg[0];
+ subtype = type_reg[1];
+ } else {
+ rc = qpnp_vreg_read(vreg, QPNP_COMMON_REG_TYPE, raw_type, 2);
+ if (rc) {
+ vreg_err(vreg,
+ "could not read type register, rc=%d\n", rc);
+ return rc;
+ }
+ type = raw_type[0];
+ subtype = raw_type[1];
}
- type = raw_type[0];
- subtype = raw_type[1];
rc = -ENODEV;
for (i = 0; i < ARRAY_SIZE(supported_regulators); i++) {