RE: [PATCH] usb: phy-tegra-usb.c: wrong pointer check for remap UTMI

2013-12-03 Thread Venu Byravarasu
Hi Stephen,

Initially Chris sent this patch to Linux-USB alias alone  there I Acked it.
Plz check http://marc.info/?l=linux-usbm=138475663023376w=1 

Then he resent the patch to linux-kernel alias with my ACK added.

Thanks,
Venu


 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Wednesday, December 04, 2013 9:29 AM
 To: Chris Ruehl; ba...@ti.com
 Cc: gre...@linuxfoundation.org; thierry.red...@gmail.com; linux-
 u...@vger.kernel.org; linux-te...@vger.kernel.org; linux-
 ker...@vger.kernel.org; Venu Byravarasu
 Subject: Re: [PATCH] usb: phy-tegra-usb.c: wrong pointer check for remap
 UTMI
 
 On 12/03/2013 07:02 PM, Chris Ruehl wrote:
  usb: phy-tegra-usb.c: wrong pointer check for remap UTMI
 
  A wrong pointer was used to test the result of devm_ioremap()
 
  Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
  Acked-by: Venu Byravarasu vbyravar...@nvidia.com
 
 Out of curiosity, when did that ack happen? I didn't see it. But anyway,
 
 Acked-by: Stephen Warren swar...@nvidia.com

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


RE: phy-tegra-usb.c: wrong pointer check for remap UTMI

2013-11-17 Thread Venu Byravarasu
 -Original Message-
 From: Chris Ruehl [mailto:chris.ru...@gtsys.com.hk]
 Sent: Monday, November 18, 2013 11:56 AM
 To: linux-usb@vger.kernel.org; Venu Byravarasu; Greg Kroah-Hartman
 Subject: phy-tegra-usb.c: wrong pointer check for remap UTMI
 
 
 While I hunt an other problem with my UPLI I see this problem.
 Linux-next 20131105 source.
 
 commit bd6a053d0497bc71e182e8a1063a8ae7d803fc7d
 Author: Chris Ruehl chris.ru...@gtsys.com.hk
 Date:   Mon Nov 18 14:21:58 2013 +0800
 
  Fix wrong pointer when remap UTMI pad
 
 diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
 index 82232ac..bbe4f8e 100644
 --- a/drivers/usb/phy/phy-tegra-usb.c
 +++ b/drivers/usb/phy/phy-tegra-usb.c
 @@ -876,7 +876,7 @@ static int utmi_phy_probe(struct tegra_usb_phy
 *tegra_phy,
 
  tegra_phy-pad_regs = devm_ioremap(pdev-dev, res-start,
  resource_size(res));
 -   if (!tegra_phy-regs) {
 +   if (!tegra_phy-pad_regs) {

Seems to be originated due to copy-paste problem.
Anyhow, thanks for fixing. 

Acked-by: Venu Byravarasu vbyravar...@nvidia.com

  dev_err(pdev-dev, Failed to remap UTMI Pad regs\n);
  return -ENOMEM;
  }

---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---


[PATCH v4 1/8] ARM: tegra: finalize USB EHCI and PHY bindings

2013-05-16 Thread Venu Byravarasu
The existing Tegra USB bindings have a few issues:

1) Many properties are documented as being part of the EHCI controller
node, yet they apply more to the PHY device. They should be moved.

2) Some registers in PHY1 are shared with PHY3, and hence PHY3 needs a
reg entry to point at PHY1's register space. We can't assume the PHY1
driver is present, so the PHY3 driver will directly access those
registers.

3) The list of clocks required by the PHY was missing some required
entries.

4) UTMI PHY Timing parameters are added

5) VBUS control is now specified using a regulator rather than a plain GPIO

6) Added nvidia,is-wired property to indicate whether the device is
hard wired on the board, or pluggable.

This patch fixes the binding definition to resolve these issues.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v3:
Added a blank line at EOF of nvidia,tegra20-usb-phy.txt.

delta from v2:
Moved vbus-supply under Required properties for dr_mode == otg heading.

delta from v1:
1. added UTMI PHY timing params.
2. replaced gadget with peripheral in dr_mode
3. added nvidia,is-wired  vbus-supply params.

 
.../bindings/usb/nvidia,tegra20-ehci.txt   |   27 ++--
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   41 ++-
 2 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
index 34c9528..df09330 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
@@ -6,27 +6,10 @@ Practice : Universal Serial Bus with the following 
modifications
 and additions :
 
 Required properties :
- - compatible : Should be nvidia,tegra20-ehci for USB controllers
-   used in host mode.
- - phy_type : Should be one of ulpi or utmi.
- - nvidia,vbus-gpio : If present, specifies a gpio that needs to be
-   activated for the bus to be powered.
- - nvidia,phy : phandle of the PHY instance, the controller is connected to.
-
-Required properties for phy_type == ulpi:
-  - nvidia,phy-reset-gpio : The GPIO used to reset the PHY.
+ - compatible : Should be nvidia,tegra20-ehci.
+ - nvidia,phy : phandle of the PHY that the controller is connected to.
+ - clocks : Contains a single entry which defines the USB controller's clock.
 
 Optional properties:
-  - dr_mode : dual role mode. Indicates the working mode for
-   nvidia,tegra20-ehci compatible controllers.  Can be host, peripheral,
-   or otg.  Default to host if not defined for backward compatibility.
-  host means this is a host controller
-  peripheral means it is device controller
-  otg means it can operate as either (on the go)
-  - nvidia,has-legacy-mode : boolean indicates whether this controller can
-operate in legacy mode (as APX 2500 / 2600). In legacy mode some
-registers are accessed through the APB_MISC base address instead of
-the USB controller. Since this is a legacy issue it probably does not
-warrant a compatible string of its own.
-  - nvidia,needs-double-reset : boolean is to be set for some of the Tegra2
-USB ports, which need reset twice due to hardware issues.
+ - nvidia,needs-double-reset : boolean is to be set for some of the Tegra20
+   USB ports, which need reset twice due to hardware issues.
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
index 6bdaba2..c4c9e9e 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
@@ -4,14 +4,49 @@ The device node for Tegra SOC USB PHY:
 
 Required properties :
  - compatible : Should be nvidia,tegra20-usb-phy.
- - reg : Address and length of the register set for the USB PHY interface.
- - phy_type : Should be one of ulpi or utmi.
+ - reg : Defines the following set of registers, in the order listed:
+   - The PHY's own register set.
+ Always present.
+   - The register set of the PHY containing the UTMI pad control registers.
+ Present if-and-only-if phy_type == utmi.
+ - phy_type : Should be one of utmi, ulpi or hsic.
+ - clocks : Defines the clocks listed in the clock-names property.
+ - clock-names : The following clock names must be present:
+   - reg: The clock needed to access the PHY's own registers. This is the
+ associated EHCI controller's clock. Always present.
+   - pll_u: PLL_U. Always present.
+   - timer: The timeout clock (clk_m). Present if phy_type == utmi.
+   - utmi-pads: The clock needed to access the UTMI pad control registers.
+ Present if phy_type == utmi.
+   - ulpi-link: The clock Tegra provides to the ULPI PHY (cdev2).
+ Present if phy_type == ulpi, and ULPI link mode is in use.
 
 Required properties for phy_type == ulpi:
   - nvidia,phy-reset-gpio : The GPIO used to reset the PHY

[PATCH v4 3/8] ARM: tegra: update device trees for USB binding rework

2013-05-16 Thread Venu Byravarasu
This patch updates all Tegra board files so that they contain all the
properties required by the updated USB DT binding. Note that this patch
only adds the new properties and does not yet remove the old properties,
in order to maintain bisectability. The old properties will be removed
once the driver has been updated to assume the new bindings.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v3:
Added status field to USB PHY DT nodes.

delta from v2:
1. Removed dr_mode setting to otg, due to lack of knowledge of all Vbus 
supplies,
 on all target platforms.

2. All changes related to 'nvidia,phy-reset-gpio' were moved to patch 2 of the
 same series.

delta from v1:
1. Fixed voltage regulators were used for vbus-supply
2. Added UTMI PHY timing Parameters to DT.

 arch/arm/boot/dts/tegra20-harmony.dts   |9 ++
 arch/arm/boot/dts/tegra20-iris-512.dts  |9 +-
 arch/arm/boot/dts/tegra20-paz00.dts |9 ++
 arch/arm/boot/dts/tegra20-seaboard.dts  |   20 
 arch/arm/boot/dts/tegra20-tamonten.dtsi |4 ++
 arch/arm/boot/dts/tegra20-trimslice.dts |   19 
 arch/arm/boot/dts/tegra20-ventana.dts   |9 ++
 arch/arm/boot/dts/tegra20-whistler.dts  |   28 +
 arch/arm/boot/dts/tegra20.dtsi  |   49 +++---
 9 files changed, 143 insertions(+), 13 deletions(-)

diff --git a/arch/arm/boot/dts/tegra20-harmony.dts 
b/arch/arm/boot/dts/tegra20-harmony.dts
index e84f3f6..ec52937 100644
--- a/arch/arm/boot/dts/tegra20-harmony.dts
+++ b/arch/arm/boot/dts/tegra20-harmony.dts
@@ -428,12 +428,17 @@
status = okay;
};
 
+   usb-phy@c500 {
+   status = okay;
+   };
+
usb@c5004000 {
status = okay;
nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
usb-phy@c5004000 {
+   status = okay;
nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
@@ -441,6 +446,10 @@
status = okay;
};
 
+   usb-phy@c5008000 {
+   status = okay;
+   };
+
sdhci@c8000200 {
status = okay;
cd-gpios = gpio 69 1; /* gpio PI5 */
diff --git a/arch/arm/boot/dts/tegra20-iris-512.dts 
b/arch/arm/boot/dts/tegra20-iris-512.dts
index 52f1103..9f64f70 100644
--- a/arch/arm/boot/dts/tegra20-iris-512.dts
+++ b/arch/arm/boot/dts/tegra20-iris-512.dts
@@ -38,13 +38,20 @@
 
usb@c500 {
status = okay;
-   dr_mode = otg;
+   };
+
+   usb-phy@c500 {
+   status = okay;
};
 
usb@c5008000 {
status = okay;
};
 
+   usb-phy@c5008000 {
+   status = okay;
+   };
+
serial@70006000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/tegra20-paz00.dts 
b/arch/arm/boot/dts/tegra20-paz00.dts
index e9ac2a9..1c17ffa 100644
--- a/arch/arm/boot/dts/tegra20-paz00.dts
+++ b/arch/arm/boot/dts/tegra20-paz00.dts
@@ -427,12 +427,17 @@
status = okay;
};
 
+   usb-phy@c500 {
+   status = okay;
+   };
+
usb@c5004000 {
status = okay;
nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
};
 
usb-phy@c5004000 {
+   status = okay;
nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
};
 
@@ -440,6 +445,10 @@
status = okay;
};
 
+   usb-phy@c5008000 {
+   status = okay;
+   };
+
sdhci@c800 {
status = okay;
cd-gpios = gpio 173 1; /* gpio PV5 */
diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts 
b/arch/arm/boot/dts/tegra20-seaboard.dts
index 9dd4f8e..b832088 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -569,12 +569,19 @@
dr_mode = otg;
};
 
+   usb-phy@c500 {
+   status = okay;
+   vbus-supply = vbus_reg;
+   dr_mode = otg;
+   };
+
usb@c5004000 {
status = okay;
nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
usb-phy@c5004000 {
+   status = okay;
nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
@@ -582,6 +589,10 @@
status = okay;
};
 
+   usb-phy@c5008000 {
+   status = okay;
+   };
+
sdhci@c800 {
status = okay;
power-gpios = gpio 86 0; /* gpio PK6 */
@@ -807,6 +818,15 @@
gpio = pmic 1 0;
enable-active-high;
};
+
+   vbus_reg: regulator@3 {
+   compatible = regulator-fixed;
+   reg = 3

[PATCH v4 5/8] usb: phy: tegra: Get PHY mode using DT

2013-05-16 Thread Venu Byravarasu
Added a new PHY mode to support OTG.
Obtained Tegra USB PHY mode using DT property.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v3  v2:
No change

delta from v1:
replaced gadget with peripheral.


 
drivers/usb/host/ehci-tegra.c |1 -
 drivers/usb/phy/phy-tegra-usb.c   |   13 +++--
 include/linux/usb/tegra_usb_phy.h |3 ++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index e3eddc3..568a6fa 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -736,7 +736,6 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 
tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
pdata-phy_config,
-   TEGRA_USB_PHY_MODE_HOST,
tegra_ehci_set_pts,
tegra_ehci_set_phcd);
if (IS_ERR(tegra-phy)) {
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 8bcc12f..0ff1f3e 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -687,7 +687,7 @@ static int  tegra_usb_phy_suspend(struct usb_phy *x, int 
suspend)
 }
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-   void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode,
+   void __iomem *regs, void *config,
void (*set_pts)(struct usb_phy *x, u8 pts_val),
void (*set_phcd)(struct usb_phy *x, bool enable))
 
@@ -705,7 +705,6 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
phy-instance = instance;
phy-regs = regs;
phy-config = config;
-   phy-mode = phy_mode;
phy-dev = dev;
phy-is_legacy_phy =
of_property_read_bool(np, nvidia,has-legacy-mode);
@@ -717,6 +716,16 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
else
phy-is_ulpi_phy = true;
 
+   err = of_property_match_string(np, dr_mode, otg);
+   if (err  0) {
+   err = of_property_match_string(np, dr_mode, peripheral);
+   if (err  0)
+   phy-mode = TEGRA_USB_PHY_MODE_HOST;
+   else
+   phy-mode = TEGRA_USB_PHY_MODE_DEVICE;
+   } else
+   phy-mode = TEGRA_USB_PHY_MODE_OTG;
+
if (!phy-config) {
if (phy-is_ulpi_phy) {
pr_err(%s: ulpi phy configuration missing, __func__);
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index 1b7519a..ff2d959 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -42,6 +42,7 @@ enum tegra_usb_phy_port_speed {
 enum tegra_usb_phy_mode {
TEGRA_USB_PHY_MODE_DEVICE,
TEGRA_USB_PHY_MODE_HOST,
+   TEGRA_USB_PHY_MODE_OTG,
 };
 
 struct tegra_xtal_freq;
@@ -66,7 +67,7 @@ struct tegra_usb_phy {
 };
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-   void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode,
+   void __iomem *regs, void *config,
void (*set_pts)(struct usb_phy *x, u8 pts_val),
void (*set_phcd)(struct usb_phy *x, bool enable));
 
-- 
1.7.0.4

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


[PATCH v4 8/8] usb: phy: registering Tegra USB PHY as platform driver

2013-05-16 Thread Venu Byravarasu
Registered Tegra USB PHY as a separate platform driver.

To synchronize host controller and PHY initialization, used deferred
probe mechanism. As PHY should be initialized before EHCI starts running,
deferred probe of Tegra EHCI driver till PHY probe gets completed.

Got rid of instance number based handling in host driver.

Made use of DT params to get the PHY Pad registers.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v3:
Removed functions pointers to access PORTSC registers from PHY  accessing
them from PHY using exported functions.

delta from v2:
Rebased to TOT and applied same changes as on v2.

delta from v1:
1. Removed extra memory allocation for u_phy-otg
2. Moved ulpi_init code into separate function.
3. Initializing all clk and GPIOs in probe.
4. Used devm_  APIs wherever possible.

 drivers/usb/host/ehci-tegra.c |  104 +---
 drivers/usb/phy/phy-tegra-usb.c   |  325 -
 include/linux/usb/tegra_usb_phy.h |   11 +-
 3 files changed, 230 insertions(+), 210 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 568a6fa..c8ee919 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -611,7 +611,7 @@ static const struct dev_pm_ops tegra_ehci_pm_ops = {
 /* Bits of PORTSC1, which will get cleared by writing 1 into them */
 #define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
 
-static void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
+void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
 {
unsigned long val;
struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
@@ -622,8 +622,9 @@ static void tegra_ehci_set_pts(struct usb_phy *x, u8 
pts_val)
val |= TEGRA_USB_PORTSC1_PTS(pts_val  3);
writel(val, base + TEGRA_USB_PORTSC1);
 }
+EXPORT_SYMBOL_GPL(tegra_ehci_set_pts);
 
-static void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
+void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
 {
unsigned long val;
struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
@@ -636,6 +637,7 @@ static void tegra_ehci_set_phcd(struct usb_phy *x, bool 
enable)
val = ~TEGRA_USB_PORTSC1_PHCD;
writel(val, base + TEGRA_USB_PORTSC1);
 }
+EXPORT_SYMBOL_GPL(tegra_ehci_set_phcd);
 
 static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32);
 
@@ -647,7 +649,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
struct tegra_ehci_platform_data *pdata;
int err = 0;
int irq;
-   int instance = pdev-id;
+   struct device_node *np_phy;
struct usb_phy *u_phy;
 
pdata = pdev-dev.platform_data;
@@ -670,38 +672,49 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!tegra)
return -ENOMEM;
 
-   hcd = usb_create_hcd(tegra_ehci_hc_driver, pdev-dev,
-   dev_name(pdev-dev));
-   if (!hcd) {
-   dev_err(pdev-dev, Unable to create HCD\n);
-   return -ENOMEM;
-   }
-
-   platform_set_drvdata(pdev, tegra);
-
tegra-clk = devm_clk_get(pdev-dev, NULL);
if (IS_ERR(tegra-clk)) {
dev_err(pdev-dev, Can't get ehci clock\n);
-   err = PTR_ERR(tegra-clk);
-   goto fail_clk;
+   return PTR_ERR(tegra-clk);
}
 
err = clk_prepare_enable(tegra-clk);
if (err)
-   goto fail_clk;
+   return err;
 
tegra_periph_reset_assert(tegra-clk);
udelay(1);
tegra_periph_reset_deassert(tegra-clk);
 
+   np_phy = of_parse_phandle(pdev-dev.of_node, nvidia,phy, 0);
+   if (!np_phy) {
+   err = -ENODEV;
+   goto cleanup_clk;
+   }
+
+   u_phy = tegra_usb_get_phy(np_phy);
+   if (IS_ERR(u_phy)) {
+   err = PTR_ERR(u_phy);
+   goto cleanup_clk;
+   }
+
tegra-needs_double_reset = of_property_read_bool(pdev-dev.of_node,
nvidia,needs-double-reset);
 
+   hcd = usb_create_hcd(tegra_ehci_hc_driver, pdev-dev,
+   dev_name(pdev-dev));
+   if (!hcd) {
+   dev_err(pdev-dev, Unable to create HCD\n);
+   err = -ENOMEM;
+   goto cleanup_clk;
+   }
+   hcd-phy = u_phy;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(pdev-dev, Failed to get I/O memory\n);
err = -ENXIO;
-   goto fail_io;
+   goto cleanup_hcd_create;
}
hcd-rsrc_start = res-start;
hcd-rsrc_len = resource_size(res);
@@ -709,57 +722,28 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!hcd-regs) {
dev_err(pdev-dev, Failed to remap I/O memory\n);
err = -ENOMEM;
-   goto fail_io;
-   }
-
-   /* This is pretty ugly and needs to be fixed when we do only

[PATCH v4 6/8] usb: phy: tegra: get ULPI reset GPIO info using DT.

2013-05-16 Thread Venu Byravarasu
As GPIO information is avail through DT, used it to get Tegra ULPI
reset GPIO number. Added a new member to tegra_usb_phy structure to
store this number.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1, v2  v3: no change.

 drivers/usb/phy/phy-tegra-usb.c   |   25 +++--
 include/linux/usb/tegra_usb_phy.h |1 +
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 0ff1f3e..b8c688a 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -541,11 +541,10 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
int ret;
unsigned long val;
void __iomem *base = phy-regs;
-   struct tegra_ulpi_config *config = phy-config;
 
-   gpio_direction_output(config-reset_gpio, 0);
+   gpio_direction_output(phy-reset_gpio, 0);
msleep(5);
-   gpio_direction_output(config-reset_gpio, 1);
+   gpio_direction_output(phy-reset_gpio, 1);
 
clk_prepare_enable(phy-clk);
msleep(1);
@@ -603,10 +602,8 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
 
 static int ulpi_phy_power_off(struct tegra_usb_phy *phy)
 {
-   struct tegra_ulpi_config *config = phy-config;
-
clk_disable(phy-clk);
-   return gpio_direction_output(config-reset_gpio, 0);
+   return gpio_direction_output(phy-reset_gpio, 0);
 }
 
 static int tegra_phy_init(struct usb_phy *x)
@@ -622,18 +619,18 @@ static inttegra_phy_init(struct usb_phy *x)
pr_err(%s: can't get ulpi clock\n, __func__);
return PTR_ERR(phy-clk);
}
-   if (!gpio_is_valid(ulpi_config-reset_gpio))
-   ulpi_config-reset_gpio =
-   of_get_named_gpio(phy-dev-of_node,
- nvidia,phy-reset-gpio, 0);
-   if (!gpio_is_valid(ulpi_config-reset_gpio)) {
+
+   phy-reset_gpio =
+   of_get_named_gpio(phy-dev-of_node,
+ nvidia,phy-reset-gpio, 0);
+   if (!gpio_is_valid(phy-reset_gpio)) {
pr_err(%s: invalid reset gpio: %d\n, __func__,
-  ulpi_config-reset_gpio);
+  phy-reset_gpio);
err = -EINVAL;
goto err1;
}
-   gpio_request(ulpi_config-reset_gpio, ulpi_phy_reset_b);
-   gpio_direction_output(ulpi_config-reset_gpio, 0);
+   gpio_request(phy-reset_gpio, ulpi_phy_reset_b);
+   gpio_direction_output(phy-reset_gpio, 0);
phy-ulpi = otg_ulpi_create(ulpi_viewport_access_ops, 0);
phy-ulpi-io_priv = phy-regs + ULPI_VIEWPORT;
} else {
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index ff2d959..97d123c 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -62,6 +62,7 @@ struct tegra_usb_phy {
struct device *dev;
bool is_legacy_phy;
bool is_ulpi_phy;
+   int reset_gpio;
void (*set_pts)(struct usb_phy *x, u8 pts_val);
void (*set_phcd)(struct usb_phy *x, bool enable);
 };
-- 
1.7.0.4

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


[PATCH v4 4/8] usb: phy: tegra: Return correct error value provided by clk_get_sys

2013-05-16 Thread Venu Byravarasu
In case if clk_get_sys fails, return correct error value provided by
the API.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1, v2  v3: no change.

 drivers/usb/phy/phy-tegra-usb.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 17d8112..8bcc12f 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -620,8 +620,7 @@ static int  tegra_phy_init(struct usb_phy *x)
phy-clk = clk_get_sys(NULL, ulpi_config-clk);
if (IS_ERR(phy-clk)) {
pr_err(%s: can't get ulpi clock\n, __func__);
-   err = -ENXIO;
-   goto err1;
+   return PTR_ERR(phy-clk);
}
if (!gpio_is_valid(ulpi_config-reset_gpio))
ulpi_config-reset_gpio =
-- 
1.7.0.4

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


[PATCH v4 2/8] arm: dt: Tegra20: Modify ULPI reset GPIO properties

2013-05-16 Thread Venu Byravarasu
1. All Tegra20 ULPI reset GPIO DT properties are modified to indicate active
low nature of the GPIO.
2. Placed USB PHY DT node immediately below the EHCI controller DT nodes
and corrected reg value in the name of USB PHY DT node.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v3:
No code changes. Commit message only updated.

delta from v2:
Created this patch as per comments received at:
http://marc.info/?l=linux-usbm=136501761810344w=2

 arch/arm/boot/dts/tegra20-colibri-512.dtsi |6 +-
 arch/arm/boot/dts/tegra20-harmony.dts  |   10 +-
 arch/arm/boot/dts/tegra20-paz00.dts|   10 +-
 arch/arm/boot/dts/tegra20-seaboard.dts |   10 +-
 arch/arm/boot/dts/tegra20-trimslice.dts|   10 +-
 arch/arm/boot/dts/tegra20-ventana.dts  |   10 +-
 6 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/arch/arm/boot/dts/tegra20-colibri-512.dtsi 
b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
index a573b94..c12af78 100644
--- a/arch/arm/boot/dts/tegra20-colibri-512.dtsi
+++ b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
@@ -449,7 +449,11 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
+   };
+
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
sdhci@c8000600 {
diff --git a/arch/arm/boot/dts/tegra20-harmony.dts 
b/arch/arm/boot/dts/tegra20-harmony.dts
index e7d5de4..e84f3f6 100644
--- a/arch/arm/boot/dts/tegra20-harmony.dts
+++ b/arch/arm/boot/dts/tegra20-harmony.dts
@@ -430,15 +430,15 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c8000200 {
diff --git a/arch/arm/boot/dts/tegra20-paz00.dts 
b/arch/arm/boot/dts/tegra20-paz00.dts
index e3e0c99..e9ac2a9 100644
--- a/arch/arm/boot/dts/tegra20-paz00.dts
+++ b/arch/arm/boot/dts/tegra20-paz00.dts
@@ -429,15 +429,15 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts 
b/arch/arm/boot/dts/tegra20-seaboard.dts
index cee4c34..9dd4f8e 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -571,15 +571,15 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
diff --git a/arch/arm/boot/dts/tegra20-trimslice.dts 
b/arch/arm/boot/dts/tegra20-trimslice.dts
index 9cc78a1..fd7afd6 100644
--- a/arch/arm/boot/dts/tegra20-trimslice.dts
+++ b/arch/arm/boot/dts/tegra20-trimslice.dts
@@ -316,15 +316,15 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
diff --git a/arch/arm/boot/dts/tegra20-ventana.dts 
b/arch/arm/boot/dts/tegra20-ventana.dts
index dd38f1f..a75a0e7 100644
--- a/arch/arm/boot/dts/tegra20-ventana.dts
+++ b/arch/arm/boot/dts/tegra20-ventana.dts
@@ -507,15 +507,15 @@
 
usb@c5004000

[PATCH v4 0/8] Tegra USB PHY driver series

2013-05-16 Thread Venu Byravarasu
delta from v3:
This patch series is prepared as follow up of TEGRA USB PHY driver patch series
discussed at: https://lkml.org/lkml/2013/5/10/241

Venu Byravarasu (8):
  ARM: tegra: finalize USB EHCI and PHY bindings
  arm: dt: Tegra20: Modify ULPI reset GPIO properties
  ARM: tegra: update device trees for USB binding rework
  usb: phy: tegra: Return correct error value provided by clk_get_sys
  usb: phy: tegra: Get PHY mode using DT
  usb: phy: tegra: get ULPI reset GPIO info using DT.
  usb: phy: tegra: Add error handling  clean up.
  usb: phy: registering Tegra USB PHY as platform driver

 .../bindings/usb/nvidia,tegra20-ehci.txt   |   27 +--
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   41 +++-
 arch/arm/boot/dts/tegra20-colibri-512.dtsi |6 +-
 arch/arm/boot/dts/tegra20-harmony.dts  |   15 +-
 arch/arm/boot/dts/tegra20-iris-512.dts |9 +-
 arch/arm/boot/dts/tegra20-paz00.dts|   15 +-
 arch/arm/boot/dts/tegra20-seaboard.dts |   26 ++-
 arch/arm/boot/dts/tegra20-tamonten.dtsi|4 +
 arch/arm/boot/dts/tegra20-trimslice.dts|   25 ++-
 arch/arm/boot/dts/tegra20-ventana.dts  |   15 +-
 arch/arm/boot/dts/tegra20-whistler.dts |   28 ++
 arch/arm/boot/dts/tegra20.dtsi |   49 +++-
 drivers/usb/host/ehci-tegra.c  |  105 +++
 drivers/usb/phy/phy-tegra-usb.c|  318 
 include/linux/usb/tegra_usb_phy.h  |   13 +-
 15 files changed, 451 insertions(+), 245 deletions(-)

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


[PATCH v3 00/10] Tegra USB PHY driver series

2013-05-10 Thread Venu Byravarasu
delta from v2:
This patch is prepared as follow up patch of TEGRA USB PHY driver
patch series discussed at:
http://marc.info/?l=linux-tegram=136497946026787w=2

Venu Byravarasu (10):
  ARM: tegra: finalize USB EHCI and PHY bindings
  arm: dt: Tegra20: Modify ULPI reset GPIO properties
  ARM: tegra: update device trees for USB binding rework
  Revert usb: phy: tegra: don't call into tegra-ehci directly
  usb: phy: tegra: Get PHY mode using DT
  usb: phy: tegra: Return correct error value provided by clk_get_sys
  usb: phy: tegra: get ULPI reset GPIO info using DT.
  usb: phy: tegra: Add error handling  clean up.
  usb: phy: registering Tegra USB PHY as platform driver
  Usb: Move PORTSC access to PHY

 .../bindings/usb/nvidia,tegra20-ehci.txt   |   27 +--
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   40 ++-
 arch/arm/boot/dts/tegra20-colibri-512.dtsi |6 +-
 arch/arm/boot/dts/tegra20-harmony.dts  |   10 +-
 arch/arm/boot/dts/tegra20-iris-512.dts |1 -
 arch/arm/boot/dts/tegra20-paz00.dts|   10 +-
 arch/arm/boot/dts/tegra20-seaboard.dts |   24 +-
 arch/arm/boot/dts/tegra20-trimslice.dts|   23 +-
 arch/arm/boot/dts/tegra20-ventana.dts  |   10 +-
 arch/arm/boot/dts/tegra20-whistler.dts |   26 ++
 arch/arm/boot/dts/tegra20.dtsi |   46 ++-
 drivers/usb/host/ehci-tegra.c  |  143 +++--
 drivers/usb/phy/phy-tegra-usb.c|  349 +---
 include/linux/usb/tegra_usb_phy.h  |9 +-
 14 files changed, 424 insertions(+), 300 deletions(-)

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


[PATCH v3 01/10] ARM: tegra: finalize USB EHCI and PHY bindings

2013-05-10 Thread Venu Byravarasu
The existing Tegra USB bindings have a few issues:

1) Many properties are documented as being part of the EHCI controller
node, yet they apply more to the PHY device. They should be moved.

2) Some registers in PHY1 are shared with PHY3, and hence PHY3 needs a
reg entry to point at PHY1's register space. We can't assume the PHY1
driver is present, so the PHY3 driver will directly access those
registers.

3) The list of clocks required by the PHY was missing some required
entries.

4) UTMI PHY Timing parameters are added

5) VBUS control is now specified using a regulator rather than a plain GPIO

6) Added nvidia,is-wired property to indicate whether the device is
hard wired on the board, or pluggable.

This patch fixes the binding definition to resolve these issues.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:
1. added UTMI PHY timing params.
2. replaced gadget with peripheral in dr_mode
3. added nvidia,is-wired  vbus-supply params.

delta from v2:
Moved vbus-supply under Required properties for dr_mode == otg heading.


 .../bindings/usb/nvidia,tegra20-ehci.txt   |   27 ++---
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   40 ++-
 2 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
index 34c9528..df09330 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
@@ -6,27 +6,10 @@ Practice : Universal Serial Bus with the following 
modifications
 and additions :
 
 Required properties :
- - compatible : Should be nvidia,tegra20-ehci for USB controllers
-   used in host mode.
- - phy_type : Should be one of ulpi or utmi.
- - nvidia,vbus-gpio : If present, specifies a gpio that needs to be
-   activated for the bus to be powered.
- - nvidia,phy : phandle of the PHY instance, the controller is connected to.
-
-Required properties for phy_type == ulpi:
-  - nvidia,phy-reset-gpio : The GPIO used to reset the PHY.
+ - compatible : Should be nvidia,tegra20-ehci.
+ - nvidia,phy : phandle of the PHY that the controller is connected to.
+ - clocks : Contains a single entry which defines the USB controller's clock.
 
 Optional properties:
-  - dr_mode : dual role mode. Indicates the working mode for
-   nvidia,tegra20-ehci compatible controllers.  Can be host, peripheral,
-   or otg.  Default to host if not defined for backward compatibility.
-  host means this is a host controller
-  peripheral means it is device controller
-  otg means it can operate as either (on the go)
-  - nvidia,has-legacy-mode : boolean indicates whether this controller can
-operate in legacy mode (as APX 2500 / 2600). In legacy mode some
-registers are accessed through the APB_MISC base address instead of
-the USB controller. Since this is a legacy issue it probably does not
-warrant a compatible string of its own.
-  - nvidia,needs-double-reset : boolean is to be set for some of the Tegra2
-USB ports, which need reset twice due to hardware issues.
+ - nvidia,needs-double-reset : boolean is to be set for some of the Tegra20
+   USB ports, which need reset twice due to hardware issues.
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
index 6bdaba2..292d8e2 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
@@ -4,14 +4,48 @@ The device node for Tegra SOC USB PHY:
 
 Required properties :
  - compatible : Should be nvidia,tegra20-usb-phy.
- - reg : Address and length of the register set for the USB PHY interface.
- - phy_type : Should be one of ulpi or utmi.
+ - reg : Defines the following set of registers, in the order listed:
+   - The PHY's own register set.
+ Always present.
+   - The register set of the PHY containing the UTMI pad control registers.
+ Present if-and-only-if phy_type == utmi.
+ - phy_type : Should be one of utmi, ulpi or hsic.
+ - clocks : Defines the clocks listed in the clock-names property.
+ - clock-names : The following clock names must be present:
+   - reg: The clock needed to access the PHY's own registers. This is the
+ associated EHCI controller's clock. Always present.
+   - pll_u: PLL_U. Always present.
+   - timer: The timeout clock (clk_m). Present if phy_type == utmi.
+   - utmi-pads: The clock needed to access the UTMI pad control registers.
+ Present if phy_type == utmi.
+   - ulpi-link: The clock Tegra provides to the ULPI PHY (cdev2).
+ Present if phy_type == ulpi, and ULPI link mode is in use.
 
 Required properties for phy_type == ulpi:
   - nvidia,phy-reset-gpio : The GPIO used to reset the PHY.
 
+Required PHY timing params for utmi phy:
+  - nvidia,hssync-start-delay

[PATCH v3 09/10] usb: phy: registering Tegra USB PHY as platform driver

2013-05-10 Thread Venu Byravarasu
Registered Tegra USB PHY as a separate platform driver.

To synchronize host controller and PHY initialization, used deferred
probe mechanism. As PHY should be initialized before EHCI starts running,
deferred probe of Tegra EHCI driver till PHY probe gets completed.

Got rid of instance number based handling in host driver.

Made use of DT params to get the PHY Pad registers.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:
1. Removed extra memory allocation for u_phy-otg
2. Moved ulpi_init code into separate function.
3. Initializing all clk and GPIOs in probe.
4. Used devm_  APIs wherever possible.

delta from v2:
Rebased to TOT and applied same changes as on v2.

drivers/usb/host/ehci-tegra.c |   95 +---
 drivers/usb/phy/phy-tegra-usb.c   |  314 +
 include/linux/usb/tegra_usb_phy.h |3 +-
 3 files changed, 218 insertions(+), 194 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index f4b2164..406abd9 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -649,7 +649,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
struct tegra_ehci_platform_data *pdata;
int err = 0;
int irq;
-   int instance = pdev-id;
+   struct device_node *np_phy;
struct usb_phy *u_phy;
 
pdata = pdev-dev.platform_data;
@@ -672,38 +672,49 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!tegra)
return -ENOMEM;
 
-   hcd = usb_create_hcd(tegra_ehci_hc_driver, pdev-dev,
-   dev_name(pdev-dev));
-   if (!hcd) {
-   dev_err(pdev-dev, Unable to create HCD\n);
-   return -ENOMEM;
-   }
-
-   platform_set_drvdata(pdev, tegra);
-
tegra-clk = devm_clk_get(pdev-dev, NULL);
if (IS_ERR(tegra-clk)) {
dev_err(pdev-dev, Can't get ehci clock\n);
-   err = PTR_ERR(tegra-clk);
-   goto fail_clk;
+   return PTR_ERR(tegra-clk);
}
 
err = clk_prepare_enable(tegra-clk);
if (err)
-   goto fail_clk;
+   return err;
 
tegra_periph_reset_assert(tegra-clk);
udelay(1);
tegra_periph_reset_deassert(tegra-clk);
 
+   np_phy = of_parse_phandle(pdev-dev.of_node, nvidia,phy, 0);
+   if (!np_phy) {
+   err = -ENODEV;
+   goto cleanup_clk;
+   }
+
+   u_phy = tegra_usb_get_phy(np_phy);
+   if (IS_ERR(u_phy)) {
+   err = PTR_ERR(u_phy);
+   goto cleanup_clk;
+   }
+
tegra-needs_double_reset = of_property_read_bool(pdev-dev.of_node,
nvidia,needs-double-reset);
 
+   hcd = usb_create_hcd(tegra_ehci_hc_driver, pdev-dev,
+   dev_name(pdev-dev));
+   if (!hcd) {
+   dev_err(pdev-dev, Unable to create HCD\n);
+   err = -ENOMEM;
+   goto cleanup_clk;
+   }
+   hcd-phy = u_phy;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(pdev-dev, Failed to get I/O memory\n);
err = -ENXIO;
-   goto fail_io;
+   goto cleanup_hcd_create;
}
hcd-rsrc_start = res-start;
hcd-rsrc_len = resource_size(res);
@@ -711,55 +722,28 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!hcd-regs) {
dev_err(pdev-dev, Failed to remap I/O memory\n);
err = -ENOMEM;
-   goto fail_io;
-   }
-
-   /* This is pretty ugly and needs to be fixed when we do only
-* device-tree probing. Old code relies on the platform_device
-* numbering that we lack for device-tree-instantiated devices.
-*/
-   if (instance  0) {
-   switch (res-start) {
-   case TEGRA_USB_BASE:
-   instance = 0;
-   break;
-   case TEGRA_USB2_BASE:
-   instance = 1;
-   break;
-   case TEGRA_USB3_BASE:
-   instance = 2;
-   break;
-   default:
-   err = -ENODEV;
-   dev_err(pdev-dev, unknown usb instance\n);
-   goto fail_io;
-   }
+   goto cleanup_hcd_create;
}
 
