Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-15 Thread Roger Quadros
On 10/15/2013 08:31 AM, Kishon Vijay Abraham I wrote:
 Hi Roger,
 
 On Monday 14 October 2013 03:51 PM, Roger Quadros wrote:
 +Vivek

 On 10/14/2013 12:26 PM, Kishon Vijay Abraham I wrote:
 Hi Roger,

 On Friday 11 October 2013 08:39 PM, Roger Quadros wrote:
 Hi,

 On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().

 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
  
  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
   depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
   depends on EXTCON
   select USB_PHY
 + select GENERIC_PHY
   select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
   help
 Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
  
   usb_phy_init(dwc-usb2_phy);
   usb_phy_init(dwc-usb3_phy);

 How about adding
 +  if (dwc-usb2_phy)
 +  usb_phy_init(dwc-usb2_phy);
 +  if (dwc-usb3_phy)
 +  usb_phy_init(dwc-usb3_phy);

 Thankfully that usb_phy_init will check if phy is NULL.

 both usb phy and generic phy shouldn't be present together.

 ok.

 +
 + if (dwc-usb2_generic_phy)
 + phy_init(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + phy_init(dwc-usb3_generic_phy);
 +
   mdelay(100);
  
   /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
   usb_phy_shutdown(dwc-usb2_phy);
   usb_phy_shutdown(dwc-usb3_phy);

 here as well

 +
 + if (dwc-usb2_generic_phy)
 + phy_power_off(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + phy_power_off(dwc-usb3_generic_phy);
  }
  
  #define DWC3_ALIGN_MASK  (16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
   dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
   }
  
 + if (of_property_read_bool(node, phys) || pdata-has_phy) {
 + dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 + if (IS_ERR(dwc-usb2_generic_phy)) {
 + dev_err(dev, no usb2 phy configured yet);
 + return PTR_ERR(dwc-usb2_generic_phy);
 + }
 +
 + dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 + if (IS_ERR(dwc-usb3_generic_phy)) {
 + dev_err(dev, no usb3 phy configured yet);
 + return PTR_ERR(dwc-usb3_generic_phy);
 + }

 better to add
 +  /* Don't use USB PHY if generic PHY was found */
 +  dwc-usb2_phy = dwc-usb3_phy = NULL;

 ok.

 + } else {

 not required as we've used kzalloc for dwc.

 + dwc-usb2_generic_phy = NULL;
 + dwc-usb3_generic_phy = NULL;
 + }
 +
   /* default to superspeed if no maximum_speed passed */
   if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
   dwc-maximum_speed = USB_SPEED_SUPER;
 @@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)

 if (dwc-usb2_phy)

   usb_phy_set_suspend(dwc-usb2_phy, 0);

 if (dwc-usb3_phy)

   usb_phy_set_suspend(dwc-usb3_phy, 0);
  
 + if (dwc-usb2_generic_phy)
 + phy_power_on(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-15 Thread Felipe Balbi
On Tue, Oct 15, 2013 at 11:01:16AM +0530, Kishon Vijay Abraham I wrote:
 Hi Roger,
 
 On Monday 14 October 2013 03:51 PM, Roger Quadros wrote:
  +Vivek
  
  On 10/14/2013 12:26 PM, Kishon Vijay Abraham I wrote:
  Hi Roger,
 
  On Friday 11 October 2013 08:39 PM, Roger Quadros wrote:
  Hi,
 
  On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
  Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
  power_on and power_off the following APIs are used phy_init(), 
  phy_exit(),
  phy_power_on() and phy_power_off().
 
  However using the old USB phy library wont be removed till the PHYs of 
  all
  other SoC's using dwc3 core is adapted to the Generic PHY Framework.
 
  Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
  ---
   Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
   drivers/usb/dwc3/Kconfig   |1 +
   drivers/usb/dwc3/core.c|   49 
  
   drivers/usb/dwc3/core.h|7 
   4 files changed, 61 insertions(+), 2 deletions(-)
 
  diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
  b/Documentation/devicetree/bindings/usb/dwc3.txt
  index e807635..471366d 100644
  --- a/Documentation/devicetree/bindings/usb/dwc3.txt
  +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
  @@ -6,11 +6,13 @@ Required properties:
- compatible: must be snps,dwc3
- reg : Address and length of the register set for the device
- interrupts: Interrupts used by the dwc3 controller.
  +
  +Optional properties:
- usb-phy : array of phandle for the PHY device.  The first element
  in the array is expected to be a handle to the USB2/HS PHY and
  the second element is expected to be a handle to the USB3/SS PHY
  -
  -Optional properties:
  + - phys: from the *Generic PHY* bindings
  + - phy-names: from the *Generic PHY* bindings
- tx-fifo-resize: determines if the FIFO *has* to be reallocated.
   
   This is usually a subnode to DWC3 glue to which it is connected.
  diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
  index cfc16dd..ad7ce83 100644
  --- a/drivers/usb/dwc3/Kconfig
  +++ b/drivers/usb/dwc3/Kconfig
  @@ -3,6 +3,7 @@ config USB_DWC3
   depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
   depends on EXTCON
   select USB_PHY
  +select GENERIC_PHY
   select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
   help
 Say Y or M here if your system has a Dual Role SuperSpeed
  diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
  index 428c29e..485d365 100644
  --- a/drivers/usb/dwc3/core.c
  +++ b/drivers/usb/dwc3/core.c
  @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
   
   usb_phy_init(dwc-usb2_phy);
   usb_phy_init(dwc-usb3_phy);
 
  How about adding
  + if (dwc-usb2_phy)
  + usb_phy_init(dwc-usb2_phy);
  + if (dwc-usb3_phy)
  + usb_phy_init(dwc-usb3_phy);
 
  Thankfully that usb_phy_init will check if phy is NULL.
 
  both usb phy and generic phy shouldn't be present together.
 
  ok.
 
  +
  +if (dwc-usb2_generic_phy)
  +phy_init(dwc-usb2_generic_phy);
  +if (dwc-usb3_generic_phy)
  +phy_init(dwc-usb3_generic_phy);
  +
   mdelay(100);
   
   /* Clear USB3 PHY reset */
  @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
   {
   usb_phy_shutdown(dwc-usb2_phy);
   usb_phy_shutdown(dwc-usb3_phy);
 
  here as well
 
  +
  +if (dwc-usb2_generic_phy)
  +phy_power_off(dwc-usb2_generic_phy);
  +if (dwc-usb3_generic_phy)
  +phy_power_off(dwc-usb3_generic_phy);
   }
   
   #define DWC3_ALIGN_MASK (16 - 1)
  @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
   dwc-usb3_phy = devm_usb_get_phy(dev, 
  USB_PHY_TYPE_USB3);
   }
   
  +if (of_property_read_bool(node, phys) || pdata-has_phy) {
  +dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
  +if (IS_ERR(dwc-usb2_generic_phy)) {
  +dev_err(dev, no usb2 phy configured yet);
  +return PTR_ERR(dwc-usb2_generic_phy);
  +}
  +
  +dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
  +if (IS_ERR(dwc-usb3_generic_phy)) {
  +dev_err(dev, no usb3 phy configured yet);
  +return PTR_ERR(dwc-usb3_generic_phy);
  +}
 
  better to add
  + /* Don't use USB PHY if generic PHY was found */
  + dwc-usb2_phy = dwc-usb3_phy = NULL;
 
  ok.
 
  +} else {
 
  not required as we've used kzalloc for dwc.
 
  +dwc-usb2_generic_phy = NULL;
  +dwc-usb3_generic_phy = NULL;
  +}
  +
   /* default to superspeed if no maximum_speed passed */
 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-15 Thread Felipe Balbi
Hi,

On Mon, Oct 14, 2013 at 01:21:29PM +0300, Roger Quadros wrote:
 +Vivek
 
 On 10/14/2013 12:26 PM, Kishon Vijay Abraham I wrote:
  Hi Roger,
  
  On Friday 11 October 2013 08:39 PM, Roger Quadros wrote:
  Hi,
 
  On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
  Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
  power_on and power_off the following APIs are used phy_init(), phy_exit(),
  phy_power_on() and phy_power_off().
 
  However using the old USB phy library wont be removed till the PHYs of all
  other SoC's using dwc3 core is adapted to the Generic PHY Framework.
 
  Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
  ---
   Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
   drivers/usb/dwc3/Kconfig   |1 +
   drivers/usb/dwc3/core.c|   49 
  
   drivers/usb/dwc3/core.h|7 
   4 files changed, 61 insertions(+), 2 deletions(-)
 
  diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
  b/Documentation/devicetree/bindings/usb/dwc3.txt
  index e807635..471366d 100644
  --- a/Documentation/devicetree/bindings/usb/dwc3.txt
  +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
  @@ -6,11 +6,13 @@ Required properties:
- compatible: must be snps,dwc3
- reg : Address and length of the register set for the device
- interrupts: Interrupts used by the dwc3 controller.
  +
  +Optional properties:
- usb-phy : array of phandle for the PHY device.  The first element
  in the array is expected to be a handle to the USB2/HS PHY and
  the second element is expected to be a handle to the USB3/SS PHY
  -
  -Optional properties:
  + - phys: from the *Generic PHY* bindings
  + - phy-names: from the *Generic PHY* bindings
- tx-fifo-resize: determines if the FIFO *has* to be reallocated.
   
   This is usually a subnode to DWC3 glue to which it is connected.
  diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
  index cfc16dd..ad7ce83 100644
  --- a/drivers/usb/dwc3/Kconfig
  +++ b/drivers/usb/dwc3/Kconfig
  @@ -3,6 +3,7 @@ config USB_DWC3
depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
depends on EXTCON
select USB_PHY
  + select GENERIC_PHY
select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
help
  Say Y or M here if your system has a Dual Role SuperSpeed
  diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
  index 428c29e..485d365 100644
  --- a/drivers/usb/dwc3/core.c
  +++ b/drivers/usb/dwc3/core.c
  @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
   
