[U-Boot] [PATCH v1 5/7] power: pmic: rk8xx: add pmic_shutdown() implement
Elaine Zhang
zhangqing at rock-chips.com
Wed Sep 4 07:10:25 UTC 2019
From: Joseph Chen <chenjh at rock-chips.com>
Signed-off-by: Joseph Chen <chenjh at rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing at rock-chips.com>
---
drivers/power/pmic/rk8xx.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 00c8a2e091d8..df2056913ced 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -49,6 +49,44 @@ static int rk8xx_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
return 0;
}
+static int rk8xx_shutdown(struct udevice *dev)
+{
+ struct rk8xx_priv *priv = dev_get_priv(dev);
+ u8 val, dev_off;
+ int ret = 0;
+
+ switch (priv->variant) {
+ case RK808_ID:
+ dev_off = BIT(3);
+ break;
+ case RK805_ID:
+ case RK816_ID:
+ case RK818_ID:
+ dev_off = BIT(0);
+ break;
+ default:
+ printf("Unknown PMIC: RK%x\n", priv->variant);
+ return -EINVAL;
+ }
+
+ ret = dm_i2c_read(dev, REG_DEVCTRL, &val, 1);
+ if (ret) {
+ printf("read error from device: %p register: %#x!",
+ dev, REG_DEVCTRL);
+ return ret;
+ }
+
+ val |= dev_off;
+ ret = dm_i2c_write(dev, REG_DEVCTRL, &val, 1);
+ if (ret) {
+ printf("write error to device: %p register: %#x!",
+ dev, REG_DEVCTRL);
+ return ret;
+ }
+
+ return 0;
+}
+
#if CONFIG_IS_ENABLED(PMIC_CHILDREN)
static int rk8xx_bind(struct udevice *dev)
{
@@ -91,6 +129,7 @@ static struct dm_pmic_ops rk8xx_ops = {
.reg_count = rk8xx_reg_count,
.read = rk8xx_read,
.write = rk8xx_write,
+ .shutdown = rk8xx_shutdown,
};
static const struct udevice_id rk8xx_ids[] = {
--
1.9.1
More information about the U-Boot
mailing list