[U-Boot] [PATCH v7 13/26] pmic:max8997: Function for calculating LDO internal register value

Lukasz Majewski l.majewski at samsung.com
Tue Nov 13 14:22:04 CET 2012


Function for calculating LDO internal register value from passed micro
Volt.

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>
---
Changes for v2:
- MAX8997_LDO_MAX_VAL defined
Changes for v3:
- None
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
Changes for v7:
- None
---
 drivers/power/pmic/pmic_max8997.c |   16 ++++++++++++++++
 include/power/max8997_pmic.h      |    2 ++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/power/pmic/pmic_max8997.c b/drivers/power/pmic/pmic_max8997.c
index 7fe1b53..2e46884 100644
--- a/drivers/power/pmic/pmic_max8997.c
+++ b/drivers/power/pmic/pmic_max8997.c
@@ -27,6 +27,22 @@
 #include <i2c.h>
 #include <errno.h>
 
+unsigned char max8997_reg_ldo(int uV)
+{
+	unsigned char ret;
+	if (uV <= 800000)
+		return 0;
+	if (uV >= 3950000)
+		return MAX8997_LDO_MAX_VAL;
+	ret = (uV - 800000) / 50000;
+	if (ret > MAX8997_LDO_MAX_VAL) {
+		printf("MAX8997 LDO SETTING ERROR (%duV) -> %u\n", uV, ret);
+		ret = MAX8997_LDO_MAX_VAL;
+	}
+
+	return ret;
+}
+
 int pmic_init(unsigned char bus)
 {
 	static const char name[] = "MAX8997_PMIC";
diff --git a/include/power/max8997_pmic.h b/include/power/max8997_pmic.h
index 1db7deb..03cac04 100644
--- a/include/power/max8997_pmic.h
+++ b/include/power/max8997_pmic.h
@@ -200,4 +200,6 @@ enum {
 	EN_LDO = (0x3 << 6),
 };
 
+#define MAX8997_LDO_MAX_VAL 0x3F
+unsigned char max8997_reg_ldo(int uV);
 #endif /* __MAX8997_PMIC_H_ */
-- 
1.7.2.3



More information about the U-Boot mailing list