Re: [PATCH v2] chipidea: ci_hdrc_imx: Allow handling the clock for an USB phy/hub

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 14, 2013 at 08:47:40AM -0200, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@xxxxxxxxxxxxx>
>
> When using external USB PHY or USB hub, it is common that they require a clock
> input.
>
> Add a 'clk_phy' clock, so that it can be retrieved from the device tree and
> enabled in the driver, so that the clock can properly drive the external
> USB phy/hub.
>
> Tested on a imx6q-udoo board, that connects via USBH1 to a USB2514 hub.
>
> In this board the USB2514 is clocked from a 24MHz clock that comes from the
> imx6q CLKO2 pin.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@xxxxxxxxxxxxx>

NACK! We have the phy framework for this. If you are unsure you can use the
nop phy here as in mx53.dtsi.

        usbphy0: usbphy@0 {
                compatible = "usb-nop-xceiv";
                clocks = <&clks 124>;
                clock-names = "main_clk";
                status = "okay";
        };

Just setup the right clock in the phy node and overwrite the fsl,usbphy in
your usbnode. i.e.

        usbotg: usb@02184000 {
                fsl,usbphy = <&usbphy0>;
                status = "okay";
        };

I don't see why we need to handle phy clocks in the ci_hdrc_imx glue.

Thanks,
Michael

> ---
> Changes since v1:
> - Fix the clock error handling (Russell King)
>
>  Documentation/devicetree/bindings/usb/ci13xxx-imx.txt |  2 ++
>  drivers/usb/chipidea/ci_hdrc_imx.c                    | 13 +++++++++++++
>  2 files changed, 15 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
> index b4b5b79..07ba38c 100644
> --- a/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
> +++ b/Documentation/devicetree/bindings/usb/ci13xxx-imx.txt
> @@ -18,6 +18,8 @@ Optional properties:
>  - vbus-supply: regulator for vbus
>  - disable-over-current: disable over current detect
>  - external-vbus-divider: enables off-chip resistor divider for Vbus
> +- clocks: phandle to the clock that drives the USB hub
> +- clock-names: must be "phy"
>
>  Examples:
>  usb@02184000 { /* USB OTG */
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index bb5d976..3edf10a 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -27,6 +27,7 @@ struct ci_hdrc_imx_data {
>  	struct usb_phy *phy;
>  	struct platform_device *ci_pdev;
>  	struct clk *clk;
> +	struct clk *clk_phy;
>  	struct imx_usbmisc_data *usbmisc_data;
>  };
>
> @@ -148,6 +149,16 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  		}
>  	}
>
> +	data->clk_phy = devm_clk_get(&pdev->dev, "phy");
> +	if (!IS_ERR(data->clk_phy)) {
> +		ret = clk_prepare_enable(data->clk_phy);
> +		if (ret) {
> +			dev_err(&pdev->dev,
> +				"Failed to enable clk_phy: %d\n", ret);
> +			goto disable_device;
> +		}
> +	}
> +
>  	platform_set_drvdata(pdev, data);
>
>  	pm_runtime_no_callbacks(&pdev->dev);
> @@ -167,6 +178,8 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev)
>  	struct ci_hdrc_imx_data *data = platform_get_drvdata(pdev);
>
>  	pm_runtime_disable(&pdev->dev);
> +	if (!IS_ERR(data->clk_phy))
> +		clk_disable_unprepare(data->clk_phy);
>  	ci_hdrc_remove_device(data->ci_pdev);
>  	clk_disable_unprepare(data->clk);
>
> --
> 1.8.1.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

--
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux