mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 15:14:43 +00:00
power: as3722: fix ldo_get/set_enable for ldo index bigger than 7
Fix ldo_get_enable() and ldo_set_enable() functions for LDOs with an index > 7. Turns out there are actually two separate AS3722_LDO_CONTROL registers AS3722_LDO_CONTROL0 and AS3722_LDO_CONTROL1. Actually make use of both. While at it also actually use the enable parameter of the ldo_set_enable() function which now truly allows disabling as opposed to only enabling LDOs. Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Signed-off-by: Tom Warren <twarren@nvidia.com>
This commit is contained in:
parent
c0cb8c8e86
commit
4616e33b6a
2 changed files with 18 additions and 3 deletions
|
@ -13,6 +13,8 @@
|
|||
#include <power/pmic.h>
|
||||
#include <power/regulator.h>
|
||||
|
||||
#define AS3722_LDO_CONTROL0_MAX_INDEX 7
|
||||
|
||||
static int stepdown_get_value(struct udevice *dev)
|
||||
{
|
||||
return -ENOSYS;
|
||||
|
@ -68,10 +70,16 @@ static int ldo_set_value(struct udevice *dev, int uvolt)
|
|||
static int ldo_set_enable(struct udevice *dev, bool enable)
|
||||
{
|
||||
struct udevice *pmic = dev_get_parent(dev);
|
||||
u8 ctrl_reg = AS3722_LDO_CONTROL0;
|
||||
int ldo = dev->driver_data;
|
||||
int ret;
|
||||
|
||||
ret = pmic_clrsetbits(pmic, AS3722_LDO_CONTROL, 0, 1 << ldo);
|
||||
if (ldo > AS3722_LDO_CONTROL0_MAX_INDEX) {
|
||||
ctrl_reg = AS3722_LDO_CONTROL1;
|
||||
ldo -= 8;
|
||||
}
|
||||
|
||||
ret = pmic_clrsetbits(pmic, ctrl_reg, !enable << ldo, enable << ldo);
|
||||
if (ret < 0) {
|
||||
debug("%s: failed to write LDO control register: %d", __func__,
|
||||
ret);
|
||||
|
@ -84,10 +92,16 @@ static int ldo_set_enable(struct udevice *dev, bool enable)
|
|||
static int ldo_get_enable(struct udevice *dev)
|
||||
{
|
||||
struct udevice *pmic = dev_get_parent(dev);
|
||||
u8 ctrl_reg = AS3722_LDO_CONTROL0;
|
||||
int ldo = dev->driver_data;
|
||||
int ret;
|
||||
|
||||
ret = pmic_reg_read(pmic, AS3722_LDO_CONTROL);
|
||||
if (ldo > AS3722_LDO_CONTROL0_MAX_INDEX) {
|
||||
ctrl_reg = AS3722_LDO_CONTROL1;
|
||||
ldo -= 8;
|
||||
}
|
||||
|
||||
ret = pmic_reg_read(pmic, ctrl_reg);
|
||||
if (ret < 0) {
|
||||
debug("%s: failed to read SD control register: %d", __func__,
|
||||
ret);
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
#define AS3722_SD_VOLTAGE(n) (0x00 + (n))
|
||||
#define AS3722_LDO_VOLTAGE(n) (0x10 + (n))
|
||||
#define AS3722_SD_CONTROL 0x4d
|
||||
#define AS3722_LDO_CONTROL 0x4e
|
||||
#define AS3722_LDO_CONTROL0 0x4e
|
||||
#define AS3722_LDO_CONTROL1 0x4f
|
||||
#define AS3722_ASIC_ID1 0x90
|
||||
#define AS3722_ASIC_ID2 0x91
|
||||
|
||||
|
|
Loading…
Reference in a new issue