Patchwork [U-Boot,v2,13/21] pmic:max8997: Function for calculating LDO internal register value

login
register
mail settings
Submitter Łukasz Majewski
Date Oct. 5, 2012, 8:16 a.m.
Message ID <1349425003-32523-14-git-send-email-l.majewski@samsung.com>
Download mbox | patch
Permalink /patch/189439/
State Changes Requested
Delegated to: Stefano Babic
Headers show

Comments

Łukasz Majewski - Oct. 5, 2012, 8:16 a.m.
Function for calculating LDO internal register value from passed micro
Volt.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Stefano Babic <sbabic@denx.de>
---
Changes for v2:
- MAX8997_LDO_MAX_VAL defined
---
 drivers/power/max8997/pmic_max8997.c |   16 ++++++++++++++++
 include/power/max8997_pmic.h         |    2 ++
 2 files changed, 18 insertions(+), 0 deletions(-)

Patch

diff --git a/drivers/power/max8997/pmic_max8997.c b/drivers/power/max8997/pmic_max8997.c
index 4e8283a..47ef7f6 100644
--- a/drivers/power/max8997/pmic_max8997.c
+++ b/drivers/power/max8997/pmic_max8997.c
@@ -26,6 +26,22 @@ 
 #include <power/max8997_pmic.h>
 #include <i2c.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)
 {
 	struct pmic *p = pmic_alloc();
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_ */