-   tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
-   pdata-phy_config);
-   if (IS_ERR(tegra-phy)) {
-   dev_err(pdev-dev, Failed to open USB phy\n);
-   err = -ENXIO;
-   goto fail_io;
+   err = usb_phy_init(hcd-phy);
+   if (err) {
+   dev_err(pdev-dev, Failed to initialize phy\n);
+   goto cleanup_hcd_create;
}
 
-   hcd-phy

[PATCH v3 10/10] Usb: Move PORTSC access to PHY

2013-05-10 Thread Venu Byravarasu
Changes with this patch:
1. As PHY is being registered as separate platform driver  EHCI Tegra
is no more calling PHY open, moved tegra_ehci_set_pts  tegra_ehci_set_phcd
functions to PHY driver,

2. Removed unused defines for multiple USB port base addresses

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
This is a new patch being added into the series, to address the revert done
with patch#4 of the series.

 drivers/usb/host/ehci-tegra.c |   49 -
 drivers/usb/phy/phy-tegra-usb.c   |   37 +--
 include/linux/usb/tegra_usb_phy.h |4 ---
 3 files changed, 34 insertions(+), 56 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 406abd9..2340d7a 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -30,15 +30,6 @@
 #include linux/usb/tegra_usb_phy.h
 #include linux/clk/tegra.h
 
-#define TEGRA_USB_BASE 0xC500
-#define TEGRA_USB2_BASE0xC5004000
-#define TEGRA_USB3_BASE0xC5008000
-
-/* PORTSC registers */
-#define TEGRA_USB_PORTSC1  0x184
-#define TEGRA_USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
-#define TEGRA_USB_PORTSC1_PHCD (1  23)
-
 #define TEGRA_USB_DMA_ALIGN 32
 
 struct tegra_ehci_hcd {
@@ -608,37 +599,6 @@ static const struct dev_pm_ops tegra_ehci_pm_ops = {
 
 #endif
 
-/* Bits of PORTSC1, which will get cleared by writing 1 into them */
-#define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
-
-void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
-{
-   unsigned long val;
-   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
-   void __iomem *base = hcd-regs;
-
-   val = readl(base + TEGRA_USB_PORTSC1)  ~TEGRA_PORTSC1_RWC_BITS;
-   val = ~TEGRA_USB_PORTSC1_PTS(3);
-   val |= TEGRA_USB_PORTSC1_PTS(pts_val  3);
-   writel(val, base + TEGRA_USB_PORTSC1);
-}
-EXPORT_SYMBOL_GPL(tegra_ehci_set_pts);
-
-void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
-{
-   unsigned long val;
-   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
-   void __iomem *base = hcd-regs;
-
-   val = readl(base + TEGRA_USB_PORTSC1)  ~TEGRA_PORTSC1_RWC_BITS;
-   if (enable)
-   val |= TEGRA_USB_PORTSC1_PHCD;
-   else
-   val = ~TEGRA_USB_PORTSC1_PHCD;
-   writel(val, base + TEGRA_USB_PORTSC1);
-}
-EXPORT_SYMBOL_GPL(tegra_ehci_set_phcd);
-
 static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32);
 
 static int tegra_ehci_probe(struct platform_device *pdev)
@@ -731,15 +691,6 @@ static int tegra_ehci_probe(struct platform_device *pdev)
goto cleanup_hcd_create;
}
 
-   u_phy-otg = devm_kzalloc(pdev-dev, sizeof(struct usb_otg),
-GFP_KERNEL);
-   if (!u_phy-otg) {
-   dev_err(pdev-dev, Failed to alloc memory for otg\n);
-   err = -ENOMEM;
-   goto cleanup_phy;
-   }
-   u_phy-otg-host = hcd_to_bus(hcd);
-
err = usb_phy_set_suspend(hcd-phy, 0);
if (err) {
dev_err(pdev-dev, Failed to power on the phy\n);
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 4d81b19..b2a909f 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -33,6 +33,7 @@
 #include asm/mach-types.h
 #include linux/usb/tegra_usb_phy.h
 #include linux/module.h
+#include linux/usb/ehci_def.h
 
 #define ULPI_VIEWPORT  0x170
 
@@ -196,6 +197,36 @@ static struct tegra_utmip_config utmip_default[] = {
},
 };
 
+/* PORTSC registers */
+#define TEGRA_USB_PORTSC1  0x184
+#define TEGRA_USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
+#define TEGRA_USB_PORTSC1_PHCD (1  23)
+
+/* Bits of PORTSC1, which will get cleared by writing 1 into them */
+#define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
+
+static void tegra_ehci_set_pts(void __iomem *base, u8 pts_val)
+{
+   unsigned long val;
+
+   val = readl(base + TEGRA_USB_PORTSC1)  ~TEGRA_PORTSC1_RWC_BITS;
+   val = ~TEGRA_USB_PORTSC1_PTS(3);
+   val |= TEGRA_USB_PORTSC1_PTS(pts_val  3);
+   writel(val, base + TEGRA_USB_PORTSC1);
+}
+
+static void tegra_ehci_set_phcd(void __iomem *base, bool enable)
+{
+   unsigned long val;
+
+   val = readl(base + TEGRA_USB_PORTSC1)  ~TEGRA_PORTSC1_RWC_BITS;
+   if (enable)
+   val |= TEGRA_USB_PORTSC1_PHCD;
+   else
+   val = ~TEGRA_USB_PORTSC1_PHCD;
+   writel(val, base + TEGRA_USB_PORTSC1);
+}
+
 static int utmip_pad_open(struct tegra_usb_phy *phy)
 {
phy-pad_clk = devm_clk_get(phy-dev, utmi-pads);
@@ -282,7 +313,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
val = ~USB_SUSP_SET;
writel(val, base + USB_SUSP_CTRL);
} else
-   tegra_ehci_set_phcd(phy-u_phy, true);
+   tegra_ehci_set_phcd(base

[PATCH v3 05/10] usb: phy: tegra: Get PHY mode using DT

2013-05-10 Thread Venu Byravarasu
Added a new PHY mode to support OTG.
Obtained Tegra USB PHY mode using DT property.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:
replaced gadget with peripheral.

delta from v2:
No change

 drivers/usb/host/ehci-tegra.c |3 +--
 drivers/usb/phy/phy-tegra-usb.c   |   13 +++--
 include/linux/usb/tegra_usb_phy.h |3 ++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index ed201ae..f4b2164 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -737,8 +737,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
}
 
tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
-   pdata-phy_config,
-   TEGRA_USB_PHY_MODE_HOST);
+   pdata-phy_config);
if (IS_ERR(tegra-phy)) {
dev_err(pdev-dev, Failed to open USB phy\n);
err = -ENXIO;
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 5487d38..91b6e29 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -688,7 +688,7 @@ static int  tegra_usb_phy_suspend(struct usb_phy *x, int 
suspend)
 }
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-   void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode)
+   void __iomem *regs, void *config)
 {
struct tegra_usb_phy *phy;
unsigned long parent_rate;
@@ -703,7 +703,6 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
phy-instance = instance;
phy-regs = regs;
phy-config = config;
-   phy-mode = phy_mode;
phy-dev = dev;
phy-is_legacy_phy =
of_property_read_bool(np, nvidia,has-legacy-mode);
@@ -713,6 +712,16 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
else
phy-is_ulpi_phy = true;
 
+   err = of_property_match_string(np, dr_mode, otg);
+   if (err  0) {
+   err = of_property_match_string(np, dr_mode, peripheral);
+   if (err  0)
+   phy-mode = TEGRA_USB_PHY_MODE_HOST;
+   else
+   phy-mode = TEGRA_USB_PHY_MODE_DEVICE;
+   } else
+   phy-mode = TEGRA_USB_PHY_MODE_OTG;
+
if (!phy-config) {
if (phy-is_ulpi_phy) {
pr_err(%s: ulpi phy configuration missing, __func__);
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index 9ebebe9..a7af923 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -42,6 +42,7 @@ enum tegra_usb_phy_port_speed {
 enum tegra_usb_phy_mode {
TEGRA_USB_PHY_MODE_DEVICE,
TEGRA_USB_PHY_MODE_HOST,
+   TEGRA_USB_PHY_MODE_OTG,
 };
 
 struct tegra_xtal_freq;
@@ -64,7 +65,7 @@ struct tegra_usb_phy {
 };
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-   void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode);
+   void __iomem *regs, void *config);
 
 void tegra_usb_phy_preresume(struct usb_phy *phy);
 
-- 
1.7.0.4

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


[PATCH v3 06/10] usb: phy: tegra: Return correct error value provided by clk_get_sys

2013-05-10 Thread Venu Byravarasu
In case if clk_get_sys fails, return correct error value provided by
the API.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1  v2: no change.

 drivers/usb/phy/phy-tegra-usb.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 91b6e29..16851e2 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -620,8 +620,7 @@ static int  tegra_phy_init(struct usb_phy *x)
phy-clk = clk_get_sys(NULL, ulpi_config-clk);
if (IS_ERR(phy-clk)) {
pr_err(%s: can't get ulpi clock\n, __func__);
-   err = -ENXIO;
-   goto err1;
+   return PTR_ERR(phy-clk);
}
if (!gpio_is_valid(ulpi_config-reset_gpio))
ulpi_config-reset_gpio =
-- 
1.7.0.4

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


[PATCH v3 08/10] usb: phy: tegra: Add error handling clean up.

2013-05-10 Thread Venu Byravarasu
Check return values from all GPIO APIs and handle errors accordingly.

Remove the call to clk_disable_unprepare(); this function does not
prepare or enable the clock, so the error path should not disable or
unprepare it.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:
no changes.

delta from v2:
Fixed checkpatch warnings.


 drivers/usb/phy/phy-tegra-usb.c |   50 ++
 1 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index a2a89a9..dce692a 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -542,9 +542,17 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
unsigned long val;
void __iomem *base = phy-regs;
 
-   gpio_direction_output(phy-reset_gpio, 0);
+   ret = gpio_direction_output(phy-reset_gpio, 0);
+   if (ret  0) {
+   dev_err(phy-dev, gpio %d not set to 0\n, phy-reset_gpio);
+   return ret;
+   }
msleep(5);
-   gpio_direction_output(phy-reset_gpio, 1);
+   ret = gpio_direction_output(phy-reset_gpio, 1);
+   if (ret  0) {
+   dev_err(phy-dev, gpio %d not set to 1\n, phy-reset_gpio);
+   return ret;
+   }
 
clk_prepare_enable(phy-clk);
msleep(1);
@@ -624,24 +632,44 @@ static inttegra_phy_init(struct usb_phy *x)
of_get_named_gpio(phy-dev-of_node,
  nvidia,phy-reset-gpio, 0);
if (!gpio_is_valid(phy-reset_gpio)) {
-   pr_err(%s: invalid reset gpio: %d\n, __func__,
+   dev_err(phy-dev, invalid gpio: %d\n,
+   phy-reset_gpio);
+   err = phy-reset_gpio;
+   goto cleanup_clk_get;
+   }
+
+   err = gpio_request(phy-reset_gpio, ulpi_phy_reset_b);
+   if (err  0) {
+   dev_err(phy-dev, request failed for gpio: %d\n,
   phy-reset_gpio);
-   err = -EINVAL;
-   goto err1;
+   goto cleanup_clk_get;
+   }
+
+   err = gpio_direction_output(phy-reset_gpio, 0);
+   if (err  0) {
+   dev_err(phy-dev, gpio %d direction not set to 
output\n,
+  phy-reset_gpio);
+   goto cleanup_gpio_req;
}
-   gpio_request(phy-reset_gpio, ulpi_phy_reset_b);
-   gpio_direction_output(phy-reset_gpio, 0);
+
phy-ulpi = otg_ulpi_create(ulpi_viewport_access_ops, 0);
+   if (!phy-ulpi) {
+   dev_err(phy-dev, otg_ulpi_create returned err\n);
+   err = -ENOMEM;
+   goto cleanup_gpio_req;
+   }
+
phy-ulpi-io_priv = phy-regs + ULPI_VIEWPORT;
} else {
err = utmip_pad_open(phy);
if (err  0)
-   goto err1;
+   return err;
}
return 0;
-err1:
-   clk_disable_unprepare(phy-pll_u);
-   clk_put(phy-pll_u);
+cleanup_gpio_req:
+   gpio_free(phy-reset_gpio);
+cleanup_clk_get:
+   clk_put(phy-clk);
return err;
 }
 
-- 
1.7.0.4

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


[PATCH v3 07/10] usb: phy: tegra: get ULPI reset GPIO info using DT.

2013-05-10 Thread Venu Byravarasu
As GPIO information is avail through DT, used it to get Tegra ULPI
reset GPIO number. Added a new member to tegra_usb_phy structure to
store this number.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1  v2: no change.

 drivers/usb/phy/phy-tegra-usb.c   |   25 +++--
 include/linux/usb/tegra_usb_phy.h |1 +
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 16851e2..a2a89a9 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -541,11 +541,10 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
int ret;
unsigned long val;
void __iomem *base = phy-regs;
-   struct tegra_ulpi_config *config = phy-config;
 
-   gpio_direction_output(config-reset_gpio, 0);
+   gpio_direction_output(phy-reset_gpio, 0);
msleep(5);
-   gpio_direction_output(config-reset_gpio, 1);
+   gpio_direction_output(phy-reset_gpio, 1);
 
clk_prepare_enable(phy-clk);
msleep(1);
@@ -603,10 +602,8 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
 
 static int ulpi_phy_power_off(struct tegra_usb_phy *phy)
 {
-   struct tegra_ulpi_config *config = phy-config;
-
clk_disable(phy-clk);
-   return gpio_direction_output(config-reset_gpio, 0);
+   return gpio_direction_output(phy-reset_gpio, 0);
 }
 
 static int tegra_phy_init(struct usb_phy *x)
@@ -622,18 +619,18 @@ static inttegra_phy_init(struct usb_phy *x)
pr_err(%s: can't get ulpi clock\n, __func__);
return PTR_ERR(phy-clk);
}
-   if (!gpio_is_valid(ulpi_config-reset_gpio))
-   ulpi_config-reset_gpio =
-   of_get_named_gpio(phy-dev-of_node,
- nvidia,phy-reset-gpio, 0);
-   if (!gpio_is_valid(ulpi_config-reset_gpio)) {
+
+   phy-reset_gpio =
+   of_get_named_gpio(phy-dev-of_node,
+ nvidia,phy-reset-gpio, 0);
+   if (!gpio_is_valid(phy-reset_gpio)) {
pr_err(%s: invalid reset gpio: %d\n, __func__,
-  ulpi_config-reset_gpio);
+  phy-reset_gpio);
err = -EINVAL;
goto err1;
}
-   gpio_request(ulpi_config-reset_gpio, ulpi_phy_reset_b);
-   gpio_direction_output(ulpi_config-reset_gpio, 0);
+   gpio_request(phy-reset_gpio, ulpi_phy_reset_b);
+   gpio_direction_output(phy-reset_gpio, 0);
phy-ulpi = otg_ulpi_create(ulpi_viewport_access_ops, 0);
phy-ulpi-io_priv = phy-regs + ULPI_VIEWPORT;
} else {
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index a7af923..6cfb8f1 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -62,6 +62,7 @@ struct tegra_usb_phy {
struct device *dev;
bool is_legacy_phy;
bool is_ulpi_phy;
+   int reset_gpio;
 };
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-- 
1.7.0.4

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


[PATCH v3 04/10] Revert usb: phy: tegra: don't call into tegra-ehci directly

2013-05-10 Thread Venu Byravarasu
This reverts commit ee5d5499edb94cd03738a52a7e234b139da8fd72.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
As PHY is being registered as separate driver, solution proposed with
this patch cannot work anymore.
Hence pushed patch 10 of this series to address the issue.

 drivers/usb/host/ehci-tegra.c |   10 +-
 drivers/usb/phy/phy-tegra-usb.c   |   13 -
 include/linux/usb/tegra_usb_phy.h |   10 +-
 3 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index e3eddc3..ed201ae 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -611,7 +611,7 @@ static const struct dev_pm_ops tegra_ehci_pm_ops = {
 /* Bits of PORTSC1, which will get cleared by writing 1 into them */
 #define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
 
-static void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
+void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
 {
unsigned long val;
struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
@@ -622,8 +622,9 @@ static void tegra_ehci_set_pts(struct usb_phy *x, u8 
pts_val)
val |= TEGRA_USB_PORTSC1_PTS(pts_val  3);
writel(val, base + TEGRA_USB_PORTSC1);
 }
+EXPORT_SYMBOL_GPL(tegra_ehci_set_pts);
 
-static void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
+void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
 {
unsigned long val;
struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
@@ -636,6 +637,7 @@ static void tegra_ehci_set_phcd(struct usb_phy *x, bool 
enable)
val = ~TEGRA_USB_PORTSC1_PHCD;
writel(val, base + TEGRA_USB_PORTSC1);
 }
+EXPORT_SYMBOL_GPL(tegra_ehci_set_phcd);
 
 static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32);
 
@@ -736,9 +738,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 
tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
pdata-phy_config,
-   TEGRA_USB_PHY_MODE_HOST,
-   tegra_ehci_set_pts,
-   tegra_ehci_set_phcd);
+   TEGRA_USB_PHY_MODE_HOST);
if (IS_ERR(tegra-phy)) {
dev_err(pdev-dev, Failed to open USB phy\n);
err = -ENXIO;
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 17d8112..5487d38 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -299,7 +299,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
val = ~USB_SUSP_SET;
writel(val, base + USB_SUSP_CTRL);
} else
-   phy-set_phcd(phy-u_phy, true);
+   tegra_ehci_set_phcd(phy-u_phy, true);
 
if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0)  0)
pr_err(%s: timeout waiting for phy to stabilize\n, __func__);
@@ -321,7 +321,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
val = ~USB_SUSP_CLR;
writel(val, base + USB_SUSP_CTRL);
} else
-   phy-set_phcd(phy-u_phy, false);
+   tegra_ehci_set_phcd(phy-u_phy, false);
 
if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID,
 USB_PHY_CLK_VALID))
@@ -444,7 +444,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
utmi_phy_clk_enable(phy);
 
if (!phy-is_legacy_phy)
-   phy-set_pts(phy-u_phy, 0);
+   tegra_ehci_set_pts(phy-u_phy, 0);
 
return 0;
 }
@@ -688,10 +688,7 @@ static int tegra_usb_phy_suspend(struct usb_phy *x, int 
suspend)
 }
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-   void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode,
-   void (*set_pts)(struct usb_phy *x, u8 pts_val),
-   void (*set_phcd)(struct usb_phy *x, bool enable))
-
+   void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode)
 {
struct tegra_usb_phy *phy;
unsigned long parent_rate;
@@ -710,8 +707,6 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
phy-dev = dev;
phy-is_legacy_phy =
of_property_read_bool(np, nvidia,has-legacy-mode);
-   phy-set_pts = set_pts;
-   phy-set_phcd = set_phcd;
err = of_property_match_string(np, phy_type, ulpi);
if (err  0)
phy-is_ulpi_phy = false;
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index 1b7519a..9ebebe9 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -61,14 +61,10 @@ struct tegra_usb_phy {
struct device *dev;
bool is_legacy_phy;
bool is_ulpi_phy;
-   void (*set_pts)(struct usb_phy *x, u8 pts_val);
-   void

[PATCH v3 02/10] arm: dt: Tegra20: Modify ULPI reset GPIO properties

2013-05-10 Thread Venu Byravarasu
changes with this patch:
1. All Tegra20 ULPI reset GPIO DT properties are modified to indicate active
low nature of the GPIO.
2. Placed USB PHY DT node immediately below the EHCI controller DT nodes
and corrected reg value in the name of USB PHY DT node.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
Created this patch as per comments received at:
http://marc.info/?l=linux-usbm=136501761810344w=2

 arch/arm/boot/dts/tegra20-colibri-512.dtsi |6 +-
 arch/arm/boot/dts/tegra20-harmony.dts  |   10 +-
 arch/arm/boot/dts/tegra20-paz00.dts|   10 +-
 arch/arm/boot/dts/tegra20-seaboard.dts |   10 +-
 arch/arm/boot/dts/tegra20-trimslice.dts|   10 +-
 arch/arm/boot/dts/tegra20-ventana.dts  |   10 +-
 6 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/arch/arm/boot/dts/tegra20-colibri-512.dtsi 
b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
index a573b94..c12af78 100644
--- a/arch/arm/boot/dts/tegra20-colibri-512.dtsi
+++ b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
@@ -449,7 +449,11 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
+   };
+
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
sdhci@c8000600 {
diff --git a/arch/arm/boot/dts/tegra20-harmony.dts 
b/arch/arm/boot/dts/tegra20-harmony.dts
index e7d5de4..e84f3f6 100644
--- a/arch/arm/boot/dts/tegra20-harmony.dts
+++ b/arch/arm/boot/dts/tegra20-harmony.dts
@@ -430,15 +430,15 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c8000200 {
diff --git a/arch/arm/boot/dts/tegra20-paz00.dts 
b/arch/arm/boot/dts/tegra20-paz00.dts
index e3e0c99..e9ac2a9 100644
--- a/arch/arm/boot/dts/tegra20-paz00.dts
+++ b/arch/arm/boot/dts/tegra20-paz00.dts
@@ -429,15 +429,15 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts 
b/arch/arm/boot/dts/tegra20-seaboard.dts
index cee4c34..9dd4f8e 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -571,15 +571,15 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 1; /* gpio PV1, active low 
*/
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
diff --git a/arch/arm/boot/dts/tegra20-trimslice.dts 
b/arch/arm/boot/dts/tegra20-trimslice.dts
index 9cc78a1..fd7afd6 100644
--- a/arch/arm/boot/dts/tegra20-trimslice.dts
+++ b/arch/arm/boot/dts/tegra20-trimslice.dts
@@ -316,15 +316,15 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
diff --git a/arch/arm/boot/dts/tegra20-ventana.dts 
b/arch/arm/boot/dts/tegra20-ventana.dts
index dd38f1f..a75a0e7 100644
--- a/arch/arm/boot/dts/tegra20-ventana.dts
+++ b/arch/arm/boot/dts/tegra20-ventana.dts
@@ -507,15 +507,15 @@
 
usb@c5004000 {
status = okay;
-   nvidia,phy

[PATCH v3 03/10] ARM: tegra: update device trees for USB binding rework

2013-05-10 Thread Venu Byravarasu
This patch updates all Tegra board files so that they contain all the
properties required by the updated USB DT binding. Note that this patch
only adds the new properties and does not yet remove the old properties,
in order to maintain bisectability. The old properties will be removed
once the driver has been updated to assume the new bindings.

The only exception is otg property which was removed, as VBUS details
for all the boards are not known. This should not affect for those boards
in any way, as otg is not really supported in Tegra20 USB driver, though
it was set in DT properties.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:
1. Fixed voltage regulators were used for vbus-supply
2. Added UTMI PHY timing Parameters to DT.

delta from v2:
1. Removed dr_mode setting to otg, due to:
  a. Any ways existing Tegra USB driver does not support OTG.
  b. lack of knowledge of all Vbus supplies, on all target platforms.
Once real OTG support is added to Tegra USB driver, then this property can be
 set back to otg, for target platforms.

2. All changes related to 'nvidia,phy-reset-gpio' were moved to patch 2 of the
 same series.

 arch/arm/boot/dts/tegra20-iris-512.dts  |1 -
 arch/arm/boot/dts/tegra20-seaboard.dts  |   14 +-
 arch/arm/boot/dts/tegra20-trimslice.dts |   13 +
 arch/arm/boot/dts/tegra20-whistler.dts  |   26 +
 arch/arm/boot/dts/tegra20.dtsi  |   46 +++
 5 files changed, 86 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boot/dts/tegra20-iris-512.dts 
b/arch/arm/boot/dts/tegra20-iris-512.dts
index 52f1103..b7f71e8 100644
--- a/arch/arm/boot/dts/tegra20-iris-512.dts
+++ b/arch/arm/boot/dts/tegra20-iris-512.dts
@@ -38,7 +38,6 @@
 
usb@c500 {
status = okay;
-   dr_mode = otg;
};
 
usb@c5008000 {
diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts 
b/arch/arm/boot/dts/tegra20-seaboard.dts
index 9dd4f8e..d51e969 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -566,7 +566,10 @@
usb@c500 {
status = okay;
nvidia,vbus-gpio = gpio 24 0; /* PD0 */
-   dr_mode = otg;
+   };
+
+   usb-phy@c500 {
+   vbus-supply = vbus_reg;
};
 
usb@c5004000 {
@@ -807,6 +810,15 @@
gpio = pmic 1 0;
enable-active-high;
};
+
+   vbus_reg: regulator@3 {
+   compatible = regulator-fixed;
+   reg = 3;
+   regulator-name = vdd_5v0;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   gpio = gpio 24 0; /* PD0 */
+   };
};
 
sound {
diff --git a/arch/arm/boot/dts/tegra20-trimslice.dts 
b/arch/arm/boot/dts/tegra20-trimslice.dts
index fd7afd6..85699f0 100644
--- a/arch/arm/boot/dts/tegra20-trimslice.dts
+++ b/arch/arm/boot/dts/tegra20-trimslice.dts
@@ -314,6 +314,10 @@
nvidia,vbus-gpio = gpio 170 0; /* gpio PV2 */
};
 
+   usb-phy@c500 {
+   vbus-supply = vbus_reg;
+   };
+
usb@c5004000 {
status = okay;
nvidia,phy-reset-gpio = gpio 168 1; /* gpio PV0, active low 
*/
@@ -390,6 +394,15 @@
regulator-max-microvolt = 180;
regulator-always-on;
};
+
+   vbus_reg: regulator@2 {
+   compatible = regulator-fixed;
+   reg = 2;
+   regulator-name = vdd_5v0;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   gpio = gpio 170 0; /* PV2 */
+   };
};
 
sound {
diff --git a/arch/arm/boot/dts/tegra20-whistler.dts 
b/arch/arm/boot/dts/tegra20-whistler.dts
index d2567f8..9aec63a 100644
--- a/arch/arm/boot/dts/tegra20-whistler.dts
+++ b/arch/arm/boot/dts/tegra20-whistler.dts
@@ -511,11 +511,19 @@
nvidia,vbus-gpio = tca6416 0 0; /* GPIO_PMU0 */
};
 
+   usb-phy@c500 {
+   vbus-supply = vbus_reg1;
+   };
+
usb@c5008000 {
status = okay;
nvidia,vbus-gpio = tca6416 1 0; /* GPIO_PMU1 */
};
 
+   usb-phy@c5008000 {
+   vbus-supply = vbus_reg2;
+   };
+
sdhci@c8000400 {
status = okay;
cd-gpios = gpio 69 1; /* gpio PI5 */
@@ -568,6 +576,24 @@
regulator-max-microvolt = 500;
regulator-always-on;
};
+
+   vbus_reg1: regulator@2 {
+   compatible = regulator-fixed;
+   reg = 2;
+   regulator

RE: [PATCH v2 1/7] ARM: tegra: finalize USB EHCI and PHY bindings

2013-04-04 Thread Venu Byravarasu
 -Original Message-
 From: linux-tegra-ow...@vger.kernel.org [mailto:linux-tegra-
 ow...@vger.kernel.org] On Behalf Of Stephen Warren
 Sent: Thursday, April 04, 2013 12:38 AM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; ba...@ti.com;
 st...@rowland.harvard.edu; linux-te...@vger.kernel.org; linux-
 u...@vger.kernel.org; linux-ker...@vger.kernel.org
 Subject: Re: [PATCH v2 1/7] ARM: tegra: finalize USB EHCI and PHY bindings
 
 On 04/03/2013 02:41 AM, Venu Byravarasu wrote:
  The existing Tegra USB bindings have a few issues:
 ...
  This patch fixes the binding definition to resolve these issues.
 
  diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-
 phy.txt b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-
 phy.txt
 
   Required properties :
 ...
  +  - vbus-supply: regulator for VBUS
 
 Doesn't the driver only need to control VBUS if the port is in OTG mode?
 
 If there is no VBUS control, and the HW provides VBUS, I think that the
 port can only operate in host mode.
 
 If there is no VBUS control, and the HW does not provide VBUS, I think
 that the port can only operate in peripheral mode.
 
 If there is VBUS control, then shouldn't the port always operate in OTG
 mode, or are there other reasons to control VBUS even in host-only mode?
 
 If VBUS control is only useful for OTG mode, then I think the
 vbus-supply property should be documented in a Required properties for
 dr_mode == otg section.

Agree, will do it in next patch update.

 
 I assume that VBUS control makes no sense for a peripheral-mode-only
 port, so if VBUS control is useful for host-only mode as well as OTG
 mode, then I think the vbus-supply property should be documented in a
 Required properties for dr_mode != peripheral section.
 
 Is the following table correct?
 
 Port operating mode:  hostperipheral  otg
   --  ---
 VBUS control required:no  no  yes
 VBUS control useful:  yes[1]? no  yes
 
 [1] perhaps for power-saving/suspend???
 
For waking system up from sleep via devices connected to USB, I think Vbus is 
always
kept ON in host mode. 

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


RE: [PATCH v2 6/7] usb: phy: tegra: Add error handling clean up.

2013-04-04 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Thursday, April 04, 2013 1:06 AM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; ba...@ti.com;
 st...@rowland.harvard.edu; linux-te...@vger.kernel.org; linux-
 u...@vger.kernel.org; linux-ker...@vger.kernel.org
 Subject: Re: [PATCH v2 6/7] usb: phy: tegra: Add error handling  clean up.
 
 On 04/03/2013 02:41 AM, Venu Byravarasu wrote:
  Check return values from all GPIO APIs and handle errors accordingly.
  Remove clk_disable_unprepare which is no more needed.
 
 checkpatch fails:

As these are checkpatch warnings only, did not pay much attention on that.
Any how will fix it in next update.

 
  WARNING: line over 80 characters
  #27: FILE: drivers/usb/phy/phy-tegra-usb.c:547:
  +   dev_err(phy-dev, gpio %d direction not set\n, phy-
 reset_gpio);
 
  WARNING: line over 80 characters
  #34: FILE: drivers/usb/phy/phy-tegra-usb.c:553:
  +   dev_err(phy-dev, gpio %d direction not set\n, phy-
 reset_gpio);
 
  total: 0 errors, 2 warnings, 72 lines checked
 
  0006-usb-phy-tegra-Add-error-handling-clean-up.patch has style problems,
 please review.

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


RE: [PATCH v2 2/7] ARM: tegra: update device trees for USB binding rework

2013-04-04 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Thursday, April 04, 2013 12:47 AM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; ba...@ti.com;
 st...@rowland.harvard.edu; linux-te...@vger.kernel.org; linux-
 u...@vger.kernel.org; linux-ker...@vger.kernel.org
 Subject: Re: [PATCH v2 2/7] ARM: tegra: update device trees for USB binding
 rework
 
 On 04/03/2013 02:41 AM, Venu Byravarasu wrote:
  This patch updates all Tegra board files so that they contain all the
 
 The binding documentation says that the vbus-supply property is required
 in all cases. However, many of the DT files still don't have that
 property even after this patch. That's inconsistent.

Will edit the binding to have the vbus-supply only for otg cases. 

 
  diff --git a/arch/arm/boot/dts/tegra20-iris-512.dts
 b/arch/arm/boot/dts/tegra20-iris-512.dts
  index 52f1103..c99eccc 100644
  --- a/arch/arm/boot/dts/tegra20-iris-512.dts
  +++ b/arch/arm/boot/dts/tegra20-iris-512.dts
  @@ -41,6 +41,10 @@
  dr_mode = otg;
  };
 
  +   usb-phy@c500 {
  +   dr_mode = otg;
  +   };
 
 Since this port claims to be OTG-capable, presumably a vbus-supply
 property is mandatory here? If you don't know enough about the board to
 correctly set up such a regulator, lets just mark this port as host-only
 for now; we can switch it back to OTG-mode later once someone implements
 the required regulator. This won't lose any functionality, since we
 don't support OTG-mode yet anyway. However, it will allow the device
 tree to be correct/consistent in the mean time.
 
Agree completely.
Will update the patch accordingly and send for review.

 
  diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts
 b/arch/arm/boot/dts/tegra20-seaboard.dts
 
  +   usb-phy@c500 {
  +   vbus-supply = vbus_reg;
  +   dr_mode = otg;
  +   };
 
 Where is the nvidia,vbus-gpio property? Since your code changes don't
 actually implement use of the vbus-supply property yet, they will expect
 the vbus-gpio property to exist in the PHY node.

As of now Vbus-gpio is being used by EHCI driver only.
As anyways we wanted to use vbus-supply, will implement its
support in PHY driver and remove vbus-gpio from EHCI node. 
Hence did not add vbus-gpio to PHY DT nodes.

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


[PATCH v2 5/7] usb: phy: tegra: get ULPI reset GPIO info using DT.

2013-04-03 Thread Venu Byravarasu
As GPIO information is avail through DT, used it to get Tegra ULPI
reset GPIO number. Added a new member to tegra_usb_phy structure to
store this number.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v2: no change.

 drivers/usb/phy/phy-tegra-usb.c   |   25 +++--
 include/linux/usb/tegra_usb_phy.h |1 +
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 16851e2..a2a89a9 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -541,11 +541,10 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
int ret;
unsigned long val;
void __iomem *base = phy-regs;
-   struct tegra_ulpi_config *config = phy-config;
 
-   gpio_direction_output(config-reset_gpio, 0);
+   gpio_direction_output(phy-reset_gpio, 0);
msleep(5);
-   gpio_direction_output(config-reset_gpio, 1);
+   gpio_direction_output(phy-reset_gpio, 1);
 
clk_prepare_enable(phy-clk);
msleep(1);
@@ -603,10 +602,8 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
 
 static int ulpi_phy_power_off(struct tegra_usb_phy *phy)
 {
-   struct tegra_ulpi_config *config = phy-config;
-
clk_disable(phy-clk);
-   return gpio_direction_output(config-reset_gpio, 0);
+   return gpio_direction_output(phy-reset_gpio, 0);
 }
 
 static int tegra_phy_init(struct usb_phy *x)
@@ -622,18 +619,18 @@ static inttegra_phy_init(struct usb_phy *x)
pr_err(%s: can't get ulpi clock\n, __func__);
return PTR_ERR(phy-clk);
}
-   if (!gpio_is_valid(ulpi_config-reset_gpio))
-   ulpi_config-reset_gpio =
-   of_get_named_gpio(phy-dev-of_node,
- nvidia,phy-reset-gpio, 0);
-   if (!gpio_is_valid(ulpi_config-reset_gpio)) {
+
+   phy-reset_gpio =
+   of_get_named_gpio(phy-dev-of_node,
+ nvidia,phy-reset-gpio, 0);
+   if (!gpio_is_valid(phy-reset_gpio)) {
pr_err(%s: invalid reset gpio: %d\n, __func__,
-  ulpi_config-reset_gpio);
+  phy-reset_gpio);
err = -EINVAL;
goto err1;
}
-   gpio_request(ulpi_config-reset_gpio, ulpi_phy_reset_b);
-   gpio_direction_output(ulpi_config-reset_gpio, 0);
+   gpio_request(phy-reset_gpio, ulpi_phy_reset_b);
+   gpio_direction_output(phy-reset_gpio, 0);
phy-ulpi = otg_ulpi_create(ulpi_viewport_access_ops, 0);
phy-ulpi-io_priv = phy-regs + ULPI_VIEWPORT;
} else {
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index a7af923..6cfb8f1 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -62,6 +62,7 @@ struct tegra_usb_phy {
struct device *dev;
bool is_legacy_phy;
bool is_ulpi_phy;
+   int reset_gpio;
 };
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-- 
1.7.0.4

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


[PATCH v2 6/7] usb: phy: tegra: Add error handling clean up.

2013-04-03 Thread Venu Byravarasu
Check return values from all GPIO APIs and handle errors accordingly.
Remove clk_disable_unprepare which is no more needed.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v2: no change.

 drivers/usb/phy/phy-tegra-usb.c |   50 ++
 1 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index a2a89a9..01c5e23 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -542,9 +542,17 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
unsigned long val;
void __iomem *base = phy-regs;
 
-   gpio_direction_output(phy-reset_gpio, 0);
+   ret = gpio_direction_output(phy-reset_gpio, 0);
+   if (ret  0) {
+   dev_err(phy-dev, gpio %d direction not set\n, 
phy-reset_gpio);
+   return ret;
+   }
msleep(5);
-   gpio_direction_output(phy-reset_gpio, 1);
+   ret = gpio_direction_output(phy-reset_gpio, 1);
+   if (ret  0) {
+   dev_err(phy-dev, gpio %d direction not set\n, 
phy-reset_gpio);
+   return ret;
+   }
 
clk_prepare_enable(phy-clk);
msleep(1);
@@ -624,24 +632,44 @@ static inttegra_phy_init(struct usb_phy *x)
of_get_named_gpio(phy-dev-of_node,
  nvidia,phy-reset-gpio, 0);
if (!gpio_is_valid(phy-reset_gpio)) {
-   pr_err(%s: invalid reset gpio: %d\n, __func__,
+   dev_err(phy-dev, invalid gpio: %d\n,
+   phy-reset_gpio);
+   err = phy-reset_gpio;
+   goto cleanup_clk_get;
+   }
+
+   err = gpio_request(phy-reset_gpio, ulpi_phy_reset_b);
+   if (err  0) {
+   dev_err(phy-dev, request failed for gpio: %d\n,
   phy-reset_gpio);
-   err = -EINVAL;
-   goto err1;
+   goto cleanup_clk_get;
+   }
+
+   err = gpio_direction_output(phy-reset_gpio, 0);
+   if (err  0) {
+   dev_err(phy-dev, gpio %d direction not set to 
output\n,
+  phy-reset_gpio);
+   goto cleanup_gpio_req;
}
-   gpio_request(phy-reset_gpio, ulpi_phy_reset_b);
-   gpio_direction_output(phy-reset_gpio, 0);
+
phy-ulpi = otg_ulpi_create(ulpi_viewport_access_ops, 0);
+   if (!phy-ulpi) {
+   dev_err(phy-dev, otg_ulpi_create returned err\n);
+   err = -ENOMEM;
+   goto cleanup_gpio_req;
+   }
+
phy-ulpi-io_priv = phy-regs + ULPI_VIEWPORT;
} else {
err = utmip_pad_open(phy);
if (err  0)
-   goto err1;
+   return err;
}
return 0;
-err1:
-   clk_disable_unprepare(phy-pll_u);
-   clk_put(phy-pll_u);
+cleanup_gpio_req:
+   gpio_free(phy-reset_gpio);
+cleanup_clk_get:
+   clk_put(phy-clk);
return err;
 }
 
-- 
1.7.0.4

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


[PATCH v2 7/7] usb: phy: registering Tegra USB PHY as platform driver

2013-04-03 Thread Venu Byravarasu
Registered Tegra USB PHY as a separate platform driver.

To synchronize host controller and PHY initialization, used deferred
probe mechanism. As PHY should be initialized before EHCI starts running,
deferred probe of Tegra EHCI driver till PHY probe gets completed.

Got rid of instance number based handling in host driver.

Made use of DT params to get the PHY Pad registers.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:
1. Removed extra memory allocation for u_phy-otg
2. Moved ulpi_init code into separate function.
3. Initializing all clk and GPIOs in probe.
4. Used devm_  APIs wherever possible.

 drivers/usb/host/ehci-tegra.c |   94 +---
 drivers/usb/phy/phy-tegra-usb.c   |  314 +
 include/linux/usb/tegra_usb_phy.h |3 +-
 3 files changed, 218 insertions(+), 193 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index afe9629..11f125f 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -648,7 +648,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
struct tegra_ehci_platform_data *pdata;
int err = 0;
int irq;
-   int instance = pdev-id;
+   struct device_node *np_phy;
struct usb_phy *u_phy;
 
pdata = pdev-dev.platform_data;
@@ -671,34 +671,45 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!tegra)
return -ENOMEM;
 
-   hcd = usb_create_hcd(tegra_ehci_hc_driver, pdev-dev,
-   dev_name(pdev-dev));
-   if (!hcd) {
-   dev_err(pdev-dev, Unable to create HCD\n);
-   return -ENOMEM;
-   }
-
-   platform_set_drvdata(pdev, tegra);
-
tegra-clk = devm_clk_get(pdev-dev, NULL);
if (IS_ERR(tegra-clk)) {
dev_err(pdev-dev, Can't get ehci clock\n);
-   err = PTR_ERR(tegra-clk);
-   goto fail_clk;
+   return PTR_ERR(tegra-clk);
}
 
err = clk_prepare_enable(tegra-clk);
if (err)
-   goto fail_clk;
+   return err;
+
+   np_phy = of_parse_phandle(pdev-dev.of_node, nvidia,phy, 0);
+   if (!np_phy) {
+   err = -ENODEV;
+   goto cleanup_clk;
+   }
+
+   u_phy = tegra_usb_get_phy(np_phy);
+   if (IS_ERR(u_phy)) {
+   err = PTR_ERR(u_phy);
+   goto cleanup_clk;
+   }
 
tegra-needs_double_reset = of_property_read_bool(pdev-dev.of_node,
nvidia,needs-double-reset);
 
+   hcd = usb_create_hcd(tegra_ehci_hc_driver, pdev-dev,
+   dev_name(pdev-dev));
+   if (!hcd) {
+   dev_err(pdev-dev, Unable to create HCD\n);
+   err = -ENOMEM;
+   goto cleanup_clk;
+   }
+   hcd-phy = u_phy;
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(pdev-dev, Failed to get I/O memory\n);
err = -ENXIO;
-   goto fail_io;
+   goto cleanup_hcd_create;
}
hcd-rsrc_start = res-start;
hcd-rsrc_len = resource_size(res);
@@ -706,55 +717,28 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!hcd-regs) {
dev_err(pdev-dev, Failed to remap I/O memory\n);
err = -ENOMEM;
-   goto fail_io;
-   }
-
-   /* This is pretty ugly and needs to be fixed when we do only
-* device-tree probing. Old code relies on the platform_device
-* numbering that we lack for device-tree-instantiated devices.
-*/
-   if (instance  0) {
-   switch (res-start) {
-   case TEGRA_USB_BASE:
-   instance = 0;
-   break;
-   case TEGRA_USB2_BASE:
-   instance = 1;
-   break;
-   case TEGRA_USB3_BASE:
-   instance = 2;
-   break;
-   default:
-   err = -ENODEV;
-   dev_err(pdev-dev, unknown usb instance\n);
-   goto fail_io;
-   }
+   goto cleanup_hcd_create;
}
 