usb_phy_init(dwc-usb2_phy);
usb_phy_init(dwc-usb3_phy);
 
  How about adding
  +  if (dwc-usb2_phy)
  +  usb_phy_init(dwc-usb2_phy);
  +  if (dwc-usb3_phy)
  +  usb_phy_init(dwc-usb3_phy);
  
  Thankfully that usb_phy_init will check if phy is NULL.
 
  both usb phy and generic phy shouldn't be present together.
  
  ok.
 
  +
  + if (dwc-usb2_generic_phy)
  + phy_init(dwc-usb2_generic_phy);
  + if (dwc-usb3_generic_phy)
  + phy_init(dwc-usb3_generic_phy);
  +
mdelay(100);
   
/* Clear USB3 PHY reset */
  @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
   {
usb_phy_shutdown(dwc-usb2_phy);
usb_phy_shutdown(dwc-usb3_phy);
 
  here as well
 
  +
  + if (dwc-usb2_generic_phy)
  + phy_power_off(dwc-usb2_generic_phy);
  + if (dwc-usb3_generic_phy)
  + phy_power_off(dwc-usb3_generic_phy);
   }
   
   #define DWC3_ALIGN_MASK  (16 - 1)
  @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
}
   
  + if (of_property_read_bool(node, phys) || pdata-has_phy) {
  + dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
  + if (IS_ERR(dwc-usb2_generic_phy)) {
  + dev_err(dev, no usb2 phy configured yet);
  + return PTR_ERR(dwc-usb2_generic_phy);
  + }
  +
  + dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
  + if (IS_ERR(dwc-usb3_generic_phy)) {
  + dev_err(dev, no usb3 phy configured yet);
  + return PTR_ERR(dwc-usb3_generic_phy);
  + }
 
  better to add
  +  /* Don't use USB PHY if generic PHY was found */
  +  dwc-usb2_phy = dwc-usb3_phy = NULL;
  
  ok.
 
  + } else {
 
  not required as we've used kzalloc for dwc.
 
  + dwc-usb2_generic_phy = NULL;
  + dwc-usb3_generic_phy = NULL;
  + }
  +
/* default to superspeed if no maximum_speed passed */
if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
dwc-maximum_speed = USB_SPEED_SUPER;
  @@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)
 
  if (dwc-usb2_phy)
 
usb_phy_set_suspend(dwc-usb2_phy, 0);
 
  if (dwc-usb3_phy)
 
usb_phy_set_suspend(dwc-usb3_phy, 0);
   
  + if (dwc-usb2_generic_phy)
  + 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-15 Thread Felipe Balbi
On Tue, Oct 15, 2013 at 10:57:16AM +0300, Roger Quadros wrote:
 On 10/15/2013 08:31 AM, Kishon Vijay Abraham I wrote:
  Hi Roger,
  
  On Monday 14 October 2013 03:51 PM, Roger Quadros wrote:
  +Vivek
 
  On 10/14/2013 12:26 PM, Kishon Vijay Abraham I wrote:
  Hi Roger,
 
  On Friday 11 October 2013 08:39 PM, Roger Quadros wrote:
  Hi,
 
  On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
  Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
  power_on and power_off the following APIs are used phy_init(), 
  phy_exit(),
  phy_power_on() and phy_power_off().
 
  However using the old USB phy library wont be removed till the PHYs of 
  all
  other SoC's using dwc3 core is adapted to the Generic PHY Framework.
 
  Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
  ---
   Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
   drivers/usb/dwc3/Kconfig   |1 +
   drivers/usb/dwc3/core.c|   49 
  
   drivers/usb/dwc3/core.h|7 
   4 files changed, 61 insertions(+), 2 deletions(-)
 
  diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
  b/Documentation/devicetree/bindings/usb/dwc3.txt
  index e807635..471366d 100644
  --- a/Documentation/devicetree/bindings/usb/dwc3.txt
  +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
  @@ -6,11 +6,13 @@ Required properties:
- compatible: must be snps,dwc3
- reg : Address and length of the register set for the device
- interrupts: Interrupts used by the dwc3 controller.
  +
  +Optional properties:
- usb-phy : array of phandle for the PHY device.  The first element
  in the array is expected to be a handle to the USB2/HS PHY and
  the second element is expected to be a handle to the USB3/SS PHY
  -
  -Optional properties:
  + - phys: from the *Generic PHY* bindings
  + - phy-names: from the *Generic PHY* bindings
- tx-fifo-resize: determines if the FIFO *has* to be reallocated.
   
   This is usually a subnode to DWC3 glue to which it is connected.
  diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
  index cfc16dd..ad7ce83 100644
  --- a/drivers/usb/dwc3/Kconfig
  +++ b/drivers/usb/dwc3/Kconfig
  @@ -3,6 +3,7 @@ config USB_DWC3
  depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
  depends on EXTCON
  select USB_PHY
  +   select GENERIC_PHY
  select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
  help
Say Y or M here if your system has a Dual Role SuperSpeed
  diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
  index 428c29e..485d365 100644
  --- a/drivers/usb/dwc3/core.c
  +++ b/drivers/usb/dwc3/core.c
  @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
   
  usb_phy_init(dwc-usb2_phy);
  usb_phy_init(dwc-usb3_phy);
 
  How about adding
  +if (dwc-usb2_phy)
  +usb_phy_init(dwc-usb2_phy);
  +if (dwc-usb3_phy)
  +usb_phy_init(dwc-usb3_phy);
 
  Thankfully that usb_phy_init will check if phy is NULL.
 
  both usb phy and generic phy shouldn't be present together.
 
  ok.
 
  +
  +   if (dwc-usb2_generic_phy)
  +   phy_init(dwc-usb2_generic_phy);
  +   if (dwc-usb3_generic_phy)
  +   phy_init(dwc-usb3_generic_phy);
  +
  mdelay(100);
   
  /* Clear USB3 PHY reset */
  @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
   {
  usb_phy_shutdown(dwc-usb2_phy);
  usb_phy_shutdown(dwc-usb3_phy);
 
  here as well
 
  +
  +   if (dwc-usb2_generic_phy)
  +   phy_power_off(dwc-usb2_generic_phy);
  +   if (dwc-usb3_generic_phy)
  +   phy_power_off(dwc-usb3_generic_phy);
   }
   
   #define DWC3_ALIGN_MASK(16 - 1)
  @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
  dwc-usb3_phy = devm_usb_get_phy(dev, 
  USB_PHY_TYPE_USB3);
  }
   
  +   if (of_property_read_bool(node, phys) || pdata-has_phy) {
  +   dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
  +   if (IS_ERR(dwc-usb2_generic_phy)) {
  +   dev_err(dev, no usb2 phy configured yet);
  +   return PTR_ERR(dwc-usb2_generic_phy);
  +   }
  +
  +   dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
  +   if (IS_ERR(dwc-usb3_generic_phy)) {
  +   dev_err(dev, no usb3 phy configured yet);
  +   return PTR_ERR(dwc-usb3_generic_phy);
  +   }
 
  better to add
  +/* Don't use USB PHY if generic PHY was found */
  +dwc-usb2_phy = dwc-usb3_phy = NULL;
 
  ok.
 
  +   } else {
 
  not required as we've used kzalloc for dwc.
 
  +   dwc-usb2_generic_phy = NULL;
  +   dwc-usb3_generic_phy = NULL;
  +   }
  +

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-15 Thread Roger Quadros
On 10/15/2013 02:57 PM, Felipe Balbi wrote:
 Hi,
 
 On Mon, Oct 14, 2013 at 01:21:29PM +0300, Roger Quadros wrote:
 +Vivek

 On 10/14/2013 12:26 PM, Kishon Vijay Abraham I wrote:
 Hi Roger,

 On Friday 11 October 2013 08:39 PM, Roger Quadros wrote:
 Hi,

 On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().

 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
  
  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
   depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
   depends on EXTCON
   select USB_PHY
 + select GENERIC_PHY
   select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
   help
 Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
  
   usb_phy_init(dwc-usb2_phy);
   usb_phy_init(dwc-usb3_phy);

 How about adding
 +  if (dwc-usb2_phy)
 +  usb_phy_init(dwc-usb2_phy);
 +  if (dwc-usb3_phy)
 +  usb_phy_init(dwc-usb3_phy);

 Thankfully that usb_phy_init will check if phy is NULL.

 both usb phy and generic phy shouldn't be present together.

 ok.

 +
 + if (dwc-usb2_generic_phy)
 + phy_init(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + phy_init(dwc-usb3_generic_phy);
 +
   mdelay(100);
  
   /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
   usb_phy_shutdown(dwc-usb2_phy);
   usb_phy_shutdown(dwc-usb3_phy);

 here as well

 +
 + if (dwc-usb2_generic_phy)
 + phy_power_off(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + phy_power_off(dwc-usb3_generic_phy);
  }
  
  #define DWC3_ALIGN_MASK  (16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
   dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
   }
  
 + if (of_property_read_bool(node, phys) || pdata-has_phy) {
 + dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 + if (IS_ERR(dwc-usb2_generic_phy)) {
 + dev_err(dev, no usb2 phy configured yet);
 + return PTR_ERR(dwc-usb2_generic_phy);
 + }
 +
 + dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 + if (IS_ERR(dwc-usb3_generic_phy)) {
 + dev_err(dev, no usb3 phy configured yet);
 + return PTR_ERR(dwc-usb3_generic_phy);
 + }

 better to add
 +  /* Don't use USB PHY if generic PHY was found */
 +  dwc-usb2_phy = dwc-usb3_phy = NULL;

 ok.

 + } else {

 not required as we've used kzalloc for dwc.

 + dwc-usb2_generic_phy = NULL;
 + dwc-usb3_generic_phy = NULL;
 + }
 +
   /* default to superspeed if no maximum_speed passed */
   if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
   dwc-maximum_speed = USB_SPEED_SUPER;
 @@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)

 if (dwc-usb2_phy)

   usb_phy_set_suspend(dwc-usb2_phy, 0);

 if (dwc-usb3_phy)

   usb_phy_set_suspend(dwc-usb3_phy, 0);
  
 + if (dwc-usb2_generic_phy)
 + phy_power_on(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-15 Thread Felipe Balbi
Hi,

On Tue, Oct 15, 2013 at 03:10:42PM +0300, Roger Quadros wrote:
  @@ -665,6 +669,9 @@ struct dwc3 {
  struct usb_phy  *usb2_phy;
  struct usb_phy  *usb3_phy;
   
  +   struct phy  *usb2_generic_phy;
  +   struct phy  *usb3_generic_phy;
  +
  void __iomem*regs;
  size_t  regs_size;
   
 
 
  Do you have any suggestions on how to get only individual PHYs? like only
  usb2phy or usb3phy?
 
  My earlier understanding was that both PHYs are needed only if .speed is 
  super-speed
  and only usb2phy is needed for high-speed. But as per Vivek's email it 
  seems
  Samsung's exynos5 SoC doesn't need usb2phy for super-speed.
 
  So to keeps things flexible, I can propose the following approach
  - if speed == 'high-speed' usb2phy must be present. usb3phy will be 
  ignored if supplied.
  - if speed == 'super-speed' usb3phy must be present and usb2phy is 
  optional but must be
  initialized if supplied.
  - if speed is not specified, we default to 'super-speed'.
 
  Felipe, does this address the issue you were facing with OMAP5?
  
  on OMAP5 we cannot skip USB3 PHY initialization. But then it becomes a
  question of supporting a test feature (in OMAP5 case it would be cool to
  force controller to lower speeds for testing) or coping with a broken
  DTS.
  
 
 I don't think we can protect ourselves from all possible broken
 configurations of DTS.
 I would vote for simplicity and maximum flexibility.
 
 So IMO we should just depend on DTS to provide the phys that are
 needed by the platform.
 In the driver we initialize whatever PHY is provided and don't
 complain if any or even all PHYs are missing.

considering that DTS is an ABI, I really think eventually we *will* have
broken DTBs burned into ROM and we will have to find ways to work with
those too. Same thing already happens today with ACPI tables.

 If this is not good enough then could you please suggest an
 alternative? Thanks.

The alternative would be to mandate nop xceiv for the missing PHY, but
that doesn't solve anything, really, as DTS authors might still forget
about the NOP xceiv and you can argue that forcing NOP xceiv would be a
SW configuration.

So, perhaps we go with the approach that all PHYs are optional, and
here's my original patch which makes USB3 PHY optional:

commit 979b84f96e4b7559b596b2933ae198aba267f260
Author: Felipe Balbi ba...@ti.com
Date:   Sun Jun 30 18:39:23 2013 +0300

usb: dwc3: core: make USB3 PHY optional

If we want a port to work at any speed lower
than Superspeed, it makes no sense to even
initialize/power up the USB3 transceiver,
provided it won't be used.

We can use the oportunity to save some power
and leave the superspeed transceiver powered
off.

There is at least one such case which is
Texas Instruments' AM437x which has one
of its USB3 ports without a matching USB3
PHY (that port is hardwired to work on USB2
only).

Signed-off-by: Felipe Balbi ba...@ti.com

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 74f9cf0..7a5ab93 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -387,16 +387,34 @@ static int dwc3_probe(struct platform_device *pdev)
if (node) {
dwc-maximum_speed = of_usb_get_maximum_speed(node);
 
-   dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 0);
-   dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 1);
+   switch (dwc-maximum_speed) {
+   case USB_SPEED_SUPER:
+   dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, 
usb-phy, 0);
+   dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, 
usb-phy, 1);
+   break;
+   case USB_SPEED_HIGH:
+   case USB_SPEED_FULL:
+   case USB_SPEED_LOW:
+   dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, 
usb-phy, 0);
+   break;
+   }
 
