diff mbox series

[v21,3/5] i2c: mediatek: mt65xx: add optional vbus-supply

Message ID 20210507131406.2224177-4-hsinyi@chromium.org (mailing list archive)
State New, archived
Headers show
Series add power control in i2c | expand

Commit Message

Hsin-Yi Wang May 7, 2021, 1:14 p.m. UTC
Add vbus-supply which provides power to SCL/SDA. Pass this regulator
into core so it can be turned on/off for low power mode support.

Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
---
 drivers/i2c/busses/i2c-mt65xx.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Matthias Brugger May 12, 2021, 3:46 p.m. UTC | #1
On 07/05/2021 15:14, Hsin-Yi Wang wrote:
> Add vbus-supply which provides power to SCL/SDA. Pass this regulator
> into core so it can be turned on/off for low power mode support.
> 
> Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> ---
>  drivers/i2c/busses/i2c-mt65xx.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index 5ddfa4e56ee2..22d1d14b5de5 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -1220,6 +1220,13 @@ static int mtk_i2c_probe(struct platform_device *pdev)
>  	i2c->adap.quirks = i2c->dev_comp->quirks;
>  	i2c->adap.timeout = 2 * HZ;
>  	i2c->adap.retries = 1;
> +	i2c->adap.bus_regulator = devm_regulator_get_optional(&pdev->dev, "vbus");
> +	if (IS_ERR(i2c->adap.bus_regulator)) {
> +		if (PTR_ERR(i2c->adap.bus_regulator) == -ENODEV)
> +			i2c->adap.bus_regulator = NULL;
> +		else
> +			return PTR_ERR(i2c->adap.bus_regulator);
> +	}
>  
>  	ret = mtk_i2c_parse_dt(pdev->dev.of_node, i2c);
>  	if (ret)
>
Qii Wang May 17, 2021, 8:06 a.m. UTC | #2
On Fri, 2021-05-07 at 21:14 +0800, Hsin-Yi Wang wrote:
> Add vbus-supply which provides power to SCL/SDA. Pass this regulator
> into core so it can be turned on/off for low power mode support.
> 
> Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>

Reviewed-by: Qii Wang <qii.wang@mediatek.com>

> ---
>  drivers/i2c/busses/i2c-mt65xx.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index 5ddfa4e56ee2..22d1d14b5de5 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -1220,6 +1220,13 @@ static int mtk_i2c_probe(struct platform_device *pdev)
>  	i2c->adap.quirks = i2c->dev_comp->quirks;
>  	i2c->adap.timeout = 2 * HZ;
>  	i2c->adap.retries = 1;
> +	i2c->adap.bus_regulator = devm_regulator_get_optional(&pdev->dev, "vbus");
> +	if (IS_ERR(i2c->adap.bus_regulator)) {
> +		if (PTR_ERR(i2c->adap.bus_regulator) == -ENODEV)
> +			i2c->adap.bus_regulator = NULL;
> +		else
> +			return PTR_ERR(i2c->adap.bus_regulator);
> +	}
>  
>  	ret = mtk_i2c_parse_dt(pdev->dev.of_node, i2c);
>  	if (ret)
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
index 5ddfa4e56ee2..22d1d14b5de5 100644
--- a/drivers/i2c/busses/i2c-mt65xx.c
+++ b/drivers/i2c/busses/i2c-mt65xx.c
@@ -1220,6 +1220,13 @@  static int mtk_i2c_probe(struct platform_device *pdev)
 	i2c->adap.quirks = i2c->dev_comp->quirks;
 	i2c->adap.timeout = 2 * HZ;
 	i2c->adap.retries = 1;
+	i2c->adap.bus_regulator = devm_regulator_get_optional(&pdev->dev, "vbus");
+	if (IS_ERR(i2c->adap.bus_regulator)) {
+		if (PTR_ERR(i2c->adap.bus_regulator) == -ENODEV)
+			i2c->adap.bus_regulator = NULL;
+		else
+			return PTR_ERR(i2c->adap.bus_regulator);
+	}
 
 	ret = mtk_i2c_parse_dt(pdev->dev.of_node, i2c);
 	if (ret)