-   tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
-   pdata-phy_config);
-   if (IS_ERR(tegra-phy)) {
-   dev_err(pdev-dev, Failed to open USB phy\n);
-   err = -ENXIO;
-   goto fail_io;
+   err = usb_phy_init(hcd-phy);
+   if (err) {
+   dev_err(pdev-dev, Failed to initialize phy\n);
+   goto cleanup_hcd_create;
}
 
-   hcd-phy = u_phy = tegra-phy-u_phy;
-   usb_phy_init(hcd-phy);
-
u_phy-otg = devm_kzalloc(pdev-dev, sizeof(struct usb_otg),
 GFP_KERNEL

[PATCH v2 4/7] usb: phy: tegra: Return correct error value provided by clk_get_sys

2013-04-03 Thread Venu Byravarasu
In case if clk_get_sys fails, return correct error value provided by
the API.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1: no change.

 drivers/usb/phy/phy-tegra-usb.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 91b6e29..16851e2 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -620,8 +620,7 @@ static int  tegra_phy_init(struct usb_phy *x)
phy-clk = clk_get_sys(NULL, ulpi_config-clk);
if (IS_ERR(phy-clk)) {
pr_err(%s: can't get ulpi clock\n, __func__);
-   err = -ENXIO;
-   goto err1;
+   return PTR_ERR(phy-clk);
}
if (!gpio_is_valid(ulpi_config-reset_gpio))
ulpi_config-reset_gpio =
-- 
1.7.0.4

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


[PATCH v2 2/7] ARM: tegra: update device trees for USB binding rework

2013-04-03 Thread Venu Byravarasu
This patch updates all Tegra board files so that they contain all the
properties required by the updated USB DT binding. Note that this patch
only adds the new properties and does not yet remove the old properties,
in order to maintain bisectability. The old properties will be removed
once the driver has been updated to assume the new bindings.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:
1. Fixed voltage regulators were used for vbus-supply
2. Added UTMI PHY timing Parameters to DT.

 arch/arm/boot/dts/tegra20-colibri-512.dtsi |4 ++
 arch/arm/boot/dts/tegra20-harmony.dts  |8 ++--
 arch/arm/boot/dts/tegra20-iris-512.dts |4 ++
 arch/arm/boot/dts/tegra20-paz00.dts|8 ++--
 arch/arm/boot/dts/tegra20-seaboard.dts |   22 +++--
 arch/arm/boot/dts/tegra20-trimslice.dts|   21 ++--
 arch/arm/boot/dts/tegra20-ventana.dts  |7 ++--
 arch/arm/boot/dts/tegra20.dtsi |   46 ---
 8 files changed, 89 insertions(+), 31 deletions(-)

diff --git a/arch/arm/boot/dts/tegra20-colibri-512.dtsi 
b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
index cb73e62..af5a7ae 100644
--- a/arch/arm/boot/dts/tegra20-colibri-512.dtsi
+++ b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
@@ -443,6 +443,10 @@
nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
};
 
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   };
+
sdhci@c8000600 {
cd-gpios = gpio 23 1; /* gpio PC7 */
};
diff --git a/arch/arm/boot/dts/tegra20-harmony.dts 
b/arch/arm/boot/dts/tegra20-harmony.dts
index 5fb0888..3454ce2 100644
--- a/arch/arm/boot/dts/tegra20-harmony.dts
+++ b/arch/arm/boot/dts/tegra20-harmony.dts
@@ -427,12 +427,12 @@
nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c8000200 {
diff --git a/arch/arm/boot/dts/tegra20-iris-512.dts 
b/arch/arm/boot/dts/tegra20-iris-512.dts
index 52f1103..c99eccc 100644
--- a/arch/arm/boot/dts/tegra20-iris-512.dts
+++ b/arch/arm/boot/dts/tegra20-iris-512.dts
@@ -41,6 +41,10 @@
dr_mode = otg;
};
 
+   usb-phy@c500 {
+   dr_mode = otg;
+   };
+
usb@c5008000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/tegra20-paz00.dts 
b/arch/arm/boot/dts/tegra20-paz00.dts
index 43fd28b..cc76129 100644
--- a/arch/arm/boot/dts/tegra20-paz00.dts
+++ b/arch/arm/boot/dts/tegra20-paz00.dts
@@ -426,12 +426,12 @@
nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts 
b/arch/arm/boot/dts/tegra20-seaboard.dts
index 4f810a5..d234766 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -563,17 +563,22 @@
dr_mode = otg;
};
 
+   usb-phy@c500 {
+   vbus-supply = vbus_reg;
+   dr_mode = otg;
+   };
+
usb@c5004000 {
status = okay;
nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
@@ -786,6 +791,15 @@
gpio = pmic 1 0;
enable-active-high;
};
+
+   vbus_reg: regulator@3 {
+   compatible = regulator-fixed;
+   reg = 3;
+   regulator-name = vdd_5v0;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   gpio = gpio 24 0; /* PD0 */
+   };
};
 
