Re: [RFC PATCH 2/2] usb: phy: Add platform driver support for ULPI PHYs

2015-09-24 Thread Peter Chen
On Thu, Sep 24, 2015 at 09:21:16AM +, Subbaraya Sundeep Bhatta wrote:
> > > +uphy->flags);
> > > +
> > > + uphy->usb_phy->set_vbus = usbphy_set_vbus;
> > 
> > When you will call it?
> 
> I am calling it in host.c and otg_fsm.c of Chipidea driver wherever
> regulator_enable/disable is called to control VBUS like below: 
> 
> if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL) {
> if (enable)
> ci->usb_phy->set_vbus(ci->usb_phy, 1);
> else
> ci->usb_phy->set_vbus(ci->usb_phy, 0);
> }
> 
> After these changes host mode and otg modes works fine
> for my case.
> 

Get it, there are several vbus control ways, I may need to consolidate
them, of cos, this is another topic.

-- 

Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [RFC PATCH 2/2] usb: phy: Add platform driver support for ULPI PHYs

2015-09-24 Thread Subbaraya Sundeep Bhatta
Hi Peter,

> -Original Message-
> From: Peter Chen [mailto:peter.c...@freescale.com]
> Sent: Thursday, September 24, 2015 2:37 PM
> To: Subbaraya Sundeep Bhatta
> Cc: ba...@ti.com; devicet...@vger.kernel.org; kis...@ti.com;
> gre...@linuxfoundation.org; linux-usb@vger.kernel.org; linux-
> ker...@vger.kernel.org; Punnaiah Choudary Kalluri; Subbaraya Sundeep Bhatta
> Subject: Re: [RFC PATCH 2/2] usb: phy: Add platform driver support for ULPI
> PHYs
> 
> On Wed, Sep 23, 2015 at 06:24:33PM +0530, Subbaraya Sundeep Bhatta
> wrote:
> > Based on board design USB controller needs explicit software access to
> > ULPI PHY for controlling VBUS. This patch adds platform driver support
> > for generic ULPI PHYs and provides a USB2 PHY device to controllers.
> >
> > Signed-off-by: Subbaraya Sundeep Bhatta <sbha...@xilinx.com>
> > ---
> >  drivers/usb/phy/Kconfig |   12 +++
> >  drivers/usb/phy/Makefile|1 +
> >  drivers/usb/phy/phy-platform-ulpi.c |  143
> > +++
> >  3 files changed, 156 insertions(+), 0 deletions(-)  create mode
> > 100644 drivers/usb/phy/phy-platform-ulpi.c
> >
> > diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index
> > 7d3beee..2956ad4 100644
> > --- a/drivers/usb/phy/Kconfig
> > +++ b/drivers/usb/phy/Kconfig
> > @@ -201,6 +201,18 @@ config USB_RCAR_PHY
> >   To compile this driver as a module, choose M here: the
> >   module will be called phy-rcar-usb.
> >
> > +config USB_PLATFORM_ULPI_PHY
> > +   tristate "Platform driver support for ULPI PHYs"
> > +   depends on ARCH_ZYNQ || COMPILE_TEST
> 
> If you want this as a common driver, drop platform dependency please.

