[U-Boot] [PATCH 1/3] misc:pmic: Support for voltage to register value conversion function

Lukasz Majewski l.majewski at samsung.com
Wed Mar 28 10:45:10 CEST 2012


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 <l.majewski at samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
Cc: Stefano Babic <sbabic at denx.de>
---
 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



More information about the U-Boot mailing list