sound {
diff --git a/arch/arm/boot/dts/tegra20-trimslice.dts 
b/arch/arm/boot/dts/tegra20-trimslice.dts
index 955bf49..8f2bb9b 100644
--- a/arch/arm/boot/dts/tegra20-trimslice.dts
+++ b/arch/arm/boot/dts/tegra20-trimslice.dts
@@ -305,17 +305,21 @@
nvidia,vbus-gpio = gpio 170 0; /* gpio PV2

[PATCH v2 0/7] Tegra USB PHY driver series

2013-04-03 Thread Venu Byravarasu
delta from v1:
This patch is prepared as follow up patch of TEGRA USB PHY driver
patch series being discussed at:
http://marc.info/?l=linux-tegram=136361016003625w=2 

Venu Byravarasu (7):
  ARM: tegra: finalize USB EHCI and PHY bindings
  ARM: tegra: update device trees for USB binding rework
  usb: phy: tegra: Get PHY mode using DT
  usb: phy: tegra: Return correct error value provided by clk_get_sys
  usb: phy: tegra: get ULPI reset GPIO info using DT.
  usb: phy: tegra: Add error handling  clean up.
  usb: phy: registering Tegra USB PHY as platform driver

 .../bindings/usb/nvidia,tegra20-ehci.txt   |   27 +--
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   39 +++-
 arch/arm/boot/dts/tegra20-colibri-512.dtsi |4 +
 arch/arm/boot/dts/tegra20-harmony.dts  |8 +-
 arch/arm/boot/dts/tegra20-iris-512.dts |4 +
 arch/arm/boot/dts/tegra20-paz00.dts|8 +-
 arch/arm/boot/dts/tegra20-seaboard.dts |   22 ++-
 arch/arm/boot/dts/tegra20-trimslice.dts|   21 +-
 arch/arm/boot/dts/tegra20-ventana.dts  |7 +-
 arch/arm/boot/dts/tegra20.dtsi |   46 +++-
 drivers/usb/host/ehci-tegra.c  |   95 +++
 drivers/usb/phy/phy-tegra-usb.c|  309 
 include/linux/usb/tegra_usb_phy.h  |5 +-
 13 files changed, 364 insertions(+), 231 deletions(-)

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


[PATCH v2 3/7] usb: phy: tegra: Get PHY mode using DT

2013-04-03 Thread Venu Byravarasu
Added a new PHY mode to support OTG.
Obtained Tegra USB PHY mode using DT property.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:
replaced gadget with peripheral.

 drivers/usb/host/ehci-tegra.c |3 +--
 drivers/usb/phy/phy-tegra-usb.c   |   13 +++--
 include/linux/usb/tegra_usb_phy.h |3 ++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 1d2488c..afe9629 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -732,8 +732,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
}
 
tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
-   pdata-phy_config,
-   TEGRA_USB_PHY_MODE_HOST);
+   pdata-phy_config);
if (IS_ERR(tegra-phy)) {
dev_err(pdev-dev, Failed to open USB phy\n);
err = -ENXIO;
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index 5487d38..91b6e29 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -688,7 +688,7 @@ static int  tegra_usb_phy_suspend(struct usb_phy *x, int 
suspend)
 }
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-   void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode)
+   void __iomem *regs, void *config)
 {
struct tegra_usb_phy *phy;
unsigned long parent_rate;
@@ -703,7 +703,6 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
phy-instance = instance;
phy-regs = regs;
phy-config = config;
-   phy-mode = phy_mode;
phy-dev = dev;
phy-is_legacy_phy =
of_property_read_bool(np, nvidia,has-legacy-mode);
@@ -713,6 +712,16 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
else
phy-is_ulpi_phy = true;
 
+   err = of_property_match_string(np, dr_mode, otg);
+   if (err  0) {
+   err = of_property_match_string(np, dr_mode, peripheral);
+   if (err  0)
+   phy-mode = TEGRA_USB_PHY_MODE_HOST;
+   else
+   phy-mode = TEGRA_USB_PHY_MODE_DEVICE;
+   } else
+   phy-mode = TEGRA_USB_PHY_MODE_OTG;
+
if (!phy-config) {
if (phy-is_ulpi_phy) {
pr_err(%s: ulpi phy configuration missing, __func__);
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index 9ebebe9..a7af923 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -42,6 +42,7 @@ enum tegra_usb_phy_port_speed {
 enum tegra_usb_phy_mode {
TEGRA_USB_PHY_MODE_DEVICE,
TEGRA_USB_PHY_MODE_HOST,
+   TEGRA_USB_PHY_MODE_OTG,
 };
 
 struct tegra_xtal_freq;
@@ -64,7 +65,7 @@ struct tegra_usb_phy {
 };
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-   void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode);
+   void __iomem *regs, void *config);
 
 void tegra_usb_phy_preresume(struct usb_phy *phy);
 
-- 
1.7.0.4

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


[PATCH resend] usb: host: tegra: Reset Tegra USB controller before init

2013-04-03 Thread Venu Byravarasu
To clear any configurations made by U-Boot on Tegra USB controller,
reset it before init in probe.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
Acked-by: Alan Stern st...@rowland.harvard.edu
Acked-by: Greg Kroah-Hartman gre...@linuxfoundation.org
reviewed-by: Stephen Warren swar...@nvidia.com
---
This patch was already reviewed at:  
http://marc.info/?l=linux-usbm=136203353205291w=2

 drivers/usb/host/ehci-tegra.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 1d2488c..60ed5d1 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -28,6 +28,7 @@
 #include linux/pm_runtime.h
 #include linux/usb/ehci_def.h
 #include linux/usb/tegra_usb_phy.h
+#include linux/clk/tegra.h
 
 #define TEGRA_USB_BASE 0xC500
 #define TEGRA_USB2_BASE0xC5004000
@@ -691,6 +692,10 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (err)
goto fail_clk;
 
+   tegra_periph_reset_assert(tegra-clk);
+   udelay(1);
+   tegra_periph_reset_deassert(tegra-clk);
+
tegra-needs_double_reset = of_property_read_bool(pdev-dev.of_node,
nvidia,needs-double-reset);
 
-- 
1.7.0.4

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


RE: [PATCH] usb: host: tegra: Reset Tegra USB controller before init

2013-04-03 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Tuesday, April 02, 2013 9:02 PM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu; linux-
 u...@vger.kernel.org; linux-ker...@vger.kernel.org
 Subject: Re: [PATCH] usb: host: tegra: Reset Tegra USB controller before init
 
 On 04/02/2013 01:12 AM, Venu Byravarasu wrote:
  gre...@linuxfoundation.org wrote at Tuesday, March 05, 2013 6:04 AM:
  On Mon, Mar 04, 2013 at 09:55:44AM -0700, Stephen Warren wrote:
  On 03/04/2013 12:55 AM, Venu Byravarasu wrote:
  Stephen Warren wrote at Thursday, February 28, 2013 11:47 PM:
  On 02/27/2013 11:36 PM, Venu Byravarasu wrote:
  To clear any configurations made by U-Boot on Tegra USB controller,
  reset it before init in probe.
 ...
  Acked-by: Greg Kroah-Hartman gre...@linuxfoundation.org
 
  Hi Greg,
 
  Stephen initially thought that the patch can be taken through tegra tree,
 along with
  other patches posted at  http://marc.info/?l=linux-
 tegram=136361016003625w=2 .
  As some other issues are blocking that patch series, can this change be
 merged
  independent of that patch series via USB tree?
 
  The original change can be seen at http://marc.info/?l=linux-
 usbm=136203353205291w=2
 
 Venu, you should simply repost the patch; I'm sure its not in anyone's
 email inbox any more.
 
Resent the patch, with ACKs added.
Latest patch can be seen at: 
http://marc.info/?l=linux-tegram=136498598329081w=2 

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


RE: [PATCH] usb: host: ehci-tegra: Fix oops in error cleanup

2013-04-03 Thread Venu Byravarasu
 -Original Message-
 From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb-
 ow...@vger.kernel.org] On Behalf Of Thierry Reding
 Sent: Wednesday, April 03, 2013 2:11 AM
 To: Felipe Balbi
 Cc: Stephen Warren; Alan Stern; linux-te...@vger.kernel.org; linux-
 u...@vger.kernel.org
 Subject: [PATCH] usb: host: ehci-tegra: Fix oops in error cleanup
 
 The cleanup path checks whether the transceiver was properly initialized
 using IS_ERR(). However it can also happen that the cleanup path is run
 before the transceiver was initialized (or the operating mode isn't set
 to TEGRA_USB_OTG) and is therefore NULL. Add a separate label for error
 unwinding and initialize the transceiver field to ERR_PTR(-ENODEV) when
 the operating mode isn't TEGRA_USB_OTG to allow for consistent checking.

This change looks good to me.
Acked-by: Venu Byravarasu vbyravar...@nvidia.com

 
 Signed-off-by: Thierry Reding thie...@gilfi.de
 ---
  drivers/usb/host/ehci-tegra.c | 7 +--
  1 file changed, 5 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 index 1d2488c..c8cb488 100644
 --- a/drivers/usb/host/ehci-tegra.c
 +++ b/drivers/usb/host/ehci-tegra.c
 @@ -755,7 +755,7 @@ static int tegra_ehci_probe(struct platform_device
 *pdev)
   err = usb_phy_set_suspend(hcd-phy, 0);
   if (err) {
   dev_err(pdev-dev, Failed to power on the phy\n);
 - goto fail;
 + goto fail_phy;
   }
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] usb: host: tegra: Reset Tegra USB controller before init

2013-04-02 Thread Venu Byravarasu
 -Original Message-
 From: gre...@linuxfoundation.org [mailto:gre...@linuxfoundation.org]
 Sent: Tuesday, March 05, 2013 6:04 AM
 To: Stephen Warren
 Cc: Venu Byravarasu; st...@rowland.harvard.edu; linux-
 u...@vger.kernel.org; linux-ker...@vger.kernel.org
 Subject: Re: [PATCH] usb: host: tegra: Reset Tegra USB controller before init
 
 On Mon, Mar 04, 2013 at 09:55:44AM -0700, Stephen Warren wrote:
  On 03/04/2013 12:55 AM, Venu Byravarasu wrote:
   Stephen Warren wrote at Thursday, February 28, 2013 11:47 PM:
   On 02/27/2013 11:36 PM, Venu Byravarasu wrote:
   To clear any configurations made by U-Boot on Tegra USB controller,
   reset it before init in probe.
  
   diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-
 tegra.c
  
   @@ -691,6 +692,10 @@ static int tegra_ehci_probe(struct
 platform_device
   *pdev)
   if (err)
   goto fail_clk;
  
   +   tegra_periph_reset_assert(tegra-clk);
   +   udelay(1);
   +   tegra_periph_reset_deassert(tegra-clk);
  

  Alan, Greg, if you're OK with this patch now, or for any revised
  version, an Ack so I can take it through the Tegra tree would be great,
  thanks.
 
 Acked-by: Greg Kroah-Hartman gre...@linuxfoundation.org
 
Hi Greg,

Stephen initially thought that the patch can be taken through tegra tree, along 
with
other patches posted at  http://marc.info/?l=linux-tegram=136361016003625w=2 .
As some other issues are blocking that patch series, can this change be merged
independent of that patch series via USB tree?

The original change can be seen at 
http://marc.info/?l=linux-usbm=136203353205291w=2  

Thanks,
Venu

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


RE: [PATCH 0/7] USB: PHY: Tegra: registering TEGRA USB PHY as platform driver

2013-03-20 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Wednesday, March 20, 2013 1:22 AM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 linux-te...@vger.kernel.org; devicetree-disc...@lists.ozlabs.org
 Subject: Re: [PATCH 0/7] USB: PHY: Tegra: registering TEGRA USB PHY as
 platform driver
 
 On 03/18/2013 06:29 AM, Venu Byravarasu wrote:
  As part of this series, apart from patch containing changes to register
 TEGRA
  USB PHY driver as platform driver, prepared below patches:
  1. Re-arranging  adding new DT properties.
  2. Getting various params from DT properties added.
  3. code clean up.
 
 Venu, I'm curious whether these patches were tested at all. I have found
 at least two significant problems with trivial testing:

Stephen,
Initially started testing after applying each and every patch.
Like that tested till first 5 patches.
As did not see any issues till then, applied rest 2 patches at once and tested 
with that.
Though did not see mouse getting vbus on the 1st boot, Vbus was coming fine 
after disconnect and connect.
Hence did not test thereafter.

After checking your current mail, tried now and observed that there seems to be 
some real issue with patch#7 only. (As tried now after applying till patch# 6 
and did not see this issue).
Will debug further on patch#7 and update with proper fix after addressing your 
other comments.

Thanks for the review  heads up,
venu

 
 1)
 
 reboot or shutdown -h now both cause the following crash, with or
 without any USB devices plugged in (or ever having been plugged in):
 
  [  355.836288] Unable to handle kernel NULL pointer dereference at virtual
 address 0028
  [  355.847961] pgd = ed62
  [  355.854093] [0028] *pgd=
 ...
  [  356.146728] [c02e5978] (tegra_ehci_hcd_shutdown+0x18/0x2c) from
 [c0279edc] (platform_drv_shutdown+0x18/0x1c)
  [  356.160379] [c0279edc] (platform_drv_shutdown+0x18/0x1c) from
 [c027703c] (device_shutdown+0x34/0x188)
  [  356.173464] [c027703c] (device_shutdown+0x34/0x188) from
 [c0034650] (kernel_restart_prepare+0x34/0x3c)
  [  356.186668] [c0034650] (kernel_restart_prepare+0x34/0x3c) from
 [c0034664] (kernel_restart+0xc/0x4c)
  [  356.199637] [c0034664] (kernel_restart+0xc/0x4c) from [c0034858]
 (sys_reboot+0x1ac/0x1d8)
  [  356.211704] [c0034858] (sys_reboot+0x1ac/0x1d8) from [c000e2c0]
 (ret_fast_syscall+0x0/0x30)
  [  356.223965] Code: ebfe4b27 e5903000 e24300e8 e5133044 (e5933028)
  [  356.233896] ---[ end trace 088d89482b4af176 ]---
 
 2)
 
 The first time enumeration USB devices is attempted on a port fails. For
 devices that are plugged in at boot, this means that to get them
 working, they must be unplugged and re-plugged after boot. For devices
 that are not plugged in at boot, this means they must be plugged,
 unplugged, and then plugged in again.
 
 This is obviously problematic in and of itself. This is especially true
 for boards like Harmony that have a built-in USB hub and network chip. I
 didn't actually test this, but I assume that they cannot be made to work
 at all with this patch series, since they cannot be unplugged.
 
 The failed enumeration is accompanied by the following message:
 
 [2.451530] hub 3-0:1.0: unable to enumerate USB device on port 1
 
 Both of these problems reproduce on at least boards Ventana and
 Seaboard(Springbank), although I assume that all boards are affected.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 0/7] USB: PHY: Tegra: registering TEGRA USB PHY as platform driver

2013-03-20 Thread Venu Byravarasu
 -Original Message-
 From: Venu Byravarasu
 Sent: Wednesday, March 20, 2013 11:30 AM
 To: 'Stephen Warren'
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 linux-te...@vger.kernel.org; devicetree-disc...@lists.ozlabs.org
 Subject: RE: [PATCH 0/7] USB: PHY: Tegra: registering TEGRA USB PHY as
 platform driver
 
  -Original Message-
  From: Stephen Warren [mailto:swar...@wwwdotorg.org]
  Sent: Wednesday, March 20, 2013 1:22 AM
  To: Venu Byravarasu
  Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
  ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
  linux-te...@vger.kernel.org; devicetree-disc...@lists.ozlabs.org
  Subject: Re: [PATCH 0/7] USB: PHY: Tegra: registering TEGRA USB PHY as
  platform driver
 
  On 03/18/2013 06:29 AM, Venu Byravarasu wrote:
   As part of this series, apart from patch containing changes to register
  TEGRA
   USB PHY driver as platform driver, prepared below patches:
   1. Re-arranging  adding new DT properties.
   2. Getting various params from DT properties added.
   3. code clean up.
 
  Venu, I'm curious whether these patches were tested at all. I have found
  at least two significant problems with trivial testing:
 
 Stephen,
 Initially started testing after applying each and every patch.
 Like that tested till first 5 patches.
 As did not see any issues till then, applied rest 2 patches at once and tested
 with that.
 Though did not see mouse getting vbus on the 1st boot, Vbus was coming
 fine after disconnect and connect.
 Hence did not test thereafter.
 
 After checking your current mail, tried now and observed that there seems to
 be some real issue with patch#7 only. (As tried now after applying till patch#
 6 and did not see this issue).
 Will debug further on patch#7 and update with proper fix after addressing
 your other comments.

Debugged further and found that the issue is because of 
http://marc.info/?l=linux-arm-kernelm=135890098024987w=2 
On reverting that patch and applying it on top of patch#7, able to see  
enumeration working fine.

Anyhow, will take care of your other comments and merge this change with 
patch#7 and resend
for review.

 
 Thanks for the review  heads up,
 venu
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 1/7] ARM: tegra: finalize USB EHCI and PHY bindings

2013-03-20 Thread Venu Byravarasu
 -Original Message-
 From: kishon [mailto:kis...@ti.com]
 Sent: Wednesday, March 20, 2013 4:49 PM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 swar...@wwwdotorg.org; linux-te...@vger.kernel.org; devicetree-
 disc...@lists.ozlabs.org
 Subject: Re: [PATCH 1/7] ARM: tegra: finalize USB EHCI and PHY bindings
 
 Hi,
 
 On Monday 18 March 2013 05:59 PM, Venu Byravarasu wrote:
  The existing Tegra USB bindings have a few issues:
 
  1) Many properties are documented as being part of the EHCI controller
  node, yet they apply more to the PHY device. They should be moved.
 
  2) Some registers in PHY1 are shared with PHY3, and hence PHY3 needs a
  reg entry to point at PHY1's register space. We can't assume the PHY1
  driver is present, so the PHY3 driver will directly access those
  registers.
 
  3) The list of clocks required by the PHY was missing some required
  entries.
 
  This patch fixes the binding definition to resolve these issues.
 
  Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
  ---
.../bindings/usb/nvidia,tegra20-ehci.txt   |   27 
  +++
.../bindings/usb/nvidia,tegra20-usb-phy.txt|   27
 +--
2 files changed, 29 insertions(+), 25 deletions(-)
 
  diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
 b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
  index 34c9528..df09330 100644
  --- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
  +++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
  @@ -6,27 +6,10 @@ Practice : Universal Serial Bus with the following
 modifications
and additions :
 
Required properties :
  - - compatible : Should be nvidia,tegra20-ehci for USB controllers
  -   used in host mode.
  - - phy_type : Should be one of ulpi or utmi.
 
Optional properties:
  -  - dr_mode : dual role mode. Indicates the working mode for

  index 6bdaba2..7ceccd3 100644
  --- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
  +++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
  @@ -4,8 +4,24 @@ The device node for Tegra SOC USB PHY:
 
Required properties :
  + - phy_type : Should be one of utmi, ulpi or hsic.
 
 dt property names generally dont have _.

Thanks Kishon, for your comments.
Is it mandatory or optional?
If it is mandatory, then I might have to change dr_mode as well along with 
phy_type.
 
 
 Thanks
 Kishon
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/7] ARM: tegra: update device trees for USB binding rework

2013-03-20 Thread Venu Byravarasu
 -Original Message-
 From: kishon [mailto:kis...@ti.com]
 Sent: Wednesday, March 20, 2013 4:53 PM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 swar...@wwwdotorg.org; linux-te...@vger.kernel.org; devicetree-
 disc...@lists.ozlabs.org
 Subject: Re: [PATCH 2/7] ARM: tegra: update device trees for USB binding
 rework
 
 Hi,
 
 On Monday 18 March 2013 05:59 PM, Venu Byravarasu wrote:
  This patch updates all Tegra board files so that they contain all the
  properties required by the updated USB DT binding. Note that this patch
  only adds the new properties and does not yet remove the old properties,
  in order to maintain bisectability. The old properties will be removed
  once the driver has been updated to assume the new bindings.
 
  Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
  ---
arch/arm/boot/dts/tegra20-colibri-512.dtsi |4 +++
arch/arm/boot/dts/tegra20-harmony.dts  |8 +++---
arch/arm/boot/dts/tegra20-iris-512.dts |4 +++
arch/arm/boot/dts/tegra20-paz00.dts|8 +++---
arch/arm/boot/dts/tegra20-seaboard.dts |   13 +++---
arch/arm/boot/dts/tegra20-trimslice.dts|   12 +++---
arch/arm/boot/dts/tegra20-ventana.dts  |7 +++--
arch/arm/boot/dts/tegra20.dtsi |   32 
  +--
8 files changed, 57 insertions(+), 31 deletions(-)
 
  diff --git a/arch/arm/boot/dts/tegra20-colibri-512.dtsi
 b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
  index cb73e62..af5a7ae 100644
  --- a/arch/arm/boot/dts/tegra20-colibri-512.dtsi
  +++ b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
  @@ -443,6 +443,10 @@
  nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
  };
 
  +   usb-phy@c5004000 {
 This node doesn't have a *reg* property. So @c5004000 is not needed.
 This comment applies to all the nodes which doesn't have *reg* property.

Thanks Kishon for the comments.
As I've 3 usb-phy DT nodes, how to differentiate between them if I remove this 
@Address ?

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


RE: [PATCH 2/7] ARM: tegra: update device trees for USB binding rework

2013-03-20 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Wednesday, March 20, 2013 1:24 AM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 linux-te...@vger.kernel.org; devicetree-disc...@lists.ozlabs.org
 Subject: Re: [PATCH 2/7] ARM: tegra: update device trees for USB binding
 rework
 
 On 03/18/2013 06:29 AM, Venu Byravarasu wrote:
  This patch updates all Tegra board files so that they contain all the
  properties required by the updated USB DT binding. Note that this patch
  only adds the new properties and does not yet remove the old properties,
  in order to maintain bisectability. The old properties will be removed
  once the driver has been updated to assume the new bindings.
 
  Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
  ---
   arch/arm/boot/dts/tegra20-colibri-512.dtsi |4 +++
   arch/arm/boot/dts/tegra20-harmony.dts  |8 +++---
   arch/arm/boot/dts/tegra20-iris-512.dts |4 +++
   arch/arm/boot/dts/tegra20-paz00.dts|8 +++---
   arch/arm/boot/dts/tegra20-seaboard.dts |   13 +++---
   arch/arm/boot/dts/tegra20-trimslice.dts|   12 +++---
   arch/arm/boot/dts/tegra20-ventana.dts  |7 +++--
   arch/arm/boot/dts/tegra20.dtsi |   32 
  +--
   8 files changed, 57 insertions(+), 31 deletions(-)
 
 I think you forgot to update arch/arm/boot/dts/tegra20-whistler.dts in
 this patch.
 
Thanks Stephen, will add that  send updated patch for review.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 3/7] usb: phy: tegra: Get PHY mode using DT

2013-03-20 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Wednesday, March 20, 2013 1:29 AM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 linux-te...@vger.kernel.org; devicetree-disc...@lists.ozlabs.org
 Subject: Re: [PATCH 3/7] usb: phy: tegra: Get PHY mode using DT
 
 On 03/18/2013 06:29 AM, Venu Byravarasu wrote:
  Added a new PHY mode to support OTG.
  Obtained Tegra USB PHY mode using DT property.
 
  diff --git a/drivers/usb/phy/tegra_usb_phy.c
 b/drivers/usb/phy/tegra_usb_phy.c
 
  @@ -713,6 +712,16 @@ struct tegra_usb_phy
 *tegra_usb_phy_open(struct device *dev, int instance,
  else
  phy-is_ulpi_phy = true;
 
  +   err = of_property_match_string(np, dr_mode, otg);
  +   if (err  0) {
  +   err = of_property_match_string(np, dr_mode, gadget);
  +   if (err  0)
 
 The binding says the 3 legal values for this property are host,
 peripheral, or otg. This agrees with the usage in
 Documentation/devicetree/bindings/usb/fsl-usb.txt and
 drivers/usb/host/fsl-mph-dr-of.c. So, gadget is not something the code
 should be checking for.

Agree, will correct it. 

 
 I'm sure I pointed this out before.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/7] ARM: tegra: update device trees for USB binding rework

2013-03-20 Thread Venu Byravarasu
 -Original Message-
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Wednesday, March 20, 2013 5:55 PM
 To: Venu Byravarasu
 Cc: kishon; gre...@linuxfoundation.org; st...@rowland.harvard.edu;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 swar...@wwwdotorg.org; linux-te...@vger.kernel.org; devicetree-
 disc...@lists.ozlabs.org
 Subject: Re: [PATCH 2/7] ARM: tegra: update device trees for USB binding
 rework
 
 * PGP Signed by an unknown key
 
 On Wed, Mar 20, 2013 at 05:47:46PM +0530, Venu Byravarasu wrote:
   -Original Message-
   From: kishon [mailto:kis...@ti.com]
   Sent: Wednesday, March 20, 2013 4:53 PM
   To: Venu Byravarasu
   Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
   ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
   swar...@wwwdotorg.org; linux-te...@vger.kernel.org; devicetree-
   disc...@lists.ozlabs.org
   Subject: Re: [PATCH 2/7] ARM: tegra: update device trees for USB binding
   rework
  
   Hi,
   

+   usb-phy@c5004000 {
   This node doesn't have a *reg* property. So @c5004000 is not needed.
   This comment applies to all the nodes which doesn't have *reg* property.
 
  Thanks Kishon for the comments.
  As I've 3 usb-phy DT nodes, how to differentiate between them if I remove
 this @Address ?
 
 then add reg property :-)

Thanks Felipe, for confirming. 

 
 --
 balbi
 
 * Unknown Key
 * 0x35CAA444
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 7/7] usb: phy: registering tegra USB PHY as platform driver

2013-03-20 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Wednesday, March 20, 2013 1:51 AM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 linux-te...@vger.kernel.org; devicetree-disc...@lists.ozlabs.org
 Subject: Re: [PATCH 7/7] usb: phy: registering tegra USB PHY as platform
 driver
 
 On 03/18/2013 06:29 AM, Venu Byravarasu wrote:
  Registered tegra USB PHY as a separate platform driver.
 
  diff --git a/drivers/usb/phy/tegra_usb_phy.c
 b/drivers/usb/phy/tegra_usb_phy.c
 
   static void tegra_usb_phy_close(struct usb_phy *x)
   {
  if (phy-is_ulpi_phy)
  clk_put(phy-clk);
 
 phy-clk is obtained using devm_clk_get(). This typically means you
 never need to clk_put() it, and if for some reason you really have to,
 you should use devm_clk_put() instead of plain clk_put().

Agree, will remove clk_put.
 
 
  @@ -774,23 +667,53 @@ struct tegra_usb_phy
 *tegra_usb_phy_open(struct device *dev, int instance,
 
  +   err = gpio_request(phy-reset_gpio, ulpi_phy_reset_b);
 
 I think you can use devm_gpio_request() here to simplify the error-handling.

Sure, will do. 

 
 I wonder why in the ULPI case, all the code is inline here, whereas in
 the UTMI case, this simply calls a function. Wouldn't it be more
 consistent to have the following code here:
 
   if (phy-is_ulpi_phy)
   err = ulpi_open();
   else
   err = utmip_open();
   if (err)
   goto fail;

Sure, will take care of this in next patch. 

 
  +static int tegra_usb_phy_probe(struct platform_device *pdev)
 
 Hmmm. Note that in order to make deferred probe work correctly, all the
 gpio_request(), clk_get(), etc. calls that acquire resources from other
 drivers must happen here in probe() and not in tegra_usb_phy_open().
 
In present code tegra_usb_phy_open() is indirectly called via usb_phy_init() 
from ehci-tegra.c.
Between obtaining PHY handle (and hence getting into deferred probe, when it is 
not available)
and calling usb_phy_init, no other USB registers were accessed. Hence I was 
doing this way.

Do you still think it would be better to move gpio and clk APIs to probe?

 
  +   err = of_property_match_string(np, dr_mode, otg);
  +   if (err  0) {
  +   err = of_property_match_string(np, dr_mode, gadget);
 
 Again, use peripheral, not gadget.

Will do. 

 
  +struct usb_phy *tegra_usb_get_phy(struct device_node *dn)
  +{
  +   struct device *dev;
  +   struct tegra_usb_phy *tegra_phy;
  +
  +   dev = driver_find_device(tegra_usb_phy_driver.driver, NULL, dn,
  +tegra_usb_phy_match);
  +   if (!dev)
  +   return ERR_PTR(-EPROBE_DEFER);
  +
  +   tegra_phy = dev_get_drvdata(dev);
  +
  +   return tegra_phy-u_phy;
  +}
 
 I think you need a module_get() somewhere in there, and also need to add
 a tegra_usb_put_phy() function too, so you can call module_put() from it.

Am not clear on why to add module_get here. Can you plz provide more details?
 
Thanks Stephen, for the review.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/7] ARM: tegra: finalize USB EHCI and PHY bindings

2013-03-18 Thread Venu Byravarasu
The existing Tegra USB bindings have a few issues:

1) Many properties are documented as being part of the EHCI controller
node, yet they apply more to the PHY device. They should be moved.

2) Some registers in PHY1 are shared with PHY3, and hence PHY3 needs a
reg entry to point at PHY1's register space. We can't assume the PHY1
driver is present, so the PHY3 driver will directly access those
registers.

3) The list of clocks required by the PHY was missing some required
entries.

This patch fixes the binding definition to resolve these issues.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 .../bindings/usb/nvidia,tegra20-ehci.txt   |   27 +++
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   27 +--
 2 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
index 34c9528..df09330 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
@@ -6,27 +6,10 @@ Practice : Universal Serial Bus with the following 
modifications
 and additions :
 
 Required properties :
- - compatible : Should be nvidia,tegra20-ehci for USB controllers
-   used in host mode.
- - phy_type : Should be one of ulpi or utmi.
- - nvidia,vbus-gpio : If present, specifies a gpio that needs to be
-   activated for the bus to be powered.
- - nvidia,phy : phandle of the PHY instance, the controller is connected to.
-
-Required properties for phy_type == ulpi:
-  - nvidia,phy-reset-gpio : The GPIO used to reset the PHY.
+ - compatible : Should be nvidia,tegra20-ehci.
+ - nvidia,phy : phandle of the PHY that the controller is connected to.
+ - clocks : Contains a single entry which defines the USB controller's clock.
 
 Optional properties:
-  - dr_mode : dual role mode. Indicates the working mode for
-   nvidia,tegra20-ehci compatible controllers.  Can be host, peripheral,
-   or otg.  Default to host if not defined for backward compatibility.
-  host means this is a host controller
-  peripheral means it is device controller
-  otg means it can operate as either (on the go)
-  - nvidia,has-legacy-mode : boolean indicates whether this controller can
-operate in legacy mode (as APX 2500 / 2600). In legacy mode some
-registers are accessed through the APB_MISC base address instead of
-the USB controller. Since this is a legacy issue it probably does not
-warrant a compatible string of its own.
-  - nvidia,needs-double-reset : boolean is to be set for some of the Tegra2
-USB ports, which need reset twice due to hardware issues.
+ - nvidia,needs-double-reset : boolean is to be set for some of the Tegra20
+   USB ports, which need reset twice due to hardware issues.
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
index 6bdaba2..7ceccd3 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
@@ -4,8 +4,24 @@ The device node for Tegra SOC USB PHY:
 
 Required properties :
  - compatible : Should be nvidia,tegra20-usb-phy.
- - reg : Address and length of the register set for the USB PHY interface.
- - phy_type : Should be one of ulpi or utmi.
+ - reg : Defines the following set of registers, in the order listed:
+   - The PHY's own register set.
+ Always present.
+   - The register set of the PHY containing the UTMI pad control registers.
+ Present if-and-only-if phy_type == utmi.
+ - phy_type : Should be one of utmi, ulpi or hsic.
+ - clocks : Defines the clocks listed in the clock-names property.
+ - clock-names : The following clock names must be present:
+   - reg: The clock needed to access the PHY's own registers. This is the
+ associated EHCI controller's clock. Always present.
+   - pll_u: PLL_U. Always present.
+   - timer: The timeout clock (clk_m). Present if phy_type == utmi.
+   - utmi-pads: The clock needed to access the UTMI pad control registers.
+ Present if phy_type == utmi.
+   - ulpi-link: The clock Tegra provides to the ULPI PHY (cdev2).
+ Present if phy_type == ulpi, and ULPI link mode is in use.
+   - nvidia,vbus-gpio : If present, specifies a GPIO that needs to be
+activated for the bus to be powered.
 
 Required properties for phy_type == ulpi:
   - nvidia,phy-reset-gpio : The GPIO used to reset the PHY.
@@ -14,4 +30,9 @@ Optional properties:
   - nvidia,has-legacy-mode : boolean indicates whether this controller can
 operate in legacy mode (as APX 2500 / 2600). In legacy mode some
 registers are accessed through the APB_MISC base address instead of
-the USB controller.
\ No newline at end of file
+the USB controller.
+  - dr_mode : dual role mode. Indicates the working mode for the PHY. Can

[PATCH 5/7] usb: phy: tegra: get ULPI reset GPIO info using DT.

2013-03-18 Thread Venu Byravarasu
As GPIO information is avail through DT, used it to get Tegra ULPI
reset GPIO number. Added a new member to tegra_usb_phy structure to
store this number.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/phy/tegra_usb_phy.c   |   25 +++--
 include/linux/usb/tegra_usb_phy.h |1 +
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index b5b2037..29c5ac4 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -541,11 +541,10 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
int ret;
unsigned long val;
void __iomem *base = phy-regs;
-   struct tegra_ulpi_config *config = phy-config;
 
-   gpio_direction_output(config-reset_gpio, 0);
+   gpio_direction_output(phy-reset_gpio, 0);
msleep(5);
-   gpio_direction_output(config-reset_gpio, 1);
+   gpio_direction_output(phy-reset_gpio, 1);
 
clk_prepare_enable(phy-clk);
msleep(1);
@@ -603,10 +602,8 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
 
 static int ulpi_phy_power_off(struct tegra_usb_phy *phy)
 {
-   struct tegra_ulpi_config *config = phy-config;
-
clk_disable(phy-clk);
-   return gpio_direction_output(config-reset_gpio, 0);
+   return gpio_direction_output(phy-reset_gpio, 0);
 }
 
 static int tegra_phy_init(struct usb_phy *x)
@@ -622,18 +619,18 @@ static inttegra_phy_init(struct usb_phy *x)
pr_err(%s: can't get ulpi clock\n, __func__);
return PTR_ERR(phy-clk);
}
-   if (!gpio_is_valid(ulpi_config-reset_gpio))
-   ulpi_config-reset_gpio =
-   of_get_named_gpio(phy-dev-of_node,
- nvidia,phy-reset-gpio, 0);
-   if (!gpio_is_valid(ulpi_config-reset_gpio)) {
+
+   phy-reset_gpio =
+   of_get_named_gpio(phy-dev-of_node,
+ nvidia,phy-reset-gpio, 0);
+   if (!gpio_is_valid(phy-reset_gpio)) {
pr_err(%s: invalid reset gpio: %d\n, __func__,
-  ulpi_config-reset_gpio);
+  phy-reset_gpio);
err = -EINVAL;
goto err1;
}
-   gpio_request(ulpi_config-reset_gpio, ulpi_phy_reset_b);
-   gpio_direction_output(ulpi_config-reset_gpio, 0);
+   gpio_request(phy-reset_gpio, ulpi_phy_reset_b);
+   gpio_direction_output(phy-reset_gpio, 0);
phy-ulpi = otg_ulpi_create(ulpi_viewport_access_ops, 0);
phy-ulpi-io_priv = phy-regs + ULPI_VIEWPORT;
} else {
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index a7af923..6cfb8f1 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -62,6 +62,7 @@ struct tegra_usb_phy {
struct device *dev;
bool is_legacy_phy;
bool is_ulpi_phy;
+   int reset_gpio;
 };
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-- 
1.7.0.4

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


[PATCH 7/7] usb: phy: registering tegra USB PHY as platform driver

2013-03-18 Thread Venu Byravarasu
Registered tegra USB PHY as a separate platform driver.

To synchronize host controller and PHY initialization, used deferred
probe mechanism. As PHY should be initialized before EHCI starts running,
deferred probe of Tegra EHCI driver till PHY probe gets completed.

Got rid of instance number based handling in host driver.

Made use of DT params to get the PHY Pad registers.

Merged tegra_phy_init into tegra_usb_phy_init.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/host/ehci-tegra.c |   99 ++--
 drivers/usb/phy/tegra_usb_phy.c   |  308 +
 include/linux/usb/tegra_usb_phy.h |3 +-
 3 files changed, 221 insertions(+), 189 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 7afb962..772fa29 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -648,7 +648,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
struct tegra_ehci_platform_data *pdata;
int err = 0;
int irq;
-   int instance = pdev-id;
+   struct device_node *np_phy;
struct usb_phy *u_phy;
 
pdata = pdev-dev.platform_data;
@@ -671,34 +671,56 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!tegra)
return -ENOMEM;
 
-   hcd = usb_create_hcd(tegra_ehci_hc_driver, pdev-dev,
-   dev_name(pdev-dev));
-   if (!hcd) {
-   dev_err(pdev-dev, Unable to create HCD\n);
-   return -ENOMEM;
-   }
-
platform_set_drvdata(pdev, tegra);
 
tegra-clk = devm_clk_get(pdev-dev, NULL);
if (IS_ERR(tegra-clk)) {
dev_err(pdev-dev, Can't get ehci clock\n);
-   err = PTR_ERR(tegra-clk);
-   goto fail_clk;
+   return PTR_ERR(tegra-clk);
}
 
err = clk_prepare_enable(tegra-clk);
if (err)
-   goto fail_clk;
+   return err;
+
+   np_phy = of_parse_phandle(pdev-dev.of_node, nvidia,phy, 0);
+   if (!np_phy) {
+   err = -ENODEV;
+   goto cleanup_clk;
+   }
+
+   u_phy = tegra_usb_get_phy(np_phy);
+   if (IS_ERR(u_phy)) {
+   err = PTR_ERR(u_phy);
+   goto cleanup_clk;
+   }
 
tegra-needs_double_reset = of_property_read_bool(pdev-dev.of_node,
nvidia,needs-double-reset);
 
+   hcd = usb_create_hcd(tegra_ehci_hc_driver, pdev-dev,
+   dev_name(pdev-dev));
+   if (!hcd) {
+   dev_err(pdev-dev, Unable to create HCD\n);
+   err = -ENOMEM;
+   goto cleanup_clk;
+   }
+   hcd-phy = u_phy;
+   u_phy-otg = devm_kzalloc(pdev-dev, sizeof(struct usb_otg),
+GFP_KERNEL);
+   if (!u_phy-otg) {
+   dev_err(pdev-dev, Failed to alloc memory for otg\n);
+   err = -ENXIO;
+   goto cleanup_hcd_create;
+   }
+
+   u_phy-otg-host = hcd_to_bus(hcd);
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(pdev-dev, Failed to get I/O memory\n);
err = -ENXIO;
-   goto fail_io;
+   goto cleanup_hcd_create;
}
hcd-rsrc_start = res-start;
hcd-rsrc_len = resource_size(res);
@@ -706,55 +728,28 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (!hcd-regs) {
dev_err(pdev-dev, Failed to remap I/O memory\n);
err = -ENOMEM;
-   goto fail_io;
-   }
-
-   /* This is pretty ugly and needs to be fixed when we do only
-* device-tree probing. Old code relies on the platform_device
-* numbering that we lack for device-tree-instantiated devices.
-*/
-   if (instance  0) {
-   switch (res-start) {
-   case TEGRA_USB_BASE:
-   instance = 0;
-   break;
-   case TEGRA_USB2_BASE:
-   instance = 1;
-   break;
-   case TEGRA_USB3_BASE:
-   instance = 2;
-   break;
-   default:
-   err = -ENODEV;
-   dev_err(pdev-dev, unknown usb instance\n);
-   goto fail_io;
-   }
+   goto cleanup_hcd_create;
}
 
-   tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
-   pdata-phy_config);
-   if (IS_ERR(tegra-phy)) {
-   dev_err(pdev-dev, Failed to open USB phy\n);
-   err = -ENXIO;
-   goto fail_io;
+   err = usb_phy_init(hcd-phy);
+   if (err) {
+   dev_err(pdev-dev, Failed to initialize phy\n);
+   goto cleanup_hcd_create;
}
 
-   hcd-phy

[PATCH 2/7] ARM: tegra: update device trees for USB binding rework

2013-03-18 Thread Venu Byravarasu
This patch updates all Tegra board files so that they contain all the
properties required by the updated USB DT binding. Note that this patch
only adds the new properties and does not yet remove the old properties,
in order to maintain bisectability. The old properties will be removed
once the driver has been updated to assume the new bindings.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 arch/arm/boot/dts/tegra20-colibri-512.dtsi |4 +++
 arch/arm/boot/dts/tegra20-harmony.dts  |8 +++---
 arch/arm/boot/dts/tegra20-iris-512.dts |4 +++
 arch/arm/boot/dts/tegra20-paz00.dts|8 +++---
 arch/arm/boot/dts/tegra20-seaboard.dts |   13 +++---
 arch/arm/boot/dts/tegra20-trimslice.dts|   12 +++---
 arch/arm/boot/dts/tegra20-ventana.dts  |7 +++--
 arch/arm/boot/dts/tegra20.dtsi |   32 +--
 8 files changed, 57 insertions(+), 31 deletions(-)

diff --git a/arch/arm/boot/dts/tegra20-colibri-512.dtsi 
b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
index cb73e62..af5a7ae 100644
--- a/arch/arm/boot/dts/tegra20-colibri-512.dtsi
+++ b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
@@ -443,6 +443,10 @@
nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
};
 
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   };
+
sdhci@c8000600 {
cd-gpios = gpio 23 1; /* gpio PC7 */
};
diff --git a/arch/arm/boot/dts/tegra20-harmony.dts 
b/arch/arm/boot/dts/tegra20-harmony.dts
index 1f79c0d..14dd6ed 100644
--- a/arch/arm/boot/dts/tegra20-harmony.dts
+++ b/arch/arm/boot/dts/tegra20-harmony.dts
@@ -427,12 +427,12 @@
nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c8000200 {
diff --git a/arch/arm/boot/dts/tegra20-iris-512.dts 
b/arch/arm/boot/dts/tegra20-iris-512.dts
index 52f1103..c99eccc 100644
--- a/arch/arm/boot/dts/tegra20-iris-512.dts
+++ b/arch/arm/boot/dts/tegra20-iris-512.dts
@@ -41,6 +41,10 @@
dr_mode = otg;
};
 
+   usb-phy@c500 {
+   dr_mode = otg;
+   };
+
usb@c5008000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/tegra20-paz00.dts 
b/arch/arm/boot/dts/tegra20-paz00.dts
index 9db36da..cc3c032 100644
--- a/arch/arm/boot/dts/tegra20-paz00.dts
+++ b/arch/arm/boot/dts/tegra20-paz00.dts
@@ -426,12 +426,12 @@
nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts 
b/arch/arm/boot/dts/tegra20-seaboard.dts
index 715a8b8..320964f 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -563,17 +563,22 @@
dr_mode = otg;
};
 
+   usb-phy@c500 {
+   nvidia,vbus-gpio = gpio 24 0; /* PD0 */
+   dr_mode = otg;
+   };
+
usb@c5004000 {
status = okay;
nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 169 0; /* gpio PV1 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
diff --git a/arch/arm/boot/dts/tegra20-trimslice.dts 
b/arch/arm/boot/dts/tegra20-trimslice.dts
index 98f3e44..3a8d6ed 100644
--- a/arch/arm/boot/dts/tegra20-trimslice.dts
+++ b/arch/arm/boot/dts/tegra20-trimslice.dts
@@ -305,17 +305,21 @@
nvidia,vbus-gpio = gpio 170 0; /* gpio PV2 */
};
 
+   usb-phy@c500 {
+   nvidia,vbus-gpio = gpio 170 0; /* gpio PV2 */
+   };
+
usb@c5004000 {
status = okay;
nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
};
 
-   usb@c5008000 {
-   status = okay;
+   usb-phy@c5004000 {
+   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
};
 
-   usb-phy@c5004400 {
-   nvidia,phy-reset-gpio = gpio 168 0; /* gpio PV0 */
+   usb@c5008000 {
+   status = okay;
};
 
sdhci@c800 {
diff --git a/arch

[PATCH 3/7] usb: phy: tegra: Get PHY mode using DT

2013-03-18 Thread Venu Byravarasu
Added a new PHY mode to support OTG.
Obtained Tegra USB PHY mode using DT property.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/host/ehci-tegra.c |3 +--
 drivers/usb/phy/tegra_usb_phy.c   |   13 +++--
 include/linux/usb/tegra_usb_phy.h |3 ++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 568aecc..7afb962 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -732,8 +732,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
}
 
tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
-   pdata-phy_config,
-   TEGRA_USB_PHY_MODE_HOST);
+   pdata-phy_config);
if (IS_ERR(tegra-phy)) {
dev_err(pdev-dev, Failed to open USB phy\n);
err = -ENXIO;
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 5487d38..93abd68 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -688,7 +688,7 @@ static int  tegra_usb_phy_suspend(struct usb_phy *x, int 
suspend)
 }
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-   void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode)
+   void __iomem *regs, void *config)
 {
struct tegra_usb_phy *phy;
unsigned long parent_rate;
@@ -703,7 +703,6 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
phy-instance = instance;
phy-regs = regs;
phy-config = config;
-   phy-mode = phy_mode;
phy-dev = dev;
phy-is_legacy_phy =
of_property_read_bool(np, nvidia,has-legacy-mode);
@@ -713,6 +712,16 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
else
phy-is_ulpi_phy = true;
 
+   err = of_property_match_string(np, dr_mode, otg);
+   if (err  0) {
+   err = of_property_match_string(np, dr_mode, gadget);
+   if (err  0)
+   phy-mode = TEGRA_USB_PHY_MODE_HOST;
+   else
+   phy-mode = TEGRA_USB_PHY_MODE_DEVICE;
+   } else
+   phy-mode = TEGRA_USB_PHY_MODE_OTG;
+
if (!phy-config) {
if (phy-is_ulpi_phy) {
pr_err(%s: ulpi phy configuration missing, __func__);
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index 9ebebe9..a7af923 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -42,6 +42,7 @@ enum tegra_usb_phy_port_speed {
 enum tegra_usb_phy_mode {
TEGRA_USB_PHY_MODE_DEVICE,
TEGRA_USB_PHY_MODE_HOST,
+   TEGRA_USB_PHY_MODE_OTG,
 };
 
 struct tegra_xtal_freq;
@@ -64,7 +65,7 @@ struct tegra_usb_phy {
 };
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-   void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode);
+   void __iomem *regs, void *config);
 
 void tegra_usb_phy_preresume(struct usb_phy *phy);
 
-- 
1.7.0.4

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


[PATCH 4/7] usb: phy: tegra: Return correct error value provided by clk_get_sys

2013-03-18 Thread Venu Byravarasu
In case if clk_get_sys fails, return correct error value provided by
the API.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/phy/tegra_usb_phy.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 93abd68..b5b2037 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -620,8 +620,7 @@ static int  tegra_phy_init(struct usb_phy *x)
phy-clk = clk_get_sys(NULL, ulpi_config-clk);
if (IS_ERR(phy-clk)) {
pr_err(%s: can't get ulpi clock\n, __func__);
-   err = -ENXIO;
-   goto err1;
+   return PTR_ERR(phy-clk);
}
if (!gpio_is_valid(ulpi_config-reset_gpio))
ulpi_config-reset_gpio =
-- 
1.7.0.4

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


[PATCH 0/7] USB: PHY: Tegra: registering TEGRA USB PHY as platform driver

2013-03-18 Thread Venu Byravarasu
As part of this series, apart from patch containing changes to register TEGRA
USB PHY driver as platform driver, prepared below patches:
1. Re-arranging  adding new DT properties.
2. Getting various params from DT properties added.
3. code clean up.

Venu Byravarasu (7):
  ARM: tegra: finalize USB EHCI and PHY bindings
  ARM: tegra: update device trees for USB binding rework
  usb: phy: tegra: Get PHY mode using DT
  usb: phy: tegra: Return correct error value provided by clk_get_sys
  usb: phy: tegra: get ULPI reset GPIO info using DT.
  usb: phy: tegra: Add error handling  clean up.
  usb: phy: registering tegra USB PHY as platform driver

 .../bindings/usb/nvidia,tegra20-ehci.txt   |   27 +--
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   27 ++-
 arch/arm/boot/dts/tegra20-colibri-512.dtsi |4 +
 arch/arm/boot/dts/tegra20-harmony.dts  |8 +-
 arch/arm/boot/dts/tegra20-iris-512.dts |4 +
 arch/arm/boot/dts/tegra20-paz00.dts|8 +-
 arch/arm/boot/dts/tegra20-seaboard.dts |   13 +-
 arch/arm/boot/dts/tegra20-trimslice.dts|   12 +-
 arch/arm/boot/dts/tegra20-ventana.dts  |7 +-
 arch/arm/boot/dts/tegra20.dtsi |   32 ++-
 drivers/usb/host/ehci-tegra.c  |  100 +++
 drivers/usb/phy/tegra_usb_phy.c|  301 
 include/linux/usb/tegra_usb_phy.h  |5 +-
 13 files changed, 322 insertions(+), 226 deletions(-)

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


RE: [PATCH 5/7] usb: phy: tegra: get ULPI reset GPIO info using DT.

2013-03-18 Thread Venu Byravarasu
 -Original Message-
 From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb-
 ow...@vger.kernel.org] On Behalf Of Sergei Shtylyov
 Sent: Monday, March 18, 2013 6:32 PM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 swar...@wwwdotorg.org; linux-te...@vger.kernel.org; devicetree-
 disc...@lists.ozlabs.org
 Subject: Re: [PATCH 5/7] usb: phy: tegra: get ULPI reset GPIO info using DT.
 
 Hello.
 
 On 18-03-2013 16:29, Venu Byravarasu wrote:
 
  As GPIO information is avail through DT, used it to get Tegra ULPI
  reset GPIO number. Added a new member to tegra_usb_phy structure to
  store this number.
 
  Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
  ---
drivers/usb/phy/tegra_usb_phy.c   |   25 +++--
include/linux/usb/tegra_usb_phy.h |1 +
2 files changed, 12 insertions(+), 14 deletions(-)
 
  diff --git a/drivers/usb/phy/tegra_usb_phy.c
 b/drivers/usb/phy/tegra_usb_phy.c
  index b5b2037..29c5ac4 100644
  --- a/drivers/usb/phy/tegra_usb_phy.c
  +++ b/drivers/usb/phy/tegra_usb_phy.c
 [...]
  @@ -622,18 +619,18 @@ static inttegra_phy_init(struct usb_phy *x)
 [...]
  -   gpio_request(ulpi_config-reset_gpio, ulpi_phy_reset_b);
  -   gpio_direction_output(ulpi_config-reset_gpio, 0);
  +   gpio_request(phy-reset_gpio, ulpi_phy_reset_b);
  +   gpio_direction_output(phy-reset_gpio, 0);
 
 Why not use goio_request_one() instead of these two? Thought maybe it's
 a
 material of another patch...

Sure, can take this up as part of next patch.
Thanks for the review. 

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


RE: [PATCH] usb: phy: rename all phy drivers to phy-$name.c

2013-03-13 Thread Venu Byravarasu
 -Original Message-
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Friday, March 08, 2013 1:08 PM
 To: Venu Byravarasu
 Cc: Stephen Warren; Felipe Balbi; Linux USB Mailing List; Greg KH; linux-
 te...@vger.kernel.org; s.ha...@pengutronix.de; sachin.ka...@linaro.org;
 aletes@gmail.com; gautam.vi...@samsung.com;
 kuninori.morimoto...@renesas.com; p.pan...@samsung.com;
 sti...@antcom.de; t...@atomide.com; y...@marvell.com
 Subject: Re: [PATCH] usb: phy: rename all phy drivers to phy-$name.c
 
 * PGP Signed by an unknown key
 
 On Fri, Mar 08, 2013 at 12:51:13PM +0530, Venu Byravarasu wrote:
   -Original Message-
   From: linux-tegra-ow...@vger.kernel.org [mailto:linux-tegra-
   ow...@vger.kernel.org] On Behalf Of Stephen Warren
   Sent: Friday, March 08, 2013 2:07 AM
   To: Felipe Balbi; Venu Byravarasu
   Cc: Linux USB Mailing List; Greg KH; linux-te...@vger.kernel.org;
   s.ha...@pengutronix.de; sachin.ka...@linaro.org;
 aletes@gmail.com;
   gautam.vi...@samsung.com; kuninori.morimoto...@renesas.com;
   p.pan...@samsung.com; sti...@antcom.de; t...@atomide.com;
   y...@marvell.com
   Subject: Re: [PATCH] usb: phy: rename all phy drivers to phy-$name.c
  
   On 03/07/2013 08:45 AM, Felipe Balbi wrote:
this will make sure that we have sensible names
for all phy drivers. Current situation was already
quite bad with too generic names being used.
  
   Is phy-$name specific enough? There are other types of PHY such as
   Ethernet, etc. What about phy-usb-$name?
  
   Venu, please comment on what conflicts, if any, this will cause with the
   patches you'll be sending to clean up the Tegra USB/PHY drivers. Thanks.
 
  As this is just a name change, it should not cause any big issues, other 
  than
 porting
  all changes on top of this new file.
 
  Felipe,
  When can we expect these changes getting merged into linux-next?
 
 After -rc2 is tagged, I will have everything I need to start my -next
 branch. From that point on it should be in linux-next ;-)

As your change is not yet merged, can you plz exclude Tegra USB PHY driver 
renaming 
alone from your patch, as my patches are almost ready on top of current 
linux-next code base?
If you are OK, I can push the renaming patch as part of my last patch, so that 
manual merge on
top of new file can be avoided and your target of changing file names also will 
be served. 

 
 --
 balbi
 
 * Unknown Key
 * 0x35CAA444
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] usb: host: tegra: Reset Tegra USB controller before init