Ok I will remove depends on.
> 
> > +   select USB_PHY
> > +   select USB_ULPI_VIEWPORT
> > +   help
> > + Say Y here to add support for the Platform driver for ULPI PHYs.
> > + This adds platform driver support for all generic ULPI PHYs and is
> > + typically used if usb controller driver needs explicit access to PHY.
> > +
> > + To compile this driver as a module, choose M here.
> > +
> >  config USB_ULPI
> > bool "Generic ULPI Transceiver Driver"
> > depends on ARM || ARM64
> > diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index
> > 19c0dcc..8431b6b 100644
> > --- a/drivers/usb/phy/Makefile
> > +++ b/drivers/usb/phy/Makefile
> > @@ -24,6 +24,7 @@ obj-$(CONFIG_USB_QCOM_8X16_PHY)   += phy-
> qcom-8x16-usb.o
> >  obj-$(CONFIG_USB_MV_OTG)   += phy-mv-usb.o
> >  obj-$(CONFIG_USB_MXS_PHY)  += phy-mxs-usb.o
> >  obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o
> > +obj-$(CONFIG_USB_PLATFORM_ULPI_PHY)+= phy-platform-ulpi.o
> >  obj-$(CONFIG_USB_ULPI) += phy-ulpi.o
> >  obj-$(CONFIG_USB_ULPI_VIEWPORT)+= phy-ulpi-viewport.o
> >  obj-$(CONFIG_KEYSTONE_USB_PHY) += phy-keystone.o
> > diff --git a/drivers/usb/phy/phy-platform-ulpi.c
> > b/drivers/usb/phy/phy-platform-ulpi.c
> > new file mode 100644
> > index 000..fb89363
> > --- /dev/null
> > +++ b/drivers/usb/phy/phy-platform-ulpi.c
> > @@ -0,0 +1,143 @@
> > +/*
> > + * Platform driver for generic ULPI PHYs.
> > + *
> > + * Copyright (C) 2015 Xilinx, Inc.
> > + *
> > + * Author: Subbaraya Sundeep <sbha...@xilinx.com>
> > + *
> > + * This program is free software; you can redistribute it
> > + * and/or modify it under the terms of the GNU General Public
> > + * License as published by the Free Software Foundation;
> > + * either version 2 of the License, or (at your option) any
> > + * later version.
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +/**
> > + * struct ulpi_phy - The ULPI PHY
> > + * @usb_phy: pointer to usb phy
> > + * @regs: base address of USB controller to which PHY is connected
> > + * @vp_offset: ulpi viewport register offset of USB controller
> > + * @flags: initial required settings of PHY  */
> > +
> > +struct ulpi_phy {
> > +   struct usb_phy  *usb_phy;
> > +   void __iomem *regs;
> > +   unsigned int vp_offset;
> > +   unsigned int flags;
> > +};
> > +
> > +/**
> > + * usbphy_set_vbus - Sets VBUS by writing to PHY.
> > + * @phy: pointer to PHY
> > + * @on: 1 - turn on VBUS
> > + * 0 - turn off VBUS
> > + * Return: 0 for success and error value on failure  

Re: [RFC PATCH 2/2] usb: phy: Add platform driver support for ULPI PHYs

2015-09-24 Thread Peter Chen
On Wed, Sep 23, 2015 at 06:24:33PM +0530, Subbaraya Sundeep Bhatta wrote:
> Based on board design USB controller needs explicit software
> access to ULPI PHY for controlling VBUS. This patch adds platform
> driver support for generic ULPI PHYs and provides a USB2 PHY device
> to controllers.
> 
> Signed-off-by: Subbaraya Sundeep Bhatta 
> ---
>  drivers/usb/phy/Kconfig |   12 +++
>  drivers/usb/phy/Makefile|1 +
>  drivers/usb/phy/phy-platform-ulpi.c |  143 
> +++
>  3 files changed, 156 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/usb/phy/phy-platform-ulpi.c
> 
> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> index 7d3beee..2956ad4 100644
> --- a/drivers/usb/phy/Kconfig
> +++ b/drivers/usb/phy/Kconfig
> @@ -201,6 +201,18 @@ config USB_RCAR_PHY
> To compile this driver as a module, choose M here: the
> module will be called phy-rcar-usb.
>  
> +config USB_PLATFORM_ULPI_PHY
> + tristate "Platform driver support for ULPI PHYs"
> + depends on ARCH_ZYNQ || COMPILE_TEST

If you want this as a common driver, drop platform dependency please.

> + select USB_PHY
> + select USB_ULPI_VIEWPORT
> + help
> +   Say Y here to add support for the Platform driver for ULPI PHYs.
> +   This adds platform driver support for all generic ULPI PHYs and is
> +   typically used if usb controller driver needs explicit access to PHY.
> +   
> +   To compile this driver as a module, choose M here.
> +
>  config USB_ULPI
>   bool "Generic ULPI Transceiver Driver"
>   depends on ARM || ARM64
> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> index 19c0dcc..8431b6b 100644
> --- a/drivers/usb/phy/Makefile
> +++ b/drivers/usb/phy/Makefile
> @@ -24,6 +24,7 @@ obj-$(CONFIG_USB_QCOM_8X16_PHY) += phy-qcom-8x16-usb.o
>  obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o
>  obj-$(CONFIG_USB_MXS_PHY)+= phy-mxs-usb.o
>  obj-$(CONFIG_USB_RCAR_PHY)   += phy-rcar-usb.o
> +obj-$(CONFIG_USB_PLATFORM_ULPI_PHY)  += phy-platform-ulpi.o
>  obj-$(CONFIG_USB_ULPI)   += phy-ulpi.o
>  obj-$(CONFIG_USB_ULPI_VIEWPORT)  += phy-ulpi-viewport.o
>  obj-$(CONFIG_KEYSTONE_USB_PHY)   += phy-keystone.o
> diff --git a/drivers/usb/phy/phy-platform-ulpi.c 
> b/drivers/usb/phy/phy-platform-ulpi.c
> new file mode 100644
> index 000..fb89363
> --- /dev/null
> +++ b/drivers/usb/phy/phy-platform-ulpi.c
> @@ -0,0 +1,143 @@
> +/*
> + * Platform driver for generic ULPI PHYs.
> + *
> + * Copyright (C) 2015 Xilinx, Inc.
> + *
> + * Author: Subbaraya Sundeep 
> + *
> + * This program is free software; you can redistribute it
> + * and/or modify it under the terms of the GNU General Public
> + * License as published by the Free Software Foundation;
> + * either version 2 of the License, or (at your option) any
> + * later version.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * struct ulpi_phy - The ULPI PHY
> + * @usb_phy: pointer to usb phy
> + * @regs: base address of USB controller to which PHY is connected
> + * @vp_offset: ulpi viewport register offset of USB controller
> + * @flags: initial required settings of PHY
> + */
> +
> +struct ulpi_phy {
> + struct usb_phy  *usb_phy;
> + void __iomem *regs;
> + unsigned int vp_offset;
> + unsigned int flags;
> +};
> +
> +/**
> + * usbphy_set_vbus - Sets VBUS by writing to PHY.
> + * @phy: pointer to PHY
> + * @on: 1 - turn on VBUS
> + *   0 - turn off VBUS
> + * Return: 0 for success and error value on failure
> + */
> +static int usbphy_set_vbus(struct usb_phy *phy, int on)
> +{
> + unsigned int flags = usb_phy_io_read(phy, ULPI_OTG_CTRL);
> +
> + flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
> +
> + if (on) {
> + if (phy->flags & ULPI_OTG_DRVVBUS)
> + flags |= ULPI_OTG_CTRL_DRVVBUS;
> +
> + if (phy->flags & ULPI_OTG_DRVVBUS_EXT)
> + flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
> + }
> +
> + return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL);
> +}
> +
> +/**
> + * ulpi_phy_probe - The device probe function for driver initialization.
> + * @pdev: pointer to the platform device structure.
> + *
> + * Return: 0 for success and error value on failure
> + */
> +static int ulpi_phy_probe(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct resource *res;
> + struct ulpi_phy *uphy;
> + bool flag;
> + int ret;
> +
> + uphy = devm_kzalloc(>dev, sizeof(*uphy), GFP_KERNEL);
> + if (!uphy)
> + return -ENOMEM;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + uphy->regs = devm_ioremap(>dev, res->start, resource_size(res));
> + if (IS_ERR(uphy->regs))
> + return PTR_ERR(uphy->regs);