dwc-needs_fifo_resize = of_property_read_bool(node, 
tx-fifo-resize);
dwc-dr_mode = of_usb_get_dr_mode(node);
} else if (pdata) {
dwc-maximum_speed = pdata-maximum_speed;
 
-   dwc-usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
-   dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
+   switch (dwc-maximum_speed) {
+   case USB_SPEED_SUPER:
+   dwc-usb2_phy = devm_usb_get_phy(dev, 
USB_PHY_TYPE_USB2);
+   dwc-usb3_phy = devm_usb_get_phy(dev, 
USB_PHY_TYPE_USB3);
+   break;
+   case USB_SPEED_HIGH:
+   case USB_SPEED_FULL:
+   case USB_SPEED_LOW:
+   dwc-usb2_phy = devm_usb_get_phy(dev, 
USB_PHY_TYPE_USB2);
+   break;
+   }
 
 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-15 Thread Roger Quadros
On 10/15/2013 04:19 PM, Felipe Balbi wrote:
 Hi,
 
 On Tue, Oct 15, 2013 at 03:10:42PM +0300, Roger Quadros wrote:
 @@ -665,6 +669,9 @@ struct dwc3 {
 struct usb_phy  *usb2_phy;
 struct usb_phy  *usb3_phy;
  
 +   struct phy  *usb2_generic_phy;
 +   struct phy  *usb3_generic_phy;
 +
 void __iomem*regs;
 size_t  regs_size;
  


 Do you have any suggestions on how to get only individual PHYs? like only
 usb2phy or usb3phy?

 My earlier understanding was that both PHYs are needed only if .speed is 
 super-speed
 and only usb2phy is needed for high-speed. But as per Vivek's email it 
 seems
 Samsung's exynos5 SoC doesn't need usb2phy for super-speed.

 So to keeps things flexible, I can propose the following approach
 - if speed == 'high-speed' usb2phy must be present. usb3phy will be 
 ignored if supplied.
 - if speed == 'super-speed' usb3phy must be present and usb2phy is 
 optional but must be
 initialized if supplied.
 - if speed is not specified, we default to 'super-speed'.

 Felipe, does this address the issue you were facing with OMAP5?

 on OMAP5 we cannot skip USB3 PHY initialization. But then it becomes a
 question of supporting a test feature (in OMAP5 case it would be cool to
 force controller to lower speeds for testing) or coping with a broken
 DTS.


 I don't think we can protect ourselves from all possible broken
 configurations of DTS.
 I would vote for simplicity and maximum flexibility.

 So IMO we should just depend on DTS to provide the phys that are
 needed by the platform.
 In the driver we initialize whatever PHY is provided and don't
 complain if any or even all PHYs are missing.
 
 considering that DTS is an ABI, I really think eventually we *will* have
 broken DTBs burned into ROM and we will have to find ways to work with
 those too. Same thing already happens today with ACPI tables.
 
 If this is not good enough then could you please suggest an
 alternative? Thanks.
 
 The alternative would be to mandate nop xceiv for the missing PHY, but
 that doesn't solve anything, really, as DTS authors might still forget
 about the NOP xceiv and you can argue that forcing NOP xceiv would be a
 SW configuration.
 
 So, perhaps we go with the approach that all PHYs are optional, and
 here's my original patch which makes USB3 PHY optional:
 
 commit 979b84f96e4b7559b596b2933ae198aba267f260
 Author: Felipe Balbi ba...@ti.com
 Date:   Sun Jun 30 18:39:23 2013 +0300
 
 usb: dwc3: core: make USB3 PHY optional
 
 If we want a port to work at any speed lower
 than Superspeed, it makes no sense to even
 initialize/power up the USB3 transceiver,
 provided it won't be used.
 
 We can use the oportunity to save some power
 and leave the superspeed transceiver powered
 off.
 
 There is at least one such case which is
 Texas Instruments' AM437x which has one
 of its USB3 ports without a matching USB3
 PHY (that port is hardwired to work on USB2
 only).
 
 Signed-off-by: Felipe Balbi ba...@ti.com
 
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 74f9cf0..7a5ab93 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -387,16 +387,34 @@ static int dwc3_probe(struct platform_device *pdev)
   if (node) {
   dwc-maximum_speed = of_usb_get_maximum_speed(node);
  
 - dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 0);
 - dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 1);
 + switch (dwc-maximum_speed) {
 + case USB_SPEED_SUPER:
 + dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, 
 usb-phy, 0);
 + dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, 
 usb-phy, 1);
 + break;
 + case USB_SPEED_HIGH:
 + case USB_SPEED_FULL:
 + case USB_SPEED_LOW:
 + dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, 
 usb-phy, 0);
 + break;
 + }
  
   dwc-needs_fifo_resize = of_property_read_bool(node, 
 tx-fifo-resize);
   dwc-dr_mode = of_usb_get_dr_mode(node);
   } else if (pdata) {
   dwc-maximum_speed = pdata-maximum_speed;
  
 - dwc-usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 - dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
 + switch (dwc-maximum_speed) {
 + case USB_SPEED_SUPER:
 + dwc-usb2_phy = devm_usb_get_phy(dev, 
 USB_PHY_TYPE_USB2);
 + dwc-usb3_phy = devm_usb_get_phy(dev, 
 USB_PHY_TYPE_USB3);
 + break;
 + case USB_SPEED_HIGH:
 + case USB_SPEED_FULL:
 + case USB_SPEED_LOW:
 + dwc-usb2_phy = devm_usb_get_phy(dev, 
 USB_PHY_TYPE_USB2);
 + break;
 +   

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-15 Thread Felipe Balbi
Hi,

On Tue, Oct 15, 2013 at 04:48:51PM +0300, Roger Quadros wrote:
 On 10/15/2013 04:19 PM, Felipe Balbi wrote:
  Hi,
  
  On Tue, Oct 15, 2013 at 03:10:42PM +0300, Roger Quadros wrote:
  @@ -665,6 +669,9 @@ struct dwc3 {
struct usb_phy  *usb2_phy;
struct usb_phy  *usb3_phy;
   
  + struct phy  *usb2_generic_phy;
  + struct phy  *usb3_generic_phy;
  +
void __iomem*regs;
size_t  regs_size;
   
 
 
  Do you have any suggestions on how to get only individual PHYs? like 
  only
  usb2phy or usb3phy?
 
  My earlier understanding was that both PHYs are needed only if .speed is 
  super-speed
  and only usb2phy is needed for high-speed. But as per Vivek's email it 
  seems
  Samsung's exynos5 SoC doesn't need usb2phy for super-speed.
 
  So to keeps things flexible, I can propose the following approach
  - if speed == 'high-speed' usb2phy must be present. usb3phy will be 
  ignored if supplied.
  - if speed == 'super-speed' usb3phy must be present and usb2phy is 
  optional but must be
  initialized if supplied.
  - if speed is not specified, we default to 'super-speed'.
 
  Felipe, does this address the issue you were facing with OMAP5?
 
  on OMAP5 we cannot skip USB3 PHY initialization. But then it becomes a
  question of supporting a test feature (in OMAP5 case it would be cool to
  force controller to lower speeds for testing) or coping with a broken
  DTS.
 
 
  I don't think we can protect ourselves from all possible broken
  configurations of DTS.
  I would vote for simplicity and maximum flexibility.
 
  So IMO we should just depend on DTS to provide the phys that are
  needed by the platform.
  In the driver we initialize whatever PHY is provided and don't
  complain if any or even all PHYs are missing.
  
  considering that DTS is an ABI, I really think eventually we *will* have
  broken DTBs burned into ROM and we will have to find ways to work with
  those too. Same thing already happens today with ACPI tables.
  
  If this is not good enough then could you please suggest an
  alternative? Thanks.
  
  The alternative would be to mandate nop xceiv for the missing PHY, but
  that doesn't solve anything, really, as DTS authors might still forget
  about the NOP xceiv and you can argue that forcing NOP xceiv would be a
  SW configuration.
  
  So, perhaps we go with the approach that all PHYs are optional, and
  here's my original patch which makes USB3 PHY optional:
  
  commit 979b84f96e4b7559b596b2933ae198aba267f260
  Author: Felipe Balbi ba...@ti.com
  Date:   Sun Jun 30 18:39:23 2013 +0300
  
  usb: dwc3: core: make USB3 PHY optional
  
  If we want a port to work at any speed lower
  than Superspeed, it makes no sense to even
  initialize/power up the USB3 transceiver,
  provided it won't be used.
  
  We can use the oportunity to save some power
  and leave the superspeed transceiver powered
  off.
  
  There is at least one such case which is
  Texas Instruments' AM437x which has one
  of its USB3 ports without a matching USB3
  PHY (that port is hardwired to work on USB2
  only).
  
  Signed-off-by: Felipe Balbi ba...@ti.com
  
  diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
  index 74f9cf0..7a5ab93 100644
  --- a/drivers/usb/dwc3/core.c
  +++ b/drivers/usb/dwc3/core.c
  @@ -387,16 +387,34 @@ static int dwc3_probe(struct platform_device *pdev)
  if (node) {
  dwc-maximum_speed = of_usb_get_maximum_speed(node);
   
  -   dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 0);
  -   dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 1);
  +   switch (dwc-maximum_speed) {
  +   case USB_SPEED_SUPER:
  +   dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, 
  usb-phy, 0);
  +   dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, 
  usb-phy, 1);
  +   break;
  +   case USB_SPEED_HIGH:
  +   case USB_SPEED_FULL:
  +   case USB_SPEED_LOW:
  +   dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, 
  usb-phy, 0);
  +   break;
  +   }
   
  dwc-needs_fifo_resize = of_property_read_bool(node, 
  tx-fifo-resize);
  dwc-dr_mode = of_usb_get_dr_mode(node);
  } else if (pdata) {
  dwc-maximum_speed = pdata-maximum_speed;
   
  -   dwc-usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
  -   dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
  +   switch (dwc-maximum_speed) {
  +   case USB_SPEED_SUPER:
  +   dwc-usb2_phy = devm_usb_get_phy(dev, 
  USB_PHY_TYPE_USB2);
  +   dwc-usb3_phy = devm_usb_get_phy(dev, 
  USB_PHY_TYPE_USB3);
  +   break;
  +   case USB_SPEED_HIGH:
  +   case USB_SPEED_FULL:
  +   case 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-15 Thread Roger Quadros
On 10/15/2013 04:56 PM, Felipe Balbi wrote:
 Hi,
 
 On Tue, Oct 15, 2013 at 04:48:51PM +0300, Roger Quadros wrote:
 On 10/15/2013 04:19 PM, Felipe Balbi wrote:
 Hi,

 On Tue, Oct 15, 2013 at 03:10:42PM +0300, Roger Quadros wrote:
 @@ -665,6 +669,9 @@ struct dwc3 {
   struct usb_phy  *usb2_phy;
   struct usb_phy  *usb3_phy;
  
 + struct phy  *usb2_generic_phy;
 + struct phy  *usb3_generic_phy;
 +
   void __iomem*regs;
   size_t  regs_size;
  


 Do you have any suggestions on how to get only individual PHYs? like 
 only
 usb2phy or usb3phy?

 My earlier understanding was that both PHYs are needed only if .speed is 
 super-speed
 and only usb2phy is needed for high-speed. But as per Vivek's email it 
 seems
 Samsung's exynos5 SoC doesn't need usb2phy for super-speed.

 So to keeps things flexible, I can propose the following approach
 - if speed == 'high-speed' usb2phy must be present. usb3phy will be 
 ignored if supplied.
 - if speed == 'super-speed' usb3phy must be present and usb2phy is 
 optional but must be
 initialized if supplied.
 - if speed is not specified, we default to 'super-speed'.

 Felipe, does this address the issue you were facing with OMAP5?

 on OMAP5 we cannot skip USB3 PHY initialization. But then it becomes a
 question of supporting a test feature (in OMAP5 case it would be cool to
 force controller to lower speeds for testing) or coping with a broken
 DTS.


 I don't think we can protect ourselves from all possible broken
 configurations of DTS.
 I would vote for simplicity and maximum flexibility.

 So IMO we should just depend on DTS to provide the phys that are
 needed by the platform.
 In the driver we initialize whatever PHY is provided and don't
 complain if any or even all PHYs are missing.

 considering that DTS is an ABI, I really think eventually we *will* have
 broken DTBs burned into ROM and we will have to find ways to work with
 those too. Same thing already happens today with ACPI tables.

 If this is not good enough then could you please suggest an
 alternative? Thanks.

 The alternative would be to mandate nop xceiv for the missing PHY, but
 that doesn't solve anything, really, as DTS authors might still forget
 about the NOP xceiv and you can argue that forcing NOP xceiv would be a
 SW configuration.

 So, perhaps we go with the approach that all PHYs are optional, and
 here's my original patch which makes USB3 PHY optional:

 commit 979b84f96e4b7559b596b2933ae198aba267f260
 Author: Felipe Balbi ba...@ti.com
 Date:   Sun Jun 30 18:39:23 2013 +0300

 usb: dwc3: core: make USB3 PHY optional
 
 If we want a port to work at any speed lower
 than Superspeed, it makes no sense to even
 initialize/power up the USB3 transceiver,
 provided it won't be used.
 
 We can use the oportunity to save some power
 and leave the superspeed transceiver powered
 off.
 
 There is at least one such case which is
 Texas Instruments' AM437x which has one
 of its USB3 ports without a matching USB3
 PHY (that port is hardwired to work on USB2
 only).
 
 Signed-off-by: Felipe Balbi ba...@ti.com

 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 74f9cf0..7a5ab93 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -387,16 +387,34 @@ static int dwc3_probe(struct platform_device *pdev)
 if (node) {
 dwc-maximum_speed = of_usb_get_maximum_speed(node);
  
 -   dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 0);
 -   dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 1);
 +   switch (dwc-maximum_speed) {
 +   case USB_SPEED_SUPER:
 +   dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, 
 usb-phy, 0);
 +   dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, 
 usb-phy, 1);
 +   break;
 +   case USB_SPEED_HIGH:
 +   case USB_SPEED_FULL:
 +   case USB_SPEED_LOW:
 +   dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, 
 usb-phy, 0);
 +   break;
 +   }
  
 dwc-needs_fifo_resize = of_property_read_bool(node, 
 tx-fifo-resize);
 dwc-dr_mode = of_usb_get_dr_mode(node);
 } else if (pdata) {
 dwc-maximum_speed = pdata-maximum_speed;
  
 -   dwc-usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 -   dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
 +   switch (dwc-maximum_speed) {
 +   case USB_SPEED_SUPER:
 +   dwc-usb2_phy = devm_usb_get_phy(dev, 
 USB_PHY_TYPE_USB2);
 +   dwc-usb3_phy = devm_usb_get_phy(dev, 
 USB_PHY_TYPE_USB3);
 +   break;
 +   case USB_SPEED_HIGH:
 +   case USB_SPEED_FULL:
 +   case USB_SPEED_LOW:
 +   dwc-usb2_phy = devm_usb_get_phy(dev, 
 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-15 Thread Felipe Balbi
On Tue, Oct 15, 2013 at 05:03:50PM +0300, Roger Quadros wrote:
 On 10/15/2013 04:56 PM, Felipe Balbi wrote:
  Hi,
  
  On Tue, Oct 15, 2013 at 04:48:51PM +0300, Roger Quadros wrote:
  On 10/15/2013 04:19 PM, Felipe Balbi wrote:
  Hi,
 
  On Tue, Oct 15, 2013 at 03:10:42PM +0300, Roger Quadros wrote:
  @@ -665,6 +669,9 @@ struct dwc3 {
  struct usb_phy  *usb2_phy;
  struct usb_phy  *usb3_phy;
   
  +   struct phy  *usb2_generic_phy;
  +   struct phy  *usb3_generic_phy;
  +
  void __iomem*regs;
  size_t  regs_size;
   
 
 
  Do you have any suggestions on how to get only individual PHYs? like 
  only
  usb2phy or usb3phy?
 
  My earlier understanding was that both PHYs are needed only if .speed 
  is super-speed
  and only usb2phy is needed for high-speed. But as per Vivek's email 
  it seems
  Samsung's exynos5 SoC doesn't need usb2phy for super-speed.
 
  So to keeps things flexible, I can propose the following approach
  - if speed == 'high-speed' usb2phy must be present. usb3phy will be 
  ignored if supplied.
  - if speed == 'super-speed' usb3phy must be present and usb2phy is 
  optional but must be
  initialized if supplied.
  - if speed is not specified, we default to 'super-speed'.
 
  Felipe, does this address the issue you were facing with OMAP5?
 
  on OMAP5 we cannot skip USB3 PHY initialization. But then it becomes a
  question of supporting a test feature (in OMAP5 case it would be cool to
  force controller to lower speeds for testing) or coping with a broken
  DTS.
 
 
  I don't think we can protect ourselves from all possible broken
  configurations of DTS.
  I would vote for simplicity and maximum flexibility.
 
  So IMO we should just depend on DTS to provide the phys that are
  needed by the platform.
  In the driver we initialize whatever PHY is provided and don't
  complain if any or even all PHYs are missing.
 
  considering that DTS is an ABI, I really think eventually we *will* have
  broken DTBs burned into ROM and we will have to find ways to work with
  those too. Same thing already happens today with ACPI tables.
 
  If this is not good enough then could you please suggest an
  alternative? Thanks.
 
  The alternative would be to mandate nop xceiv for the missing PHY, but
  that doesn't solve anything, really, as DTS authors might still forget
  about the NOP xceiv and you can argue that forcing NOP xceiv would be a
  SW configuration.
 
  So, perhaps we go with the approach that all PHYs are optional, and
  here's my original patch which makes USB3 PHY optional:
 
  commit 979b84f96e4b7559b596b2933ae198aba267f260
  Author: Felipe Balbi ba...@ti.com
  Date:   Sun Jun 30 18:39:23 2013 +0300
 
  usb: dwc3: core: make USB3 PHY optional
  
  If we want a port to work at any speed lower
  than Superspeed, it makes no sense to even
  initialize/power up the USB3 transceiver,
  provided it won't be used.
  
  We can use the oportunity to save some power
  and leave the superspeed transceiver powered
  off.
  
  There is at least one such case which is
  Texas Instruments' AM437x which has one
  of its USB3 ports without a matching USB3
  PHY (that port is hardwired to work on USB2
  only).
  
  Signed-off-by: Felipe Balbi ba...@ti.com
 
  diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
  index 74f9cf0..7a5ab93 100644
  --- a/drivers/usb/dwc3/core.c
  +++ b/drivers/usb/dwc3/core.c
  @@ -387,16 +387,34 @@ static int dwc3_probe(struct platform_device *pdev)
if (node) {
dwc-maximum_speed = of_usb_get_maximum_speed(node);
   
  - dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 0);
  - dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, usb-phy, 1);
  + switch (dwc-maximum_speed) {
  + case USB_SPEED_SUPER:
  + dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, 
  usb-phy, 0);
  + dwc-usb3_phy = devm_usb_get_phy_by_phandle(dev, 
  usb-phy, 1);
  + break;
  + case USB_SPEED_HIGH:
  + case USB_SPEED_FULL:
  + case USB_SPEED_LOW:
  + dwc-usb2_phy = devm_usb_get_phy_by_phandle(dev, 
  usb-phy, 0);
  + break;
  + }
   
dwc-needs_fifo_resize = of_property_read_bool(node, 
  tx-fifo-resize);
dwc-dr_mode = of_usb_get_dr_mode(node);
} else if (pdata) {
dwc-maximum_speed = pdata-maximum_speed;
   
  - dwc-usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
  - dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
  + switch (dwc-maximum_speed) {
  + case USB_SPEED_SUPER:
  + dwc-usb2_phy = devm_usb_get_phy(dev, 
  USB_PHY_TYPE_USB2);
  + dwc-usb3_phy = devm_usb_get_phy(dev, 
  USB_PHY_TYPE_USB3);
  + break;
  + case USB_SPEED_HIGH:
  + 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-14 Thread Kishon Vijay Abraham I
Hi Roger,

On Friday 11 October 2013 08:39 PM, Roger Quadros wrote:
 Hi,
 
 On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().

 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
  
  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
  depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
  depends on EXTCON
  select USB_PHY
 +select GENERIC_PHY
  select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
  help
Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
  
  usb_phy_init(dwc-usb2_phy);
  usb_phy_init(dwc-usb3_phy);
 
 How about adding
 + if (dwc-usb2_phy)
 + usb_phy_init(dwc-usb2_phy);
 + if (dwc-usb3_phy)
 + usb_phy_init(dwc-usb3_phy);

Thankfully that usb_phy_init will check if phy is NULL.
 
 both usb phy and generic phy shouldn't be present together.

ok.
 
 +
 +if (dwc-usb2_generic_phy)
 +phy_init(dwc-usb2_generic_phy);
 +if (dwc-usb3_generic_phy)
 +phy_init(dwc-usb3_generic_phy);
 +
  mdelay(100);
  
  /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
  usb_phy_shutdown(dwc-usb2_phy);
  usb_phy_shutdown(dwc-usb3_phy);
 
 here as well
 
 +
 +if (dwc-usb2_generic_phy)
 +phy_power_off(dwc-usb2_generic_phy);
 +if (dwc-usb3_generic_phy)
 +phy_power_off(dwc-usb3_generic_phy);
  }
  
  #define DWC3_ALIGN_MASK (16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
  dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
  }
  
 +if (of_property_read_bool(node, phys) || pdata-has_phy) {
 +dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 +if (IS_ERR(dwc-usb2_generic_phy)) {
 +dev_err(dev, no usb2 phy configured yet);
 +return PTR_ERR(dwc-usb2_generic_phy);
 +}
 +
 +dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 +if (IS_ERR(dwc-usb3_generic_phy)) {
 +dev_err(dev, no usb3 phy configured yet);
 +return PTR_ERR(dwc-usb3_generic_phy);
 +}
 
 better to add
 + /* Don't use USB PHY if generic PHY was found */
 + dwc-usb2_phy = dwc-usb3_phy = NULL;

ok.
 
 +} else {
 
 not required as we've used kzalloc for dwc.
 
 +dwc-usb2_generic_phy = NULL;
 +dwc-usb3_generic_phy = NULL;
 +}
 +
  /* default to superspeed if no maximum_speed passed */
  if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
  dwc-maximum_speed = USB_SPEED_SUPER;
 @@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)
 
 if (dwc-usb2_phy)
 
  usb_phy_set_suspend(dwc-usb2_phy, 0);
 
 if (dwc-usb3_phy)
 
  usb_phy_set_suspend(dwc-usb3_phy, 0);
  
 +if (dwc-usb2_generic_phy)
 +phy_power_on(dwc-usb2_generic_phy);
 +if (dwc-usb3_generic_phy)
 +phy_power_on(dwc-usb3_generic_phy);

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-14 Thread Roger Quadros
+Vivek

