mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthias Brugger <matthias.bgg@gmail.com>
To: Chunfeng Yun <chunfeng.yun@mediatek.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Felipe Balbi <felipe.balbi@linux.intel.com>,
	Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org,
	linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 6/9] usb: xhci-mtk: add optional mcu and dma bus clocks
Date: Fri, 13 Oct 2017 15:55:27 +0200	[thread overview]
Message-ID: <7a64bd4c-9bf3-4807-fa75-fb5d73e8507c@gmail.com> (raw)
In-Reply-To: <3f81e076f513ef7d3e3e20ba2f752ed5bd48c9a2.1507882470.git.chunfeng.yun@mediatek.com>



On 10/13/2017 10:26 AM, Chunfeng Yun wrote:
> There are mcu_bus and dma_bus clocks needed to be controlled by
> driver on some SoCs, so add them as optional ones
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---

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

>   drivers/usb/host/xhci-mtk.c |   79 ++++++++++++++++++++++++++++++++-----------
>   drivers/usb/host/xhci-mtk.h |    2 ++
>   2 files changed, 62 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
> index d60463c..e5caabe 100644
> --- a/drivers/usb/host/xhci-mtk.c
> +++ b/drivers/usb/host/xhci-mtk.c
> @@ -221,6 +221,44 @@ static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk)
>   	return xhci_mtk_host_enable(mtk);
>   }
>   
> +/* ignore the error if the clock does not exist */
> +static struct clk *optional_clk_get(struct device *dev, const char *id)
> +{
> +	struct clk *opt_clk;
> +
> +	opt_clk = devm_clk_get(dev, id);
> +	/* ignore error number except EPROBE_DEFER */
> +	if (IS_ERR(opt_clk) && (PTR_ERR(opt_clk) != -EPROBE_DEFER))
> +		opt_clk = NULL;
> +
> +	return opt_clk;
> +}
> +
> +static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk)
> +{
> +	struct device *dev = mtk->dev;
> +
> +	mtk->sys_clk = devm_clk_get(dev, "sys_ck");
> +	if (IS_ERR(mtk->sys_clk)) {
> +		dev_err(dev, "fail to get sys_ck\n");
> +		return PTR_ERR(mtk->sys_clk);
> +	}
> +
> +	mtk->ref_clk = optional_clk_get(dev, "ref_ck");
> +	if (IS_ERR(mtk->ref_clk))
> +		return PTR_ERR(mtk->ref_clk);
> +
> +	mtk->mcu_clk = optional_clk_get(dev, "mcu_ck");
> +	if (IS_ERR(mtk->mcu_clk))
> +		return PTR_ERR(mtk->mcu_clk);
> +
> +	mtk->dma_clk = optional_clk_get(dev, "dma_ck");
> +	if (IS_ERR(mtk->dma_clk))
> +		return PTR_ERR(mtk->dma_clk);
> +
> +	return 0;
> +}
> +
>   static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk)
>   {
>   	int ret;
> @@ -237,16 +275,34 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk)
>   		goto sys_clk_err;
>   	}
>   
> +	ret = clk_prepare_enable(mtk->mcu_clk);
> +	if (ret) {
> +		dev_err(mtk->dev, "failed to enable mcu_clk\n");
> +		goto mcu_clk_err;
> +	}
> +
> +	ret = clk_prepare_enable(mtk->dma_clk);
> +	if (ret) {
> +		dev_err(mtk->dev, "failed to enable dma_clk\n");
> +		goto dma_clk_err;
> +	}
> +
>   	return 0;
>   
> +dma_clk_err:
> +	clk_disable_unprepare(mtk->mcu_clk);
> +mcu_clk_err:
> +	clk_disable_unprepare(mtk->sys_clk);
>   sys_clk_err:
>   	clk_disable_unprepare(mtk->ref_clk);
>   ref_clk_err:
> -	return -EINVAL;
> +	return ret;
>   }
>   
>   static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk)
>   {
> +	clk_disable_unprepare(mtk->dma_clk);
> +	clk_disable_unprepare(mtk->mcu_clk);
>   	clk_disable_unprepare(mtk->sys_clk);
>   	clk_disable_unprepare(mtk->ref_clk);
>   }
> @@ -529,24 +585,9 @@ static int xhci_mtk_probe(struct platform_device *pdev)
>   		return PTR_ERR(mtk->vusb33);
>   	}
>   
> -	mtk->sys_clk = devm_clk_get(dev, "sys_ck");
> -	if (IS_ERR(mtk->sys_clk)) {
> -		dev_err(dev, "fail to get sys_ck\n");
> -		return PTR_ERR(mtk->sys_clk);
> -	}
> -
> -	/*
> -	 * reference clock is usually a "fixed-clock", make it optional
> -	 * for backward compatibility and ignore the error if it does
> -	 * not exist.
> -	 */
> -	mtk->ref_clk = devm_clk_get(dev, "ref_ck");
> -	if (IS_ERR(mtk->ref_clk)) {
> -		if (PTR_ERR(mtk->ref_clk) == -EPROBE_DEFER)
> -			return -EPROBE_DEFER;
> -
> -		mtk->ref_clk = NULL;
> -	}
> +	ret = xhci_mtk_clks_get(mtk);
> +	if (ret)
> +		return ret;
>   
>   	mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
>   	/* optional property, ignore the error if it does not exist */
> diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h
> index 67783a7..45ff5c6 100644
> --- a/drivers/usb/host/xhci-mtk.h
> +++ b/drivers/usb/host/xhci-mtk.h
> @@ -126,6 +126,8 @@ struct xhci_hcd_mtk {
>   	struct regulator *vbus;
>   	struct clk *sys_clk;	/* sys and mac clock */
>   	struct clk *ref_clk;
> +	struct clk *mcu_clk;
> +	struct clk *dma_clk;
>   	struct regmap *pericfg;
>   	struct phy **phys;
>   	int num_phys;
> 

  reply	other threads:[~2017-10-13 13:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13  8:26 [PATCH v2 1/9] usb: xhci-mtk: use dma_set_mask_and_coherent() in probe function Chunfeng Yun
2017-10-13  8:26 ` [PATCH v2 2/9] usb: xhci-mtk: use ports count from xhci in xhci_mtk_sch_init() Chunfeng Yun
2017-10-13  8:26 ` [PATCH v2 3/9] usb: xhci-mtk: check clock stability of U3_MAC Chunfeng Yun
2017-10-13  8:26 ` [PATCH v2 4/9] usb: xhci-mtk: support option to disable usb3 ports Chunfeng Yun
2017-10-13  8:26 ` [PATCH v2 5/9] usb: xhci-mtk: remove dummy wakeup debounce clocks Chunfeng Yun
2017-10-13 13:49   ` Matthias Brugger
2017-10-13  8:26 ` [PATCH v2 6/9] usb: xhci-mtk: add optional mcu and dma bus clocks Chunfeng Yun
2017-10-13 13:55   ` Matthias Brugger [this message]
2017-10-13  8:26 ` [PATCH v2 7/9] usb: host: modify description for MTK xHCI config Chunfeng Yun
2017-10-13 10:32   ` Mathias Nyman
2017-10-16  3:25     ` Chunfeng Yun
2017-10-17 10:20     ` Greg Kroah-Hartman
2017-10-17 10:42       ` Mathias Nyman
2017-10-22  3:31         ` Chunfeng Yun
2017-10-13  8:26 ` [PATCH v2 8/9] dt-bindings: usb: mtk-xhci: add a optional property to disable u3ports Chunfeng Yun
2017-10-13  8:26 ` [PATCH v2 9/9] dt-bindings: usb: mtk-xhci: remove dummy clocks and add optional ones Chunfeng Yun
2017-10-13 13:56   ` Matthias Brugger

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=7a64bd4c-9bf3-4807-fa75-fb5d73e8507c@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=chunfeng.yun@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --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=mark.rutland@arm.com \
    --cc=mathias.nyman@intel.com \
    --cc=robh+dt@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome