All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chunfeng Yun <chunfeng.yun@mediatek.com>
To: AngeloGioacchino Del Regno  <angelogioacchino.delregno@collabora.com>
Cc: <mathias.nyman@intel.com>, <gregkh@linuxfoundation.org>,
	<matthias.bgg@gmail.com>, <linux-usb@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <kernel@collabora.com>
Subject: Re: [PATCH v2] usb: host: xhci-mtk: Simplify supplies handling with regulator_bulk
Date: Mon, 28 Feb 2022 16:19:00 +0800	[thread overview]
Message-ID: <d072b376ef5eb5d14cbcf35e342dd359d532bd23.camel@mediatek.com> (raw)
In-Reply-To: <20220214111905.77903-1-angelogioacchino.delregno@collabora.com>

On Mon, 2022-02-14 at 12:19 +0100, AngeloGioacchino Del Regno wrote:
> Remove the custom functions xhci_mtk_ldos_{enable,disable}() by
> switching to using regulator_bulk to perform the very same thing,
> as the regulators are always either both enabled or both disabled.
> 
> Signed-off-by: AngeloGioacchino Del Regno <
> angelogioacchino.delregno@collabora.com>
> ---
> 
> v2: Change dynamic vregs array to static definition with new
> xhci_mtk_vregs_get()
>     helper as requested by Chunfeng
> 
>  drivers/usb/host/xhci-mtk.c | 44 ++++++++++-------------------------
> --
>  drivers/usb/host/xhci-mtk.h |  5 +++--
>  2 files changed, 14 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-
> mtk.c
> index e25bad0894cf..b89b4f159a4d 100644
> --- a/drivers/usb/host/xhci-mtk.c
> +++ b/drivers/usb/host/xhci-mtk.c
> @@ -401,29 +401,14 @@ static int xhci_mtk_clks_get(struct
> xhci_hcd_mtk *mtk)
>  	return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM,
> clks);
>  }
>  
> -static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk)
> +static int xhci_mtk_vregs_get(struct xhci_hcd_mtk *mtk)
>  {
> -	int ret;
> +	struct regulator_bulk_data *supplies = mtk->supplies;
>  
> -	ret = regulator_enable(mtk->vbus);
> -	if (ret) {
> -		dev_err(mtk->dev, "failed to enable vbus\n");
> -		return ret;
> -	}
> -
> -	ret = regulator_enable(mtk->vusb33);
> -	if (ret) {
> -		dev_err(mtk->dev, "failed to enable vusb33\n");
> -		regulator_disable(mtk->vbus);
> -		return ret;
> -	}
> -	return 0;
> -}
> +	supplies[0].supply = "vbus";
> +	supplies[1].supply = "vusb33";
>  
> -static void xhci_mtk_ldos_disable(struct xhci_hcd_mtk *mtk)
> -{
> -	regulator_disable(mtk->vbus);
> -	regulator_disable(mtk->vusb33);
> +	return devm_regulator_bulk_get(mtk->dev, BULK_VREGS_NUM,
> supplies);
>  }
>  
>  static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd
> *xhci)
> @@ -513,17 +498,10 @@ static int xhci_mtk_probe(struct
> platform_device *pdev)
>  		return -ENOMEM;
>  
>  	mtk->dev = dev;
> -	mtk->vbus = devm_regulator_get(dev, "vbus");
> -	if (IS_ERR(mtk->vbus)) {
> -		dev_err(dev, "fail to get vbus\n");
> -		return PTR_ERR(mtk->vbus);
> -	}
>  
> -	mtk->vusb33 = devm_regulator_get(dev, "vusb33");
> -	if (IS_ERR(mtk->vusb33)) {
> -		dev_err(dev, "fail to get vusb33\n");
> -		return PTR_ERR(mtk->vusb33);
> -	}
> +	ret = xhci_mtk_vregs_get(mtk);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "Failed to get
> regulators\n");
>  
>  	ret = xhci_mtk_clks_get(mtk);
>  	if (ret)
> @@ -564,7 +542,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  	pm_runtime_enable(dev);
>  	pm_runtime_get_sync(dev);
>  
> -	ret = xhci_mtk_ldos_enable(mtk);
> +	ret = regulator_bulk_enable(BULK_VREGS_NUM, mtk->supplies);
>  	if (ret)
>  		goto disable_pm;
>  
> @@ -673,7 +651,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  	clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
>  
>  disable_ldos:
> -	xhci_mtk_ldos_disable(mtk);
> +	regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies);
>  
>  disable_pm:
>  	pm_runtime_put_noidle(dev);
> @@ -701,7 +679,7 @@ static int xhci_mtk_remove(struct platform_device
> *pdev)
>  	usb_put_hcd(hcd);
>  	xhci_mtk_sch_exit(mtk);
>  	clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
> -	xhci_mtk_ldos_disable(mtk);
> +	regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies);
>  
>  	pm_runtime_disable(dev);
>  	pm_runtime_put_noidle(dev);
> diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-
> mtk.h
> index 4b1ea89f959a..ffd4b493b4ba 100644
> --- a/drivers/usb/host/xhci-mtk.h
> +++ b/drivers/usb/host/xhci-mtk.h
> @@ -11,10 +11,12 @@
>  
>  #include <linux/clk.h>
>  #include <linux/hashtable.h>
> +#include <linux/regulator/consumer.h>
>  
>  #include "xhci.h"
>  
>  #define BULK_CLKS_NUM	5
> +#define BULK_VREGS_NUM	2
>  
>  /* support at most 64 ep, use 32 size hash table */
>  #define SCH_EP_HASH_BITS	5
> @@ -150,9 +152,8 @@ struct xhci_hcd_mtk {
>  	int num_u3_ports;
>  	int u2p_dis_msk;
>  	int u3p_dis_msk;
> -	struct regulator *vusb33;
> -	struct regulator *vbus;
>  	struct clk_bulk_data clks[BULK_CLKS_NUM];
> +	struct regulator_bulk_data supplies[BULK_VREGS_NUM];
>  	unsigned int has_ippc:1;
>  	unsigned int lpm_support:1;
>  	unsigned int u2_lpm_disable:1;

Acked-by: Chunfeng Yun <chunfeng.yun@mediatek.com>

Thanks a lot



WARNING: multiple messages have this Message-ID (diff)
From: Chunfeng Yun <chunfeng.yun@mediatek.com>
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: <mathias.nyman@intel.com>, <gregkh@linuxfoundation.org>,
	<matthias.bgg@gmail.com>, <linux-usb@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>,
	 <linux-kernel@vger.kernel.org>, <kernel@collabora.com>
Subject: Re: [PATCH v2] usb: host: xhci-mtk: Simplify supplies handling with regulator_bulk
Date: Mon, 28 Feb 2022 16:19:00 +0800	[thread overview]
Message-ID: <d072b376ef5eb5d14cbcf35e342dd359d532bd23.camel@mediatek.com> (raw)
In-Reply-To: <20220214111905.77903-1-angelogioacchino.delregno@collabora.com>

On Mon, 2022-02-14 at 12:19 +0100, AngeloGioacchino Del Regno wrote:
> Remove the custom functions xhci_mtk_ldos_{enable,disable}() by
> switching to using regulator_bulk to perform the very same thing,
> as the regulators are always either both enabled or both disabled.
> 
> Signed-off-by: AngeloGioacchino Del Regno <
> angelogioacchino.delregno@collabora.com>
> ---
> 
> v2: Change dynamic vregs array to static definition with new
> xhci_mtk_vregs_get()
>     helper as requested by Chunfeng
> 
>  drivers/usb/host/xhci-mtk.c | 44 ++++++++++-------------------------
> --
>  drivers/usb/host/xhci-mtk.h |  5 +++--
>  2 files changed, 14 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-
> mtk.c
> index e25bad0894cf..b89b4f159a4d 100644
> --- a/drivers/usb/host/xhci-mtk.c
> +++ b/drivers/usb/host/xhci-mtk.c
> @@ -401,29 +401,14 @@ static int xhci_mtk_clks_get(struct
> xhci_hcd_mtk *mtk)
>  	return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM,
> clks);
>  }
>  
> -static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk)
> +static int xhci_mtk_vregs_get(struct xhci_hcd_mtk *mtk)
>  {
> -	int ret;
> +	struct regulator_bulk_data *supplies = mtk->supplies;
>  
> -	ret = regulator_enable(mtk->vbus);
> -	if (ret) {
> -		dev_err(mtk->dev, "failed to enable vbus\n");
> -		return ret;
> -	}
> -
> -	ret = regulator_enable(mtk->vusb33);
> -	if (ret) {
> -		dev_err(mtk->dev, "failed to enable vusb33\n");
> -		regulator_disable(mtk->vbus);
> -		return ret;
> -	}
> -	return 0;
> -}
> +	supplies[0].supply = "vbus";
> +	supplies[1].supply = "vusb33";
>  
> -static void xhci_mtk_ldos_disable(struct xhci_hcd_mtk *mtk)
> -{
> -	regulator_disable(mtk->vbus);
> -	regulator_disable(mtk->vusb33);
> +	return devm_regulator_bulk_get(mtk->dev, BULK_VREGS_NUM,
> supplies);
>  }
>  
>  static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd
> *xhci)
> @@ -513,17 +498,10 @@ static int xhci_mtk_probe(struct
> platform_device *pdev)
>  		return -ENOMEM;
>  
>  	mtk->dev = dev;
> -	mtk->vbus = devm_regulator_get(dev, "vbus");
> -	if (IS_ERR(mtk->vbus)) {
> -		dev_err(dev, "fail to get vbus\n");
> -		return PTR_ERR(mtk->vbus);
> -	}
>  
> -	mtk->vusb33 = devm_regulator_get(dev, "vusb33");
> -	if (IS_ERR(mtk->vusb33)) {
> -		dev_err(dev, "fail to get vusb33\n");
> -		return PTR_ERR(mtk->vusb33);
> -	}
> +	ret = xhci_mtk_vregs_get(mtk);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "Failed to get
> regulators\n");
>  
>  	ret = xhci_mtk_clks_get(mtk);
>  	if (ret)
> @@ -564,7 +542,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  	pm_runtime_enable(dev);
>  	pm_runtime_get_sync(dev);
>  
> -	ret = xhci_mtk_ldos_enable(mtk);
> +	ret = regulator_bulk_enable(BULK_VREGS_NUM, mtk->supplies);
>  	if (ret)
>  		goto disable_pm;
>  
> @@ -673,7 +651,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  	clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
>  
>  disable_ldos:
> -	xhci_mtk_ldos_disable(mtk);
> +	regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies);
>  
>  disable_pm:
>  	pm_runtime_put_noidle(dev);
> @@ -701,7 +679,7 @@ static int xhci_mtk_remove(struct platform_device
> *pdev)
>  	usb_put_hcd(hcd);
>  	xhci_mtk_sch_exit(mtk);
>  	clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
> -	xhci_mtk_ldos_disable(mtk);
> +	regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies);
>  
>  	pm_runtime_disable(dev);
>  	pm_runtime_put_noidle(dev);
> diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-
> mtk.h
> index 4b1ea89f959a..ffd4b493b4ba 100644
> --- a/drivers/usb/host/xhci-mtk.h
> +++ b/drivers/usb/host/xhci-mtk.h
> @@ -11,10 +11,12 @@
>  
>  #include <linux/clk.h>
>  #include <linux/hashtable.h>
> +#include <linux/regulator/consumer.h>
>  
>  #include "xhci.h"
>  
>  #define BULK_CLKS_NUM	5
> +#define BULK_VREGS_NUM	2
>  
>  /* support at most 64 ep, use 32 size hash table */
>  #define SCH_EP_HASH_BITS	5
> @@ -150,9 +152,8 @@ struct xhci_hcd_mtk {
>  	int num_u3_ports;
>  	int u2p_dis_msk;
>  	int u3p_dis_msk;
> -	struct regulator *vusb33;
> -	struct regulator *vbus;
>  	struct clk_bulk_data clks[BULK_CLKS_NUM];
> +	struct regulator_bulk_data supplies[BULK_VREGS_NUM];
>  	unsigned int has_ippc:1;
>  	unsigned int lpm_support:1;
>  	unsigned int u2_lpm_disable:1;

Acked-by: Chunfeng Yun <chunfeng.yun@mediatek.com>

Thanks a lot

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: Chunfeng Yun <chunfeng.yun@mediatek.com>
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: <mathias.nyman@intel.com>, <gregkh@linuxfoundation.org>,
	<matthias.bgg@gmail.com>, <linux-usb@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>,
	 <linux-kernel@vger.kernel.org>, <kernel@collabora.com>
Subject: Re: [PATCH v2] usb: host: xhci-mtk: Simplify supplies handling with regulator_bulk
Date: Mon, 28 Feb 2022 16:19:00 +0800	[thread overview]
Message-ID: <d072b376ef5eb5d14cbcf35e342dd359d532bd23.camel@mediatek.com> (raw)
In-Reply-To: <20220214111905.77903-1-angelogioacchino.delregno@collabora.com>

On Mon, 2022-02-14 at 12:19 +0100, AngeloGioacchino Del Regno wrote:
> Remove the custom functions xhci_mtk_ldos_{enable,disable}() by
> switching to using regulator_bulk to perform the very same thing,
> as the regulators are always either both enabled or both disabled.
> 
> Signed-off-by: AngeloGioacchino Del Regno <
> angelogioacchino.delregno@collabora.com>
> ---
> 
> v2: Change dynamic vregs array to static definition with new
> xhci_mtk_vregs_get()
>     helper as requested by Chunfeng
> 
>  drivers/usb/host/xhci-mtk.c | 44 ++++++++++-------------------------
> --
>  drivers/usb/host/xhci-mtk.h |  5 +++--
>  2 files changed, 14 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-
> mtk.c
> index e25bad0894cf..b89b4f159a4d 100644
> --- a/drivers/usb/host/xhci-mtk.c
> +++ b/drivers/usb/host/xhci-mtk.c
> @@ -401,29 +401,14 @@ static int xhci_mtk_clks_get(struct
> xhci_hcd_mtk *mtk)
>  	return devm_clk_bulk_get_optional(mtk->dev, BULK_CLKS_NUM,
> clks);
>  }
>  
> -static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk)
> +static int xhci_mtk_vregs_get(struct xhci_hcd_mtk *mtk)
>  {
> -	int ret;
> +	struct regulator_bulk_data *supplies = mtk->supplies;
>  
> -	ret = regulator_enable(mtk->vbus);
> -	if (ret) {
> -		dev_err(mtk->dev, "failed to enable vbus\n");
> -		return ret;
> -	}
> -
> -	ret = regulator_enable(mtk->vusb33);
> -	if (ret) {
> -		dev_err(mtk->dev, "failed to enable vusb33\n");
> -		regulator_disable(mtk->vbus);
> -		return ret;
> -	}
> -	return 0;
> -}
> +	supplies[0].supply = "vbus";
> +	supplies[1].supply = "vusb33";
>  
> -static void xhci_mtk_ldos_disable(struct xhci_hcd_mtk *mtk)
> -{
> -	regulator_disable(mtk->vbus);
> -	regulator_disable(mtk->vusb33);
> +	return devm_regulator_bulk_get(mtk->dev, BULK_VREGS_NUM,
> supplies);
>  }
>  
>  static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd
> *xhci)
> @@ -513,17 +498,10 @@ static int xhci_mtk_probe(struct
> platform_device *pdev)
>  		return -ENOMEM;
>  
>  	mtk->dev = dev;
> -	mtk->vbus = devm_regulator_get(dev, "vbus");
> -	if (IS_ERR(mtk->vbus)) {
> -		dev_err(dev, "fail to get vbus\n");
> -		return PTR_ERR(mtk->vbus);
> -	}
>  
> -	mtk->vusb33 = devm_regulator_get(dev, "vusb33");
> -	if (IS_ERR(mtk->vusb33)) {
> -		dev_err(dev, "fail to get vusb33\n");
> -		return PTR_ERR(mtk->vusb33);
> -	}
> +	ret = xhci_mtk_vregs_get(mtk);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "Failed to get
> regulators\n");
>  
>  	ret = xhci_mtk_clks_get(mtk);
>  	if (ret)
> @@ -564,7 +542,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  	pm_runtime_enable(dev);
>  	pm_runtime_get_sync(dev);
>  
> -	ret = xhci_mtk_ldos_enable(mtk);
> +	ret = regulator_bulk_enable(BULK_VREGS_NUM, mtk->supplies);
>  	if (ret)
>  		goto disable_pm;
>  
> @@ -673,7 +651,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  	clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
>  
>  disable_ldos:
> -	xhci_mtk_ldos_disable(mtk);
> +	regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies);
>  
>  disable_pm:
>  	pm_runtime_put_noidle(dev);
> @@ -701,7 +679,7 @@ static int xhci_mtk_remove(struct platform_device
> *pdev)
>  	usb_put_hcd(hcd);
>  	xhci_mtk_sch_exit(mtk);
>  	clk_bulk_disable_unprepare(BULK_CLKS_NUM, mtk->clks);
> -	xhci_mtk_ldos_disable(mtk);
> +	regulator_bulk_disable(BULK_VREGS_NUM, mtk->supplies);
>  
>  	pm_runtime_disable(dev);
>  	pm_runtime_put_noidle(dev);
> diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-
> mtk.h
> index 4b1ea89f959a..ffd4b493b4ba 100644
> --- a/drivers/usb/host/xhci-mtk.h
> +++ b/drivers/usb/host/xhci-mtk.h
> @@ -11,10 +11,12 @@
>  
>  #include <linux/clk.h>
>  #include <linux/hashtable.h>
> +#include <linux/regulator/consumer.h>
>  
>  #include "xhci.h"
>  
>  #define BULK_CLKS_NUM	5
> +#define BULK_VREGS_NUM	2
>  
>  /* support at most 64 ep, use 32 size hash table */
>  #define SCH_EP_HASH_BITS	5
> @@ -150,9 +152,8 @@ struct xhci_hcd_mtk {
>  	int num_u3_ports;
>  	int u2p_dis_msk;
>  	int u3p_dis_msk;
> -	struct regulator *vusb33;
> -	struct regulator *vbus;
>  	struct clk_bulk_data clks[BULK_CLKS_NUM];
> +	struct regulator_bulk_data supplies[BULK_VREGS_NUM];
>  	unsigned int has_ippc:1;
>  	unsigned int lpm_support:1;
>  	unsigned int u2_lpm_disable:1;

Acked-by: Chunfeng Yun <chunfeng.yun@mediatek.com>

Thanks a lot

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-02-28  8:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 11:19 [PATCH v2] usb: host: xhci-mtk: Simplify supplies handling with regulator_bulk AngeloGioacchino Del Regno
2022-02-14 11:19 ` AngeloGioacchino Del Regno
2022-02-14 11:19 ` AngeloGioacchino Del Regno
2022-02-28  8:19 ` Chunfeng Yun [this message]
2022-02-28  8:19   ` Chunfeng Yun
2022-02-28  8:19   ` Chunfeng Yun

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=d072b376ef5eb5d14cbcf35e342dd359d532bd23.camel@mediatek.com \
    --to=chunfeng.yun@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=matthias.bgg@gmail.com \
    /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.