On 10/14/2013 12:26 PM, Kishon Vijay Abraham I wrote:
 Hi Roger,
 
 On Friday 11 October 2013 08:39 PM, Roger Quadros wrote:
 Hi,

 On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().

 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
  
  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
 depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
 depends on EXTCON
 select USB_PHY
 +   select GENERIC_PHY
 select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
 help
   Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
  
 usb_phy_init(dwc-usb2_phy);
 usb_phy_init(dwc-usb3_phy);

 How about adding
 +if (dwc-usb2_phy)
 +usb_phy_init(dwc-usb2_phy);
 +if (dwc-usb3_phy)
 +usb_phy_init(dwc-usb3_phy);
 
 Thankfully that usb_phy_init will check if phy is NULL.

 both usb phy and generic phy shouldn't be present together.
 
 ok.

 +
 +   if (dwc-usb2_generic_phy)
 +   phy_init(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   phy_init(dwc-usb3_generic_phy);
 +
 mdelay(100);
  
 /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
 usb_phy_shutdown(dwc-usb2_phy);
 usb_phy_shutdown(dwc-usb3_phy);

 here as well

 +
 +   if (dwc-usb2_generic_phy)
 +   phy_power_off(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   phy_power_off(dwc-usb3_generic_phy);
  }
  
  #define DWC3_ALIGN_MASK(16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
 dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
 }
  
 +   if (of_property_read_bool(node, phys) || pdata-has_phy) {
 +   dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 +   if (IS_ERR(dwc-usb2_generic_phy)) {
 +   dev_err(dev, no usb2 phy configured yet);
 +   return PTR_ERR(dwc-usb2_generic_phy);
 +   }
 +
 +   dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 +   if (IS_ERR(dwc-usb3_generic_phy)) {
 +   dev_err(dev, no usb3 phy configured yet);
 +   return PTR_ERR(dwc-usb3_generic_phy);
 +   }

 better to add
 +/* Don't use USB PHY if generic PHY was found */
 +dwc-usb2_phy = dwc-usb3_phy = NULL;
 
 ok.

 +   } else {

 not required as we've used kzalloc for dwc.

 +   dwc-usb2_generic_phy = NULL;
 +   dwc-usb3_generic_phy = NULL;
 +   }
 +
 /* default to superspeed if no maximum_speed passed */
 if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
 dwc-maximum_speed = USB_SPEED_SUPER;
 @@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)

 if (dwc-usb2_phy)

 usb_phy_set_suspend(dwc-usb2_phy, 0);

 if (dwc-usb3_phy)

 usb_phy_set_suspend(dwc-usb3_phy, 0);
  
 +   if (dwc-usb2_generic_phy)
 +   phy_power_on(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-14 Thread Kishon Vijay Abraham I
Hi Roger,

On Monday 14 October 2013 03:51 PM, Roger Quadros wrote:
 +Vivek
 
 On 10/14/2013 12:26 PM, Kishon Vijay Abraham I wrote:
 Hi Roger,

 On Friday 11 October 2013 08:39 PM, Roger Quadros wrote:
 Hi,

 On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().

 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
  
  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
depends on EXTCON
select USB_PHY
 +  select GENERIC_PHY
select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
help
  Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
  
usb_phy_init(dwc-usb2_phy);
usb_phy_init(dwc-usb3_phy);

 How about adding
 +   if (dwc-usb2_phy)
 +   usb_phy_init(dwc-usb2_phy);
 +   if (dwc-usb3_phy)
 +   usb_phy_init(dwc-usb3_phy);

 Thankfully that usb_phy_init will check if phy is NULL.

 both usb phy and generic phy shouldn't be present together.

 ok.

 +
 +  if (dwc-usb2_generic_phy)
 +  phy_init(dwc-usb2_generic_phy);
 +  if (dwc-usb3_generic_phy)
 +  phy_init(dwc-usb3_generic_phy);
 +
mdelay(100);
  
/* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
usb_phy_shutdown(dwc-usb2_phy);
usb_phy_shutdown(dwc-usb3_phy);

 here as well

 +
 +  if (dwc-usb2_generic_phy)
 +  phy_power_off(dwc-usb2_generic_phy);
 +  if (dwc-usb3_generic_phy)
 +  phy_power_off(dwc-usb3_generic_phy);
  }
  
  #define DWC3_ALIGN_MASK   (16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
}
  
 +  if (of_property_read_bool(node, phys) || pdata-has_phy) {
 +  dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 +  if (IS_ERR(dwc-usb2_generic_phy)) {
 +  dev_err(dev, no usb2 phy configured yet);
 +  return PTR_ERR(dwc-usb2_generic_phy);
 +  }
 +
 +  dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 +  if (IS_ERR(dwc-usb3_generic_phy)) {
 +  dev_err(dev, no usb3 phy configured yet);
 +  return PTR_ERR(dwc-usb3_generic_phy);
 +  }

 better to add
 +   /* Don't use USB PHY if generic PHY was found */
 +   dwc-usb2_phy = dwc-usb3_phy = NULL;

 ok.

 +  } else {

 not required as we've used kzalloc for dwc.

 +  dwc-usb2_generic_phy = NULL;
 +  dwc-usb3_generic_phy = NULL;
 +  }
 +
