RE: [PATCH v2 3/5] drivers: usb: phy: Add qoriq usb 2.0 phy driver support

2016-07-11 Thread Rajesh Bhagat


> -Original Message-
> From: Peter Chen [mailto:hzpeterc...@gmail.com]
> Sent: Monday, July 11, 2016 12:24 PM
> To: Rajesh Bhagat <rajesh.bha...@nxp.com>
> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org;
> devicet...@vger.kernel.org; Peter Chen <peter.c...@nxp.com>;
> gre...@linuxfoundation.org; kis...@ti.com; robh...@kernel.org;
> shawn...@kernel.org; linux-arm-ker...@lists.infradead.org
> Subject: Re: [PATCH v2 3/5] drivers: usb: phy: Add qoriq usb 2.0 phy driver 
> support
> 
> On Sat, Jul 09, 2016 at 10:00:54AM +0530, Rajesh Bhagat wrote:
> > Adds qoriq usb 2.0 phy driver support for LS1021A and LS1012A
> > platform.
> >
> > Signed-off-by: Rajesh Bhagat <rajesh.bha...@nxp.com>
> > ---
> > Changes in v2:
> >  - Replaced Freescale with QorIQ in comments section
> >  - Changed the compatible string to fsl,qoriq-usb2-phy and added
> > version
> >  - Added dependency on ARCH_MXC/ARCH_LAYERSCAPE and OF in Kconfig
> >  - Dropped CONFIG_ULPI #ifdefs to make code generic
> >  - Removed calls to devm free/release calls
> >
> >  drivers/phy/Kconfig  |   8 ++
> >  drivers/phy/Makefile |   1 +
> >  drivers/phy/phy-qoriq-usb2.c | 228
> > +++
> >  drivers/phy/phy-qoriq-usb2.h |  50 ++
> >  4 files changed, 287 insertions(+)
> >  create mode 100644 drivers/phy/phy-qoriq-usb2.c  create mode 100644
> > drivers/phy/phy-qoriq-usb2.h
> >
> > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index
> > b869b98..cc69299 100644
> > --- a/drivers/phy/Kconfig
> > +++ b/drivers/phy/Kconfig
> > @@ -434,4 +434,12 @@ config PHY_CYGNUS_PCIE
> >
> >  source "drivers/phy/tegra/Kconfig"
> >
> > +config PHY_QORIQ_USB2
> > +   tristate "QorIQ USB 2.0 PHY driver"
> > +   depends on ARCH_MXC || ARCH_LAYERSCAPE
> 

Hello Peter,

> It seems mxc platforms do not use this PHY.
> Besides, if you are using ULPI phy, you need to depend on ULPI bus.
> 

QorIQ platform are having both ULPI and non-ULPI PHY variants, Hence
this PHY driver is targeted for both. And driver takes decision on run time 
which PHY is there according to information passed in DTS files. 


Best Regards,
Rajesh Bhagat 