2013-03-03 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Thursday, February 28, 2013 11:47 PM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu; linux-
 u...@vger.kernel.org; linux-ker...@vger.kernel.org
 Subject: Re: [PATCH] usb: host: tegra: Reset Tegra USB controller before init
 
 On 02/27/2013 11:36 PM, Venu Byravarasu wrote:
  To clear any configurations made by U-Boot on Tegra USB controller,
  reset it before init in probe.
 
  diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 
  @@ -691,6 +692,10 @@ static int tegra_ehci_probe(struct platform_device
 *pdev)
  if (err)
  goto fail_clk;
 
  +   tegra_periph_reset_assert(tegra-clk);
  +   udelay(1);
  +   tegra_periph_reset_deassert(tegra-clk);
 
 I think this patch might cause unintended consequences.
 
 When the Tegra PHY code is converted to a driver (i.e. has its own
 probe), the initial order of execution of the PHY and EHCI driver probes
 will not be guaranteed.
 
 In particular, since the EHCI probe will attempt to find the PHY
 device, and defer the EHCI probe until it can do so, this guarantees
 that the PHY's probe() will have completed before EHCI's probe()
 completes (although EHCI's probe may start running first some number of
 times, and be retried with -EPROBE_DEFERRED for a variety of reasons).
 
 Now, if the PHY driver's probe() actually touches HW and sets up some
 registers, isn't this reset call going to trash any of that register
 setup? Or, will PHY probe() not touch registers, but only do so during
 the standard PHY open/init op/API calls?
 
Yes, PHY driver probe does not touch any registers. It just sets up the PHY API 
hooks.
These APIs will be called from ehci-tegra.c as part of ehci tegra probe 
function, after
getting  PHY handle, which in turn happens after issuing above reset.

Thanks to Stephen  Alan, for the review comments.
 
 
 I think the way to solve this is to put the reset call into the PHY
 driver. I assume it has access to the appropriate clock object. 

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


[PATCH] usb: host: tegra: Reset Tegra USB controller before init

2013-02-27 Thread Venu Byravarasu
To clear any configurations made by U-Boot on Tegra USB controller,
reset it before init in probe.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
When U-Boot configures a Tegra USB controller in device mode and if the EHCI
driver of kernel tries to set it to HOST mode, message irq 52: nobody cared
appears and IRQ gets disabled.

This issue was initially reported with: 
http://marc.info/?l=linux-tegram=136110175423601w=2

To avoid such issues, due to configurations made by U-Boot driver, reset the
Tegra USB controller, before configuring it by kernel.


 drivers/usb/host/ehci-tegra.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 568aecc..83d190a 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -28,6 +28,7 @@
 #include linux/pm_runtime.h
 #include linux/usb/ehci_def.h
 #include linux/usb/tegra_usb_phy.h
+#include linux/clk/tegra.h
 
 #define TEGRA_USB_BASE 0xC500
 #define TEGRA_USB2_BASE0xC5004000
@@ -691,6 +692,10 @@ static int tegra_ehci_probe(struct platform_device *pdev)
if (err)
goto fail_clk;
 
+   tegra_periph_reset_assert(tegra-clk);
+   udelay(1);
+   tegra_periph_reset_deassert(tegra-clk);
+
tegra-needs_double_reset = of_property_read_bool(pdev-dev.of_node,
nvidia,needs-double-reset);
 
-- 
1.7.0.4

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


[PATCH v3] usb: phy: moving all PHY API definitions to usb/phy directory

2013-02-07 Thread Venu Byravarasu
As drivers/usb/otg/otg.c contains most of the PHY related APIs which
are not OTG specific, moving them to more logical place under
drivers/usb/phy.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v2:
renamed usb_phy.c to phy.c.

delta from v1:
Missed adding newly created file usb_phy.c with previous patch.
hence sending v2, after adding that.

 drivers/usb/otg/otg.c|  422 
 drivers/usb/phy/Makefile |1 +
 drivers/usb/{otg/otg.c = phy/phy.c} |  907 --
 3 files changed, 438 insertions(+), 892 deletions(-)
 copy drivers/usb/{otg/otg.c = phy/phy.c} (92%)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index e181439..a5357e9 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -9,431 +9,9 @@
  * (at your option) any later version.
  */
 
-#include linux/kernel.h
 #include linux/export.h
-#include linux/err.h
-#include linux/device.h
-#include linux/module.h
-#include linux/slab.h
-#include linux/of.h
-
 #include linux/usb/otg.h
 
-static LIST_HEAD(phy_list);
-static LIST_HEAD(phy_bind_list);
-static DEFINE_SPINLOCK(phy_lock);
-
-static struct usb_phy *__usb_find_phy(struct list_head *list,
-   enum usb_phy_type type)
-{
-   struct usb_phy  *phy = NULL;
-
-   list_for_each_entry(phy, list, head) {
-   if (phy-type != type)
-   continue;
-
-   return phy;
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static struct usb_phy *__usb_find_phy_dev(struct device *dev,
-   struct list_head *list, u8 index)
-{
-   struct usb_phy_bind *phy_bind = NULL;
-
-   list_for_each_entry(phy_bind, list, list) {
-   if (!(strcmp(phy_bind-dev_name, dev_name(dev))) 
-   phy_bind-index == index) {
-   if (phy_bind-phy)
-   return phy_bind-phy;
-   else
-   return ERR_PTR(-EPROBE_DEFER);
-   }
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static struct usb_phy *__of_usb_find_phy(struct device_node *node)
-{
-   struct usb_phy  *phy;
-
-   list_for_each_entry(phy, phy_list, head) {
-   if (node != phy-dev-of_node)
-   continue;
-
-   return phy;
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static void devm_usb_phy_release(struct device *dev, void *res)
-{
-   struct usb_phy *phy = *(struct usb_phy **)res;
-
-   usb_put_phy(phy);
-}
-
-static int devm_usb_phy_match(struct device *dev, void *res, void *match_data)
-{
-   return res == match_data;
-}
-
-/**
- * devm_usb_get_phy - find the USB PHY
- * @dev - device that requests this phy
- * @type - the type of the phy the controller requires
- *
- * Gets the phy using usb_get_phy(), and associates a device with it using
- * devres. On driver detach, release function is invoked on the devres data,
- * then, devres data is freed.
- *
- * For use by USB host and peripheral drivers.
- */
-struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
-{
-   struct usb_phy **ptr, *phy;
-
-   ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
-   if (!ptr)
-   return NULL;
-
-   phy = usb_get_phy(type);
-   if (!IS_ERR(phy)) {
-   *ptr = phy;
-   devres_add(dev, ptr);
-   } else
-   devres_free(ptr);
-
-   return phy;
-}
-EXPORT_SYMBOL(devm_usb_get_phy);
-
-/**
- * usb_get_phy - find the USB PHY
- * @type - the type of the phy the controller requires
- *
- * Returns the phy driver, after getting a refcount to it; or
- * -ENODEV if there is no such phy.  The caller is responsible for
- * calling usb_put_phy() to release that count.
- *
- * For use by USB host and peripheral drivers.
- */
-struct usb_phy *usb_get_phy(enum usb_phy_type type)
-{
-   struct usb_phy  *phy = NULL;
-   unsigned long   flags;
-
-   spin_lock_irqsave(phy_lock, flags);
-
-   phy = __usb_find_phy(phy_list, type);
-   if (IS_ERR(phy)) {
-   pr_err(unable to find transceiver of type %s\n,
-   usb_phy_type_string(type));
-   goto err0;
-   }
-
-   get_device(phy-dev);
-
-err0:
-   spin_unlock_irqrestore(phy_lock, flags);
-
-   return phy;
-}
-EXPORT_SYMBOL(usb_get_phy);
-
- /**
- * devm_usb_get_phy_by_phandle - find the USB PHY by phandle
- * @dev - device that requests this phy
- * @phandle - name of the property holding the phy phandle value
- * @index - the index of the phy
- *
- * Returns the phy driver associated with the given phandle value,
- * after getting a refcount to it, -ENODEV if there is no such phy or
- * -EPROBE_DEFER if there is a phandle to the phy, but the device is
- * not yet loaded. While at that, it also associates the device with
- * the phy using devres. On driver detach, release function is invoked

RE: [PATCH v3] usb: phy: moving all PHY API definitions to usb/phy directory

2013-02-07 Thread Venu Byravarasu
 -Original Message-
 From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel-
 ow...@vger.kernel.org] On Behalf Of Stephen Warren
 Sent: Thursday, February 07, 2013 10:26 PM
 To: kishon
 Cc: Venu Byravarasu; ba...@ti.com; gre...@linuxfoundation.org; linux-
 ker...@vger.kernel.org; linux-usb@vger.kernel.org
 Subject: Re: [PATCH v3] usb: phy: moving all PHY API definitions to usb/phy
 directory
 
 On 02/07/2013 06:38 AM, kishon wrote:
  On Thursday 07 February 2013 05:02 PM, Venu Byravarasu wrote:
  As drivers/usb/otg/otg.c contains most of the PHY related APIs which
  are not OTG specific, moving them to more logical place under
  drivers/usb/phy.
 
  diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
  index b13faa1..886be13 100644
  --- a/drivers/usb/phy/Makefile
  +++ b/drivers/usb/phy/Makefile
  @@ -4,6 +4,7 @@
 
ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
  +obj-$(CONFIG_USB_COMMON)+= phy.o
 
  I think we should have a separate config for PHYs. There might be
  controllers which dont need separate PHY. But we can have that as a
  separate patch later since we might want to change the Kconfig of other
  UDC drivers.

Thanks Kishon for review comments.
Agree to your comments that we can add a new config for PHY  push it in a 
separate patch. 

 
  +/*
  + * phy.c -- USB PHY utility code
  + *
  + * Copyright (C) 2004 Texas Instruments
 
  You can update this to 2013.
 
 I'm not sure if anyone other that TI can do that?
 
  +EXPORT_SYMBOL_GPL(usb_bind_phy);
  +
  +
 
  Unnecessary spaces here.
 

Will remove them in next patch update. 

 Thanks for the review. It was very difficult to find you review comments
 since you quoted the entire patch rather than just the few pieces you
 were commenting on...
 
  You might want to do this patch after applying *[PATCH] usb: otg: use
  try_module_get in all usb_get_phy functions and add missing module_put*
  by Marc.
 
 Venu, please make sure you include the changes in that patch in your
 Tegra USB/PHY driver rework too, before you post it upstream.

Sure Stephen, thanks for your comments.

 --
 To unsubscribe from this list: send the line unsubscribe linux-kernel in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] usb: host: tegra: make use of PHY pointer of HCD

2013-01-24 Thread Venu Byravarasu
As pointer to PHY structure can be stored in struct usb_hcd
making use of it, to call Tegra PHY APIs.

Call to usb_phy_shutdown() is moved up in tegra_ehci_remove(),
so that to avoid dereferencing of hcd after its freed up.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
First version of patch can be found at
http://marc.info/?l=linux-kernelm=135581479020213w=2. As it was not
yet applied, sending v2 of the patch.

delta from v1:
Modified all Tegra PHY APIs to use standard 'structu usb_phy *' as
their parameter instead of proprietary parameter of type 'struct tegra_usb_phy 
*'.



 drivers/usb/host/ehci-tegra.c |   27 +--
 drivers/usb/phy/tegra_usb_phy.c   |   16 
 include/linux/usb/tegra_usb_phy.h |8 
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index b02622a..568aecc 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -56,7 +56,7 @@ static void tegra_ehci_power_up(struct usb_hcd *hcd)
struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd-self.controller);
 
clk_prepare_enable(tegra-clk);
-   usb_phy_set_suspend(tegra-phy-u_phy, 0);
+   usb_phy_set_suspend(hcd-phy, 0);
tegra-host_resumed = 1;
 }
 
@@ -65,7 +65,7 @@ static void tegra_ehci_power_down(struct usb_hcd *hcd)
struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd-self.controller);
 
tegra-host_resumed = 0;
-   usb_phy_set_suspend(tegra-phy-u_phy, 1);
+   usb_phy_set_suspend(hcd-phy, 1);
clk_disable_unprepare(tegra-clk);
 }
 
@@ -159,7 +159,7 @@ static int tegra_ehci_hub_control(
if (tegra-port_resuming  !(temp  PORT_SUSPEND)) {
/* Resume completed, re-enable disconnect detection */
tegra-port_resuming = 0;
-   tegra_usb_phy_postresume(tegra-phy);
+   tegra_usb_phy_postresume(hcd-phy);
}
}
 
@@ -212,7 +212,7 @@ static int tegra_ehci_hub_control(
goto done;
 
/* Disable disconnect detection during port resume */
-   tegra_usb_phy_preresume(tegra-phy);
+   tegra_usb_phy_preresume(hcd-phy);
 
ehci-reset_done[wIndex-1] = jiffies + msecs_to_jiffies(25);
 
@@ -476,7 +476,7 @@ static int controller_resume(struct device *dev)
}
 
/* Force the phy to keep data lines in suspend state */
-   tegra_ehci_phy_restore_start(tegra-phy, tegra-port_speed);
+   tegra_ehci_phy_restore_start(hcd-phy, tegra-port_speed);
 
/* Enable host mode */
tdi_reset(ehci);
@@ -543,17 +543,17 @@ static int controller_resume(struct device *dev)
}
}
 
-   tegra_ehci_phy_restore_end(tegra-phy);
+   tegra_ehci_phy_restore_end(hcd-phy);
goto done;
 
  restart:
if (tegra-port_speed = TEGRA_USB_PHY_PORT_SPEED_HIGH)
-   tegra_ehci_phy_restore_end(tegra-phy);
+   tegra_ehci_phy_restore_end(hcd-phy);
 
tegra_ehci_restart(hcd);
 
  done:
-   tegra_usb_phy_preresume(tegra-phy);
+   tegra_usb_phy_preresume(hcd-phy);
tegra-port_resuming = 1;
return 0;
 }
@@ -740,9 +740,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
goto fail_io;
}
 
-   usb_phy_init(tegra-phy-u_phy);
-
hcd-phy = u_phy = tegra-phy-u_phy;
+   usb_phy_init(hcd-phy);
+
u_phy-otg = devm_kzalloc(pdev-dev, sizeof(struct usb_otg),
 GFP_KERNEL);
if (!u_phy-otg) {
@@ -752,7 +752,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
}
u_phy-otg-host = hcd_to_bus(hcd);
 
-   err = usb_phy_set_suspend(tegra-phy-u_phy, 0);
+   err = usb_phy_set_suspend(hcd-phy, 0);
if (err) {
dev_err(pdev-dev, Failed to power on the phy\n);
goto fail;
@@ -798,7 +798,7 @@ fail:
if (!IS_ERR_OR_NULL(tegra-transceiver))
otg_set_host(tegra-transceiver-otg, NULL);
 #endif
-   usb_phy_shutdown(tegra-phy-u_phy);
+   usb_phy_shutdown(hcd-phy);
 fail_io:
clk_disable_unprepare(tegra-clk);
 fail_clk:
@@ -820,11 +820,10 @@ static int tegra_ehci_remove(struct platform_device *pdev)
otg_set_host(tegra-transceiver-otg, NULL);
 #endif
 
+   usb_phy_shutdown(hcd-phy);
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
 
-   usb_phy_shutdown(tegra-phy-u_phy);
-
clk_disable_unprepare(tegra-clk);
 
return 0;
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index d465704..5487d38 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -759,30 +759,38 @@ err0:
 }
 EXPORT_SYMBOL_GPL(tegra_usb_phy_open);
 
-void tegra_usb_phy_preresume(struct tegra_usb_phy *phy)
+void tegra_usb_phy_preresume

[PATCH] usb: phy: moving all PHY API definitions to usb/phy directory

2013-01-22 Thread Venu Byravarasu
As drivers/usb/otg/otg.c contains most of the PHY related APIs
which are not OTG specific, moving them to more logical place
under driver/usb/phy.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/otg/otg.c|  184 --
 drivers/usb/phy/Makefile |1 +
 2 files changed, 1 insertions(+), 184 deletions(-)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index a30c041..95561b9 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -17,190 +17,6 @@
 
 #include linux/usb/otg.h
 
