mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 13:11:31 +00:00
power: Add a regulator driver for the as3722 PMIC
This pmic includes regulators which should have their own driver. Add a driver to support these. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Lukasz Majewski <lukma@denx.de> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1 Tested-by: Stephen Warren <swarren@nvidia.com>
This commit is contained in:
parent
68f0081139
commit
deea211aec
4 changed files with 167 additions and 0 deletions
|
@ -34,6 +34,15 @@ config REGULATOR_ACT8846
|
|||
by the PMIC device. This driver is controlled by a device tree node
|
||||
which includes voltage limits.
|
||||
|
||||
config REGULATOR_AS3722
|
||||
bool "Enable driver for AS7322 regulator"
|
||||
depends on DM_REGULATOR && PMIC_AS3722
|
||||
help
|
||||
Enable support for the regulator functions of the AS3722. The
|
||||
driver implements enable/disable for step-down bucks and LDOs,
|
||||
but does not yet support change voltages. Currently this must be
|
||||
done using direct register writes to the PMIC.
|
||||
|
||||
config DM_REGULATOR_PFUZE100
|
||||
bool "Enable Driver Model for REGULATOR PFUZE100"
|
||||
depends on DM_REGULATOR && DM_PMIC_PFUZE100
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
obj-$(CONFIG_$(SPL_)DM_REGULATOR) += regulator-uclass.o
|
||||
obj-$(CONFIG_REGULATOR_ACT8846) += act8846.o
|
||||
obj-$(CONFIG_REGULATOR_AS3722) += as3722_regulator.o
|
||||
obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o
|
||||
obj-$(CONFIG_DM_REGULATOR_PFUZE100) += pfuze100.o
|
||||
obj-$(CONFIG_REGULATOR_PWM) += pwm_regulator.o
|
||||
|
|
149
drivers/power/regulator/as3722_regulator.c
Normal file
149
drivers/power/regulator/as3722_regulator.c
Normal file
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
* Copyright (C) 2017 Google, Inc
|
||||
* Written by Simon Glass <sjg@chromium.org>
|
||||
*
|
||||
* Placeholder regulator driver for as3722.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
#include <power/as3722.h>
|
||||
#include <power/pmic.h>
|
||||
#include <power/regulator.h>
|
||||
|
||||
static int stepdown_get_value(struct udevice *dev)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int stepdown_set_value(struct udevice *dev, int uvolt)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int stepdown_set_enable(struct udevice *dev, bool enable)
|
||||
{
|
||||
struct udevice *pmic = dev_get_parent(dev);
|
||||
int sd = dev->driver_data;
|
||||
int ret;
|
||||
|
||||
ret = pmic_clrsetbits(pmic, AS3722_SD_CONTROL, 0, 1 << sd);
|
||||
if (ret < 0) {
|
||||
debug("%s: failed to write SD control register: %d", __func__,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stepdown_get_enable(struct udevice *dev)
|
||||
{
|
||||
struct udevice *pmic = dev_get_parent(dev);
|
||||
int sd = dev->driver_data;
|
||||
int ret;
|
||||
|
||||
ret = pmic_reg_read(pmic, AS3722_SD_CONTROL);
|
||||
if (ret < 0) {
|
||||
debug("%s: failed to read SD control register: %d", __func__,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret & (1 << sd) ? true : false;
|
||||
}
|
||||
|
||||
static int ldo_get_value(struct udevice *dev)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int ldo_set_value(struct udevice *dev, int uvolt)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int ldo_set_enable(struct udevice *dev, bool enable)
|
||||
{
|
||||
struct udevice *pmic = dev_get_parent(dev);
|
||||
int ldo = dev->driver_data;
|
||||
int ret;
|
||||
|
||||
ret = pmic_clrsetbits(pmic, AS3722_LDO_CONTROL, 0, 1 << ldo);
|
||||
if (ret < 0) {
|
||||
debug("%s: failed to write LDO control register: %d", __func__,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ldo_get_enable(struct udevice *dev)
|
||||
{
|
||||
struct udevice *pmic = dev_get_parent(dev);
|
||||
int ldo = dev->driver_data;
|
||||
int ret;
|
||||
|
||||
ret = pmic_reg_read(pmic, AS3722_LDO_CONTROL);
|
||||
if (ret < 0) {
|
||||
debug("%s: failed to read SD control register: %d", __func__,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret & (1 << ldo) ? true : false;
|
||||
}
|
||||
|
||||
static int as3722_stepdown_probe(struct udevice *dev)
|
||||
{
|
||||
struct dm_regulator_uclass_platdata *uc_pdata;
|
||||
|
||||
uc_pdata = dev_get_uclass_platdata(dev);
|
||||
|
||||
uc_pdata->type = REGULATOR_TYPE_BUCK;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int as3722_ldo_probe(struct udevice *dev)
|
||||
{
|
||||
struct dm_regulator_uclass_platdata *uc_pdata;
|
||||
|
||||
uc_pdata = dev_get_uclass_platdata(dev);
|
||||
|
||||
uc_pdata->type = REGULATOR_TYPE_LDO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dm_regulator_ops as3722_stepdown_ops = {
|
||||
.get_value = stepdown_get_value,
|
||||
.set_value = stepdown_set_value,
|
||||
.get_enable = stepdown_get_enable,
|
||||
.set_enable = stepdown_set_enable,
|
||||
};
|
||||
|
||||
static const struct dm_regulator_ops as3722_ldo_ops = {
|
||||
.get_value = ldo_get_value,
|
||||
.set_value = ldo_set_value,
|
||||
.get_enable = ldo_get_enable,
|
||||
.set_enable = ldo_set_enable,
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(as3722_stepdown) = {
|
||||
.name = "as3722_stepdown",
|
||||
.id = UCLASS_REGULATOR,
|
||||
.ops = &as3722_stepdown_ops,
|
||||
.probe = as3722_stepdown_probe,
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(as3722_ldo) = {
|
||||
.name = "as3722_ldo",
|
||||
.id = UCLASS_REGULATOR,
|
||||
.ops = &as3722_ldo_ops,
|
||||
.probe = as3722_ldo_probe,
|
||||
};
|
|
@ -12,6 +12,14 @@
|
|||
#define AS3722_GPIO_OUTPUT_VDDH (1 << 0)
|
||||
#define AS3722_GPIO_INVERT (1 << 1)
|
||||
|
||||
#define AS3722_DEVICE_ID 0x0c
|
||||
#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_ASIC_ID1 0x90
|
||||
#define AS3722_ASIC_ID2 0x91
|
||||
|
||||
struct udevice;
|
||||
|
||||
int as3722_init(struct udevice **devp);
|
||||
|
|
Loading…
Add table
Reference in a new issue