> Peter
> > +   depends on OF
> > +   select GENERIC_PHY
> > +   help
> > + Enable this to support the USB2.0 PHY on the QorIQ SoC.
> > +
> >  endmenu
> > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index
> > 9c3e73c..044105a 100644
> > --- a/drivers/phy/Makefile
> > +++ b/drivers/phy/Makefile
> > @@ -53,5 +53,6 @@ obj-$(CONFIG_PHY_TUSB1210)+= 
> > phy-tusb1210.o
> >  obj-$(CONFIG_PHY_BRCM_SATA)+= phy-brcm-sata.o
> >  obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o
> >  obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
> > +obj-$(CONFIG_PHY_QORIQ_USB2)+= phy-qoriq-usb2.o
> >
> >  obj-$(CONFIG_ARCH_TEGRA) += tegra/
> > diff --git a/drivers/phy/phy-qoriq-usb2.c
> > b/drivers/phy/phy-qoriq-usb2.c new file mode 100644 index
> > 000..f74d255
> > --- /dev/null
> > +++ b/drivers/phy/phy-qoriq-usb2.c
> > @@ -0,0 +1,228 @@
> > +/*
> > + * QorIQ SoC USB 2.0 PHY driver
> > + *
> > + * Copyright 2016 Freescale Semiconductor, Inc.
> > + * Author: Rajesh Bhagat <rajesh.bha...@nxp.com>
> > + *
> > + * This program is free software; you can redistribute it and/or
> > +modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include "phy-qoriq-usb2.h"
> > +
> > +static int qoriq_usb2_phy_init(struct phy *_phy) {
> > +   struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
> > +   struct device *dev = ctx->dev;
> > +
> > +   if (ctx->ulpi_phy) {
> > +   if (usb_phy_init(ctx->ulpi_phy)) {
> > +   dev_err(dev, "unable to init transceiver, probably 
> > missing\n");
> > +   return -ENODEV;
> > +   }
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static int qoriq_usb2_phy_power_on(struct phy *_phy) {
> &

RE: [PATCH v2 3/5] drivers: usb: phy: Add qoriq usb 2.0 phy driver support

2016-07-11 Thread Rajesh Bhagat


> -Original Message-
> From: Peter Chen [mailto:hzpeterc...@gmail.com]
> Sent: Monday, July 11, 2016 12:24 PM
> To: Rajesh Bhagat 
> Cc: linux-...@vger.kernel.org; linux-kernel@vger.kernel.org;
> devicet...@vger.kernel.org; Peter Chen ;
> gre...@linuxfoundation.org; kis...@ti.com; robh...@kernel.org;
> shawn...@kernel.org; linux-arm-ker...@lists.infradead.org
> Subject: Re: [PATCH v2 3/5] drivers: usb: phy: Add qoriq usb 2.0 phy driver 
> support
> 
> On Sat, Jul 09, 2016 at 10:00:54AM +0530, Rajesh Bhagat wrote:
> > Adds qoriq usb 2.0 phy driver support for LS1021A and LS1012A
> > platform.
> >
> > Signed-off-by: Rajesh Bhagat 
> > ---
> > Changes in v2:
> >  - Replaced Freescale with QorIQ in comments section
> >  - Changed the compatible string to fsl,qoriq-usb2-phy and added
> > version
> >  - Added dependency on ARCH_MXC/ARCH_LAYERSCAPE and OF in Kconfig
> >  - Dropped CONFIG_ULPI #ifdefs to make code generic
> >  - Removed calls to devm free/release calls
> >
> >  drivers/phy/Kconfig  |   8 ++
> >  drivers/phy/Makefile |   1 +
> >  drivers/phy/phy-qoriq-usb2.c | 228
> > +++
> >  drivers/phy/phy-qoriq-usb2.h |  50 ++
> >  4 files changed, 287 insertions(+)
> >  create mode 100644 drivers/phy/phy-qoriq-usb2.c  create mode 100644
> > drivers/phy/phy-qoriq-usb2.h
> >
> > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index
> > b869b98..cc69299 100644
> > --- a/drivers/phy/Kconfig
> > +++ b/drivers/phy/Kconfig
> > @@ -434,4 +434,12 @@ config PHY_CYGNUS_PCIE
> >
> >  source "drivers/phy/tegra/Kconfig"
> >
> > +config PHY_QORIQ_USB2
> > +   tristate "QorIQ USB 2.0 PHY driver"
> > +   depends on ARCH_MXC || ARCH_LAYERSCAPE
> 

Hello Peter,

> It seems mxc platforms do not use this PHY.
> Besides, if you are using ULPI phy, you need to depend on ULPI bus.
> 

QorIQ platform are having both ULPI and non-ULPI PHY variants, Hence
this PHY driver is targeted for both. And driver takes decision on run time 
which PHY is there according to information passed in DTS files. 


Best Regards,
Rajesh Bhagat 

> Peter
> > +   depends on OF
> > +   select GENERIC_PHY
> > +   help
> > + Enable this to support the USB2.0 PHY on the QorIQ SoC.
> > +
> >  endmenu
> > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index
> > 9c3e73c..044105a 100644
> > --- a/drivers/phy/Makefile
> > +++ b/drivers/phy/Makefile
> > @@ -53,5 +53,6 @@ obj-$(CONFIG_PHY_TUSB1210)+= 
> > phy-tusb1210.o
> >  obj-$(CONFIG_PHY_BRCM_SATA)+= phy-brcm-sata.o
> >  obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o
> >  obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
> > +obj-$(CONFIG_PHY_QORIQ_USB2)+= phy-qoriq-usb2.o
> >
> >  obj-$(CONFIG_ARCH_TEGRA) += tegra/
> > diff --git a/drivers/phy/phy-qoriq-usb2.c
> > b/drivers/phy/phy-qoriq-usb2.c new file mode 100644 index
> > 000..f74d255
> > --- /dev/null
> > +++ b/drivers/phy/phy-qoriq-usb2.c
> > @@ -0,0 +1,228 @@
> > +/*
> > + * QorIQ SoC USB 2.0 PHY driver
> > + *
> > + * Copyright 2016 Freescale Semiconductor, Inc.
> > + * Author: Rajesh Bhagat 
> > + *
> > + * This program is free software; you can redistribute it and/or
> > +modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include "phy-qoriq-usb2.h"
> > +
> > +static int qoriq_usb2_phy_init(struct phy *_phy) {
> > +   struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
> > +   struct device *dev = ctx->dev;
> > +
> > +   if (ctx->ulpi_phy) {
> > +   if (usb_phy_init(ctx->ulpi_phy)) {
> > +   dev_err(dev, "unable to init transceiver, probably 
> > missing\n");
> > +   return -ENODEV;
> > +   }
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static int qoriq_usb2_phy_power_on(struct phy *_phy) {
> > +   struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
> > +   u32 flags;
> > +
> &

Re: [PATCH v2 3/5] drivers: usb: phy: Add qoriq usb 2.0 phy driver support

2016-07-11 Thread Peter Chen
On Sat, Jul 09, 2016 at 10:00:54AM +0530, Rajesh Bhagat wrote:
> Adds qoriq usb 2.0 phy driver support for LS1021A and LS1012A
> platform.
> 
> Signed-off-by: Rajesh Bhagat 
> ---
> Changes in v2:
>  - Replaced Freescale with QorIQ in comments section
>  - Changed the compatible string to fsl,qoriq-usb2-phy and added version
>  - Added dependency on ARCH_MXC/ARCH_LAYERSCAPE and OF in Kconfig
>  - Dropped CONFIG_ULPI #ifdefs to make code generic
>  - Removed calls to devm free/release calls
> 
>  drivers/phy/Kconfig  |   8 ++
>  drivers/phy/Makefile |   1 +
>  drivers/phy/phy-qoriq-usb2.c | 228 
> +++
>  drivers/phy/phy-qoriq-usb2.h |  50 ++
>  4 files changed, 287 insertions(+)
>  create mode 100644 drivers/phy/phy-qoriq-usb2.c
>  create mode 100644 drivers/phy/phy-qoriq-usb2.h
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index b869b98..cc69299 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -434,4 +434,12 @@ config PHY_CYGNUS_PCIE
>  
>  source "drivers/phy/tegra/Kconfig"
>  
> +config PHY_QORIQ_USB2
> + tristate "QorIQ USB 2.0 PHY driver"
> + depends on ARCH_MXC || ARCH_LAYERSCAPE

It seems mxc platforms do not use this PHY.
Besides, if you are using ULPI phy, you need
to depend on ULPI bus.

Peter
> + depends on OF
> + select GENERIC_PHY
> + help
> +   Enable this to support the USB2.0 PHY on the QorIQ SoC.
> +
>  endmenu
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index 9c3e73c..044105a 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -53,5 +53,6 @@ obj-$(CONFIG_PHY_TUSB1210)  += phy-tusb1210.o
>  obj-$(CONFIG_PHY_BRCM_SATA)  += phy-brcm-sata.o
>  obj-$(CONFIG_PHY_PISTACHIO_USB)  += phy-pistachio-usb.o
>  obj-$(CONFIG_PHY_CYGNUS_PCIE)+= phy-bcm-cygnus-pcie.o
> +obj-$(CONFIG_PHY_QORIQ_USB2)+= phy-qoriq-usb2.o
>  
>  obj-$(CONFIG_ARCH_TEGRA) += tegra/
> diff --git a/drivers/phy/phy-qoriq-usb2.c b/drivers/phy/phy-qoriq-usb2.c
> new file mode 100644
> index 000..f74d255
> --- /dev/null
> +++ b/drivers/phy/phy-qoriq-usb2.c
> @@ -0,0 +1,228 @@
> +/*
> + * QorIQ SoC USB 2.0 PHY driver
> + *
> + * Copyright 2016 Freescale Semiconductor, Inc.
> + * Author: Rajesh Bhagat 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "phy-qoriq-usb2.h"
> +
> +static int qoriq_usb2_phy_init(struct phy *_phy)
> +{
> + struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
> + struct device *dev = ctx->dev;
> +
> + if (ctx->ulpi_phy) {
> + if (usb_phy_init(ctx->ulpi_phy)) {
> + dev_err(dev, "unable to init transceiver, probably 
> missing\n");
> + return -ENODEV;
> + }
> + }
> +
> + return 0;
> +}
> +
> +static int qoriq_usb2_phy_power_on(struct phy *_phy)
> +{
> + struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
> + u32 flags;
> +
> + if (ctx->ulpi_phy) {
> + flags = usb_phy_io_read(ctx->ulpi_phy, ULPI_OTG_CTRL);
> + usb_phy_io_write(ctx->ulpi_phy, flags |
> +  (ULPI_OTG_CTRL_DRVVBUS_EXT |
> +  ULPI_OTG_CTRL_EXTVBUSIND), ULPI_OTG_CTRL);
> + flags = usb_phy_io_read(ctx->ulpi_phy, ULPI_IFC_CTRL);
> + usb_phy_io_write(ctx->ulpi_phy, flags |
> +  (ULPI_IFC_CTRL_EXTERNAL_VBUS |
> +  ULPI_IFC_CTRL_PASSTHRU), ULPI_IFC_CTRL);
> + }
> +
> + return 0;
> +}
> +
> +static int qoriq_usb2_phy_power_off(struct phy *_phy)
> +{
> + /* TODO: Add logic to power off phy */
> +
> + return 0;
> +}
> +
> +static int qoriq_usb2_phy_exit(struct phy *_phy)
> +{
> + struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
> +
> + if (ctx->ulpi_phy)
> + usb_phy_shutdown(ctx->ulpi_phy);
> +
> + return 0;
> +}
> +
> +static const struct phy_ops ops = {
> + .init   = qoriq_usb2_phy_init,
> + .power_on   = qoriq_usb2_phy_power_on,
> + .power_off  = qoriq_usb2_phy_power_off,
> + .exit   = qoriq_usb2_phy_exit,
> + .owner  = THIS_MODULE,
> +};
> +
> +
> +static enum qoriq_usb2_phy_ver of_usb_get_phy_version(struct device_node *np)
> +{
> + enum qoriq_usb2_phy_ver phy_version = QORIQ_PHY_UNKNOWN;
> +
> + if (of_device_is_compatible(np, "fsl,qoriq-usb2-phy")) {
> + if (of_device_is_compatible(np, "fsl,qoriq-usb2-phy-v1.0"))
> + phy_version = 

Re: [PATCH v2 3/5] drivers: usb: phy: Add qoriq usb 2.0 phy driver support

2016-07-11 Thread Peter Chen
On Sat, Jul 09, 2016 at 10:00:54AM +0530, Rajesh Bhagat wrote:
> Adds qoriq usb 2.0 phy driver support for LS1021A and LS1012A
> platform.
> 
> Signed-off-by: Rajesh Bhagat 
> ---
> Changes in v2:
>  - Replaced Freescale with QorIQ in comments section
>  - Changed the compatible string to fsl,qoriq-usb2-phy and added version
>  - Added dependency on ARCH_MXC/ARCH_LAYERSCAPE and OF in Kconfig
>  - Dropped CONFIG_ULPI #ifdefs to make code generic
>  - Removed calls to devm free/release calls
> 
>  drivers/phy/Kconfig  |   8 ++
>  drivers/phy/Makefile |   1 +
>  drivers/phy/phy-qoriq-usb2.c | 228 
> +++
>  drivers/phy/phy-qoriq-usb2.h |  50 ++
>  4 files changed, 287 insertions(+)
>  create mode 100644 drivers/phy/phy-qoriq-usb2.c
>  create mode 100644 drivers/phy/phy-qoriq-usb2.h
> 
> diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
> index b869b98..cc69299 100644
> --- a/drivers/phy/Kconfig
> +++ b/drivers/phy/Kconfig
> @@ -434,4 +434,12 @@ config PHY_CYGNUS_PCIE
>  
>  source "drivers/phy/tegra/Kconfig"
>  
> +config PHY_QORIQ_USB2
> + tristate "QorIQ USB 2.0 PHY driver"
> + depends on ARCH_MXC || ARCH_LAYERSCAPE

It seems mxc platforms do not use this PHY.
Besides, if you are using ULPI phy, you need
to depend on ULPI bus.

Peter
> + depends on OF
> + select GENERIC_PHY
> + help
> +   Enable this to support the USB2.0 PHY on the QorIQ SoC.
> +
>  endmenu
> diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
> index 9c3e73c..044105a 100644
> --- a/drivers/phy/Makefile
> +++ b/drivers/phy/Makefile
> @@ -53,5 +53,6 @@ obj-$(CONFIG_PHY_TUSB1210)  += phy-tusb1210.o
>  obj-$(CONFIG_PHY_BRCM_SATA)  += phy-brcm-sata.o
>  obj-$(CONFIG_PHY_PISTACHIO_USB)  += phy-pistachio-usb.o
>  obj-$(CONFIG_PHY_CYGNUS_PCIE)+= phy-bcm-cygnus-pcie.o
> +obj-$(CONFIG_PHY_QORIQ_USB2)+= phy-qoriq-usb2.o
>  
>  obj-$(CONFIG_ARCH_TEGRA) += tegra/
> diff --git a/drivers/phy/phy-qoriq-usb2.c b/drivers/phy/phy-qoriq-usb2.c
> new file mode 100644
> index 000..f74d255
> --- /dev/null
> +++ b/drivers/phy/phy-qoriq-usb2.c
> @@ -0,0 +1,228 @@
> +/*
> + * QorIQ SoC USB 2.0 PHY driver
> + *
> + * Copyright 2016 Freescale Semiconductor, Inc.
> + * Author: Rajesh Bhagat 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "phy-qoriq-usb2.h"
> +
> +static int qoriq_usb2_phy_init(struct phy *_phy)
> +{
> + struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
> + struct device *dev = ctx->dev;
> +
> + if (ctx->ulpi_phy) {
> + if (usb_phy_init(ctx->ulpi_phy)) {
> + dev_err(dev, "unable to init transceiver, probably 
> missing\n");
> + return -ENODEV;
> + }
> + }
> +
> + return 0;
> +}
> +
> +static int qoriq_usb2_phy_power_on(struct phy *_phy)
> +{
> + struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
> + u32 flags;
> +
> + if (ctx->ulpi_phy) {
> + flags = usb_phy_io_read(ctx->ulpi_phy, ULPI_OTG_CTRL);
> + usb_phy_io_write(ctx->ulpi_phy, flags |
> +  (ULPI_OTG_CTRL_DRVVBUS_EXT |
> +  ULPI_OTG_CTRL_EXTVBUSIND), ULPI_OTG_CTRL);
> + flags = usb_phy_io_read(ctx->ulpi_phy, ULPI_IFC_CTRL);
> + usb_phy_io_write(ctx->ulpi_phy, flags |
> +  (ULPI_IFC_CTRL_EXTERNAL_VBUS |
> +  ULPI_IFC_CTRL_PASSTHRU), ULPI_IFC_CTRL);
> + }
> +
> + return 0;
> +}
> +
> +static int qoriq_usb2_phy_power_off(struct phy *_phy)
> +{
> + /* TODO: Add logic to power off phy */
> +
> + return 0;
> +}
> +
> +static int qoriq_usb2_phy_exit(struct phy *_phy)
> +{
> + struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
> +
> + if (ctx->ulpi_phy)
> + usb_phy_shutdown(ctx->ulpi_phy);
> +
> + return 0;
> +}
> +
> +static const struct phy_ops ops = {
> + .init   = qoriq_usb2_phy_init,
> + .power_on   = qoriq_usb2_phy_power_on,
> + .power_off  = qoriq_usb2_phy_power_off,
> + .exit   = qoriq_usb2_phy_exit,
> + .owner  = THIS_MODULE,
> +};
> +
> +
> +static enum qoriq_usb2_phy_ver of_usb_get_phy_version(struct device_node *np)
> +{
> + enum qoriq_usb2_phy_ver phy_version = QORIQ_PHY_UNKNOWN;
> +
> + if (of_device_is_compatible(np, "fsl,qoriq-usb2-phy")) {
> + if (of_device_is_compatible(np, "fsl,qoriq-usb2-phy-v1.0"))
> + phy_version = QORIQ_PHY_LEGACY;
> + else if