/* default to superspeed if no maximum_speed passed */
if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
dwc-maximum_speed = USB_SPEED_SUPER;
 @@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)

 if (dwc-usb2_phy)

usb_phy_set_suspend(dwc-usb2_phy, 0);

 if (dwc-usb3_phy)

usb_phy_set_suspend(dwc-usb3_phy, 0);
  
 +  if (dwc-usb2_generic_phy)
 +  phy_power_on(dwc-usb2_generic_phy);
 +  if (dwc-usb3_generic_phy)
 +  

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-11 Thread Roger Quadros
Hi,

On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().
 
 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
  
  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
   depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
   depends on EXTCON
   select USB_PHY
 + select GENERIC_PHY
   select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
   help
 Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
  
   usb_phy_init(dwc-usb2_phy);
   usb_phy_init(dwc-usb3_phy);

How about adding
+   if (dwc-usb2_phy)
+   usb_phy_init(dwc-usb2_phy);
+   if (dwc-usb3_phy)
+   usb_phy_init(dwc-usb3_phy);

both usb phy and generic phy shouldn't be present together.

 +
 + if (dwc-usb2_generic_phy)
 + phy_init(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + phy_init(dwc-usb3_generic_phy);
 +
   mdelay(100);
  
   /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
   usb_phy_shutdown(dwc-usb2_phy);
   usb_phy_shutdown(dwc-usb3_phy);

here as well

 +
 + if (dwc-usb2_generic_phy)
 + phy_power_off(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + phy_power_off(dwc-usb3_generic_phy);
  }
  
  #define DWC3_ALIGN_MASK  (16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
   dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
   }
  
 + if (of_property_read_bool(node, phys) || pdata-has_phy) {
 + dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 + if (IS_ERR(dwc-usb2_generic_phy)) {
 + dev_err(dev, no usb2 phy configured yet);
 + return PTR_ERR(dwc-usb2_generic_phy);
 + }
 +
 + dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 + if (IS_ERR(dwc-usb3_generic_phy)) {
 + dev_err(dev, no usb3 phy configured yet);
 + return PTR_ERR(dwc-usb3_generic_phy);
 + }

better to add
+   /* Don't use USB PHY if generic PHY was found */
+   dwc-usb2_phy = dwc-usb3_phy = NULL;

 + } else {

not required as we've used kzalloc for dwc.

 + dwc-usb2_generic_phy = NULL;
 + dwc-usb3_generic_phy = NULL;
 + }
 +
   /* default to superspeed if no maximum_speed passed */
   if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
   dwc-maximum_speed = USB_SPEED_SUPER;
 @@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)

