All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elaine Zhang <zhangqing@rock-chips.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 5/7] power: pmic: rk8xx: add pmic_shutdown() implement
Date: Wed,  4 Sep 2019 15:10:25 +0800	[thread overview]
Message-ID: <1567581025-9708-1-git-send-email-zhangqing@rock-chips.com> (raw)
In-Reply-To: <1567580907-9561-1-git-send-email-zhangqing@rock-chips.com>

From: Joseph Chen <chenjh@rock-chips.com>

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@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

  parent reply	other threads:[~2019-09-04  7:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04  7:08 [U-Boot] [PATCH v1 0/8] power: pmic: support more PMIC Elaine Zhang
2019-09-04  7:08 ` [U-Boot] [PATCH v1 1/7] dm: regulator: support regulator more state Elaine Zhang
2019-09-04 10:19   ` Lukasz Majewski
2019-09-17  5:47   ` Simon Glass
2019-09-04  7:08 ` [U-Boot] [PATCH v1 2/7] power: pmic: rk816: support rk816 pmic Elaine Zhang
2019-09-04  7:45   ` Kever Yang
2019-09-04  7:08 ` [U-Boot] [PATCH v1 3/7] power: pmic: rk805: support rk805 pmic Elaine Zhang
2019-09-04  7:08 ` [U-Boot] [PATCH v1 4/7] dm: pmic: add pmic_shutdown() interface Elaine Zhang
2019-09-04  7:10 ` Elaine Zhang [this message]
2019-09-04  7:10 ` [U-Boot] [PATCH v1 6/7] pmic: add RK817 support Elaine Zhang
2019-09-04  7:40   ` Kever Yang
2019-09-04  7:10 ` [U-Boot] [PATCH v1 7/7] pmic: add rk809 support Elaine Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1567581025-9708-1-git-send-email-zhangqing@rock-chips.com \
    --to=zhangqing@rock-chips.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.