-static LIST_HEAD(phy_list);
-static DEFINE_SPINLOCK(phy_lock);
-
-static struct usb_phy *__usb_find_phy(struct list_head *list,
-   enum usb_phy_type type)
-{
-   struct usb_phy  *phy = NULL;
-
-   list_for_each_entry(phy, list, head) {
-   if (phy-type != type)
-   continue;
-
-   return phy;
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static void devm_usb_phy_release(struct device *dev, void *res)
-{
-   struct usb_phy *phy = *(struct usb_phy **)res;
-
-   usb_put_phy(phy);
-}
-
-static int devm_usb_phy_match(struct device *dev, void *res, void *match_data)
-{
-   return res == match_data;
-}
-
-/**
- * devm_usb_get_phy - find the USB PHY
- * @dev - device that requests this phy
- * @type - the type of the phy the controller requires
- *
- * Gets the phy using usb_get_phy(), and associates a device with it using
- * devres. On driver detach, release function is invoked on the devres data,
- * then, devres data is freed.
- *
- * For use by USB host and peripheral drivers.
- */
-struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
-{
-   struct usb_phy **ptr, *phy;
-
-   ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
-   if (!ptr)
-   return NULL;
-
-   phy = usb_get_phy(type);
-   if (!IS_ERR(phy)) {
-   *ptr = phy;
-   devres_add(dev, ptr);
-   } else
-   devres_free(ptr);
-
-   return phy;
-}
-EXPORT_SYMBOL(devm_usb_get_phy);
-
-/**
- * usb_get_phy - find the USB PHY
- * @type - the type of the phy the controller requires
- *
- * Returns the phy driver, after getting a refcount to it; or
- * -ENODEV if there is no such phy.  The caller is responsible for
- * calling usb_put_phy() to release that count.
- *
- * For use by USB host and peripheral drivers.
- */
-struct usb_phy *usb_get_phy(enum usb_phy_type type)
-{
-   struct usb_phy  *phy = NULL;
-   unsigned long   flags;
-
-   spin_lock_irqsave(phy_lock, flags);
-
-   phy = __usb_find_phy(phy_list, type);
-   if (IS_ERR(phy)) {
-   pr_err(unable to find transceiver of type %s\n,
-   usb_phy_type_string(type));
-   goto err0;
-   }
-
-   get_device(phy-dev);
-
-err0:
-   spin_unlock_irqrestore(phy_lock, flags);
-
-   return phy;
-}
-EXPORT_SYMBOL(usb_get_phy);
-
-/**
- * devm_usb_put_phy - release the USB PHY
- * @dev - device that wants to release this phy
- * @phy - the phy returned by devm_usb_get_phy()
- *
- * destroys the devres associated with this phy and invokes usb_put_phy
- * to release the phy.
- *
- * For use by USB host and peripheral drivers.
- */
-void devm_usb_put_phy(struct device *dev, struct usb_phy *phy)
-{
-   int r;
-
-   r = devres_destroy(dev, devm_usb_phy_release, devm_usb_phy_match, phy);
-   dev_WARN_ONCE(dev, r, couldn't find PHY resource\n);
-}
-EXPORT_SYMBOL(devm_usb_put_phy);
-
-/**
- * usb_put_phy - release the USB PHY
- * @x: the phy returned by usb_get_phy()
- *
- * Releases a refcount the caller received from usb_get_phy().
- *
- * For use by USB host and peripheral drivers.
- */
-void usb_put_phy(struct usb_phy *x)
-{
-   if (x)
-   put_device(x-dev);
-}
-EXPORT_SYMBOL(usb_put_phy);
-
-/**
- * usb_add_phy - declare the USB PHY
- * @x: the USB phy to be used; or NULL
- * @type - the type of this PHY
- *
- * This call is exclusively for use by phy drivers, which
- * coordinate the activities of drivers for host and peripheral
- * controllers, and in some cases for VBUS current regulation.
- */
-int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
-{
-   int ret = 0;
-   unsigned long   flags;
-   struct usb_phy  *phy;
-
-   if (x-type != USB_PHY_TYPE_UNDEFINED) {
-   dev_err(x-dev, not accepting initialized PHY %s\n, x-label);
-   return -EINVAL;
-   }
-
-   spin_lock_irqsave(phy_lock, flags);
-
-   list_for_each_entry(phy, phy_list, head) {
-   if (phy-type == type) {
-   ret = -EBUSY;
-   dev_err(x-dev, transceiver type %s already exists\n,
-   usb_phy_type_string(type));
-   goto out;
-   }
-   }
-
-   x-type = type;
-   list_add_tail(x-head, phy_list

[PATCH v2] usb: phy: moving all PHY API definitions to usb/phy directory

2013-01-22 Thread Venu Byravarasu
As drivers/usb/otg/otg.c contains most of the PHY related APIs
which are not OTG specific, moving them to more logical place
under driver/usb/phy.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:
Missed adding newly created file usb_phy.c with previous patch.
hence sending v2, after adding that.

 drivers/usb/otg/otg.c|  184 --
 drivers/usb/phy/Makefile |1 +
 drivers/usb/{otg/otg.c = phy/usb_phy.c} |   45 +---
 3 files changed, 6 insertions(+), 224 deletions(-)
 copy drivers/usb/{otg/otg.c = phy/usb_phy.c} (82%)

diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
index a30c041..95561b9 100644
--- a/drivers/usb/otg/otg.c
+++ b/drivers/usb/otg/otg.c
@@ -17,190 +17,6 @@
 
 #include linux/usb/otg.h
 
-static LIST_HEAD(phy_list);
-static DEFINE_SPINLOCK(phy_lock);
-
-static struct usb_phy *__usb_find_phy(struct list_head *list,
-   enum usb_phy_type type)
-{
-   struct usb_phy  *phy = NULL;
-
-   list_for_each_entry(phy, list, head) {
-   if (phy-type != type)
-   continue;
-
-   return phy;
-   }
-
-   return ERR_PTR(-ENODEV);
-}
-
-static void devm_usb_phy_release(struct device *dev, void *res)
-{
-   struct usb_phy *phy = *(struct usb_phy **)res;
-
-   usb_put_phy(phy);
-}
-
-static int devm_usb_phy_match(struct device *dev, void *res, void *match_data)
-{
-   return res == match_data;
-}
-
-/**
- * devm_usb_get_phy - find the USB PHY
- * @dev - device that requests this phy
- * @type - the type of the phy the controller requires
- *
- * Gets the phy using usb_get_phy(), and associates a device with it using
- * devres. On driver detach, release function is invoked on the devres data,
- * then, devres data is freed.
- *
- * For use by USB host and peripheral drivers.
- */
-struct usb_phy *devm_usb_get_phy(struct device *dev, enum usb_phy_type type)
-{
-   struct usb_phy **ptr, *phy;
-
-   ptr = devres_alloc(devm_usb_phy_release, sizeof(*ptr), GFP_KERNEL);
-   if (!ptr)
-   return NULL;
-
-   phy = usb_get_phy(type);
-   if (!IS_ERR(phy)) {
-   *ptr = phy;
-   devres_add(dev, ptr);
-   } else
-   devres_free(ptr);
-
-   return phy;
-}
-EXPORT_SYMBOL(devm_usb_get_phy);
-
-/**
- * usb_get_phy - find the USB PHY
- * @type - the type of the phy the controller requires
- *
- * Returns the phy driver, after getting a refcount to it; or
- * -ENODEV if there is no such phy.  The caller is responsible for
- * calling usb_put_phy() to release that count.
- *
- * For use by USB host and peripheral drivers.
- */
-struct usb_phy *usb_get_phy(enum usb_phy_type type)
-{
-   struct usb_phy  *phy = NULL;
-   unsigned long   flags;
-
-   spin_lock_irqsave(phy_lock, flags);
-
-   phy = __usb_find_phy(phy_list, type);
-   if (IS_ERR(phy)) {
-   pr_err(unable to find transceiver of type %s\n,
-   usb_phy_type_string(type));
-   goto err0;
-   }
-
-   get_device(phy-dev);
-
-err0:
-   spin_unlock_irqrestore(phy_lock, flags);
-
-   return phy;
-}
-EXPORT_SYMBOL(usb_get_phy);
-
-/**
- * devm_usb_put_phy - release the USB PHY
- * @dev - device that wants to release this phy
- * @phy - the phy returned by devm_usb_get_phy()
- *
- * destroys the devres associated with this phy and invokes usb_put_phy
- * to release the phy.
- *
- * For use by USB host and peripheral drivers.
- */
-void devm_usb_put_phy(struct device *dev, struct usb_phy *phy)
-{
-   int r;
-
-   r = devres_destroy(dev, devm_usb_phy_release, devm_usb_phy_match, phy);
-   dev_WARN_ONCE(dev, r, couldn't find PHY resource\n);
-}
-EXPORT_SYMBOL(devm_usb_put_phy);
-
-/**
- * usb_put_phy - release the USB PHY
- * @x: the phy returned by usb_get_phy()
- *
- * Releases a refcount the caller received from usb_get_phy().
- *
- * For use by USB host and peripheral drivers.
- */
-void usb_put_phy(struct usb_phy *x)
-{
-   if (x)
-   put_device(x-dev);
-}
-EXPORT_SYMBOL(usb_put_phy);
-
-/**
- * usb_add_phy - declare the USB PHY
- * @x: the USB phy to be used; or NULL
- * @type - the type of this PHY
- *
- * This call is exclusively for use by phy drivers, which
- * coordinate the activities of drivers for host and peripheral
- * controllers, and in some cases for VBUS current regulation.
- */
-int usb_add_phy(struct usb_phy *x, enum usb_phy_type type)
-{
-   int ret = 0;
-   unsigned long   flags;
-   struct usb_phy  *phy;
-
-   if (x-type != USB_PHY_TYPE_UNDEFINED) {
-   dev_err(x-dev, not accepting initialized PHY %s\n, x-label);
-   return -EINVAL;
-   }
-
-   spin_lock_irqsave(phy_lock, flags);
-
-   list_for_each_entry(phy, phy_list, head) {
-   if (phy-type == type) {
-   ret = -EBUSY;
-   dev_err(x-dev

RE: [PATCH] usb: phy: moving all PHY API definitions to usb/phy directory

2013-01-22 Thread Venu Byravarasu
 -Original Message-
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Tuesday, January 22, 2013 4:31 PM
 To: Venu Byravarasu
 Cc: ba...@ti.com; gre...@linuxfoundation.org; linux-usb@vger.kernel.org;
 linux-ker...@vger.kernel.org
 Subject: Re: [PATCH] usb: phy: moving all PHY API definitions to usb/phy
 directory
 
 * PGP Signed by an unknown key
 
 HI,
 
 On Tue, Jan 22, 2013 at 04:26:50PM +0530, Venu Byravarasu wrote:
  As drivers/usb/otg/otg.c contains most of the PHY related APIs
  which are not OTG specific, moving them to more logical place
  under driver/usb/phy.
 
  Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
  ---
   drivers/usb/otg/otg.c|  184 
  --
   drivers/usb/phy/Makefile |1 +
 
 missed git add of the new file, but hey, let's call it phy.c and place
 it on drivers/usb/phy/phy.c

Yeah, I used git commit -a  missed adding new file.
Just few min back, sent a patch update.

 
 Also, you will have to rebase on top of Kishon's latest work which I'll
 apply first.

That's fine.
I'll rebase on top of Kishon's latest work and send v3.  
In that v3 patch, will rename the file as phy.c, as you suggested above.

 
 --
 balbi
 
 * Unknown Key
 * 0x35CAA444
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v2] usb: phy: moving all PHY API definitions to usb/phy directory

2013-01-22 Thread Venu Byravarasu
 -Original Message-
 From: Roger Quadros [mailto:rog...@ti.com]
 Sent: Tuesday, January 22, 2013 7:51 PM
 To: Venu Byravarasu
 Cc: ba...@ti.com; gre...@linuxfoundation.org; linux-usb@vger.kernel.org;
 linux-ker...@vger.kernel.org
 Subject: Re: [PATCH v2] usb: phy: moving all PHY API definitions to usb/phy
 directory
 
 On 01/22/2013 01:01 PM, Venu Byravarasu wrote:
  As drivers/usb/otg/otg.c contains most of the PHY related APIs
  which are not OTG specific, moving them to more logical place
  under driver/usb/phy.
 
  Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
  ---
  delta from v1:
  Missed adding newly created file usb_phy.c with previous patch.
  hence sending v2, after adding that.
 
   drivers/usb/otg/otg.c|  184 
  --
   drivers/usb/phy/Makefile |1 +
   drivers/usb/{otg/otg.c = phy/usb_phy.c} |   45 +---
   3 files changed, 6 insertions(+), 224 deletions(-)
   copy drivers/usb/{otg/otg.c = phy/usb_phy.c} (82%)
 
 what about updating
 drivers/usb/otg/Makefile and Kconfig?
 
 i.e. remove CONFIG_USB_OTG_UTILS and otg.o there?

Thanks for your comments.
Those files may still be needed, as we're not removing otg.c,
due to remaining only otg function i.e. otg_state_string().

Felipe,
Shall I move otg_state_string() to otg.h and remove otg.c altogether?

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


RE: [PATCH 2/2] ARM: tegra: add clocks properties to USB PHY nodes

2013-01-22 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Wednesday, January 23, 2013 6:03 AM
 To: Venu Byravarasu
 Cc: Alan Stern; Greg Kroah-Hartman; linux-te...@vger.kernel.org; linux-arm-
 ker...@lists.infradead.org; linux-usb@vger.kernel.org; Stephen Warren
 Subject: Re: [PATCH 2/2] ARM: tegra: add clocks properties to USB PHY nodes
 
 On 01/22/2013 05:28 PM, Stephen Warren wrote:
  The patch to add USB PHY nodes to device tree was written before Tegra
  supported the clocks property in device tree. Now that it does, add the
  required clocks properties to these nodes.
 
  This will allow all clk_get_sys() calls in tegra_usb_phy.c to be replaced
  by clk_get(phy-dev, clock_name), as part of converting the PHY driver to
  a platform driver.
 
  diff --git a/arch/arm/boot/dts/tegra20.dtsi
 b/arch/arm/boot/dts/tegra20.dtsi
 
  +   clocks = tegra_car 22, tegra_car 127;
  +   clock-names = utmi, pll_u;
 ...
  +   clocks = tegra_car 94, tegra_car 127;
  +   clock-names = ulpi, pll_u;
 
 Hmmm. Thinking about that first clock more, if we name it just phy in
 both the UTMI and ULPI PHY nodes, we could make tegra_phy_init() perform
 the clk_get() for all PHY types, and use the same clock name everywhere,
 and hence remove the type-specific clk_get()s from tegra_phy_init() and
 utmip_pad_open().
 
 Venu, will this work for other chips such as Tegra30/Tegra114 and so on
 into the future, or do chips after Tegra20 introduce any new clocks, and
 hence break this scheme?
 
Should be fine, as same clocks are used across all chips.
Acked-by: Venu Byravarasu vbyravar...@nvidia.com

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


RE: [PATCH 1/2] usb: host: tegra: don't touch EMC clock

2013-01-22 Thread Venu Byravarasu
 -Original Message-
 From: linux-tegra-ow...@vger.kernel.org [mailto:linux-tegra-
 ow...@vger.kernel.org] On Behalf Of Stephen Warren
 Sent: Wednesday, January 23, 2013 5:58 AM
 To: Alan Stern; Greg Kroah-Hartman; Stephen Warren
 Cc: Venu Byravarasu; linux-te...@vger.kernel.org; linux-arm-
 ker...@lists.infradead.org; linux-usb@vger.kernel.org; Stephen Warren
 Subject: [PATCH 1/2] usb: host: tegra: don't touch EMC clock
 
 From: Stephen Warren swar...@nvidia.com
 
 Clock emc is for the External Memory Controller. The USB driver has no
 business touching this clock directly. Remove the code that does so.

Stephen,
This was primarily done to make sure that EMC is set to a minimum
frequency, below which data errors may occur during USB transfers.
If we plan to remove this, how should we make sure that the EMC
is programmed for the required frequency during USB transfers?
 
 
 Signed-off-by: Stephen Warren swar...@nvidia.com
 ---
 Greg, Alan, I'd like to take this patch through the Tegra tree to avoid
 any merge conflicts with the Tegra USB changes that have  recently
 happened there.
 
 Venu, When creating your patch to convert the Tegra USB PHY driver to a
 platform driver, can you assume these patches are applied first? Thanks.
 I assume that these patches make sense to you; could you ack them if so.
 ---
  drivers/usb/host/ehci-tegra.c |   17 -
  1 file changed, 17 deletions(-)
 
 diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 index 1f596fb..b02622a 100644
 --- a/drivers/usb/host/ehci-tegra.c
 +++ b/drivers/usb/host/ehci-tegra.c
 @@ -44,7 +44,6 @@ struct tegra_ehci_hcd {
   struct ehci_hcd *ehci;
   struct tegra_usb_phy *phy;
   struct clk *clk;
 - struct clk *emc_clk;
   struct usb_phy *transceiver;
   int host_resumed;
   int port_resuming;
 @@ -56,7 +55,6 @@ static void tegra_ehci_power_up(struct usb_hcd *hcd)
  {
   struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd-self.controller);
 
 - clk_prepare_enable(tegra-emc_clk);
   clk_prepare_enable(tegra-clk);
   usb_phy_set_suspend(tegra-phy-u_phy, 0);
   tegra-host_resumed = 1;
 @@ -69,7 +67,6 @@ static void tegra_ehci_power_down(struct usb_hcd
 *hcd)
   tegra-host_resumed = 0;
   usb_phy_set_suspend(tegra-phy-u_phy, 1);
   clk_disable_unprepare(tegra-clk);
 - clk_disable_unprepare(tegra-emc_clk);
  }
 
  static int tegra_ehci_internal_port_reset(
 @@ -694,16 +691,6 @@ static int tegra_ehci_probe(struct platform_device
 *pdev)
   if (err)
   goto fail_clk;
 
 - tegra-emc_clk = devm_clk_get(pdev-dev, emc);
 - if (IS_ERR(tegra-emc_clk)) {
 - dev_err(pdev-dev, Can't get emc clock\n);
 - err = PTR_ERR(tegra-emc_clk);
 - goto fail_emc_clk;
 - }
 -
 - clk_prepare_enable(tegra-emc_clk);
 - clk_set_rate(tegra-emc_clk, 4);
 -
   tegra-needs_double_reset = of_property_read_bool(pdev-
 dev.of_node,
   nvidia,needs-double-reset);
 
 @@ -813,8 +800,6 @@ fail:
  #endif
   usb_phy_shutdown(tegra-phy-u_phy);
  fail_io:
 - clk_disable_unprepare(tegra-emc_clk);
 -fail_emc_clk:
   clk_disable_unprepare(tegra-clk);
  fail_clk:
   usb_put_hcd(hcd);
 @@ -842,8 +827,6 @@ static int tegra_ehci_remove(struct platform_device
 *pdev)
 
   clk_disable_unprepare(tegra-clk);
 
 - clk_disable_unprepare(tegra-emc_clk);
 -
   return 0;
  }
 
 --
 1.7.10.4
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-tegra in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 4/4] usb: Add APIs to access host registers from Tegra PHY

2013-01-17 Thread Venu Byravarasu
As Tegra PHY driver need to access one of the Host registers,
added few APIs to ehci tegra driver.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:
Taken care of RWC bits, while accessing PORTSC register.

 drivers/usb/host/ehci-tegra.c |   70 -
 drivers/usb/phy/tegra_usb_phy.c   |   51 +++
 include/linux/usb/tegra_usb_phy.h |6 +++
 3 files changed, 88 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 55a9cde..6bbf66a 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -2,7 +2,7 @@
  * EHCI-compliant USB host controller driver for NVIDIA Tegra SoCs
  *
  * Copyright (C) 2010 Google, Inc.
- * Copyright (C) 2009 NVIDIA Corporation
+ * Copyright (C) 2009 - 2013 NVIDIA Corporation
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -33,6 +33,16 @@
 #define TEGRA_USB2_BASE0xC5004000
 #define TEGRA_USB3_BASE0xC5008000
 
+/* PORTSC registers */
+#define USB_PORTSC10x184
+#define USB_PORTSC1_PTS(x) (((x)  0x3)  30)
+#define USB_PORTSC1_PHCD   (1  23)
+#define USB_PORTSC1_WKOC   (1  22)
+#define USB_PORTSC1_WKDS   (1  21)
+#define USB_PORTSC1_WKCN   (1  20)
+#define USB_PORTSC1_PEC(1  3)
+#define USB_PORTSC1_CSC(1  1)
+
 #define TEGRA_USB_DMA_ALIGN 32
 
 struct tegra_ehci_hcd {
@@ -605,6 +615,53 @@ static const struct dev_pm_ops tegra_ehci_pm_ops = {
 
 #endif
 
+/* Bits of PORTSC1, which will get cleared by writing 1 into them */
+#define TEGRA_PORTSC_RWC_BITS (USB_PORTSC1_CSC | USB_PORTSC1_PEC)
+
+void tegra_ehci_set_wakeon_events(struct usb_phy *x, bool enable)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
+   void __iomem *base = hcd-regs;
+   u32 wake = USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN;
+
+   val = readl(base + USB_PORTSC1)  ~TEGRA_PORTSC_RWC_BITS;
+   if (enable)
+   val |= wake;
+   else
+   val = ~wake;
+   writel(val, base + USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_wakeon_events);
+
+void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
+   void __iomem *base = hcd-regs;
+
+   val = readl(base + USB_PORTSC1)  ~TEGRA_PORTSC_RWC_BITS;
+   val = ~USB_PORTSC1_PTS(3);
+   val |= USB_PORTSC1_PTS(pts_val  3);
+   writel(val, base + USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_pts);
+
+void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
+   void __iomem *base = hcd-regs;
+
+   val = readl(base + USB_PORTSC1)  ~TEGRA_PORTSC_RWC_BITS;
+   if (enable)
+   val |= USB_PORTSC1_PHCD;
+   else
+   val = ~USB_PORTSC1_PHCD;
+   writel(val, base + USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_phcd);
+
 static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32);
 
 static int tegra_ehci_probe(struct platform_device *pdev)
@@ -616,6 +673,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
int err = 0;
int irq;
int instance = pdev-id;
+   struct usb_phy *u_phy;
 
pdata = pdev-dev.platform_data;
if (!pdata) {
@@ -718,6 +776,16 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 
usb_phy_init(tegra-phy-u_phy);
 
+   hcd-phy = u_phy = tegra-phy-u_phy;
+   u_phy-otg = devm_kzalloc(pdev-dev, sizeof(struct usb_otg),
+GFP_KERNEL);
+   if (!u_phy-otg) {
+   dev_err(pdev-dev, Failed to alloc memory for otg\n);
+   err = -ENOMEM;
+   goto fail_io;
+   }
+   u_phy-otg-host = hcd_to_bus(hcd);
+
err = usb_phy_set_suspend(tegra-phy-u_phy, 0);
if (err) {
dev_err(pdev-dev, Failed to power on the phy\n);
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index ce1ff2a..f3b73b3 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -36,19 +36,6 @@
 
 #define ULPI_VIEWPORT  0x170
 
-#define USB_PORTSC10x184
-#define   USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
-#define   USB_PORTSC1_PSPD(x)  (((x)  0x3)  26)
-#define   USB_PORTSC1_PHCD (1  23)
-#define   USB_PORTSC1_WKOC (1  22)
-#define   USB_PORTSC1_WKDS (1  21)
-#define   USB_PORTSC1_WKCN (1  20)
-#define   USB_PORTSC1_PTC(x)   (((x)  0xf)  16)
-#define   USB_PORTSC1_PP   (1  12)
-#define   USB_PORTSC1_SUSP (1  7)
-#define   USB_PORTSC1_PE   (1  2)
-#define   USB_PORTSC1_CCS  (1  0)
-
 #define USB_SUSP_CTRL  0x400
 #define

RE: [PATCH v2 4/4] usb: Add APIs to access host registers from Tegra PHY

2013-01-17 Thread Venu Byravarasu
 -Original Message-
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Thursday, January 17, 2013 2:33 PM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; st...@rowland.harvard.edu;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org;
 swar...@wwwdotorg.org; linux-te...@vger.kernel.org
 Subject: Re: [PATCH v2 4/4] usb: Add APIs to access host registers from Tegra
 PHY
 
 * PGP Signed by an unknown key
 
 Hi,
 
 On Thu, Jan 17, 2013 at 01:58:12PM +0530, Venu Byravarasu wrote:
  As Tegra PHY driver need to access one of the Host registers,
  added few APIs to ehci tegra driver.
 
  Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
 
 Stephen is this another of those patches you're gonna take care of
 yourself ?
 
  ---
  delta from v1:
  Taken care of RWC bits, while accessing PORTSC register.
 
   drivers/usb/host/ehci-tegra.c |   70
 -
   drivers/usb/phy/tegra_usb_phy.c   |   51 +++
   include/linux/usb/tegra_usb_phy.h |6 +++
   3 files changed, 88 insertions(+), 39 deletions(-)
 
  diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
  index 55a9cde..6bbf66a 100644
  --- a/drivers/usb/host/ehci-tegra.c
  +++ b/drivers/usb/host/ehci-tegra.c
  @@ -2,7 +2,7 @@
* EHCI-compliant USB host controller driver for NVIDIA Tegra SoCs
*
* Copyright (C) 2010 Google, Inc.
  - * Copyright (C) 2009 NVIDIA Corporation
  + * Copyright (C) 2009 - 2013 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
  @@ -33,6 +33,16 @@
   #define TEGRA_USB2_BASE0xC5004000
   #define TEGRA_USB3_BASE0xC5008000
 
  +/* PORTSC registers */
  +#define USB_PORTSC10x184
  +#define USB_PORTSC1_PTS(x) (((x)  0x3)  30)
  +#define USB_PORTSC1_PHCD   (1  23)
  +#define USB_PORTSC1_WKOC   (1  22)
  +#define USB_PORTSC1_WKDS   (1  21)
  +#define USB_PORTSC1_WKCN   (1  20)
  +#define USB_PORTSC1_PEC(1  3)
  +#define USB_PORTSC1_CSC(1  1)
 
 please prepend this with TEGRA_ just as other defines.

Sure, will add it. 

 
  +
   #define TEGRA_USB_DMA_ALIGN 32
 
   struct tegra_ehci_hcd {
  @@ -605,6 +615,53 @@ static const struct dev_pm_ops
 tegra_ehci_pm_ops = {
 
   #endif
 
  +/* Bits of PORTSC1, which will get cleared by writing 1 into them */
  +#define TEGRA_PORTSC_RWC_BITS (USB_PORTSC1_CSC |
 USB_PORTSC1_PEC)
  +
  +void tegra_ehci_set_wakeon_events(struct usb_phy *x, bool enable)
  +{
  +   unsigned long val;
  +   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
  +   void __iomem *base = hcd-regs;
  +   u32 wake = USB_PORTSC1_WKOC | USB_PORTSC1_WKDS |
 USB_PORTSC1_WKCN;
  +
  +   val = readl(base + USB_PORTSC1)  ~TEGRA_PORTSC_RWC_BITS;
  +   if (enable)
  +   val |= wake;
  +   else
  +   val = ~wake;
  +   writel(val, base + USB_PORTSC1);
  +}
  +EXPORT_SYMBOL_GPL(tegra_ehci_set_wakeon_events);
  +
  +void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
  +{
  +   unsigned long val;
  +   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
  +   void __iomem *base = hcd-regs;
  +
  +   val = readl(base + USB_PORTSC1)  ~TEGRA_PORTSC_RWC_BITS;
  +   val = ~USB_PORTSC1_PTS(3);
  +   val |= USB_PORTSC1_PTS(pts_val  3);
  +   writel(val, base + USB_PORTSC1);
  +}
  +EXPORT_SYMBOL_GPL(tegra_ehci_set_pts);
  +
  +void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
  +{
  +   unsigned long val;
  +   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
  +   void __iomem *base = hcd-regs;
  +
  +   val = readl(base + USB_PORTSC1)  ~TEGRA_PORTSC_RWC_BITS;
  +   if (enable)
  +   val |= USB_PORTSC1_PHCD;
  +   else
  +   val = ~USB_PORTSC1_PHCD;
  +   writel(val, base + USB_PORTSC1);
  +}
  +EXPORT_SYMBOL_GPL(tegra_ehci_set_phcd);
 
 NAK to these three functions, you need to use whatever the PHY API
 provides you, if it misses something, let's see how we can add those as
 generic calls.
 
 In fact, I wonder why do you want PHY driver to access Host address
 space. Why don't you let your host driver handle the above ?

Tegra20 SOC contains 3 instances of USB controllers.
Some of these controllers can be configured to use different varieties
of PHYs e.g. instance 3 can be configured to use either UTMI or ICUSB PHYs.
Bits 31  30 from PORTSC register were allocated by our SOC designers
to inform the host controller about the PHY type to be used. 

As type of PHY is a property related to PHY DT nodes, PHY driver will get this 
info.
(Will remove phy_type from controller DT node soon, after all patches get 
merged.)
However as PORTSC register is in controller domain, added tegra_ehci_set_pts() 
API
 to serve the purpose.

As per Tegra USB PHY design, need to wait for PHY clock to stabilize once we
set/clear PHCD bit. Hence this is being accessed from PHY driver. To serve this
purpose added

RE: [PATCH v2 4/4] usb: Add APIs to access host registers from Tegra PHY

2013-01-17 Thread Venu Byravarasu
 -Original Message-
 From: Alan Stern [mailto:st...@rowland.harvard.edu]
 Sent: Thursday, January 17, 2013 8:45 PM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; ba...@ti.com; linux-usb@vger.kernel.org;
 linux-ker...@vger.kernel.org; swar...@wwwdotorg.org; linux-
 te...@vger.kernel.org
 Subject: Re: [PATCH v2 4/4] usb: Add APIs to access host registers from Tegra
 PHY
 
 On Thu, 17 Jan 2013, Venu Byravarasu wrote:
 
  As Tegra PHY driver need to access one of the Host registers,
  added few APIs to ehci tegra driver.
 
  Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
  ---
  delta from v1:
  Taken care of RWC bits, while accessing PORTSC register.
 
   drivers/usb/host/ehci-tegra.c |   70
 -
   drivers/usb/phy/tegra_usb_phy.c   |   51 +++
   include/linux/usb/tegra_usb_phy.h |6 +++
   3 files changed, 88 insertions(+), 39 deletions(-)
 
  diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
  index 55a9cde..6bbf66a 100644
  --- a/drivers/usb/host/ehci-tegra.c
  +++ b/drivers/usb/host/ehci-tegra.c
  @@ -2,7 +2,7 @@
* EHCI-compliant USB host controller driver for NVIDIA Tegra SoCs
*
* Copyright (C) 2010 Google, Inc.
  - * Copyright (C) 2009 NVIDIA Corporation
  + * Copyright (C) 2009 - 2013 NVIDIA Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
  @@ -33,6 +33,16 @@
   #define TEGRA_USB2_BASE0xC5004000
   #define TEGRA_USB3_BASE0xC5008000
 
  +/* PORTSC registers */
  +#define USB_PORTSC10x184
  +#define USB_PORTSC1_PTS(x) (((x)  0x3)  30)
  +#define USB_PORTSC1_PHCD   (1  23)
  +#define USB_PORTSC1_WKOC   (1  22)
  +#define USB_PORTSC1_WKDS   (1  21)
  +#define USB_PORTSC1_WKCN   (1  20)
  +#define USB_PORTSC1_PEC(1  3)
  +#define USB_PORTSC1_CSC(1  1)
 
 Why redefine these values when they are already defined in
 include/linux/usb/ehci_defs.h?

Agreed. Will remove all above defines except PHCD  PTS, as these two
fields are added by tegra SOC to PORTSC.

 
  @@ -605,6 +615,53 @@ static const struct dev_pm_ops
 tegra_ehci_pm_ops = {
 
   #endif
 
  +/* Bits of PORTSC1, which will get cleared by writing 1 into them */
  +#define TEGRA_PORTSC_RWC_BITS (USB_PORTSC1_CSC |
 USB_PORTSC1_PEC)
 
 Likewise for this.  Not to mention that you forgot to include the
 overcurrent-change bit.

As OCC bit is not supported by Tegra20 SOC, did not include it.
Should I still add this, to be compliant with EHCI spec?
Based on your comments, I can update the patch and send for review.

 
 Alan Stern

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


RE: [PATCH v2 4/4] usb: Add APIs to access host registers from Tegra PHY

2013-01-17 Thread Venu Byravarasu
 -Original Message-
 From: Venu Byravarasu
 Sent: Friday, January 18, 2013 10:26 AM
 To: 'Alan Stern'
 Cc: gre...@linuxfoundation.org; ba...@ti.com; linux-usb@vger.kernel.org;
 linux-ker...@vger.kernel.org; swar...@wwwdotorg.org; linux-
 te...@vger.kernel.org
 Subject: RE: [PATCH v2 4/4] usb: Add APIs to access host registers from Tegra
 PHY
 
  -Original Message-
  From: Alan Stern [mailto:st...@rowland.harvard.edu]
  Sent: Thursday, January 17, 2013 8:45 PM
  To: Venu Byravarasu
  Cc: gre...@linuxfoundation.org; ba...@ti.com; linux-usb@vger.kernel.org;
  linux-ker...@vger.kernel.org; swar...@wwwdotorg.org; linux-
  te...@vger.kernel.org
  Subject: Re: [PATCH v2 4/4] usb: Add APIs to access host registers from
 Tegra
  PHY
 
  On Thu, 17 Jan 2013, Venu Byravarasu wrote:
 
   As Tegra PHY driver need to access one of the Host registers,
   added few APIs to ehci tegra driver.
  
   Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
   ---
   delta from v1:
   Taken care of RWC bits, while accessing PORTSC register.
  
drivers/usb/host/ehci-tegra.c |   70
  -
drivers/usb/phy/tegra_usb_phy.c   |   51 +++
include/linux/usb/tegra_usb_phy.h |6 +++
3 files changed, 88 insertions(+), 39 deletions(-)
  
   diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
   index 55a9cde..6bbf66a 100644
   --- a/drivers/usb/host/ehci-tegra.c
   +++ b/drivers/usb/host/ehci-tegra.c
   @@ -2,7 +2,7 @@
 * EHCI-compliant USB host controller driver for NVIDIA Tegra SoCs
 *
 * Copyright (C) 2010 Google, Inc.
   - * Copyright (C) 2009 NVIDIA Corporation
   + * Copyright (C) 2009 - 2013 NVIDIA Corporation
 *
 * This program is free software; you can redistribute it and/or modify 
   it
 * under the terms of the GNU General Public License as published by the
   @@ -33,6 +33,16 @@
#define TEGRA_USB2_BASE  0xC5004000
#define TEGRA_USB3_BASE  0xC5008000
  
   +/* PORTSC registers */
   +#define USB_PORTSC1  0x184
   +#define USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
   +#define USB_PORTSC1_PHCD (1  23)
   +#define USB_PORTSC1_WKOC (1  22)
   +#define USB_PORTSC1_WKDS (1  21)
   +#define USB_PORTSC1_WKCN (1  20)
   +#define USB_PORTSC1_PEC  (1  3)
   +#define USB_PORTSC1_CSC  (1  1)
 
  Why redefine these values when they are already defined in
  include/linux/usb/ehci_defs.h?
 
 Agreed. Will remove all above defines except PHCD  PTS, as these two
 fields are added by tegra SOC to PORTSC.
 
 
   @@ -605,6 +615,53 @@ static const struct dev_pm_ops
  tegra_ehci_pm_ops = {
  
#endif
  
   +/* Bits of PORTSC1, which will get cleared by writing 1 into them */
   +#define TEGRA_PORTSC_RWC_BITS (USB_PORTSC1_CSC |
  USB_PORTSC1_PEC)
 
  Likewise for this.  Not to mention that you forgot to include the
  overcurrent-change bit.
 
 As OCC bit is not supported by Tegra20 SOC, did not include it.
 Should I still add this, to be compliant with EHCI spec?
 Based on your comments, I can update the patch and send for review.

Any ways, as we're just adding OCC for proper RWC treatment, I don't
see any harm in adding it to the list.
Hence will update the patch with two changes mentioned by Alan. 

 
 
  Alan Stern

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


[PATCH v3 4/4] usb: Add APIs to access host registers from Tegra PHY

2013-01-17 Thread Venu Byravarasu
As Tegra PHY driver needs to access one of the Host registers,
added few APIs.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v2:
Renamed USB_PORTSC1 to TEGRA_USB_PORTSC1.
Removed tegra_ehci_set_wakeon_events() and its references.
Used standard defines for accessing PORTSC fields defined in ehci_def.h
Included OCC bit of PORTSC as part of TEGRA_PORTSC1_RWC_BITS.

delta from v1:
Taken care of RWC bits, while accessing PORTSC register.


 drivers/usb/host/ehci-tegra.c |   51 ++-
 drivers/usb/phy/tegra_usb_phy.c   |   52 -
 include/linux/usb/tegra_usb_phy.h |4 +++
 3 files changed, 64 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 55a9cde..1f596fb 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -2,7 +2,7 @@
  * EHCI-compliant USB host controller driver for NVIDIA Tegra SoCs
  *
  * Copyright (C) 2010 Google, Inc.
- * Copyright (C) 2009 NVIDIA Corporation
+ * Copyright (C) 2009 - 2013 NVIDIA Corporation
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -26,13 +26,18 @@
 #include linux/of.h
 #include linux/of_gpio.h
 #include linux/pm_runtime.h
-
+#include linux/usb/ehci_def.h
 #include linux/usb/tegra_usb_phy.h
 
 #define TEGRA_USB_BASE 0xC500
 #define TEGRA_USB2_BASE0xC5004000
 #define TEGRA_USB3_BASE0xC5008000
 
+/* PORTSC registers */
+#define TEGRA_USB_PORTSC1  0x184
+#define TEGRA_USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
+#define TEGRA_USB_PORTSC1_PHCD (1  23)
+
 #define TEGRA_USB_DMA_ALIGN 32
 
 struct tegra_ehci_hcd {
@@ -605,6 +610,37 @@ static const struct dev_pm_ops tegra_ehci_pm_ops = {
 
 #endif
 
+/* Bits of PORTSC1, which will get cleared by writing 1 into them */
+#define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
+
+void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
+   void __iomem *base = hcd-regs;
+
+   val = readl(base + TEGRA_USB_PORTSC1)  ~TEGRA_PORTSC1_RWC_BITS;
+   val = ~TEGRA_USB_PORTSC1_PTS(3);
+   val |= TEGRA_USB_PORTSC1_PTS(pts_val  3);
+   writel(val, base + TEGRA_USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_pts);
+
+void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
+   void __iomem *base = hcd-regs;
+
+   val = readl(base + TEGRA_USB_PORTSC1)  ~TEGRA_PORTSC1_RWC_BITS;
+   if (enable)
+   val |= TEGRA_USB_PORTSC1_PHCD;
+   else
+   val = ~TEGRA_USB_PORTSC1_PHCD;
+   writel(val, base + TEGRA_USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_phcd);
+
 static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32);
 
 static int tegra_ehci_probe(struct platform_device *pdev)
@@ -616,6 +652,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
int err = 0;
int irq;
int instance = pdev-id;
+   struct usb_phy *u_phy;
 
pdata = pdev-dev.platform_data;
if (!pdata) {
@@ -718,6 +755,16 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 
usb_phy_init(tegra-phy-u_phy);
 
+   hcd-phy = u_phy = tegra-phy-u_phy;
+   u_phy-otg = devm_kzalloc(pdev-dev, sizeof(struct usb_otg),
+GFP_KERNEL);
+   if (!u_phy-otg) {
+   dev_err(pdev-dev, Failed to alloc memory for otg\n);
+   err = -ENOMEM;
+   goto fail_io;
+   }
+   u_phy-otg-host = hcd_to_bus(hcd);
+
err = usb_phy_set_suspend(tegra-phy-u_phy, 0);
if (err) {
dev_err(pdev-dev, Failed to power on the phy\n);
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index ce1ff2a..d465704 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -36,19 +36,6 @@
 
 #define ULPI_VIEWPORT  0x170
 
-#define USB_PORTSC10x184
-#define   USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
-#define   USB_PORTSC1_PSPD(x)  (((x)  0x3)  26)
-#define   USB_PORTSC1_PHCD (1  23)
-#define   USB_PORTSC1_WKOC (1  22)
-#define   USB_PORTSC1_WKDS (1  21)
-#define   USB_PORTSC1_WKCN (1  20)
-#define   USB_PORTSC1_PTC(x)   (((x)  0xf)  16)
-#define   USB_PORTSC1_PP   (1  12)
-#define   USB_PORTSC1_SUSP (1  7)
-#define   USB_PORTSC1_PE   (1  2)
-#define   USB_PORTSC1_CCS  (1  0)
-
 #define USB_SUSP_CTRL  0x400
 #define   USB_WAKE_ON_CNNT_EN_DEV  (1  3)
 #define   USB_WAKE_ON_DISCON_EN_DEV(1  4)
@@ -311,11 +298,8 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
val = readl(base + USB_SUSP_CTRL);
val

[PATCH 0/4] usb: Supporting patches for registering Tegra USB PHY as a platform driver

2013-01-16 Thread Venu Byravarasu
As part of registering tegra USB PHY as platform driver, prepared
patches to add separate DT nodes describing Tegra USB PHY properties.
Modified instance number based processing to make use of the added
DT properties. As PHY will be registered as separate driver, removed
ehci register access from PHY driver and added APIs to ehci driver for
this purpose.

Venu Byravarasu (4):
  arm: tegra: Add DT nodes for Tegra USB PHY
  USB: PHY: Get rid of instance number to differentiate legacy
controller
  USB: PHY: Tegra: Get rid of instance number to differentiate PHY type
  usb: Add APIs to access host registers from Tegra PHY

 .../bindings/usb/nvidia,tegra20-ehci.txt   |1 +
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   14 +++
 arch/arm/boot/dts/tegra20.dtsi |   22 +
 drivers/usb/host/ehci-tegra.c  |   71 ++-
 drivers/usb/phy/tegra_usb_phy.c|  100 +++-
 include/linux/usb/tegra_usb_phy.h  |8 ++
 6 files changed, 149 insertions(+), 67 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt

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


[PATCH 4/4] usb: Add APIs to access host registers from Tegra PHY

2013-01-16 Thread Venu Byravarasu
As Tegra PHY driver needs to access one of the Host registers,
added few APIs.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/host/ehci-tegra.c |   71 -
 drivers/usb/phy/tegra_usb_phy.c   |   51 +++
 include/linux/usb/tegra_usb_phy.h |6 +++
 3 files changed, 89 insertions(+), 39 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 55a9cde..5299b01 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -2,7 +2,7 @@
  * EHCI-compliant USB host controller driver for NVIDIA Tegra SoCs
  *
  * Copyright (C) 2010 Google, Inc.
- * Copyright (C) 2009 NVIDIA Corporation
+ * Copyright (C) 2009 - 2013 NVIDIA Corporation
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -33,6 +33,20 @@
 #define TEGRA_USB2_BASE0xC5004000
 #define TEGRA_USB3_BASE0xC5008000
 
+/* PORTSC registers */
+#define USB_PORTSC10x184
+#define USB_PORTSC1_PTS(x) (((x)  0x3)  30)
+#define USB_PORTSC1_PSPD(x)(((x)  0x3)  26)
+#define USB_PORTSC1_PHCD   (1  23)
+#define USB_PORTSC1_WKOC   (1  22)
+#define USB_PORTSC1_WKDS   (1  21)
+#define USB_PORTSC1_WKCN   (1  20)
+#define USB_PORTSC1_PTC(x) (((x)  0xf)  16)
+#define USB_PORTSC1_PP (1  12)
+#define USB_PORTSC1_SUSP   (1  7)
+#define USB_PORTSC1_PE (1  2)
+#define USB_PORTSC1_CCS(1  0)
+
 #define TEGRA_USB_DMA_ALIGN 32
 
 struct tegra_ehci_hcd {
@@ -605,6 +619,50 @@ static const struct dev_pm_ops tegra_ehci_pm_ops = {
 
 #endif
 
+void tegra_ehci_set_wakeon_events(struct usb_phy *x, bool enable)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
+   void __iomem *base = hcd-regs;
+   u32 wake = USB_PORTSC1_WKOC | USB_PORTSC1_WKDS | USB_PORTSC1_WKCN;
+
+   val = readl(base + USB_PORTSC1);
+   if (enable)
+   val |= wake;
+   else
+   val = ~wake;
+   writel(val, base + USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_wakeon_events);
+
+void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
+   void __iomem *base = hcd-regs;
+
+   val = readl(base + USB_PORTSC1);
+   val = ~USB_PORTSC1_PTS(3);
+   val |= USB_PORTSC1_PTS(pts_val  3);
+   writel(val, base + USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_pts);
+
+void tegra_ehci_set_phcd(struct usb_phy *x, bool enable)
+{
+   unsigned long val;
+   struct usb_hcd *hcd = bus_to_hcd(x-otg-host);
+   void __iomem *base = hcd-regs;
+
+   val = readl(base + USB_PORTSC1);
+   if (enable)
+   val |= USB_PORTSC1_PHCD;
+   else
+   val = ~USB_PORTSC1_PHCD;
+   writel(val, base + USB_PORTSC1);
+}
+EXPORT_SYMBOL_GPL(tegra_ehci_set_phcd);
+
 static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32);
 
 static int tegra_ehci_probe(struct platform_device *pdev)
@@ -616,6 +674,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
int err = 0;
int irq;
int instance = pdev-id;
+   struct usb_phy *u_phy;
 
pdata = pdev-dev.platform_data;
if (!pdata) {
@@ -718,6 +777,16 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 
usb_phy_init(tegra-phy-u_phy);
 
+   hcd-phy = u_phy = tegra-phy-u_phy;
+   u_phy-otg = devm_kzalloc(pdev-dev, sizeof(struct usb_otg),
+GFP_KERNEL);
+   if (!u_phy-otg) {
+   dev_err(pdev-dev, Failed to alloc memory for otg\n);
+   err = -ENOMEM;
+   goto fail_io;
+   }
+   u_phy-otg-host = hcd_to_bus(hcd);
+
err = usb_phy_set_suspend(tegra-phy-u_phy, 0);
if (err) {
dev_err(pdev-dev, Failed to power on the phy\n);
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index ce1ff2a..f3b73b3 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -36,19 +36,6 @@
 
 #define ULPI_VIEWPORT  0x170
 
-#define USB_PORTSC10x184
-#define   USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
-#define   USB_PORTSC1_PSPD(x)  (((x)  0x3)  26)
-#define   USB_PORTSC1_PHCD (1  23)
-#define   USB_PORTSC1_WKOC (1  22)
-#define   USB_PORTSC1_WKDS (1  21)
-#define   USB_PORTSC1_WKCN (1  20)
-#define   USB_PORTSC1_PTC(x)   (((x)  0xf)  16)
-#define   USB_PORTSC1_PP   (1  12)
-#define   USB_PORTSC1_SUSP (1  7)
-#define   USB_PORTSC1_PE   (1  2)
-#define   USB_PORTSC1_CCS  (1  0)
-
 #define USB_SUSP_CTRL  0x400
 #define   USB_WAKE_ON_CNNT_EN_DEV  (1  3)
 #define   USB_WAKE_ON_DISCON_EN_DEV(1  4)
@@ -311,11 +298,8 @@ static void utmi_phy_clk_disable(struct

[PATCH 1/4] arm: tegra: Add DT nodes for Tegra USB PHY

2013-01-16 Thread Venu Byravarasu
Add DT nodes for Tegra USB PHY along with related documentation.
Also added a phandle property to controller DT node, for referring
to connected PHY instance.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 .../bindings/usb/nvidia,tegra20-ehci.txt   |1 +
 .../bindings/usb/nvidia,tegra20-usb-phy.txt|   14 
 arch/arm/boot/dts/tegra20.dtsi |   22 
 3 files changed, 37 insertions(+), 0 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt

diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
index 6ea765a..34c9528 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
@@ -11,6 +11,7 @@ Required properties :
  - phy_type : Should be one of ulpi or utmi.
  - nvidia,vbus-gpio : If present, specifies a gpio that needs to be
activated for the bus to be powered.
+ - nvidia,phy : phandle of the PHY instance, the controller is connected to.
 
 Required properties for phy_type == ulpi:
   - nvidia,phy-reset-gpio : The GPIO used to reset the PHY.
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
new file mode 100644
index 000..84a4c12
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-usb-phy.txt
@@ -0,0 +1,14 @@
+Tegra SOC USB PHY
+
+The device node for Tegra SOC USB PHY:
+
+Required properties :
+ - compatible : Should be nvidia,tegra20-usb-phy.
+ - reg : Address and length of the register set for the USB PHY interface.
+ - phy_type : Should be one of ulpi or utmi.
+
+Optional properties:
+  - nvidia,has-legacy-mode : boolean indicates whether this controller can
+operate in legacy mode (as APX 2500 / 2600). In legacy mode some
+registers are accessed through the APB_MISC base address instead of
+the USB controller.
\ No newline at end of file
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index b4c13b6..96251b0 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -394,6 +394,25 @@
#size-cells = 0;
};
 
+   phy1: usb-phy@c5000400 {
+   compatible = nvidia,tegra20-usb-phy;
+   reg = 0xc5000400 0x3c00;
+   phy_type = utmi;
+   nvidia,has-legacy-mode;
+   };
+
+   phy2: usb-phy@c5004400 {
+   compatible = nvidia,tegra20-usb-phy;
+   reg = 0xc5004400 0x3c00;
+   phy_type = ulpi;
+   };
+
+   phy3: usb-phy@c5008400 {
+   compatible = nvidia,tegra20-usb-phy;
+   reg = 0xc5008400 0x3C00;
+   phy_type = utmi;
+   };
+
usb@c500 {
compatible = nvidia,tegra20-ehci, usb-ehci;
reg = 0xc500 0x4000;
@@ -402,6 +421,7 @@
nvidia,has-legacy-mode;
status = disabled;
nvidia,needs-double-reset;
+   nvidia,phy = phy1;
};
 
usb@c5004000 {
@@ -410,6 +430,7 @@
interrupts = 0 21 0x04;
phy_type = ulpi;
status = disabled;
+   nvidia,phy = phy2;
};
 
usb@c5008000 {
@@ -418,6 +439,7 @@
interrupts = 0 97 0x04;
phy_type = utmi;
status = disabled;
+   nvidia,phy = phy3;
};
 
sdhci@c800 {
-- 
1.7.0.4

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


[PATCH 2/4] USB: PHY: Get rid of instance number to differentiate legacy controller

2013-01-16 Thread Venu Byravarasu
Tegra20 USB has 3 PHY instances. Instance 0 is based on
legacy PHY interface and other two are standard interfaces.

As instance number was used to differentiate legacy from
standard interfaces, used DT param to get this info and
processed accordingly.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/phy/tegra_usb_phy.c   |   32 +++-
 include/linux/usb/tegra_usb_phy.h |1 +
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 3059384..79280fe 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -24,6 +24,7 @@
 #include linux/platform_device.h
 #include linux/io.h
 #include linux/gpio.h
+#include linux/of.h
 #include linux/of_gpio.h
 #include linux/usb/otg.h
 #include linux/usb/ulpi.h
@@ -221,7 +222,7 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
return PTR_ERR(phy-pad_clk);
}
 
-   if (phy-instance == 0) {
+   if (phy-is_legacy_phy) {
phy-pad_regs = phy-regs;
} else {
phy-pad_regs = ioremap(TEGRA_USB_BASE, TEGRA_USB_SIZE);
@@ -236,7 +237,7 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
 
 static void utmip_pad_close(struct tegra_usb_phy *phy)
 {
-   if (phy-instance != 0)
+   if (!phy-is_legacy_phy)
iounmap(phy-pad_regs);
clk_put(phy-pad_clk);
 }
@@ -305,7 +306,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
unsigned long val;
void __iomem *base = phy-regs;
 
-   if (phy-instance == 0) {
+   if (phy-is_legacy_phy) {
val = readl(base + USB_SUSP_CTRL);
val |= USB_SUSP_SET;
writel(val, base + USB_SUSP_CTRL);
@@ -315,9 +316,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
val = readl(base + USB_SUSP_CTRL);
val = ~USB_SUSP_SET;
writel(val, base + USB_SUSP_CTRL);
-   }
-
-   if (phy-instance == 2) {
+   } else {
val = readl(base + USB_PORTSC1);
val |= USB_PORTSC1_PHCD;
writel(val, base + USB_PORTSC1);
@@ -332,7 +331,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
unsigned long val;
void __iomem *base = phy-regs;
 
-   if (phy-instance == 0) {
+   if (phy-is_legacy_phy) {
val = readl(base + USB_SUSP_CTRL);
val |= USB_SUSP_CLR;
writel(val, base + USB_SUSP_CTRL);
@@ -342,9 +341,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
val = readl(base + USB_SUSP_CTRL);
val = ~USB_SUSP_CLR;
writel(val, base + USB_SUSP_CTRL);
-   }
-
-   if (phy-instance == 2) {
+   } else {
val = readl(base + USB_PORTSC1);
val = ~USB_PORTSC1_PHCD;
writel(val, base + USB_PORTSC1);
@@ -365,7 +362,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
val |= UTMIP_RESET;
writel(val, base + USB_SUSP_CTRL);
 
-   if (phy-instance == 0) {
+   if (phy-is_legacy_phy) {
val = readl(base + USB1_LEGACY_CTRL);
val |= USB1_NO_LEGACY_MODE;
writel(val, base + USB1_LEGACY_CTRL);
@@ -440,16 +437,14 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
val |= UTMIP_BIAS_PDTRK_COUNT(0x5);
writel(val, base + UTMIP_BIAS_CFG1);
 
-   if (phy-instance == 0) {
+   if (phy-is_legacy_phy) {
val = readl(base + UTMIP_SPARE_CFG0);
if (phy-mode == TEGRA_USB_PHY_MODE_DEVICE)
val = ~FUSE_SETUP_SEL;
else
val |= FUSE_SETUP_SEL;
writel(val, base + UTMIP_SPARE_CFG0);
-   }
-
-   if (phy-instance == 2) {
+   } else {
val = readl(base + USB_SUSP_CTRL);
val |= UTMIP_PHY_ENABLE;
writel(val, base + USB_SUSP_CTRL);
@@ -459,7 +454,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
val = ~UTMIP_RESET;
writel(val, base + USB_SUSP_CTRL);
 
-   if (phy-instance == 0) {
+   if (phy-is_legacy_phy) {
val = readl(base + USB1_LEGACY_CTRL);
val = ~USB1_VBUS_SENSE_CTL_MASK;
val |= USB1_VBUS_SENSE_CTL_A_SESS_VLD;
@@ -472,7 +467,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
 
utmi_phy_clk_enable(phy);
 
-   if (phy-instance == 2) {
+   if (!phy-is_legacy_phy) {
val = readl(base + USB_PORTSC1);
val = ~USB_PORTSC1_PTS(~0);
writel(val, base + USB_PORTSC1);
@@ -739,6 +734,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
unsigned long parent_rate;
int i;
int err;
+   struct device_node *np = dev-of_node

[PATCH 3/4] USB: PHY: Tegra: Get rid of instance number to differentiate PHY type

2013-01-16 Thread Venu Byravarasu
Tegra20 USB has 3 PHY instances:
Instance 1 and 3 are UTMI. Instance 2 is ULPI.

As instance number was used to differentiate ULPI from UTMI,
used DT param to get this info and processed accordingly.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/phy/tegra_usb_phy.c   |   23 +--
 include/linux/usb/tegra_usb_phy.h |1 +
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 79280fe..ce1ff2a 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -209,11 +209,6 @@ static struct tegra_utmip_config utmip_default[] = {
},
 };
 
-static inline bool phy_is_ulpi(struct tegra_usb_phy *phy)
-{
-   return (phy-instance == 1);
-}
-
 static int utmip_pad_open(struct tegra_usb_phy *phy)
 {
phy-pad_clk = clk_get_sys(utmip-pad, NULL);
@@ -655,7 +650,7 @@ static int  tegra_phy_init(struct usb_phy *x)
struct tegra_ulpi_config *ulpi_config;
int err;
 
-   if (phy_is_ulpi(phy)) {
+   if (phy-is_ulpi_phy) {
ulpi_config = phy-config;
phy-clk = clk_get_sys(NULL, ulpi_config-clk);
if (IS_ERR(phy-clk)) {
@@ -693,7 +688,7 @@ static void tegra_usb_phy_close(struct usb_phy *x)
 {
struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, 
u_phy);
 
-   if (phy_is_ulpi(phy))
+   if (phy-is_ulpi_phy)
clk_put(phy-clk);
else
utmip_pad_close(phy);
@@ -704,7 +699,7 @@ static void tegra_usb_phy_close(struct usb_phy *x)
 
 static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
 {
-   if (phy_is_ulpi(phy))
+   if (phy-is_ulpi_phy)
return ulpi_phy_power_on(phy);
else
return utmi_phy_power_on(phy);
@@ -712,7 +707,7 @@ static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
 
 static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy)
 {
-   if (phy_is_ulpi(phy))
+   if (phy-is_ulpi_phy)
return ulpi_phy_power_off(phy);
else
return utmi_phy_power_off(phy);
@@ -749,7 +744,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
of_property_read_bool(np, nvidia,has-legacy-mode);
 
if (!phy-config) {
-   if (phy_is_ulpi(phy)) {
+   if (phy-is_ulpi_phy) {
pr_err(%s: ulpi phy configuration missing, __func__);
err = -EINVAL;
goto err0;
@@ -796,14 +791,14 @@ EXPORT_SYMBOL_GPL(tegra_usb_phy_open);
 
 void tegra_usb_phy_preresume(struct tegra_usb_phy *phy)
 {
-   if (!phy_is_ulpi(phy))
+   if (!phy-is_ulpi_phy)
utmi_phy_preresume(phy);
 }
 EXPORT_SYMBOL_GPL(tegra_usb_phy_preresume);
 
 void tegra_usb_phy_postresume(struct tegra_usb_phy *phy)
 {
-   if (!phy_is_ulpi(phy))
+   if (!phy-is_ulpi_phy)
utmi_phy_postresume(phy);
 }
 EXPORT_SYMBOL_GPL(tegra_usb_phy_postresume);
@@ -811,14 +806,14 @@ EXPORT_SYMBOL_GPL(tegra_usb_phy_postresume);
 void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy,
 enum tegra_usb_phy_port_speed port_speed)
 {
-   if (!phy_is_ulpi(phy))
+   if (!phy-is_ulpi_phy)
utmi_phy_restore_start(phy, port_speed);
 }
 EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_start);
 
 void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy)
 {
-   if (!phy_is_ulpi(phy))
+   if (!phy-is_ulpi_phy)
utmi_phy_restore_end(phy);
 }
 EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end);
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index f03e157..a6a89d4 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -60,6 +60,7 @@ struct tegra_usb_phy {
struct usb_phy u_phy;
struct device *dev;
bool is_legacy_phy;
+   bool is_ulpi_phy;
 };
 
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
-- 
1.7.0.4

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


[PATCH] usb: phy: remove unused APIs from Tegra PHY.

2013-01-15 Thread Venu Byravarasu
As tegra_usb_phy_clk_disable/enable() are not being
used, removing them.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/phy/tegra_usb_phy.c   |   13 -
 include/linux/usb/tegra_usb_phy.h |4 
 2 files changed, 0 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 2d3cae9..3059384 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -825,16 +825,3 @@ void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy)
 }
 EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end);
 
-void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy)
-{
-   if (!phy_is_ulpi(phy))
-   utmi_phy_clk_disable(phy);
-}
-EXPORT_SYMBOL_GPL(tegra_usb_phy_clk_disable);
-
-void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy)
-{
-   if (!phy_is_ulpi(phy))
-   utmi_phy_clk_enable(phy);
-}
-EXPORT_SYMBOL_GPL(tegra_usb_phy_clk_enable);
diff --git a/include/linux/usb/tegra_usb_phy.h 
b/include/linux/usb/tegra_usb_phy.h
index 176b1ca..34e6355 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -64,10 +64,6 @@ struct tegra_usb_phy {
 struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode);
 
-void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy);
-
-void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy);
-
 void tegra_usb_phy_preresume(struct tegra_usb_phy *phy);
 
 void tegra_usb_phy_postresume(struct tegra_usb_phy *phy);
-- 
1.7.0.4

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


RE: [PATCH v3] usb: phy: use kzalloc to allocate struct tegra_usb_phy

2012-12-23 Thread Venu Byravarasu
Thanks Stephen.
Venu


 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Saturday, December 22, 2012 2:25 AM
 To: Venu Byravarasu
 Cc: ba...@ti.com; gre...@linuxfoundation.org; sshtyl...@mvista.com;
 linux-ker...@vger.kernel.org; linux-usb@vger.kernel.org
 Subject: Re: [PATCH v3] usb: phy: use kzalloc to allocate struct tegra_usb_phy
 
 On 12/20/2012 11:34 PM, Venu Byravarasu wrote:
  Use kzalloc instead of kmalloc to allocate struct tegra_usb_phy.
  This ensures that all function pointers in member u_phy are
  initialized to NULL.
 
 Seems fine to me. For the record, I'd like to take this through the
 Tegra tree with all the other Tegra-related USB patches in order to
 manage any dependencies, with the USB maintainers' Acks. Thanks.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] usb: phy: tegra: Using devm API for memory allocation

2012-12-20 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Wednesday, December 19, 2012 11:08 PM
 To: Venu Byravarasu
 Cc: ba...@ti.com; gre...@linuxfoundation.org; linux-
 ker...@vger.kernel.org; linux-usb@vger.kernel.org
 Subject: Re: [PATCH] usb: phy: tegra: Using devm API for memory allocation
 
 On 12/18/2012 10:38 PM, Venu Byravarasu wrote:
  -Original Message-
  From: Stephen Warren [mailto:swar...@wwwdotorg.org]
  Sent: Tuesday, December 18, 2012 10:03 PM
  To: Venu Byravarasu
  Cc: ba...@ti.com; gre...@linuxfoundation.org; linux-
  ker...@vger.kernel.org; linux-usb@vger.kernel.org
  Subject: Re: [PATCH] usb: phy: tegra: Using devm API for memory
 allocation
 
 
  Stephen,
  As you mentioned I can replace kmalloc with kzalloc in the original code
  and push an updated patch.
  However, I just wanted to understand if there exists any issue
  in using devm_kzalloc instead of kzalloc?
 
 devm_* are intended for objects allocated during probe(), and free()d
 during remove(). The object you're allocating here isn't that case.
 
 Now, once you convert the Tegra PHY driver to be a true device, perhaps
 this object will be allocated/freed during probe/remove, so the devm_
 functions will be useful then?
 
 The problem this may cause is a memory leak. Consider the Tegra EHCI and
 PHY drivers being built as modules, the PHY driver module being inserted
 and never removed, yet the EHCI driver being continually inserted and
 removed. Since the PHY is never removed, the memory allocated by its
 devm_kzalloc() call is never freed, but it's continually re-allocated
 since tegra_usb_phy_open() is called whenever the EHCI driver module is
 inserted. You need the explicit kfree() to avoid that, and since you're
 kfree()ing somewhere other than remove(), using devm_* to make the
 allocation isn't appropriate.
 
Thanks Stephen for the detailed explanation.
Sent updated patch for review: 
http://marc.info/?l=linux-usbm=135599303216132w=2 .

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


[PATCH v3] usb: phy: use kzalloc to allocate struct tegra_usb_phy

2012-12-20 Thread Venu Byravarasu
Use kzalloc instead of kmalloc to allocate struct tegra_usb_phy.
This ensures that all function pointers in member u_phy are
initialized to NULL.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
This patch is v3 patch for the patch discussed at
http://marc.info/?l=linux-kernelm=135599303216132w=2

 drivers/usb/phy/tegra_usb_phy.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 04bf5d2..dedead5 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -736,7 +736,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev,
int err;
u8 index = is_legacy_mode ? 0 : 2;
 
-   phy = kmalloc(sizeof(struct tegra_usb_phy), GFP_KERNEL);
+   phy = kzalloc(sizeof(struct tegra_usb_phy), GFP_KERNEL);
if (!phy)
return ERR_PTR(-ENOMEM);
 
-- 
1.7.0.4

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


[PATCH] usb: tegra: Removing dependency on PHY instance number

2012-12-20 Thread Venu Byravarasu
Tegra2 has two varieties of USB PHYs:
Instance 0 - legacy PHY interface and
Instace 1  2 - non-legacy standard PHY interfaces.

PHY driver is using instance numbers to identify the
interface type.

With this patch Modified PHY driver to make use of
DT property for handling this.

ULPI PHY is used on USB PHY instance 1  UTMI is
used on other two instances. Hence modified PHY type
detection also from instance number to the parameter
passed from host driver.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
As PHY instance 2 is of UTMI type with non legacy interface,
replaced phy-instance == 2 check in all UTMI functions
with !phy-is_legacy_mode.


 drivers/usb/host/ehci-tegra.c |   27 ++-
 drivers/usb/phy/tegra_usb_phy.c   |   66 
 include/linux/usb/tegra_usb_phy.h |8 +++--
 3 files changed, 38 insertions(+), 63 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 55a9cde..9876700 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -615,7 +615,8 @@ static int tegra_ehci_probe(struct platform_device *pdev)
struct tegra_ehci_platform_data *pdata;
int err = 0;
int irq;
-   int instance = pdev-id;
+   const struct device_node *np = pdev-dev.of_node;
+   bool is_legacy_mode;
 
pdata = pdev-dev.platform_data;
if (!pdata) {
@@ -685,29 +686,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
goto fail_io;
}
 
-   /* This is pretty ugly and needs to be fixed when we do only
-* device-tree probing. Old code relies on the platform_device
-* numbering that we lack for device-tree-instantiated devices.
-*/
-   if (instance  0) {
-   switch (res-start) {
-   case TEGRA_USB_BASE:
-   instance = 0;
-   break;
-   case TEGRA_USB2_BASE:
-   instance = 1;
-   break;
-   case TEGRA_USB3_BASE:
-   instance = 2;
-   break;
-   default:
-   err = -ENODEV;
-   dev_err(pdev-dev, unknown usb instance\n);
-   goto fail_io;
-   }
-   }
+   is_legacy_mode = of_property_read_bool(np, nvidia,has-legacy-mode);
 
-   tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
+   tegra-phy = tegra_usb_phy_open(pdev-dev, is_legacy_mode, hcd-regs,
pdata-phy_config,
TEGRA_USB_PHY_MODE_HOST);
if (IS_ERR(tegra-phy)) {
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 9d13c81..9385216 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -208,11 +208,6 @@ static struct tegra_utmip_config utmip_default[] = {
},
 };
 
-static inline bool phy_is_ulpi(struct tegra_usb_phy *phy)
-{
-   return (phy-instance == 1);
-}
-
 static int utmip_pad_open(struct tegra_usb_phy *phy)
 {
phy-pad_clk = clk_get_sys(utmip-pad, NULL);
@@ -221,7 +216,7 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
return PTR_ERR(phy-pad_clk);
}
 
-   if (phy-instance == 0) {
+   if (phy-is_legacy_mode) {
phy-pad_regs = phy-regs;
} else {
phy-pad_regs = ioremap(TEGRA_USB_BASE, TEGRA_USB_SIZE);
@@ -236,7 +231,7 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
 
 static void utmip_pad_close(struct tegra_usb_phy *phy)
 {
-   if (phy-instance != 0)
+   if (!phy-is_legacy_mode)
iounmap(phy-pad_regs);
clk_put(phy-pad_clk);
 }
@@ -305,7 +300,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
unsigned long val;
void __iomem *base = phy-regs;
 
-   if (phy-instance == 0) {
+   if (phy-is_legacy_mode) {
val = readl(base + USB_SUSP_CTRL);
val |= USB_SUSP_SET;
writel(val, base + USB_SUSP_CTRL);
@@ -315,9 +310,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
val = readl(base + USB_SUSP_CTRL);
val = ~USB_SUSP_SET;
writel(val, base + USB_SUSP_CTRL);
-   }
-
-   if (phy-instance == 2) {
+   } else {
val = readl(base + USB_PORTSC1);
val |= USB_PORTSC1_PHCD;
writel(val, base + USB_PORTSC1);
@@ -332,7 +325,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
unsigned long val;
void __iomem *base = phy-regs;
 
-   if (phy-instance == 0) {
+   if (phy-is_legacy_mode) {
val = readl(base + USB_SUSP_CTRL);
val |= USB_SUSP_CLR;
writel(val, base + USB_SUSP_CTRL);
@@ -342,9 +335,7 @@ static void utmi_phy_clk_enable

RE: [PATCH] usb: phy: tegra: Using devm API for memory allocation

2012-12-18 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Tuesday, December 18, 2012 10:03 PM
 To: Venu Byravarasu
 Cc: ba...@ti.com; gre...@linuxfoundation.org; linux-
 ker...@vger.kernel.org; linux-usb@vger.kernel.org
 Subject: Re: [PATCH] usb: phy: tegra: Using devm API for memory allocation
 
 On 12/17/2012 11:21 PM, Venu Byravarasu wrote:
  Using devm_kzalloc for allocating memory needed for PHY
  pointer and hence removing kfree calls to PHY pointer.
 
 Since the kfree() here used to be in tegra_usb_phy_close() rather than
 any remove() function, does it actually make sense to use
 devm_kzalloc(); would plain using kzalloc() instead, and not removing
 the kfree() calls, be better?
 
 
Stephen,
As you mentioned I can replace kmalloc with kzalloc in the original code 
and push an updated patch.
However, I just wanted to understand if there exists any issue
in using devm_kzalloc instead of kzalloc?

 When the PHY code gets converted to be an actual probed driver, then
 perhaps using devm will make sense.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: phy: tegra: Using devm API for memory allocation

2012-12-17 Thread Venu Byravarasu
Using devm_kzalloc for allocating memory needed for PHY
pointer and hence removing kfree calls to PHY pointer.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/phy/tegra_usb_phy.c |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 9d13c81..0b99e1f 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -704,7 +704,6 @@ static void tegra_usb_phy_close(struct usb_phy *x)
utmip_pad_close(phy);
clk_disable_unprepare(phy-pll_u);
clk_put(phy-pll_u);
-   kfree(phy);
 }
 
 static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
@@ -740,7 +739,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device 
*dev, int instance,
int i;
int err;
 
-   phy = kmalloc(sizeof(struct tegra_usb_phy), GFP_KERNEL);
+   phy = devm_kzalloc(dev, sizeof(struct tegra_usb_phy), GFP_KERNEL);
if (!phy)
return ERR_PTR(-ENOMEM);
 
@@ -791,7 +790,6 @@ err1:
clk_disable_unprepare(phy-pll_u);
clk_put(phy-pll_u);
 err0:
-   kfree(phy);
return ERR_PTR(err);
 }
 EXPORT_SYMBOL_GPL(tegra_usb_phy_open);
-- 
1.7.0.4

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


[PATCH] usb: host: tegra: make use of PHY pointer of HCD

2012-12-17 Thread Venu Byravarasu
As pointer to PHY structure can be stored in struct usb_hcd
making use of it, to call PHY APIs.

Call to usb_phy_shutdown() is moved up in tegra_ehci_remove(),
so that to avoid dereferencing of hcd after its freed up.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
This patch depends on patch 
http://marc.info/?l=linux-kernelm=135581274019690w=2.
Without above patch applied, phy-notify_connect  phy-notify_disconnect are
set to some unknown values, which need not be NULL.
This creates problem when hcd-phy pointer is initialized hub_port_init() in 
hub.c
calls usb_phy_notify_connect().

Stephen,
Can you plz take this patch through tegra tree, so as to take care of the 
dependencies?

 drivers/usb/host/ehci-tegra.c |   19 +++
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index aca6606..5b2c48d 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -53,7 +53,7 @@ static void tegra_ehci_power_up(struct usb_hcd *hcd)
 
clk_prepare_enable(tegra-emc_clk);
clk_prepare_enable(tegra-clk);
-   usb_phy_set_suspend(tegra-phy-u_phy, 0);
+   usb_phy_set_suspend(hcd-phy, 0);
tegra-host_resumed = 1;
 }
 
@@ -62,7 +62,7 @@ static void tegra_ehci_power_down(struct usb_hcd *hcd)
struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd-self.controller);
 
tegra-host_resumed = 0;
-   usb_phy_set_suspend(tegra-phy-u_phy, 1);
+   usb_phy_set_suspend(hcd-phy, 1);
clk_disable_unprepare(tegra-clk);
clk_disable_unprepare(tegra-emc_clk);
 }
@@ -716,9 +716,14 @@ static int tegra_ehci_probe(struct platform_device *pdev)
goto fail_io;
}
 
-   usb_phy_init(tegra-phy-u_phy);
+   hcd-phy = tegra-phy-u_phy;
+   err = usb_phy_init(hcd-phy);
+   if (err) {
+   dev_err(pdev-dev, Failed to initialize phy\n);
+   goto fail;
+   }
 
-   err = usb_phy_set_suspend(tegra-phy-u_phy, 0);
+   err = usb_phy_set_suspend(hcd-phy, 0);
if (err) {
dev_err(pdev-dev, Failed to power on the phy\n);
goto fail;
@@ -764,7 +769,7 @@ fail:
if (!IS_ERR_OR_NULL(tegra-transceiver))
otg_set_host(tegra-transceiver-otg, NULL);
 #endif
-   usb_phy_shutdown(tegra-phy-u_phy);
+   usb_phy_shutdown(hcd-phy);
 fail_io:
clk_disable_unprepare(tegra-emc_clk);
 fail_emc_clk:
@@ -787,12 +792,10 @@ static int tegra_ehci_remove(struct platform_device *pdev)
if (!IS_ERR_OR_NULL(tegra-transceiver))
otg_set_host(tegra-transceiver-otg, NULL);
 #endif
-
+   usb_phy_shutdown(hcd-phy);
usb_remove_hcd(hcd);
usb_put_hcd(hcd);
 
-   usb_phy_shutdown(tegra-phy-u_phy);
-
clk_disable_unprepare(tegra-clk);
 
clk_disable_unprepare(tegra-emc_clk);
-- 
1.7.0.4

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


[PATCH 0/2] usb: tegra: modifying port reset based on instance number

2012-12-13 Thread Venu Byravarasu
Tegra USB host driver is using port instance number,
to handle some of the hardware issues on SOC e.g. reset PORT0
twice etc. As instance number based handling looks ugly,
added a new property to USB DT node for this purpose.
Modified host driver to make use of the information passed
through DT to reset the port second time.


Venu Byravarasu (2):
  arm: tegra: Add new DT property to USB node.
  usb: host: tegra: Resetting PORT0 based on information received via
DT.

 .../bindings/usb/nvidia,tegra20-ehci.txt   |2 ++
 arch/arm/boot/dts/tegra20.dtsi |1 +
 drivers/usb/host/ehci-tegra.c  |6 +-
 3 files changed, 8 insertions(+), 1 deletions(-)

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


[PATCH 1/2] arm: tegra: Add new DT property to USB node.

2012-12-13 Thread Venu Byravarasu
As Tegra USB host driver is using instance number for resetting
PORT0 twice, adding a new DT property for handling this.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 .../bindings/usb/nvidia,tegra20-ehci.txt   |2 ++
 arch/arm/boot/dts/tegra20.dtsi |1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt 
b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
index e9b005d..443a2b4 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
@@ -27,3 +27,5 @@ Optional properties:
 registers are accessed through the APB_MISC base address instead of
 the USB controller. Since this is a legacy issue it probably does not
 warrant a compatible string of its own.
+  - nvidia,needs-double-reset : boolean is to be set for some of the Tegra2
+USB ports, which need reset twice due to hardware issues.
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index b8effa1..3ebbd0c 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -364,6 +364,7 @@
phy_type = utmi;
nvidia,has-legacy-mode;
status = disabled;
+   nvidia,needs-double-reset;
};
 
usb@c5004000 {
-- 
1.7.0.4

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


[PATCH 2/2] usb: host: tegra: Resetting PORT0 based on information received via DT.

2012-12-13 Thread Venu Byravarasu
Tegra USB host driver is using port instance number,
to handle some of the hardware issues on SOC e.g. reset PORT0
twice etc. As instance number based handling looks ugly,
making use of information passed through DT for achieving this.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
 drivers/usb/host/ehci-tegra.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index acf1755..55a9cde 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -43,6 +43,7 @@ struct tegra_ehci_hcd {
struct usb_phy *transceiver;
int host_resumed;
int port_resuming;
+   bool needs_double_reset;
enum tegra_usb_phy_port_speed port_speed;
 };
 
@@ -184,7 +185,7 @@ static int tegra_ehci_hub_control(
}
 
/* For USB1 port we need to issue Port Reset twice internally */
-   if (tegra-phy-instance == 0 
+   if (tegra-needs_double_reset 
   (typeReq == SetPortFeature  wValue == USB_PORT_FEAT_RESET)) {
spin_unlock_irqrestore(ehci-lock, flags);
return tegra_ehci_internal_port_reset(ehci, status_reg);
@@ -666,6 +667,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
clk_prepare_enable(tegra-emc_clk);
clk_set_rate(tegra-emc_clk, 4);
 
+   tegra-needs_double_reset = of_property_read_bool(pdev-dev.of_node,
+   nvidia,needs-double-reset);
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(pdev-dev, Failed to get I/O memory\n);
-- 
1.7.0.4

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


RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-23 Thread Venu Byravarasu
 -Original Message-
 From: Venu Byravarasu
 Sent: Monday, October 22, 2012 4:04 PM
 To: 'ba...@ti.com'
 Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org; linux-
 u...@vger.kernel.org; linux-ker...@vger.kernel.org
 Subject: RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
 
 
  what is this SOC dependent PHY driver ?
 
 SOC dependent PHY driver actually deals with the PHY interface
 programming.
 e.g. please see code present in tegra2_usb_driver.c.
 
  What sort of dependencies are
  there ? Those differences should be handled with runtime checks.
 
 As PHY related bugs got fixed across different set of SOCs apart from
 adding few features, wanted to separate this out from common PHY
 functionality. This will help us in adding support for different SOCs with
 minimum set of changes.

Felipe,

Please let me know if you have any more questions on this patch.
If not, can you please merge this?

Thanks,
Venu

 
  --
  balbi
 
  * Unknown Key
  * 0x35CAA444
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-22 Thread Venu Byravarasu

 -Original Message-
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Friday, October 19, 2012 9:06 PM
 To: Venu Byravarasu
 Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org;
 ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org
 Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
 
 * PGP Signed by an unknown key
 
 Hi,
 
 On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote:
  NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
 
 I was reading this driver more closely and I have a bunch of questions
 about it, but the most important of all of them is: why isn't that a
 real PHY driver ?. It doesn't have a probe() function, it doesn't use
 struct usb_phy to represent the PHY, it has a bunch of tegra-specific
 APIs and we can't let those continue.
 
 Please, take a look at drivers/usb/phy/omap_usb2.c (misnamed actually,
 should be phy-omap-usb2.c so we have a common prefix) to see how your
 PHY driver should look like and which sort of functionality if should
 expose to the rest of the kernel.

Hi Felipe, 

I'll go through omap phy driver and prepare similar patches for tegra phy driver
and push them with upcoming patches.
As current patch is mostly re-organizing the existing phy driver, can you plz 
merge
This as is?

Thanks,
Venu

 
 Please comment on the above.
 
 cheers
 
 --
 balbi
 
 * Unknown Key
 * 0x35CAA444
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-22 Thread Venu Byravarasu
 -Original Message-
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Monday, October 22, 2012 3:33 PM
 To: Venu Byravarasu
 Cc: ba...@ti.com; st...@rowland.harvard.edu;
 gre...@linuxfoundation.org; linux-usb@vger.kernel.org; linux-
 ker...@vger.kernel.org
 Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
 
 * PGP Signed by an unknown key
 
 Hi,
 
 On Mon, Oct 22, 2012 at 02:00:00PM +0530, Venu Byravarasu wrote:
   -Original Message-
   From: Felipe Balbi [mailto:ba...@ti.com]
   Sent: Friday, October 19, 2012 9:06 PM
   To: Venu Byravarasu
   Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org;
   ba...@ti.com; linux-usb@vger.kernel.org; linux-ker...@vger.kernel.org
   Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY
 driver
  
Old Signed by an unknown key
  
   Hi,
  
   On Fri, Oct 19, 2012 at 04:08:05PM +0530, Venu Byravarasu wrote:
NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
  
   I was reading this driver more closely and I have a bunch of questions
   about it, but the most important of all of them is: why isn't that a
   real PHY driver ?. It doesn't have a probe() function, it doesn't use
   struct usb_phy to represent the PHY, it has a bunch of tegra-specific
   APIs and we can't let those continue.
  
   Please, take a look at drivers/usb/phy/omap_usb2.c (misnamed actually,
   should be phy-omap-usb2.c so we have a common prefix) to see how
 your
   PHY driver should look like and which sort of functionality if should
   expose to the rest of the kernel.
 
  Hi Felipe,
 
  I'll go through omap phy driver and prepare similar patches for tegra
  phy driver and push them with upcoming patches.
  As current patch is mostly re-organizing the existing phy driver, can
  you plz merge This as is?
 
 I would have to convince me about the need for that (and I'm open to be
 convinced ;-), because if a later series of patches will come getting
 rid of the current driver and turning it into a real PHY driver, I don't
 see the benefit of taking $SUBJECT.
 

Hi Felipe,

The current patch splits out the existing tegra USB phy driver into two parts, 
as
you would have already noticed from the code.
The probe and etc changes that you asked to add, will be applicable to common
Phy driver and should not have any implications on SOC dependent phy driver.
Hence once this patch gets merged, it will be easier for me to modify SOC
agnostic common phy driver in the way you suggested.

Thanks,
Venu

 --
 balbi
 
 * Unknown Key
 * 0x35CAA444
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver

2012-10-22 Thread Venu Byravarasu
 -Original Message-
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Monday, October 22, 2012 3:46 PM
 To: Venu Byravarasu
 Cc: ba...@ti.com; st...@rowland.harvard.edu;
 gre...@linuxfoundation.org; linux-usb@vger.kernel.org; linux-
 ker...@vger.kernel.org
 Subject: Re: [PATCH v3 resend] USB: PHY: Re-organize Tegra USB PHY driver
 
 * PGP Signed by an unknown key
 
 Hi,
 
 
  Hi Felipe,
 
  The current patch splits out the existing tegra USB phy driver into two 
  parts,
 as
  you would have already noticed from the code.
  The probe and etc changes that you asked to add, will be applicable to
 common
  Phy driver and should not have any implications on SOC dependent phy
 driver.
 
 what is this SOC dependent PHY driver ? 

SOC dependent PHY driver actually deals with the PHY interface programming.
e.g. please see code present in tegra2_usb_driver.c. 

 What sort of dependencies are
 there ? Those differences should be handled with runtime checks.
 
As PHY related bugs got fixed across different set of SOCs apart from
adding few features, wanted to separate this out from common PHY
functionality. This will help us in adding support for different SOCs with
minimum set of changes.

 --
 balbi
 
 * Unknown Key
 * 0x35CAA444
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] usb: host: tegra remove include of mach/iomap.h

2012-10-02 Thread Venu Byravarasu

 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Wednesday, October 03, 2012 4:19 AM
 To: Greg Kroah-Hartman
 Cc: linux-usb@vger.kernel.org; linux-te...@vger.kernel.org; Stephen
 Warren; Venu Byravarasu
 Subject: [PATCH] usb: host: tegra remove include of mach/iomap.h
 
 From: Stephen Warren swar...@nvidia.com
 
 Almost nothing from this file is used, and the file will hopefully be
 deleted soon. Copy the tiny portions that are used directly into
 ehci-tegra.c. I believe that Venu Byravarasu is working on cleaning up
 our USB driver, and those cleanups will remove the need for these
 constants.
 
 Signed-off-by: Stephen Warren swar...@nvidia.com
 Cc: Venu Byravarasu vbyravar...@nvidia.com
 ---
 Greg, if this patch can get into 3.7 (it's late, I know) at a point before
 wherever you branch off your USB tree for 3.8, then that would be great.
 If not, may I please request this patch be merged into a separate branch/tag
 that is merged into both the Tegra and USB trees for 3.8, since I will
 probably have cleanup patches in the Tegra tree that depend on this change,
 and Venu will likely be sending patches through the USB tree that will need
 to be merged with this too.
 ---
  drivers/usb/host/ehci-tegra.c |5 -
  1 files changed, 4 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 index 6223d17..2de0890 100644
 --- a/drivers/usb/host/ehci-tegra.c
 +++ b/drivers/usb/host/ehci-tegra.c
 @@ -28,7 +28,10 @@
  #include linux/pm_runtime.h
 
  #include linux/usb/tegra_usb_phy.h
 -#include mach/iomap.h
 +
 +#define TEGRA_USB_BASE   0xC500
 +#define TEGRA_USB2_BASE  0xC5004000
 +#define TEGRA_USB3_BASE  0xC5008000
 
  #define TEGRA_USB_DMA_ALIGN 32
 

This change looks fine to me. Plz consider my ACK.
Acked-by: Venu Byravarasu vbyravar...@nvidia.com 

 --
 1.7.0.4

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


RE: [PATCH] usb: phy: tegra remove include of mach/iomap.h

2012-10-02 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Wednesday, October 03, 2012 4:20 AM
 To: Felipe Balbi
 Cc: Greg Kroah-Hartman; linux-usb@vger.kernel.org; linux-
 te...@vger.kernel.org; Stephen Warren; Venu Byravarasu
 Subject: [PATCH] usb: phy: tegra remove include of mach/iomap.h
 
 From: Stephen Warren swar...@nvidia.com
 
 Almost nothing from this file is used, and the file will hopefully be
 deleted soon. Copy the tiny portions that are used directly into
 tegra_usb_phy.c. I believe that Venu Byravarasu is working on cleaning up
 our USB driver, and those cleanups will remove the need for these
 constants.
 
 Signed-off-by: Stephen Warren swar...@nvidia.com
 Cc: Venu Byravarasu vbyravar...@nvidia.com
 ---
 Felipe, Greg, if this patch can get into 3.7 (it's late, I know) at a point
 before wherever you branch off your USB tree for 3.8, then that would be
 great. If not, may I please request this patch be merged into a separate
 branch/tag that is merged into both the Tegra and USB trees for 3.8, since
 I will probably have cleanup patches in the Tegra tree that depend on this
 change, and Venu will likely be sending patches through the USB tree that
 will need to be merged with this too.
 ---
  drivers/usb/phy/tegra_usb_phy.c |4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/usb/phy/tegra_usb_phy.c
 b/drivers/usb/phy/tegra_usb_phy.c
 index 987116f..9d13c81 100644
 --- a/drivers/usb/phy/tegra_usb_phy.c
 +++ b/drivers/usb/phy/tegra_usb_phy.c
 @@ -29,7 +29,9 @@
  #include linux/usb/ulpi.h
  #include asm/mach-types.h
  #include linux/usb/tegra_usb_phy.h
 -#include mach/iomap.h
 +
 +#define TEGRA_USB_BASE   0xC500
 +#define TEGRA_USB_SIZE   SZ_16K

This change looks fine to me. Plz consider my ACK.
Acked-by: Venu Byravarasu vbyravar...@nvidia.com 

 
  #define ULPI_VIEWPORT0x170
 
 --
 1.7.0.4

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


RE: [PATCH v3] USB: PHY: Re-organize Tegra USB PHY driver

2012-09-24 Thread Venu Byravarasu
 -Original Message-
 From: ABRAHAM, KISHON VIJAY [mailto:kis...@ti.com]
 Sent: Monday, September 24, 2012 11:48 AM
 To: Venu Byravarasu
 Cc: Stephen Warren; ba...@ti.com; gre...@linuxfoundation.org; linux-
 ker...@vger.kernel.org; linux-usb@vger.kernel.org
 Subject: Re: [PATCH v3] USB: PHY: Re-organize Tegra USB PHY driver
 
 Hi,
 
 On Sat, Sep 22, 2012 at 2:08 PM, Venu Byravarasu
 vbyravar...@nvidia.com wrote:
  -Original Message-
  From: Stephen Warren [mailto:swar...@wwwdotorg.org]
  Sent: Friday, September 21, 2012 9:45 PM
  To: ABRAHAM, KISHON VIJAY
  Cc: Venu Byravarasu; ba...@ti.com; gre...@linuxfoundation.org; linux-
  ker...@vger.kernel.org; linux-usb@vger.kernel.org
  Subject: Re: [PATCH v3] USB: PHY: Re-organize Tegra USB PHY driver
 
  On 09/21/2012 07:09 AM, ABRAHAM, KISHON VIJAY wrote:
   Hi,
  
   On Fri, Sep 21, 2012 at 5:50 PM, Venu Byravarasu
  vbyravar...@nvidia.com wrote:
   NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
   In order to support USB PHY drivers on these SoCs, existing
   PHY driver is split into SoC agnostic common USB PHY driver
   and Tegra20-specific USB phy driver. This will facilitate
   easy addition and deletion of phy drivers for Tegra SoCs.
 
   @@ -618,6 +618,9 @@ static int tegra_ehci_probe(struct
 platform_device
  *pdev)
  ...
   pdata = pdev-dev.platform_data;
   if (!pdata) {
 
  Some missing lines of context are:
 
  dev_err(pdev-dev, Platform data missing\n);
  return -EINVAL;
  }
 
  ...
   +   params.mode = TEGRA_USB_PHY_MODE_HOST;
   +   params.config = pdata-phy_config;
  
   I fail to understand how pdata is not NULL in dt boot. I know i've
   already given this comment and you replied that you dint see any
   crash. But I'd like to know where and how pdata gets populated.
 
  In practice, the platform uses AUXDATA to provide platform data to the
  driver even when it's instantiated using device tree; see
  arch/arm/mach-tegra/board-dt-tegra20.c variables tegra_ehci*_pdata
 and
  tegra20_auxdata_lookup[].
 
  In the slightly (very very slightly, hopefully) longer term, I would
  like to completely remove the AUXDATA setup from board-dt-tegra20.c;
  tegra_ehci_probe() should do something like:
 
  pdata = pdev-dev.platform_data
  if (!pdata)
  pdata = parse_pdata_from_dt();
  /* user didn't specify any in DT either */
  if (!pdata)
  pdata = default_pdata_for_port();
 
  ... where perhaps the use of defaults could be folded into
  parse_pdata_from_dt().
 
 
  Thanks Stephen for the detailed explanation.
 
  Kishon / Felipe,
  Do you have any more questions in this related, before patch can be
 applied?
 
 I don't have any further comments.
 

Thanks Kishon for your quick response.
 

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


RE: [PATCH v2] USB: PHY: Re-organize Tegra USB PHY driver

2012-09-21 Thread Venu Byravarasu
 -Original Message-
 From: Felipe Balbi [mailto:ba...@ti.com]
 Sent: Friday, September 21, 2012 3:07 PM
 To: Venu Byravarasu
 Cc: gre...@linuxfoundation.org; ba...@ti.com; Stephen Warren; linux-
 ker...@vger.kernel.org; linux-usb@vger.kernel.org; linux-
 te...@vger.kernel.org; Stephen Warren; st...@rowland.harvard.edu
 Subject: Re: [PATCH v2] USB: PHY: Re-organize Tegra USB PHY driver
 
 * PGP Signed by an unknown key
 
 Hi,
 
 On Thu, Sep 20, 2012 at 05:32:36PM +0530, Venu Byravarasu wrote:
  Thanks Greg, for quick response.
 
 I'm waiting for a newer version fixing Kishon's comments. 

As I mentioned in reply to his comments,  most of the patch is
dealing with re-organizing the code. Hence kept the cleaning
part aside for next patch.

 BTW, his comment about pdata usage is 100% valid. You should fix that.
 

Are you referring to below comments:

It's better you have the below code under *if (np)*, since both device
node and pdata co-exist for you.
 +   phy_type = of_property_match_string(np, phy_type, utmi);
 +   if (phy_type = 0)
 
If so, I can address it and push an updated patch with that.

 --
 balbi
 
 * Unknown Key
 * 0x35CAA444
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3] USB: PHY: Re-organize Tegra USB PHY driver

2012-09-21 Thread Venu Byravarasu
NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
In order to support USB PHY drivers on these SoCs, existing
PHY driver is split into SoC agnostic common USB PHY driver
and Tegra20-specific USB phy driver. This will facilitate
easy addition and deletion of phy drivers for Tegra SoCs.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v2:

Added an if condition to check for device_node to be not NULL,
before dereferencing it.

 drivers/usb/host/ehci-tegra.c  |   26 +-
 drivers/usb/phy/Makefile   |1 +
 .../usb/phy/{tegra_usb_phy.c = tegra2_usb_phy.c}  |  421 +++--
 drivers/usb/phy/tegra2_usb_phy.h   |  140 
 drivers/usb/phy/tegra_usb_phy.c|  688 +---
 include/linux/usb/tegra_usb_phy.h  |   34 +-
 6 files changed, 298 insertions(+), 1012 deletions(-)
 copy drivers/usb/phy/{tegra_usb_phy.c = tegra2_usb_phy.c} (53%)
 create mode 100644 drivers/usb/phy/tegra2_usb_phy.h

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 6223d17..8199a6e 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -618,6 +618,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
int err = 0;
int irq;
int instance = pdev-id;
+   struct device_node *np = pdev-dev.of_node;
+   struct phy_params params;
+   int phy_type;
 
pdata = pdev-dev.platform_data;
if (!pdata) {
@@ -701,14 +704,29 @@ static int tegra_ehci_probe(struct platform_device *pdev)
break;
default:
err = -ENODEV;
-   dev_err(pdev-dev, unknown usb instance\n);
+   dev_err(pdev-dev, unknown usb inst:%d\n, instance);
goto fail_io;
}
}
 
+   if (np) {
+   phy_type = of_property_match_string(np, phy_type, utmi);
+   if (phy_type = 0)
+   params.type = TEGRA_USB_PHY_TYPE_UTMI;
+   else {
+   phy_type = of_property_match_string(np, phy_type, 
ulpi);
+   if (phy_type = 0)
+   params.type = TEGRA_USB_PHY_TYPE_ULPI;
+   else
+   params.type = TEGRA_USB_PHY_TYPE_INVALID;
+   }
+   }
+
+   params.mode = TEGRA_USB_PHY_MODE_HOST;
+   params.config = pdata-phy_config;
+
tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
-   pdata-phy_config,
-   TEGRA_USB_PHY_MODE_HOST);
+   params);
if (IS_ERR(tegra-phy)) {
dev_err(pdev-dev, Failed to open USB phy\n);
err = -ENXIO;
@@ -744,7 +762,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 
err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err) {
-   dev_err(pdev-dev, Failed to add USB HCD\n);
+   dev_err(pdev-dev, usb_add_hcd failed with err 0x%x\n, err);
goto fail;
}
 
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..21872e1 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra2_usb_phy.o
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra2_usb_phy.c
similarity index 53%
copy from drivers/usb/phy/tegra_usb_phy.c
copy to drivers/usb/phy/tegra2_usb_phy.c
index 987116f..4896a4d 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra2_usb_phy.c
@@ -1,9 +1,11 @@
 /*
  * Copyright (C) 2010 Google, Inc.
+ * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
  *
  * Author:
  * Erik Gilling konk...@google.com
  * Benoit Goby ben...@android.com
+ *  Venu Byravarasu vbyravar...@nvidia.com
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -31,187 +33,18 @@
 #include linux/usb/tegra_usb_phy.h
 #include mach/iomap.h
 
-#define ULPI_VIEWPORT  0x170
-
-#define USB_PORTSC10x184
-#define   USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
-#define   USB_PORTSC1_PSPD(x)  (((x)  0x3)  26)
-#define   USB_PORTSC1_PHCD (1  23)
-#define   USB_PORTSC1_WKOC (1  22)
-#define   USB_PORTSC1_WKDS (1  21)
-#define   USB_PORTSC1_WKCN (1  20)
-#define   USB_PORTSC1_PTC(x)   (((x)  0xf)  16)
-#define   USB_PORTSC1_PP   (1  12)
-#define   USB_PORTSC1_SUSP (1  7)
-#define   USB_PORTSC1_PE   (1  2)
-#define   USB_PORTSC1_CCS  (1  0)
-
-#define

RE: [PATCH v2] USB: PHY: Re-organize Tegra USB PHY driver

2012-09-20 Thread Venu Byravarasu
Thanks Greg, for quick response.
Venu


 -Original Message-
 From: gre...@linuxfoundation.org [mailto:gre...@linuxfoundation.org]
 Sent: Thursday, September 20, 2012 5:30 PM
 To: Venu Byravarasu
 Cc: ba...@ti.com; Stephen Warren; linux-ker...@vger.kernel.org; linux-
 u...@vger.kernel.org; linux-te...@vger.kernel.org; Stephen Warren;
 st...@rowland.harvard.edu
 Subject: Re: [PATCH v2] USB: PHY: Re-organize Tegra USB PHY driver
 
 On Thu, Sep 20, 2012 at 10:50:51AM +0530, Venu Byravarasu wrote:
  Hi Greg  Felipe,
 
  Can any of you please review and merge this change?
 
 That's up to Felipe.

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


RE: [PATCH v2] USB: PHY: Re-organize Tegra USB PHY driver

2012-09-19 Thread Venu Byravarasu
Hi Greg  Felipe,

Can any of you please review and merge this change?

Thanks,
Venu


 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Thursday, September 13, 2012 10:49 PM
 To: Venu Byravarasu
 Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org;
 ba...@ti.com; Stephen Warren; linux-ker...@vger.kernel.org; linux-
 u...@vger.kernel.org; linux-te...@vger.kernel.org
 Subject: Re: [PATCH v2] USB: PHY: Re-organize Tegra USB PHY driver
 
 On 09/13/2012 01:02 AM, Venu Byravarasu wrote:
  NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
  In order to support USB PHY drivers on these SoCs, existing
  PHY driver is split into SoC agnostic common USB PHY driver
  and Tegra20-specific USB phy driver. This will facilitate
  easy addition and deletion of phy drivers for Tegra SoCs.
 
  Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
 
 Tested-by: Stephen Warren swar...@wwwdotorg.org
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] USB: PHY: Re-organize Tegra USB PHY driver

2012-09-13 Thread Venu Byravarasu
NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
In order to support USB PHY drivers on these SoCs, existing
PHY driver is split into SoC agnostic common USB PHY driver
and Tegra20-specific USB phy driver. This will facilitate
easy addition and deletion of phy drivers for Tegra SoCs.

Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
---
delta from v1:

1. Added two new phy_open functions, which will be called based
on the phy type being used.
2. Moved function pointer initialization to these two functions.
3. Renamed usb_phy_ops to tegra_usb_phy_ops.
4. Moved tegra_freq_table from header to tegra_usb_phy.c

 drivers/usb/host/ehci-tegra.c  |   24 +-
 drivers/usb/phy/Makefile   |1 +
 .../usb/phy/{tegra_usb_phy.c = tegra2_usb_phy.c}  |  421 +++--
 drivers/usb/phy/tegra2_usb_phy.h   |  140 
 drivers/usb/phy/tegra_usb_phy.c|  688 +---
 include/linux/usb/tegra_usb_phy.h  |   34 +-
 6 files changed, 296 insertions(+), 1012 deletions(-)
 copy drivers/usb/phy/{tegra_usb_phy.c = tegra2_usb_phy.c} (53%)
 create mode 100644 drivers/usb/phy/tegra2_usb_phy.h

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 6223d17..15af372 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -618,6 +618,9 @@ static int tegra_ehci_probe(struct platform_device *pdev)
int err = 0;
int irq;
int instance = pdev-id;
+   struct device_node *np = pdev-dev.of_node;
+   struct phy_params params;
+   int phy_type;
 
pdata = pdev-dev.platform_data;
if (!pdata) {
@@ -701,14 +704,27 @@ static int tegra_ehci_probe(struct platform_device *pdev)
break;
default:
err = -ENODEV;
-   dev_err(pdev-dev, unknown usb instance\n);
+   dev_err(pdev-dev, unknown usb inst:%d\n, instance);
goto fail_io;
}
}
 
+   phy_type = of_property_match_string(np, phy_type, utmi);
+   if (phy_type = 0)
+   params.type = TEGRA_USB_PHY_TYPE_UTMI;
+   else {
+   phy_type = of_property_match_string(np, phy_type, ulpi);
+   if (phy_type = 0)
+   params.type = TEGRA_USB_PHY_TYPE_ULPI;
+   else
+   params.type = TEGRA_USB_PHY_TYPE_INVALID;
+   }
+
+   params.mode = TEGRA_USB_PHY_MODE_HOST;
+   params.config = pdata-phy_config;
+
tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
-   pdata-phy_config,
-   TEGRA_USB_PHY_MODE_HOST);
+   params);
if (IS_ERR(tegra-phy)) {
dev_err(pdev-dev, Failed to open USB phy\n);
err = -ENXIO;
@@ -744,7 +760,7 @@ static int tegra_ehci_probe(struct platform_device *pdev)
 
err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err) {
-   dev_err(pdev-dev, Failed to add USB HCD\n);
+   dev_err(pdev-dev, usb_add_hcd failed with err 0x%x\n, err);
goto fail;
}
 
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..21872e1 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra2_usb_phy.o
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra2_usb_phy.c
similarity index 53%
copy from drivers/usb/phy/tegra_usb_phy.c
copy to drivers/usb/phy/tegra2_usb_phy.c
index 987116f..4896a4d 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra2_usb_phy.c
@@ -1,9 +1,11 @@
 /*
  * Copyright (C) 2010 Google, Inc.
+ * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
  *
  * Author:
  * Erik Gilling konk...@google.com
  * Benoit Goby ben...@android.com
+ *  Venu Byravarasu vbyravar...@nvidia.com
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -31,187 +33,18 @@
 #include linux/usb/tegra_usb_phy.h
 #include mach/iomap.h
 
-#define ULPI_VIEWPORT  0x170
-
-#define USB_PORTSC10x184
-#define   USB_PORTSC1_PTS(x)   (((x)  0x3)  30)
-#define   USB_PORTSC1_PSPD(x)  (((x)  0x3)  26)
-#define   USB_PORTSC1_PHCD (1  23)
-#define   USB_PORTSC1_WKOC (1  22)
-#define   USB_PORTSC1_WKDS (1  21)
-#define   USB_PORTSC1_WKCN (1  20)
-#define   USB_PORTSC1_PTC(x)   (((x)  0xf)  16)
-#define   USB_PORTSC1_PP   (1  12)
-#define   USB_PORTSC1_SUSP (1  7)
-#define   USB_PORTSC1_PE   (1

RE: [PATCH v2] USB: PHY: Re-organize Tegra USB PHY driver

2012-09-13 Thread Venu Byravarasu
Thanks Kishon, for your comments.
Plz see my answers inline.

 -Original Message-
 From: ABRAHAM, KISHON VIJAY [mailto:kis...@ti.com]
 Sent: Thursday, September 13, 2012 3:25 PM
 To: Venu Byravarasu
 Cc: st...@rowland.harvard.edu; gre...@linuxfoundation.org;
 ba...@ti.com; Stephen Warren; linux-ker...@vger.kernel.org; linux-
 u...@vger.kernel.org; linux-te...@vger.kernel.org
 Subject: Re: [PATCH v2] USB: PHY: Re-organize Tegra USB PHY driver

 Hi,

 On Thu, Sep 13, 2012 at 12:32 PM, Venu Byravarasu
 vbyravar...@nvidia.com wrote:
  NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
  In order to support USB PHY drivers on these SoCs, existing
  PHY driver is split into SoC agnostic common USB PHY driver
  and Tegra20-specific USB phy driver. This will facilitate
  easy addition and deletion of phy drivers for Tegra SoCs.
 
  Signed-off-by: Venu Byravarasu vbyravar...@nvidia.com
  ---
  delta from v1:
 
  1. Added two new phy_open functions, which will be called based
  on the phy type being used.
  2. Moved function pointer initialization to these two functions.
  3. Renamed usb_phy_ops to tegra_usb_phy_ops.
  4. Moved tegra_freq_table from header to tegra_usb_phy.c
 
   drivers/usb/host/ehci-tegra.c  |   24 +-
   drivers/usb/phy/Makefile   |1 +
   .../usb/phy/{tegra_usb_phy.c = tegra2_usb_phy.c}  |  421 +++--
   drivers/usb/phy/tegra2_usb_phy.h   |  140 
   drivers/usb/phy/tegra_usb_phy.c|  688 
  +---
   include/linux/usb/tegra_usb_phy.h  |   34 +-
   6 files changed, 296 insertions(+), 1012 deletions(-)
   copy drivers/usb/phy/{tegra_usb_phy.c = tegra2_usb_phy.c} (53%)
   create mode 100644 drivers/usb/phy/tegra2_usb_phy.h
 
  diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
  index 6223d17..15af372 100644
  --- a/drivers/usb/host/ehci-tegra.c
  +++ b/drivers/usb/host/ehci-tegra.c
  @@ -618,6 +618,9 @@ static int tegra_ehci_probe(struct platform_device
 *pdev)
  int err = 0;
  int irq;
  int instance = pdev-id;
  +   struct device_node *np = pdev-dev.of_node;
  +   struct phy_params params;
  +   int phy_type;
 
  pdata = pdev-dev.platform_data;
  if (!pdata) {
  @@ -701,14 +704,27 @@ static int tegra_ehci_probe(struct
 platform_device *pdev)
  break;
  default:
  err = -ENODEV;
  -   dev_err(pdev-dev, unknown usb instance\n);
  +   dev_err(pdev-dev, unknown usb inst:%d\n, 
  instance);
  goto fail_io;
  }
  }

 It's better you have the below code under *if (np)*, since both device
 node and pdata co-exist for you.

Sure, will add it in upcoming patches of code-clean up.

 
  +   phy_type = of_property_match_string(np, phy_type, utmi);
  +   if (phy_type = 0)
  +   params.type = TEGRA_USB_PHY_TYPE_UTMI;
  +   else {
  +   phy_type = of_property_match_string(np, phy_type, ulpi);
  +   if (phy_type = 0)
  +   params.type = TEGRA_USB_PHY_TYPE_ULPI;
  +   else
  +   params.type = TEGRA_USB_PHY_TYPE_INVALID;
  +   }
  +
  +   params.mode = TEGRA_USB_PHY_MODE_HOST;
  +   params.config = pdata-phy_config;

 doesn't this above line result in abort when you are doing a dt boot?

I did not see any abort during my testing on Ventana.

  +
  tegra-phy = tegra_usb_phy_open(pdev-dev, instance, hcd-regs,
  -   pdata-phy_config,
  -   TEGRA_USB_PHY_MODE_HOST);
  +   params);
  if (IS_ERR(tegra-phy)) {
  dev_err(pdev-dev, Failed to open USB phy\n);
  err = -ENXIO;
  @@ -744,7 +760,7 @@ static int tegra_ehci_probe(struct platform_device
 *pdev)
 
  err = usb_add_hcd(hcd, irq, IRQF_SHARED);
  if (err) {
  -   dev_err(pdev-dev, Failed to add USB HCD\n);
  +   dev_err(pdev-dev, usb_add_hcd failed with err 0x%x\n, 
  err);
  goto fail;
  }
 
  diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
  index b069f29..21872e1 100644
  --- a/drivers/usb/phy/Makefile
  +++ b/drivers/usb/phy/Makefile
  @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
   obj-$(CONFIG_USB_ISP1301)  += isp1301.o
   obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
   obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
  +obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra2_usb_phy.o
  diff --git a/drivers/usb/phy/tegra_usb_phy.c
 b/drivers/usb/phy/tegra2_usb_phy.c
  similarity index 53%
  copy from drivers/usb/phy/tegra_usb_phy.c
  copy to drivers/usb/phy/tegra2_usb_phy.c
  index 987116f..4896a4d 100644
  --- a/drivers/usb/phy/tegra_usb_phy.c

RE: [PATCH] usb: host: tegra: code clean up

2012-09-12 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Wednesday, September 12, 2012 11:41 PM
 To: Venu Byravarasu
 Cc: ba...@ti.com; linux-ker...@vger.kernel.org; linux-usb@vger.kernel.org
 Subject: Re: [PATCH] usb: host: tegra: code clean up
 
 On 09/12/2012 01:02 AM, Venu Byravarasu wrote:
  As part of code clean up, used devm counterparts for the APIs
  possible.
 
 Almost all of this patch has already been applied as:

Agree. 
Currently Balbi's tree has bit old ehci-tegra.c.
Because of this the patches prepared with linux-next need to be rebased onto 
this tree and prepare a new patch.
My main intention behind pushing this patch was to get all changes of 
ehci-tegra.c from linux-next into balbi's code base so that I can push the same 
patch against either balbi's tree or linux-next.

 bc2ff98 drivers/usb/host/ehci-tegra.c: use devm_ functions
 
 (btw, that patch has a much better patch subject than this one)
 
 The only additions in your patch are shown below, and those changes
 should indeed be a separate patch.
 
  diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
  index 6223d17..dba9f07 100644
  --- a/drivers/usb/host/ehci-tegra.c
  +++ b/drivers/usb/host/ehci-tegra.c
  @@ -701,7 +701,7 @@ static int tegra_ehci_probe(struct platform_device
 *pdev)
  break;
  default:
  err = -ENODEV;
  -   dev_err(pdev-dev, unknown usb instance\n);
  +   dev_err(pdev-dev, unknown usb inst:%d\n, 
  instance);
  goto fail_io;
  }
  }
  @@ -744,7 +744,7 @@ static int tegra_ehci_probe(struct platform_device
 *pdev)
 
  err = usb_add_hcd(hcd, irq, IRQF_SHARED);
  if (err) {
  -   dev_err(pdev-dev, Failed to add USB HCD\n);
  +   dev_err(pdev-dev, usb_add_hcd failed with err 0x%x\n, 
  err);
  goto fail;
  }
 
  @@ -753,7 +753,7 @@ static int tegra_ehci_probe(struct platform_device
 *pdev)
 
  /* Don't skip the pm_runtime_forbid call if wakeup isn't working */
  /* if (!pdata-power_down_on_bus_suspend) */
  -   pm_runtime_forbid(pdev-dev);
  +   pm_runtime_forbid(pdev-dev);
  pm_runtime_enable(pdev-dev);
  pm_runtime_put_sync(pdev-dev);
  return err;
 
 I'm not sure that last change is worth making; hopefully, you'll fix the
 bug the causes the if to be commented out, and we can re-enabled it
 again. Removing the indent makes it much less obvious which lines of
 code the if was intended to cover.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] USB: phy: re-organize tegra phy driver

2012-09-12 Thread Venu Byravarasu
 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Thursday, September 13, 2012 12:06 AM
 To: Venu Byravarasu
 Cc: ba...@ti.com; linux-ker...@vger.kernel.org; linux-usb@vger.kernel.org;
 linux-te...@vger.kernel.org
 Subject: Re: [PATCH] USB: phy: re-organize tegra phy driver
 
 On 09/12/2012 04:58 AM, Venu Byravarasu wrote:
  Nvidia produces several Tegra SOCs viz Tegra2, Tegra3 etc.
  In order to support USB phy drivers on these SOCs, existing
  phy driver is split into SOC agnostic common USB phy driver and
  tegra2 specific USB phy driver.
  This will facilitate easy addition  deletion of phy drivers for
  Tegra SOCs.
 
 For capitalization/related reasons, I would re-write the commit
 description as:
 
 NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
 In order to support USB PHY drivers on these SoCs, existing

Will change tegra2 to Tegra20 and similar for Tegra30  NVIDIA.
However as phy is not an acronym, should we still have it in Caps?

 PHY driver is split into SoC agnostic common USB PHY driver and
 Tegra20-specific USB phy driver. This will facilitate easy addition
 and deletion of phy drivers for Tegra SoCs.
 
 ... and s/tegra/Tegra/ in the patch subject.
 
 Tested-by: Stephen Warren swar...@wwwdotorg.org
 
 (On Harmony, both the USB Ethernet on USB3/UTMI and USB2's ULPI to a
 breakout board)
 
  diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 
  @@ -706,9 +709,22 @@ static int tegra_ehci_probe(struct platform_device
 *pdev)
  }
  }
 
  +   phy_type = of_property_match_string(np, phy_type, utmi);
  +   if (phy_type = 0)
  +   params.type = TEGRA_USB_PHY_TYPE_UTMI;
  +   else {
  +   phy_type = of_property_match_string(np, phy_type,
 ulpi);
  +   if (phy_type = 0)
  +   params.type = TEGRA_USB_PHY_TYPE_ULPI;
  +   else
  +   params.type = TEGRA_USB_PHY_TYPE_INVALID;
  +   }
  +
  +   params.mode = TEGRA_USB_PHY_MODE_HOST;
 
 Do we not support device mode yet? There's a dr_mode property in the DT
 that's supposed to indicate host/device/otg.
 
  diff --git a/drivers/usb/phy/tegra2_usb_phy.c
 b/drivers/usb/phy/tegra2_usb_phy.c
 
  +#include mach/gpio-tegra.h
 
 Please remove that #include statement; the heaer is not needed, and will
 be deleted in the kernel 3.7 merge window.
 
  +static int tegra2_utmip_pad_open(struct tegra_usb_phy *phy)
  +{
  +   phy-pad_clk = clk_get_sys(utmip-pad, NULL);
  +   if (IS_ERR(phy-pad_clk)) {
  +   pr_err(%s: can't get utmip pad clock\n, __func__);
  +   return PTR_ERR(phy-pad_clk);
  +   }
  +
  +   if (phy-instance == 0) {
  +   phy-pad_regs = phy-regs;
  +   } else {
 
 Can we use something other than phy-instance here? I see lots of usage
 of this field, but we should really be deleting the following code from
 ehci-tegra.c, rather the propagating the use of that field.
 
 /* This is pretty ugly and needs to be fixed when we do only
  * device-tree probing. Old code relies on the platform_device
  * numbering that we lack for device-tree-instantiated devices.
  */
 if (instance  0) {
 switch (res-start) {
 case TEGRA_USB_BASE:
 instance = 0;
 break;
 case TEGRA_USB2_BASE:
 instance = 1;
 break;
 case TEGRA_USB3_BASE:
 instance = 2;
 break;
 default:
 err = -ENODEV;
 dev_err(pdev-dev, unknown usb instance\n);
 goto fail_io;
 }
 }
 
 Still, I suppose the cleanup not to use the instance value could be a
 later patch as long as you're aware of the issue and planning to solve it.
 
  +   phy-pad_regs = ioremap(TEGRA_USB_BASE,
 TEGRA_USB_SIZE);
 
 Hmmm. Why do we need to remap the registers again? Didn't the EHCI
 controller already map them? I'm a little confused what in HW causes the
 need for this whole if statement.
 
  +   if (!phy-pad_regs) {
  +   pr_err(%s: can't remap usb registers\n, __func__);
  +   clk_put(phy-pad_clk);
  +   return -ENOMEM;
  +   }
  +   }
 
  +static void tegra2_utmi_phy_clk_disable(struct tegra_usb_phy *phy)
  +{
  +   unsigned long val;
  +   void __iomem *base = phy-regs;
  +
  +   if (phy-instance == 0) {
 
 Hmmm. There sure are a lot of places where the code is conditional based
 on instance. This seems to be crying out to be split into more ops
 functions that get set up once at probe() time and then just used.
 
  +static int tegra2_utmi_phy_power_off(struct tegra_usb_phy *phy)
  +{
  +   unsigned long val;
  +   void __iomem *base = phy-regs;
  +
  +   tegra2_utmi_phy_clk_disable(phy);
  +
  +   if (phy-mode

RE: [PATCH] USB: phy: re-organize tegra phy driver

2012-09-12 Thread Venu Byravarasu
Forgot to address some of the comments made by stephen, in my previous update.
Hence addressing them now.
Thanks a lot Stephen, for detailed review.

 -Original Message-
 From: Stephen Warren [mailto:swar...@wwwdotorg.org]
 Sent: Thursday, September 13, 2012 12:06 AM
 To: Venu Byravarasu
 Cc: ba...@ti.com; linux-ker...@vger.kernel.org; linux-usb@vger.kernel.org;
 linux-te...@vger.kernel.org
 Subject: Re: [PATCH] USB: phy: re-organize tegra phy driver
 
 On 09/12/2012 04:58 AM, Venu Byravarasu wrote:
  Nvidia produces several Tegra SOCs viz Tegra2, Tegra3 etc.
  In order to support USB phy drivers on these SOCs, existing
  phy driver is split into SOC agnostic common USB phy driver and
  tegra2 specific USB phy driver.
  This will facilitate easy addition  deletion of phy drivers for
  Tegra SOCs.
 
 For capitalization/related reasons, I would re-write the commit
 description as:
 
 NVIDIA produces several Tegra SoCs viz Tegra20, Tegra30 etc.
 In order to support USB PHY drivers on these SoCs, existing
 PHY driver is split into SoC agnostic common USB PHY driver and
 Tegra20-specific USB phy driver. This will facilitate easy addition
 and deletion of phy drivers for Tegra SoCs.
 
 ... and s/tegra/Tegra/ in the patch subject.
 
 Tested-by: Stephen Warren swar...@wwwdotorg.org
 
 (On Harmony, both the USB Ethernet on USB3/UTMI and USB2's ULPI to a
 breakout board)
 
  diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
 
  @@ -706,9 +709,22 @@ static int tegra_ehci_probe(struct platform_device
 *pdev)
  }
  }
 
  +   phy_type = of_property_match_string(np, phy_type, utmi);
  +   if (phy_type = 0)
  +   params.type = TEGRA_USB_PHY_TYPE_UTMI;
  +   else {
  +   phy_type = of_property_match_string(np, phy_type,
 ulpi);
  +   if (phy_type = 0)
  +   params.type = TEGRA_USB_PHY_TYPE_ULPI;
  +   else
  +   params.type = TEGRA_USB_PHY_TYPE_INVALID;
  +   }
  +
  +   params.mode = TEGRA_USB_PHY_MODE_HOST;
 
 Do we not support device mode yet? There's a dr_mode property in the DT
 that's supposed to indicate host/device/otg.
 

Device  otg support will be added soon.

  diff --git a/drivers/usb/phy/tegra2_usb_phy.c
 b/drivers/usb/phy/tegra2_usb_phy.c
 
  +#include mach/gpio-tegra.h
 
 Please remove that #include statement; the heaer is not needed, and will
 be deleted in the kernel 3.7 merge window.

Sure, will remove it.

 
  +static int tegra2_utmip_pad_open(struct tegra_usb_phy *phy)
  +{
  +   phy-pad_clk = clk_get_sys(utmip-pad, NULL);
  +   if (IS_ERR(phy-pad_clk)) {
  +   pr_err(%s: can't get utmip pad clock\n, __func__);
  +   return PTR_ERR(phy-pad_clk);
  +   }
  +
  +   if (phy-instance == 0) {
  +   phy-pad_regs = phy-regs;
  +   } else {
 
 Can we use something other than phy-instance here? I see lots of usage
 of this field, but we should really be deleting the following code from
 ehci-tegra.c, rather the propagating the use of that field.

I too feel the same way.
Planning to address it in next patches. 

 
 /* This is pretty ugly and needs to be fixed when we do only
  * device-tree probing. Old code relies on the platform_device
  * numbering that we lack for device-tree-instantiated devices.
  */
 if (instance  0) {
 switch (res-start) {
 case TEGRA_USB_BASE:
 instance = 0;
 break;
 case TEGRA_USB2_BASE:
 instance = 1;
 break;
 case TEGRA_USB3_BASE:
 instance = 2;
 break;
 default:
 err = -ENODEV;
 dev_err(pdev-dev, unknown usb instance\n);
 goto fail_io;
 }
 }
 
 Still, I suppose the cleanup not to use the instance value could be a
 later patch as long as you're aware of the issue and planning to solve it.

Yes, planning to address it in next patches.

 
  +   phy-pad_regs = ioremap(TEGRA_USB_BASE,
 TEGRA_USB_SIZE);
 
 Hmmm. Why do we need to remap the registers again? Didn't the EHCI
 controller already map them? I'm a little confused what in HW causes the
 need for this whole if statement.
 

In order to have very minimal changes in the patch, I did not clean this up.
This was taken from old code, which is yet to be cleaned up.
This patch just moves tegra2 specific code from single phy driver to 
tegra2_usb_phy.c
Will address all clean up stuff in next patches.

  +   if (!phy-pad_regs) {
  +   pr_err(%s: can't remap usb registers\n, __func__);
  +   clk_put(phy-pad_clk);
  +   return -ENOMEM;
  +   }
  +   }
 
  +static void tegra2_utmi_phy_clk_disable(struct tegra_usb_phy *phy)
  +{
  +   unsigned long val;
  +   void __iomem *base = phy

  1   2   >