if (dwc-usb2_phy)

   usb_phy_set_suspend(dwc-usb2_phy, 0);

if (dwc-usb3_phy)

   usb_phy_set_suspend(dwc-usb3_phy, 0);
  
 + if (dwc-usb2_generic_phy)
 + phy_power_on(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + phy_power_on(dwc-usb3_generic_phy);
 +
   spin_lock_init(dwc-lock);
   platform_set_drvdata(pdev, dwc);
  
 @@ -576,6 +609,11 @@ 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-10-10 Thread Kishon Vijay Abraham I
On Thursday 12 September 2013 03:57 PM, Vivek Gautam wrote:
 On Thu, Sep 12, 2013 at 3:40 PM, Kishon Vijay Abraham I kis...@ti.com wrote:
 On Thursday 12 September 2013 02:57 PM, Vivek Gautam wrote:
 Hi Kishon,


 On Mon, Sep 2, 2013 at 9:13 PM, Kishon Vijay Abraham I kis...@ti.com 
 wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().

 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.

  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
 depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
 depends on EXTCON
 select USB_PHY
 +   select GENERIC_PHY
 select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
 help
   Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)

 usb_phy_init(dwc-usb2_phy);
 usb_phy_init(dwc-usb3_phy);
 +
 +   if (dwc-usb2_generic_phy)
 +   phy_init(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   phy_init(dwc-usb3_generic_phy);
 +
 mdelay(100);

 /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
 usb_phy_shutdown(dwc-usb2_phy);
 usb_phy_shutdown(dwc-usb3_phy);
 +
 +   if (dwc-usb2_generic_phy)
 +   phy_power_off(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   phy_power_off(dwc-usb3_generic_phy);
  }

  #define DWC3_ALIGN_MASK(16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
 dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
 }

 +   if (of_property_read_bool(node, phys) || pdata-has_phy) {
 +   dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 +   if (IS_ERR(dwc-usb2_generic_phy)) {
 +   dev_err(dev, no usb2 phy configured yet);
 +   return PTR_ERR(dwc-usb2_generic_phy);
 +   }

 I have a doubt here.
 As i can see in the current phy drivers structuring, for OMAP there
 are two phy drivers :
 omap phy-omap-usb2 (talking to musb controller)

 It talks to dwc3 controller also ;-)
 
 Ok
 

 and phy-omap-usb3(talking to dwc3 controller).

 Now dwc3 controller requests both usb2-phy (supported by phy-omap-usb2
 ?) and usb3-phy (supported by phy-omap-usb3 ?).
 But phy-omap-usb2 is not the one designated to talk to DWC3
 controller, then why does still DWC3 want to request usb2-phy, which
 end of the day will be phy-omap-usb2.
 May be i am wrong here since i don't have knowledge about OMAP h/w 
 architecture.

 Is it like phy-omap-usb2 includes UTMI phys for both musb controller
 as well as dwc3 controller ?

 right. It's needed for dwc3 too. The same USB2 PHY IP is used for both MUSB 
 in
 OMAP2+ platforms and DWC3 in OMAP5.
 
 Ok, but on Samsung's exynos5 series of SoCs, the USB2.0 controller has
 a separate USB-PHY interface talking to phy-samsung-usb2 driver;
 and DWC3 drd controller has separate USB-PHY interface (including both
 UTMI+ and PIPE3 control registers) talking to phy-samsung-usb3 driver.
 So in this 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-09-16 Thread Roger Quadros
Hi,

On 09/16/2013 05:52 AM, Kishon Vijay Abraham I wrote:
 On Thursday 12 September 2013 06:49 PM, Roger Quadros wrote:
 On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().

 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
   Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
   drivers/usb/dwc3/Kconfig   |1 +
   drivers/usb/dwc3/core.c|   49 
 
   drivers/usb/dwc3/core.h|7 
   4 files changed, 61 insertions(+), 2 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
- compatible: must be snps,dwc3
- reg : Address and length of the register set for the device
- interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
- usb-phy : array of phandle for the PHY device.  The first element
  in the array is expected to be a handle to the USB2/HS PHY and
  the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
- tx-fifo-resize: determines if the FIFO *has* to be reallocated.

   This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
   depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
   depends on EXTCON
   select USB_PHY
 +select GENERIC_PHY
   select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
   help
 Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)

   usb_phy_init(dwc-usb2_phy);
   usb_phy_init(dwc-usb3_phy);
 +
 +if (dwc-usb2_generic_phy)
 +phy_init(dwc-usb2_generic_phy);
 +if (dwc-usb3_generic_phy)
 +phy_init(dwc-usb3_generic_phy);
 +
   mdelay(100);

   /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
   {
   usb_phy_shutdown(dwc-usb2_phy);
   usb_phy_shutdown(dwc-usb3_phy);
 +
 +if (dwc-usb2_generic_phy)
 +phy_power_off(dwc-usb2_generic_phy);
 +if (dwc-usb3_generic_phy)
 +phy_power_off(dwc-usb3_generic_phy);
   }

   #define DWC3_ALIGN_MASK(16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
   dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
   }

 +if (of_property_read_bool(node, phys) || pdata-has_phy) {
 +dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 +if (IS_ERR(dwc-usb2_generic_phy)) {
 +dev_err(dev, no usb2 phy configured yet);
 +return PTR_ERR(dwc-usb2_generic_phy);
 +}
 +
 +dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 +if (IS_ERR(dwc-usb3_generic_phy)) {
 +dev_err(dev, no usb3 phy configured yet);
 +return PTR_ERR(dwc-usb3_generic_phy);
 +}
 +} else {
 +dwc-usb2_generic_phy = NULL;
 +dwc-usb3_generic_phy = NULL;
 +}
 +
   /* default to superspeed if no maximum_speed passed */
   if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
   dwc-maximum_speed = USB_SPEED_SUPER;
 @@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)
   usb_phy_set_suspend(dwc-usb2_phy, 0);
   usb_phy_set_suspend(dwc-usb3_phy, 0);

 +if (dwc-usb2_generic_phy)
 +phy_power_on(dwc-usb2_generic_phy);
 +if (dwc-usb3_generic_phy)
 +phy_power_on(dwc-usb3_generic_phy);
 +
   spin_lock_init(dwc-lock);
   platform_set_drvdata(pdev, dwc);

 @@ -576,6 +609,11 @@ static int dwc3_remove(struct platform_device *pdev)
   usb_phy_set_suspend(dwc-usb2_phy, 1);
   usb_phy_set_suspend(dwc-usb3_phy, 1);

 +if (dwc-usb2_generic_phy)

 if (IS_ERR())
 
 I assign NULL to usb2_generic_phy and usb3_generic_phy in case the dts entry 
 doesn't have a *phys* property.
 The IS_ERR of usb2_generic_phy is treated as an error condition and probe 
 will fail.

OK.


 +phy_power_off(dwc-usb2_generic_phy);
 +if 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-09-15 Thread Kishon Vijay Abraham I

On Thursday 12 September 2013 06:49 PM, Roger Quadros wrote:

On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:

Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
power_on and power_off the following APIs are used phy_init(), phy_exit(),
phy_power_on() and phy_power_off().

However using the old USB phy library wont be removed till the PHYs of all
other SoC's using dwc3 core is adapted to the Generic PHY Framework.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
b/Documentation/devicetree/bindings/usb/dwc3.txt
index e807635..471366d 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
+
+Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
-
-Optional properties:
+ - phys: from the *Generic PHY* bindings
+ - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.

  This is usually a subnode to DWC3 glue to which it is connected.
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index cfc16dd..ad7ce83 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -3,6 +3,7 @@ config USB_DWC3
depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
depends on EXTCON
select USB_PHY
+   select GENERIC_PHY
select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
help
  Say Y or M here if your system has a Dual Role SuperSpeed
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 428c29e..485d365 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)

usb_phy_init(dwc-usb2_phy);
usb_phy_init(dwc-usb3_phy);
+
+   if (dwc-usb2_generic_phy)
+   phy_init(dwc-usb2_generic_phy);
+   if (dwc-usb3_generic_phy)
+   phy_init(dwc-usb3_generic_phy);
+
mdelay(100);

/* Clear USB3 PHY reset */
@@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
usb_phy_shutdown(dwc-usb2_phy);
usb_phy_shutdown(dwc-usb3_phy);
+
+   if (dwc-usb2_generic_phy)
+   phy_power_off(dwc-usb2_generic_phy);
+   if (dwc-usb3_generic_phy)
+   phy_power_off(dwc-usb3_generic_phy);
  }

  #define DWC3_ALIGN_MASK   (16 - 1)
@@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
}

+   if (of_property_read_bool(node, phys) || pdata-has_phy) {
+   dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
+   if (IS_ERR(dwc-usb2_generic_phy)) {
+   dev_err(dev, no usb2 phy configured yet);
+   return PTR_ERR(dwc-usb2_generic_phy);
+   }
+
+   dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
+   if (IS_ERR(dwc-usb3_generic_phy)) {
+   dev_err(dev, no usb3 phy configured yet);
+   return PTR_ERR(dwc-usb3_generic_phy);
+   }
+   } else {
+   dwc-usb2_generic_phy = NULL;
+   dwc-usb3_generic_phy = NULL;
+   }
+
/* default to superspeed if no maximum_speed passed */
if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
dwc-maximum_speed = USB_SPEED_SUPER;
@@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)
usb_phy_set_suspend(dwc-usb2_phy, 0);
usb_phy_set_suspend(dwc-usb3_phy, 0);

+   if (dwc-usb2_generic_phy)
+   phy_power_on(dwc-usb2_generic_phy);
+   if (dwc-usb3_generic_phy)
+   phy_power_on(dwc-usb3_generic_phy);
+
spin_lock_init(dwc-lock);
platform_set_drvdata(pdev, dwc);

@@ -576,6 +609,11 @@ static int dwc3_remove(struct platform_device *pdev)
usb_phy_set_suspend(dwc-usb2_phy, 1);
usb_phy_set_suspend(dwc-usb3_phy, 1);

+   if (dwc-usb2_generic_phy)


if (IS_ERR())


I assign NULL to usb2_generic_phy and usb3_generic_phy in case the dts 
entry doesn't have a *phys* property.
The IS_ERR of usb2_generic_phy is treated as an error condition and 
probe will fail.



+ 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-09-12 Thread Vivek Gautam
Hi Kishon,


On Mon, Sep 2, 2013 at 9:13 PM, Kishon Vijay Abraham I kis...@ti.com wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().

 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.

  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
 depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
 depends on EXTCON
 select USB_PHY
 +   select GENERIC_PHY
 select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
 help
   Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)

 usb_phy_init(dwc-usb2_phy);
 usb_phy_init(dwc-usb3_phy);
 +
 +   if (dwc-usb2_generic_phy)
 +   phy_init(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   phy_init(dwc-usb3_generic_phy);
 +
 mdelay(100);

 /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
 usb_phy_shutdown(dwc-usb2_phy);
 usb_phy_shutdown(dwc-usb3_phy);
 +
 +   if (dwc-usb2_generic_phy)
 +   phy_power_off(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   phy_power_off(dwc-usb3_generic_phy);
  }

  #define DWC3_ALIGN_MASK(16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
 dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
 }

 +   if (of_property_read_bool(node, phys) || pdata-has_phy) {
 +   dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 +   if (IS_ERR(dwc-usb2_generic_phy)) {
 +   dev_err(dev, no usb2 phy configured yet);
 +   return PTR_ERR(dwc-usb2_generic_phy);
 +   }

I have a doubt here.
As i can see in the current phy drivers structuring, for OMAP there
are two phy drivers :
omap phy-omap-usb2 (talking to musb controller)
and phy-omap-usb3(talking to dwc3 controller).

Now dwc3 controller requests both usb2-phy (supported by phy-omap-usb2
?) and usb3-phy (supported by phy-omap-usb3 ?).
But phy-omap-usb2 is not the one designated to talk to DWC3
controller, then why does still DWC3 want to request usb2-phy, which
end of the day will be phy-omap-usb2.
May be i am wrong here since i don't have knowledge about OMAP h/w architecture.

Is it like phy-omap-usb2 includes UTMI phys for both musb controller
as well as dwc3 controller ?
Because if it is just for musb controller then which usb2-phy will
DWC3 be getting when it requests that type of phy.

As of now phy-samsung-usb3 driver is the interface for both UTMI+ and
PIPE3 phys for DWC3 DRD controller, and phy-samsung-usb2 driver is the
interface
for a separate USB 2.0 controller itself (not DWC3). So we have
something to correct things up for Samsung, since dwc3 initializing
the phy-samsung-usb2 is not a valid scenerio.

Can you please clarify things here ?
Thanks !!

 +
 +   dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 +   if (IS_ERR(dwc-usb3_generic_phy)) {
 +   dev_err(dev, no usb3 phy configured 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-09-12 Thread Kishon Vijay Abraham I
On Thursday 12 September 2013 02:57 PM, Vivek Gautam wrote:
 Hi Kishon,
 
 
 On Mon, Sep 2, 2013 at 9:13 PM, Kishon Vijay Abraham I kis...@ti.com wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().

 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.

  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
 depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
 depends on EXTCON
 select USB_PHY
 +   select GENERIC_PHY
 select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
 help
   Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)

 usb_phy_init(dwc-usb2_phy);
 usb_phy_init(dwc-usb3_phy);
 +
 +   if (dwc-usb2_generic_phy)
 +   phy_init(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   phy_init(dwc-usb3_generic_phy);
 +
 mdelay(100);

 /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
 usb_phy_shutdown(dwc-usb2_phy);
 usb_phy_shutdown(dwc-usb3_phy);
 +
 +   if (dwc-usb2_generic_phy)
 +   phy_power_off(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   phy_power_off(dwc-usb3_generic_phy);
  }

  #define DWC3_ALIGN_MASK(16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
 dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
 }

 +   if (of_property_read_bool(node, phys) || pdata-has_phy) {
 +   dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 +   if (IS_ERR(dwc-usb2_generic_phy)) {
 +   dev_err(dev, no usb2 phy configured yet);
 +   return PTR_ERR(dwc-usb2_generic_phy);
 +   }
 
 I have a doubt here.
 As i can see in the current phy drivers structuring, for OMAP there
 are two phy drivers :
 omap phy-omap-usb2 (talking to musb controller)

It talks to dwc3 controller also ;-)

 and phy-omap-usb3(talking to dwc3 controller).
 
 Now dwc3 controller requests both usb2-phy (supported by phy-omap-usb2
 ?) and usb3-phy (supported by phy-omap-usb3 ?).
 But phy-omap-usb2 is not the one designated to talk to DWC3
 controller, then why does still DWC3 want to request usb2-phy, which
 end of the day will be phy-omap-usb2.
 May be i am wrong here since i don't have knowledge about OMAP h/w 
 architecture.
 
 Is it like phy-omap-usb2 includes UTMI phys for both musb controller
 as well as dwc3 controller ?

right. It's needed for dwc3 too. The same USB2 PHY IP is used for both MUSB in
OMAP2+ platforms and DWC3 in OMAP5.

Thanks
Kishon
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-09-12 Thread Vivek Gautam
On Thu, Sep 12, 2013 at 3:40 PM, Kishon Vijay Abraham I kis...@ti.com wrote:
 On Thursday 12 September 2013 02:57 PM, Vivek Gautam wrote:
 Hi Kishon,


 On Mon, Sep 2, 2013 at 9:13 PM, Kishon Vijay Abraham I kis...@ti.com wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().

 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.

 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)

 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.

  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
 depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
 depends on EXTCON
 select USB_PHY
 +   select GENERIC_PHY
 select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
 help
   Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)

 usb_phy_init(dwc-usb2_phy);
 usb_phy_init(dwc-usb3_phy);
 +
 +   if (dwc-usb2_generic_phy)
 +   phy_init(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   phy_init(dwc-usb3_generic_phy);
 +
 mdelay(100);

 /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
 usb_phy_shutdown(dwc-usb2_phy);
 usb_phy_shutdown(dwc-usb3_phy);
 +
 +   if (dwc-usb2_generic_phy)
 +   phy_power_off(dwc-usb2_generic_phy);
 +   if (dwc-usb3_generic_phy)
 +   phy_power_off(dwc-usb3_generic_phy);
  }

  #define DWC3_ALIGN_MASK(16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
 dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
 }

 +   if (of_property_read_bool(node, phys) || pdata-has_phy) {
 +   dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 +   if (IS_ERR(dwc-usb2_generic_phy)) {
 +   dev_err(dev, no usb2 phy configured yet);
 +   return PTR_ERR(dwc-usb2_generic_phy);
 +   }

 I have a doubt here.
 As i can see in the current phy drivers structuring, for OMAP there
 are two phy drivers :
 omap phy-omap-usb2 (talking to musb controller)

 It talks to dwc3 controller also ;-)

