From: Ɓukasz Majewski Date: Tue, 13 Nov 2012 03:22:04 +0000 (+0000) Subject: pmic:max8997: Function for calculating LDO internal register value X-Git-Tag: v2013.01-rc2~140^2~17 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bf995a9a28c7a987be0b3df9d4f84da63c9bfb1c;p=oweals%2Fu-boot.git pmic:max8997: Function for calculating LDO internal register value Function for calculating LDO internal register value from passed micro Volt. Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Cc: Stefano Babic --- diff --git a/drivers/power/pmic/pmic_max8997.c b/drivers/power/pmic/pmic_max8997.c index 7fe1b53ff0..2e46884dd6 100644 --- a/drivers/power/pmic/pmic_max8997.c +++ b/drivers/power/pmic/pmic_max8997.c @@ -27,6 +27,22 @@ #include #include +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 1db7deb3be..03cac041f1 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_ */