[U-Boot] [PATCH v3 6/8] power: pmic: rk8xx: add pmic_shutdown() implement

Kever Yang kever.yang at rock-chips.com
Thu Sep 19 08:41:49 UTC 2019


On 2019/9/19 下午4:09, Elaine Zhang wrote:
> From: Joseph Chen <chenjh at rock-chips.com>
>
> add rk8xx_shutdown for pmic shutdown.
> It is used in applications such as UBOOT shutdown charging.
>
> Signed-off-by: Joseph Chen <chenjh at rock-chips.com>
> Signed-off-by: Elaine Zhang <zhangqing at rock-chips.com>

Reviewed-by: Kever Yang<kever.yang at rock-chips.com>

Thanks,
- Kever
> ---
>   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[] = {




More information about the U-Boot mailing list