Ok


 and phy-omap-usb3(talking to dwc3 controller).

 Now dwc3 controller requests both usb2-phy (supported by phy-omap-usb2
 ?) and usb3-phy (supported by phy-omap-usb3 ?).
 But phy-omap-usb2 is not the one designated to talk to DWC3
 controller, then why does still DWC3 want to request usb2-phy, which
 end of the day will be phy-omap-usb2.
 May be i am wrong here since i don't have knowledge about OMAP h/w 
 architecture.

 Is it like phy-omap-usb2 includes UTMI phys for both musb controller
 as well as dwc3 controller ?

 right. It's needed for dwc3 too. The same USB2 PHY IP is used for both MUSB in
 OMAP2+ platforms and DWC3 in OMAP5.

Ok, but on Samsung's exynos5 series of SoCs, the USB2.0 controller has
a separate USB-PHY interface talking to phy-samsung-usb2 driver;
and DWC3 drd controller has separate USB-PHY interface (including both
UTMI+ and PIPE3 control registers) talking to phy-samsung-usb3 driver.
So in this case DWC3 doesn't need phy-samsung-usb2 at all. It's phy is
configured by 

Re: [PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-09-12 Thread Roger Quadros
On 09/02/2013 06:43 PM, Kishon Vijay Abraham I wrote:
 Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
 power_on and power_off the following APIs are used phy_init(), phy_exit(),
 phy_power_on() and phy_power_off().
 
 However using the old USB phy library wont be removed till the PHYs of all
 other SoC's using dwc3 core is adapted to the Generic PHY Framework.
 
 Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
 ---
  Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
  drivers/usb/dwc3/Kconfig   |1 +
  drivers/usb/dwc3/core.c|   49 
 
  drivers/usb/dwc3/core.h|7 
  4 files changed, 61 insertions(+), 2 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
 b/Documentation/devicetree/bindings/usb/dwc3.txt
 index e807635..471366d 100644
 --- a/Documentation/devicetree/bindings/usb/dwc3.txt
 +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
 @@ -6,11 +6,13 @@ Required properties:
   - compatible: must be snps,dwc3
   - reg : Address and length of the register set for the device
   - interrupts: Interrupts used by the dwc3 controller.
 +
 +Optional properties:
   - usb-phy : array of phandle for the PHY device.  The first element
 in the array is expected to be a handle to the USB2/HS PHY and
 the second element is expected to be a handle to the USB3/SS PHY
 -
 -Optional properties:
 + - phys: from the *Generic PHY* bindings
 + - phy-names: from the *Generic PHY* bindings
   - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
  
  This is usually a subnode to DWC3 glue to which it is connected.
 diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
 index cfc16dd..ad7ce83 100644
 --- a/drivers/usb/dwc3/Kconfig
 +++ b/drivers/usb/dwc3/Kconfig
 @@ -3,6 +3,7 @@ config USB_DWC3
   depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
   depends on EXTCON
   select USB_PHY
 + select GENERIC_PHY
   select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
   help
 Say Y or M here if your system has a Dual Role SuperSpeed
 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
 index 428c29e..485d365 100644
 --- a/drivers/usb/dwc3/core.c
 +++ b/drivers/usb/dwc3/core.c
 @@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
  
   usb_phy_init(dwc-usb2_phy);
   usb_phy_init(dwc-usb3_phy);
 +
 + if (dwc-usb2_generic_phy)
 + phy_init(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + phy_init(dwc-usb3_generic_phy);
 +
   mdelay(100);
  
   /* Clear USB3 PHY reset */
 @@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
  {
   usb_phy_shutdown(dwc-usb2_phy);
   usb_phy_shutdown(dwc-usb3_phy);
 +
 + if (dwc-usb2_generic_phy)
 + phy_power_off(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + phy_power_off(dwc-usb3_generic_phy);
  }
  
  #define DWC3_ALIGN_MASK  (16 - 1)
 @@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
   dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
   }
  
 + if (of_property_read_bool(node, phys) || pdata-has_phy) {
 + dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 + if (IS_ERR(dwc-usb2_generic_phy)) {
 + dev_err(dev, no usb2 phy configured yet);
 + return PTR_ERR(dwc-usb2_generic_phy);
 + }
 +
 + dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 + if (IS_ERR(dwc-usb3_generic_phy)) {
 + dev_err(dev, no usb3 phy configured yet);
 + return PTR_ERR(dwc-usb3_generic_phy);
 + }
 + } else {
 + dwc-usb2_generic_phy = NULL;
 + dwc-usb3_generic_phy = NULL;
 + }
 +
   /* default to superspeed if no maximum_speed passed */
   if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
   dwc-maximum_speed = USB_SPEED_SUPER;
 @@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)
   usb_phy_set_suspend(dwc-usb2_phy, 0);
   usb_phy_set_suspend(dwc-usb3_phy, 0);
  
 + if (dwc-usb2_generic_phy)
 + phy_power_on(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)
 + phy_power_on(dwc-usb3_generic_phy);
 +
   spin_lock_init(dwc-lock);
   platform_set_drvdata(pdev, dwc);
  
 @@ -576,6 +609,11 @@ static int dwc3_remove(struct platform_device *pdev)
   usb_phy_set_suspend(dwc-usb2_phy, 1);
   usb_phy_set_suspend(dwc-usb3_phy, 1);
  
 + if (dwc-usb2_generic_phy)

if (IS_ERR())

 + phy_power_off(dwc-usb2_generic_phy);
 + if (dwc-usb3_generic_phy)

if (IS_ERR())

here and everywhere else in this patch.

 + phy_power_off(dwc-usb3_generic_phy);
 +
   pm_runtime_put(pdev-dev);
   

[PATCH 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-09-02 Thread Kishon Vijay Abraham I
Adapted dwc3 core to use the Generic PHY Framework. So for init, exit,
power_on and power_off the following APIs are used phy_init(), phy_exit(),
phy_power_on() and phy_power_off().

However using the old USB phy library wont be removed till the PHYs of all
other SoC's using dwc3 core is adapted to the Generic PHY Framework.

Signed-off-by: Kishon Vijay Abraham I kis...@ti.com
---
 Documentation/devicetree/bindings/usb/dwc3.txt |6 ++-
 drivers/usb/dwc3/Kconfig   |1 +
 drivers/usb/dwc3/core.c|   49 
 drivers/usb/dwc3/core.h|7 
 4 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
b/Documentation/devicetree/bindings/usb/dwc3.txt
index e807635..471366d 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -6,11 +6,13 @@ Required properties:
  - compatible: must be snps,dwc3
  - reg : Address and length of the register set for the device
  - interrupts: Interrupts used by the dwc3 controller.
+
+Optional properties:
  - usb-phy : array of phandle for the PHY device.  The first element
in the array is expected to be a handle to the USB2/HS PHY and
the second element is expected to be a handle to the USB3/SS PHY
-
-Optional properties:
+ - phys: from the *Generic PHY* bindings
+ - phy-names: from the *Generic PHY* bindings
  - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
 
 This is usually a subnode to DWC3 glue to which it is connected.
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index cfc16dd..ad7ce83 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -3,6 +3,7 @@ config USB_DWC3
depends on (USB || USB_GADGET)  GENERIC_HARDIRQS  HAS_DMA
depends on EXTCON
select USB_PHY
+   select GENERIC_PHY
select USB_XHCI_PLATFORM if USB_SUPPORT  USB_XHCI_HCD
help
  Say Y or M here if your system has a Dual Role SuperSpeed
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 428c29e..485d365 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -82,6 +82,12 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
 
usb_phy_init(dwc-usb2_phy);
usb_phy_init(dwc-usb3_phy);
+
+   if (dwc-usb2_generic_phy)
+   phy_init(dwc-usb2_generic_phy);
+   if (dwc-usb3_generic_phy)
+   phy_init(dwc-usb3_generic_phy);
+
mdelay(100);
 
/* Clear USB3 PHY reset */
@@ -343,6 +349,11 @@ static void dwc3_core_exit(struct dwc3 *dwc)
 {
usb_phy_shutdown(dwc-usb2_phy);
usb_phy_shutdown(dwc-usb3_phy);
+
+   if (dwc-usb2_generic_phy)
+   phy_power_off(dwc-usb2_generic_phy);
+   if (dwc-usb3_generic_phy)
+   phy_power_off(dwc-usb3_generic_phy);
 }
 
 #define DWC3_ALIGN_MASK(16 - 1)
@@ -427,6 +438,23 @@ static int dwc3_probe(struct platform_device *pdev)
dwc-usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
}
 
+   if (of_property_read_bool(node, phys) || pdata-has_phy) {
+   dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
+   if (IS_ERR(dwc-usb2_generic_phy)) {
+   dev_err(dev, no usb2 phy configured yet);
+   return PTR_ERR(dwc-usb2_generic_phy);
+   }
+
+   dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
+   if (IS_ERR(dwc-usb3_generic_phy)) {
+   dev_err(dev, no usb3 phy configured yet);
+   return PTR_ERR(dwc-usb3_generic_phy);
+   }
+   } else {
+   dwc-usb2_generic_phy = NULL;
+   dwc-usb3_generic_phy = NULL;
+   }
+
/* default to superspeed if no maximum_speed passed */
if (dwc-maximum_speed == USB_SPEED_UNKNOWN)
dwc-maximum_speed = USB_SPEED_SUPER;
@@ -450,6 +478,11 @@ static int dwc3_probe(struct platform_device *pdev)
usb_phy_set_suspend(dwc-usb2_phy, 0);
usb_phy_set_suspend(dwc-usb3_phy, 0);
 
+   if (dwc-usb2_generic_phy)
+   phy_power_on(dwc-usb2_generic_phy);
+   if (dwc-usb3_generic_phy)
+   phy_power_on(dwc-usb3_generic_phy);
+
spin_lock_init(dwc-lock);
platform_set_drvdata(pdev, dwc);
 
@@ -576,6 +609,11 @@ static int dwc3_remove(struct platform_device *pdev)
usb_phy_set_suspend(dwc-usb2_phy, 1);
usb_phy_set_suspend(dwc-usb3_phy, 1);
 
+   if (dwc-usb2_generic_phy)
+   phy_power_off(dwc-usb2_generic_phy);
+   if (dwc-usb3_generic_phy)
+   phy_power_off(dwc-usb3_generic_phy);
+
pm_runtime_put(pdev-dev);
pm_runtime_disable(pdev-dev);
 
@@ -673,6 +711,11 @@ static int dwc3_suspend(struct device *dev)
usb_phy_shutdown(dwc-usb3_phy);