]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pmic:max8997: Function for calculating LDO internal register value
authorŁukasz Majewski <l.majewski@samsung.com>
Tue, 13 Nov 2012 03:22:04 +0000 (03:22 +0000)
committerAnatolij Gustschin <agust@denx.de>
Wed, 14 Nov 2012 10:21:10 +0000 (11:21 +0100)
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>
drivers/power/pmic/pmic_max8997.c
include/power/max8997_pmic.h

index 7fe1b53ff07872eea67562258bf0b2c09bd10528..2e46884dd68191f33942eef85aad54f509341de5 100644 (file)
 #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";
index 1db7deb3bebc2a954e467ae6f6510f0c1718e0e6..03cac041f19a0f5c8d2b5f2a898ffdf8ec6bf91c 100644 (file)
@@ -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_ */