Support for voltage (in uV) to proper register value is added.
The function tied to this callback is often PMIC dependent
and shall be defined for each device.

Signed-off-by: Lukasz Majewski <[email protected]>
Signed-off-by: Kyungmin Park <[email protected]>
Cc: Stefano Babic <[email protected]>
---
 drivers/misc/pmic_core.c |   10 ++++++++++
 include/pmic.h           |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/misc/pmic_core.c b/drivers/misc/pmic_core.c
index 5d62a56..4366bf0 100644
--- a/drivers/misc/pmic_core.c
+++ b/drivers/misc/pmic_core.c
@@ -89,6 +89,16 @@ struct pmic *get_pmic(void)
        return &pmic;
 }
 
+int pmic_vol_to_reg(struct pmic *p, int uV)
+{
+       if (p->voltage_to_reg_conv == NULL) {
+               puts("PMIC: Voltage to register value function not defined\n");
+               return 0;
+       }
+
+       return p->voltage_to_reg_conv(uV);
+}
+
 int do_pmic(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        u32 ret, reg, val;
diff --git a/include/pmic.h b/include/pmic.h
index 52a1526..f8594a9 100644
--- a/include/pmic.h
+++ b/include/pmic.h
@@ -52,12 +52,14 @@ struct pmic {
                struct p_i2c i2c;
                struct p_spi spi;
        } hw;
+       int (*voltage_to_reg_conv) (int uV);
 };
 
 int pmic_init(void);
 int check_reg(u32 reg);
 struct pmic *get_pmic(void);
 int pmic_probe(struct pmic *p);
+int pmic_vol_to_reg(struct pmic *p, int uV);
 int pmic_reg_read(struct pmic *p, u32 reg, u32 *val);
 int pmic_reg_write(struct pmic *p, u32 reg, u32 val);
 int pmic_set_output(struct pmic *p, u32 reg, int ldo, int on);
-- 
1.7.2.3

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to