All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Adding usb2.0 host-phy support for exynos5250
@ 2012-10-08 14:12 Vivek Gautam
  2012-10-08 14:12 ` [PATCH 1/5] usb: phy: samsung: Add host phy support to samsung-phy driver Vivek Gautam
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Vivek Gautam @ 2012-10-08 14:12 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-samsung-soc, devicetree-discuss, gregkh, stern, balbi,
	rob.herring, kgene.kim, jg1.han, thomas.abraham, kishon,
	p.paneri, yulgon.kim

This patchset is based on the work by Praveen Paneri for
samsung-usbphy driver:
http://comments.gmane.org/gmane.linux.kernel.samsung-soc/12653

Tested on smdk5250 target with usb-next branch along with
arch patches for exynos5250:
http://thread.gmane.org/gmane.linux.kernel.samsung-soc/13042
http://thread.gmane.org/gmane.linux.kernel.samsung-soc/13048

Also tested successfully on smdkv310 for any break.

Vivek Gautam (5):
  usb: phy: samsung: Add host phy support to samsung-phy driver
  ARM: S3C64XX: Add phy_type to pmu_isolation
  ARM: Exynos5250: Enabling samsung-usbphy driver
  usb: s5p-ehci: Adding phy driver support
  usb: exynos-ohci: Adding phy driver support

 .../devicetree/bindings/usb/samsung-usbphy.txt     |   12 +-
 arch/arm/boot/dts/exynos5250.dtsi                  |    5 +
 arch/arm/mach-exynos/Kconfig                       |    1 +
 arch/arm/mach-exynos/include/mach/map.h            |    1 +
 arch/arm/mach-exynos/mach-exynos5-dt.c             |   10 +
 arch/arm/mach-exynos/setup-usb-phy.c               |   45 ++-
 arch/arm/mach-s3c64xx/setup-usb-phy.c              |    2 +-
 arch/arm/plat-samsung/include/plat/usb-phy.h       |    3 +-
 drivers/usb/host/ehci-s5p.c                        |   62 +++-
 drivers/usb/host/ohci-exynos.c                     |   62 +++-
 drivers/usb/phy/Kconfig                            |    1 -
 drivers/usb/phy/samsung-usbphy.c                   |  362 ++++++++++++++++++--
 include/linux/platform_data/samsung-usbphy.h       |    9 +-
 13 files changed, 497 insertions(+), 78 deletions(-)

-- 
1.7.6.5

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/5] usb: phy: samsung: Add host phy support to samsung-phy driver
  2012-10-08 14:12 [PATCH 0/5] Adding usb2.0 host-phy support for exynos5250 Vivek Gautam
@ 2012-10-08 14:12 ` Vivek Gautam
       [not found] ` <1349705548-15207-1-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Vivek Gautam @ 2012-10-08 14:12 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-samsung-soc, devicetree-discuss, gregkh, stern, balbi,
	rob.herring, kgene.kim, jg1.han, thomas.abraham, kishon,
	p.paneri, yulgon.kim

This patch adds host phy support for samsung's exynos5250.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
---
 drivers/usb/phy/Kconfig                      |    1 -
 drivers/usb/phy/samsung-usbphy.c             |  362 ++++++++++++++++++++++++--
 include/linux/platform_data/samsung-usbphy.h |    9 +-
 3 files changed, 344 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 313685f..1ce5b32 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -35,7 +35,6 @@ config MV_U3D_PHY
 
 config SAMSUNG_USBPHY
 	bool "Samsung USB PHY controller Driver"
-	depends on USB_S3C_HSOTG
 	select USB_OTG_UTILS
 	help
 	  Enable this to support Samsung USB phy controller for samsung
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
index ee2dee0..504ef84 100644
--- a/drivers/usb/phy/samsung-usbphy.c
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -61,9 +61,114 @@
 #define MHZ (1000*1000)
 #endif
 
+/* EXYNOS5 */
+#define EXYNOS5_PHYHOST				(0x00)
+
+#define EXYNOS5_PHYHOST_PHYSWRSTALL		(0x1 << 31)
+
+#define EXYNOS5_PHYHOST_REFCLKSEL_MASK		(0x3)
+#define EXYNOS5_PHYHOST_REFCLKSEL(_x)		((_x) << 19)
+#define EXYNOS5_PHYHOST_REFCLKSEL_XTAL		\
+		EXYNOS5_PHYHOST_REFCLKSEL(0x0)
+#define EXYNOS5_PHYHOST_REFCLKSEL_EXTL		\
+		EXYNOS5_PHYHOST_REFCLKSEL(0x1)
+#define EXYNOS5_PHYHOST_REFCLKSEL_CLKCORE	\
+		EXYNOS5_PHYHOST_REFCLKSEL(0x2)
+
+#define EXYNOS5_PHYHOST_FSEL_MASK		(0x7 << 16)
+#define EXYNOS5_PHYHOST_FSEL(_x)		((_x) << 16)
+#define EXYNOS5_PHYHOST_FSEL_CLKSEL_50M		(0x7)
+#define EXYNOS5_PHYHOST_FSEL_CLKSEL_24M		(0x5)
+#define EXYNOS5_PHYHOST_FSEL_CLKSEL_20M		(0x4)
+#define EXYNOS5_PHYHOST_FSEL_CLKSEL_19200K	(0x3)
+#define EXYNOS5_PHYHOST_FSEL_CLKSEL_12M		(0x2)
+#define EXYNOS5_PHYHOST_FSEL_CLKSEL_10M		(0x1)
+#define EXYNOS5_PHYHOST_FSEL_CLKSEL_9600K	(0x0)
+
+#define EXYNOS5_PHYHOST_COMMONON_N		(0x1 << 9)
+#define EXYNOS5_PHYHOST_SIDDQ			(0x1 << 6)
+#define EXYNOS5_PHYHOST_FORCESLEEP		(0x1 << 5)
+#define EXYNOS5_PHYHOST_FORCESUSPEND		(0x1 << 4)
+#define EXYNOS5_PHYHOST_WORDINTERFACE		(0x1 << 3)
+#define EXYNOS5_PHYHOST_UTMISWRST		(0x1 << 2)
+#define EXYNOS5_PHYHOST_LINKSWRST		(0x1 << 1)
+#define EXYNOS5_PHYHOST_PHYSWRST		(0x1 << 0)
+
+#define EXYNOS5_PHYHOST_TUNE0			(0x04)
+
+#define EXYNOS5_PHYHOST_TEST0			(0x08)
+
+#define EXYNOS5_PHYHSIC1			(0x10)
+
+#define EXYNOS5_PHYHSIC2			(0x20)
+
+#define EXYNOS5_PHYHSIC_REFCLKSEL_MASK		(0x3)
+#define EXYNOS5_PHYHSIC_REFCLKSEL		(0x2 << 23)
+
+#define EXYNOS5_PHYHSIC_REFCLKDIV_MASK		(0x7f)
+#define EXYNOS5_PHYHSIC_REFCLKDIV(_x)		((_x) << 16)
+#define EXYNOS5_PHYHSIC_REFCLKDIV_12		\
+		EXYNOS5_PHYHSIC_REFCLKDIV(0x24)
+#define EXYNOS5_PHYHSIC_REFCLKDIV_15		\
+		EXYNOS5_PHYHSIC_REFCLKDIV(0x1C)
+#define EXYNOS5_PHYHSIC_REFCLKDIV_16		\
+		EXYNOS5_PHYHSIC_REFCLKDIV(0x1A)
+#define EXYNOS5_PHYHSIC_REFCLKDIV_19_2		\
+		EXYNOS5_PHYHSIC_REFCLKDIV(0x15)
+#define EXYNOS5_PHYHSIC_REFCLKDIV_20		\
+		EXYNOS5_PHYHSIC_REFCLKDIV(0x14)
+
+#define EXYNOS5_PHYHSIC_SIDDQ			(0x1 << 6)
+#define EXYNOS5_PHYHSIC_FORCESLEEP		(0x1 << 5)
+#define EXYNOS5_PHYHSIC_FORCESUSPEND		(0x1 << 4)
+#define EXYNOS5_PHYHSIC_WORDINTERFACE		(0x1 << 3)
+#define EXYNOS5_PHYHSIC_UTMISWRST		(0x1 << 2)
+#define EXYNOS5_PHYHSIC_PHYSWRST		(0x1 << 0)
+
+#define EXYNOS5_EHCICTRL			(0x30)
+
+#define EXYNOS5_EHCICTRL_ENAINCRXALIGN		(0x1 << 29)
+#define EXYNOS5_EHCICTRL_ENAINCR4		(0x1 << 28)
+#define EXYNOS5_EHCICTRL_ENAINCR8		(0x1 << 27)
+#define EXYNOS5_EHCICTRL_ENAINCR16		(0x1 << 26)
+
+#define EXYNOS5_OHCICTRL			(0x34)
+
+#define EXYNOS5_OHCICTRL_SUSPLGCY		(0x1 << 3)
+#define EXYNOS5_OHCICTRL_APPSTARTCLK		(0x1 << 2)
+#define EXYNOS5_OHCICTRL_CNTSEL			(0x1 << 1)
+#define EXYNOS5_OHCICTRL_CLKCKTRST		(0x1 << 0)
+
+#define EXYNOS5_PHYOTG				(0x38)
+
+#define EXYNOS5_PHYOTG_PHYLINK_SWRESET		(0x1 << 14)
+#define EXYNOS5_PHYOTG_LINKSWRST_UOTG		(0x1 << 13)
+#define EXYNOS5_PHYOTG_PHY0_SWRST		(0x1 << 12)
+
+#define EXYNOS5_PHYOTG_REFCLKSEL_MASK		(0x3 << 9)
+#define EXYNOS5_PHYOTG_REFCLKSEL(_x)		((_x) << 9)
+#define EXYNOS5_PHYOTG_REFCLKSEL_XTAL		\
+		EXYNOS5_PHYOTG_REFCLKSEL(0x0)
+#define EXYNOS5_PHYOTG_REFCLKSEL_EXTL		\
+		EXYNOS5_PHYOTG_REFCLKSEL(0x1)
+#define EXYNOS5_PHYOTG_REFCLKSEL_CLKCORE	\
+		EXYNOS5_PHYOTG_REFCLKSEL(0x2)
+
+#define EXYNOS5_PHYOTG_IPPULLUP_UOTG			(0x1 << 8)
+#define EXYNOS5_PHYOTG_COMMON_ON			(0x1 << 7)
+
+#define EXYNOS5_PHYOTG_FSEL_MASK			(0x7 << 4)
+#define EXYNOS5_PHYOTG_FSEL(_x)				((_x) << 4)
+
+#define EXYNOS5_PHYOTG_FORCESLEEP			(0x1 << 3)
+#define EXYNOS5_PHYOTG_OTGDISABLE			(0x1 << 2)
+#define EXYNOS5_PHYOTG_SIDDQ_UOTG			(0x1 << 1)
+#define EXYNOS5_PHYOTG_FORCESUSPEND			(0x1 << 0)
+
 enum samsung_cpu_type {
 	TYPE_S3C64XX,
 	TYPE_EXYNOS4210,
+	TYPE_EXYNOS5250,
 };
 
 /*
@@ -84,6 +189,7 @@ struct samsung_usbphy {
 	void __iomem	*regs;
 	int		ref_clk_freq;
 	int		cpu_type;
+	atomic_t	host_usage;
 };
 
 #define phy_to_sphy(x)		container_of((x), struct samsung_usbphy, phy)
@@ -96,30 +202,175 @@ static int samsung_usbphy_get_refclk_freq(struct samsung_usbphy *sphy)
 	struct clk *ref_clk;
 	int refclk_freq = 0;
 
-	ref_clk = clk_get(sphy->dev, "xusbxti");
+	if (sphy->cpu_type == TYPE_EXYNOS5250)
+		ref_clk = clk_get(sphy->dev, "ext_xtal");
+	else
+		ref_clk = clk_get(sphy->dev, "xusbxti");
 	if (IS_ERR(ref_clk)) {
 		dev_err(sphy->dev, "Failed to get reference clock\n");
 		return PTR_ERR(ref_clk);
 	}
 
-	switch (clk_get_rate(ref_clk)) {
-	case 12 * MHZ:
-		refclk_freq |= S3C_PHYCLK_CLKSEL_12M;
-		break;
-	case 24 * MHZ:
-		refclk_freq |= S3C_PHYCLK_CLKSEL_24M;
-		break;
-	default:
-	case 48 * MHZ:
-		/* default reference clock */
-		refclk_freq |= S3C_PHYCLK_CLKSEL_48M;
-		break;
+	if (sphy->cpu_type == TYPE_EXYNOS5250) {
+		/* set clock frequency for PLL */
+		switch (clk_get_rate(ref_clk)) {
+		case 96 * 100000:
+			refclk_freq |= EXYNOS5_PHYHOST_FSEL_CLKSEL_9600K;
+			break;
+		case 10 * MHZ:
+			refclk_freq |= EXYNOS5_PHYHOST_FSEL_CLKSEL_10M;
+			break;
+		case 12 * MHZ:
+			refclk_freq |= EXYNOS5_PHYHOST_FSEL_CLKSEL_12M;
+			break;
+		case 192 * 100000:
+			refclk_freq |= EXYNOS5_PHYHOST_FSEL_CLKSEL_19200K;
+			break;
+		case 20 * MHZ:
+			refclk_freq |= EXYNOS5_PHYHOST_FSEL_CLKSEL_20M;
+			break;
+		case 50 * MHZ:
+			refclk_freq |= EXYNOS5_PHYHOST_FSEL_CLKSEL_50M;
+			break;
+		case 24 * MHZ:
+		default:
+			/* default reference clock */
+			refclk_freq |= EXYNOS5_PHYHOST_FSEL_CLKSEL_24M;
+			break;
+		}
+	} else {
+		switch (clk_get_rate(ref_clk)) {
+		case 12 * MHZ:
+			refclk_freq |= S3C_PHYCLK_CLKSEL_12M;
+			break;
+		case 24 * MHZ:
+			refclk_freq |= S3C_PHYCLK_CLKSEL_24M;
+			break;
+		default:
+		case 48 * MHZ:
+			/* default reference clock */
+			refclk_freq |= S3C_PHYCLK_CLKSEL_48M;
+			break;
+		}
 	}
 	clk_put(ref_clk);
 
 	return refclk_freq;
 }
 
+static int exynos5_phyhost_is_on(void *regs)
+{
+	return (readl(regs + EXYNOS5_PHYHOST) & EXYNOS5_PHYHOST_SIDDQ) ? 0 : 1;
+}
+
+static void samsung_exynos5_usbphy_enable(struct samsung_usbphy *sphy)
+{
+	void __iomem *regs = sphy->regs;
+	u32 phyclk = sphy->ref_clk_freq;
+	u32 phyhost;
+	u32 phyotg;
+	u32 phyhsic;
+	u32 ehcictrl;
+	u32 ohcictrl;
+
+	atomic_inc(&sphy->host_usage);
+
+	if (exynos5_phyhost_is_on(regs)) {
+		dev_info(sphy->dev, "Already power on PHY\n");
+		return;
+	}
+
+	/* Selecting Host/OTG mode; Default USB2.0PHY_CFG: HOST. */
+	if (sphy->plat && sphy->plat->phy_cfg_sel) {
+		if (sphy->plat->type)
+			sphy->plat->phy_cfg_sel(sphy->dev, sphy->plat->type);
+		else
+			sphy->plat->phy_cfg_sel(sphy->dev, TYPE_OTG);
+	}
+
+	/* Host configuration */
+	phyhost = readl(regs + EXYNOS5_PHYHOST);
+
+	/* phy reference clock configuration */
+	phyhost &= ~(EXYNOS5_PHYHOST_FSEL_MASK);
+	phyhost |= EXYNOS5_PHYHOST_FSEL(phyclk);
+
+	/* host phy reset */
+	phyhost &= ~(EXYNOS5_PHYHOST_PHYSWRST |
+			EXYNOS5_PHYHOST_PHYSWRSTALL |
+			EXYNOS5_PHYHOST_SIDDQ |
+			/* Enable normal mode of operation */
+			EXYNOS5_PHYHOST_FORCESUSPEND |
+			EXYNOS5_PHYHOST_FORCESLEEP);
+
+	/* Link reset */
+	phyhost |= (EXYNOS5_PHYHOST_LINKSWRST |
+			EXYNOS5_PHYHOST_UTMISWRST |
+			/* COMMON Block configuration during suspend */
+			EXYNOS5_PHYHOST_COMMONON_N);
+	writel(phyhost, regs + EXYNOS5_PHYHOST);
+	udelay(10);
+	phyhost &= ~(EXYNOS5_PHYHOST_LINKSWRST |
+			EXYNOS5_PHYHOST_UTMISWRST);
+	writel(phyhost, regs + EXYNOS5_PHYHOST);
+
+	/* OTG configuration */
+	phyotg = readl(regs + EXYNOS5_PHYOTG);
+
+	/* phy reference clock configuration */
+	phyotg &= ~(EXYNOS5_PHYOTG_FSEL_MASK);
+	phyotg |= EXYNOS5_PHYOTG_FSEL(phyclk);
+
+	/* Enable normal mode of operation */
+	phyotg &= ~(EXYNOS5_PHYOTG_FORCESUSPEND |
+			EXYNOS5_PHYOTG_SIDDQ_UOTG |
+			EXYNOS5_PHYOTG_FORCESLEEP |
+			EXYNOS5_PHYOTG_REFCLKSEL_MASK |
+			/* COMMON Block configuration during suspend */
+			EXYNOS5_PHYOTG_COMMON_ON);
+
+	/* OTG phy & link reset */
+	phyotg |= (EXYNOS5_PHYOTG_PHY0_SWRST |
+			EXYNOS5_PHYOTG_LINKSWRST_UOTG |
+			EXYNOS5_PHYOTG_PHYLINK_SWRESET |
+			EXYNOS5_PHYOTG_OTGDISABLE |
+			/* Set refclk */
+			EXYNOS5_PHYOTG_REFCLKSEL_CLKCORE);
+
+	writel(phyotg, regs + EXYNOS5_PHYOTG);
+	udelay(10);
+	phyotg &= ~(EXYNOS5_PHYOTG_PHY0_SWRST |
+			EXYNOS5_PHYOTG_LINKSWRST_UOTG	|
+			EXYNOS5_PHYOTG_PHYLINK_SWRESET);
+	writel(phyotg, regs + EXYNOS5_PHYOTG);
+
+	/* HSIC phy configuration */
+	phyhsic = (EXYNOS5_PHYHSIC_REFCLKDIV_12 |
+			EXYNOS5_PHYHSIC_REFCLKSEL |
+			EXYNOS5_PHYHSIC_PHYSWRST);
+	writel(phyhsic, regs + EXYNOS5_PHYHSIC1);
+	writel(phyhsic, regs + EXYNOS5_PHYHSIC2);
+	udelay(10);
+	phyhsic &= ~(EXYNOS5_PHYHSIC_PHYSWRST);
+	writel(phyhsic, regs + EXYNOS5_PHYHSIC1);
+	writel(phyhsic, regs + EXYNOS5_PHYHSIC2);
+
+	udelay(80);
+
+	/* enable EHCI DMA burst */
+	ehcictrl = readl(regs + EXYNOS5_EHCICTRL);
+	ehcictrl |= (EXYNOS5_EHCICTRL_ENAINCRXALIGN |
+				EXYNOS5_EHCICTRL_ENAINCR4 |
+				EXYNOS5_EHCICTRL_ENAINCR8 |
+				EXYNOS5_EHCICTRL_ENAINCR16);
+	writel(ehcictrl, regs + EXYNOS5_EHCICTRL);
+
+	/* set ohci_suspend_on_n */
+	ohcictrl = readl(regs + EXYNOS5_OHCICTRL);
+	ohcictrl |= EXYNOS5_OHCICTRL_SUSPLGCY;
+	writel(ohcictrl, regs + EXYNOS5_OHCICTRL);
+}
+
 static void samsung_usbphy_enable(struct samsung_usbphy *sphy)
 {
 	void __iomem *regs = sphy->regs;
@@ -155,6 +406,41 @@ static void samsung_usbphy_enable(struct samsung_usbphy *sphy)
 	writel(rstcon, regs + S3C_RSTCON);
 }
 
+static void samsung_exynos5_usbphy_disable(struct samsung_usbphy *sphy)
+{
+	void __iomem *regs = sphy->regs;
+	u32 phyhost;
+	u32 phyotg;
+	u32 phyhsic;
+
+	if (atomic_dec_return(&sphy->host_usage) > 0) {
+		dev_info(sphy->dev, "still being used\n");
+		return;
+	}
+
+	phyhsic = (EXYNOS5_PHYHSIC_REFCLKDIV_12 |
+			EXYNOS5_PHYHSIC_REFCLKSEL |
+			EXYNOS5_PHYHSIC_SIDDQ |
+			EXYNOS5_PHYHSIC_FORCESLEEP |
+			EXYNOS5_PHYHSIC_FORCESUSPEND);
+	writel(phyhsic, regs + EXYNOS5_PHYHSIC1);
+	writel(phyhsic, regs + EXYNOS5_PHYHSIC2);
+
+	phyhost = readl(regs + EXYNOS5_PHYHOST);
+	phyhost |= (EXYNOS5_PHYHOST_SIDDQ |
+			EXYNOS5_PHYHOST_FORCESUSPEND |
+			EXYNOS5_PHYHOST_FORCESLEEP |
+			EXYNOS5_PHYHOST_PHYSWRST |
+			EXYNOS5_PHYHOST_PHYSWRSTALL);
+	writel(phyhost, regs + EXYNOS5_PHYHOST);
+
+	phyotg = readl(regs + EXYNOS5_PHYOTG);
+	phyotg |= (EXYNOS5_PHYOTG_FORCESUSPEND |
+			EXYNOS5_PHYOTG_SIDDQ_UOTG |
+			EXYNOS5_PHYOTG_FORCESLEEP);
+	writel(phyotg, regs + EXYNOS5_PHYOTG);
+}
+
 static void samsung_usbphy_disable(struct samsung_usbphy *sphy)
 {
 	void __iomem *regs = sphy->regs;
@@ -194,11 +480,18 @@ static int samsung_usbphy_init(struct usb_phy *phy)
 	}
 
 	/* Disable phy isolation */
-	if (sphy->plat && sphy->plat->pmu_isolation)
-		sphy->plat->pmu_isolation(false);
+	if (sphy->plat && sphy->plat->pmu_isolation) {
+		if (sphy->plat->type)
+			sphy->plat->pmu_isolation(false, sphy->plat->type);
+		else
+			sphy->plat->pmu_isolation(false, TYPE_OTG);
+	}
 
 	/* Initialize usb phy registers */
-	samsung_usbphy_enable(sphy);
+	if (sphy->cpu_type == TYPE_EXYNOS5250)
+		samsung_exynos5_usbphy_enable(sphy);
+	else
+		samsung_usbphy_enable(sphy);
 
 	/* Disable the phy clock */
 	clk_disable_unprepare(sphy->clk);
@@ -220,11 +513,18 @@ static void samsung_usbphy_shutdown(struct usb_phy *phy)
 	}
 
 	/* De-initialize usb phy registers */
-	samsung_usbphy_disable(sphy);
+	if (sphy->cpu_type == TYPE_EXYNOS5250)
+		samsung_exynos5_usbphy_disable(sphy);
+	else
+		samsung_usbphy_disable(sphy);
 
 	/* Enable phy isolation */
-	if (sphy->plat && sphy->plat->pmu_isolation)
-		sphy->plat->pmu_isolation(true);
+	if (sphy->plat && sphy->plat->pmu_isolation) {
+		if (sphy->plat->type)
+			sphy->plat->pmu_isolation(true, sphy->plat->type);
+		else
+			sphy->plat->pmu_isolation(true, TYPE_OTG);
+	}
 
 	clk_disable_unprepare(sphy->clk);
 }
@@ -277,16 +577,9 @@ static int __devinit samsung_usbphy_probe(struct platform_device *pdev)
 	if (!sphy)
 		return -ENOMEM;
 
-	clk = devm_clk_get(dev, "otg");
-	if (IS_ERR(clk)) {
-		dev_err(dev, "Failed to get otg clock\n");
-		return PTR_ERR(clk);
-	}
-
 	sphy->dev		= &pdev->dev;
 	sphy->plat		= pdata;
 	sphy->regs		= phy_base;
-	sphy->clk		= clk;
 	sphy->phy.dev		= sphy->dev;
 	sphy->phy.label		= "samsung-usbphy";
 	sphy->phy.init		= samsung_usbphy_init;
@@ -294,6 +587,17 @@ static int __devinit samsung_usbphy_probe(struct platform_device *pdev)
 	sphy->cpu_type		= samsung_usbphy_get_driver_data(pdev);
 	sphy->ref_clk_freq	= samsung_usbphy_get_refclk_freq(sphy);
 
+	if (sphy->cpu_type == TYPE_EXYNOS5250)
+		clk = devm_clk_get(dev, "usbhost");
+	else
+		clk = devm_clk_get(dev, "otg");
+	if (IS_ERR(clk)) {
+		dev_err(dev, "Failed to get otg clock\n");
+		return PTR_ERR(clk);
+	}
+
+	sphy->clk = clk;
+
 	ret = usb_add_phy(&sphy->phy, USB_PHY_TYPE_USB2);
 	return ret;
 }
@@ -315,6 +619,9 @@ static const struct of_device_id samsung_usbphy_dt_match[] = {
 	}, {
 		.compatible = "samsung,exynos4210-usbphy",
 		.data = (void *)TYPE_EXYNOS4210,
+	}, {
+		.compatible = "samsung,exynos5250-usbphy",
+		.data = (void *)TYPE_EXYNOS5250,
 	},
 	{},
 };
@@ -330,6 +637,9 @@ static struct platform_device_id samsung_usbphy_driver_ids[] = {
 	}, {
 		.name		= "exynos4210-usbphy",
 		.driver_data	= TYPE_EXYNOS4210,
+	}, {
+		.name		= "exynos5250-usbphy",
+		.driver_data	= TYPE_EXYNOS5250,
 	},
 	{},
 };
diff --git a/include/linux/platform_data/samsung-usbphy.h b/include/linux/platform_data/samsung-usbphy.h
index 1bd24cb..2b400e0 100644
--- a/include/linux/platform_data/samsung-usbphy.h
+++ b/include/linux/platform_data/samsung-usbphy.h
@@ -18,8 +18,15 @@
  * samsung_usbphy_data - Platform data for USB PHY driver.
  * @pmu_isolation: Function to control usb phy isolation in PMU.
  */
+enum phy_type {
+	TYPE_OTG,
+	TYPE_HOST,
+};
+
 struct samsung_usbphy_data {
-	void (*pmu_isolation)(int on);
+	void (*pmu_isolation)(int on, int phy_type);
+	void (*phy_cfg_sel)(struct device *dev, int phy_type);
+	int type;
 };
 
 extern void samsung_usbphy_set_pdata(struct samsung_usbphy_data *pd);
-- 
1.7.6.5

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/5] ARM: S3C64XX: Add phy_type to pmu_isolation
       [not found] ` <1349705548-15207-1-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2012-10-08 14:12   ` Vivek Gautam
  2012-10-09  5:33     ` kishon
  0 siblings, 1 reply; 14+ messages in thread
From: Vivek Gautam @ 2012-10-08 14:12 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, balbi-l0cyMroinI0,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	kgene.kim-Sze3O3UU22JBDgjK7y7TUQ, jg1.han-Sze3O3UU22JBDgjK7y7TUQ,
	thomas.abraham-QSEj5FYQhm4dnm+yROfE0A, kishon-l0cyMroinI0,
	p.paneri-Sze3O3UU22JBDgjK7y7TUQ,
	yulgon.kim-Sze3O3UU22JBDgjK7y7TUQ

It adds 'type' argument to pmu_isolation function, aligning
with other platforms, which keeps track of usbphy_type.

Signed-off-by: Vivek Gautam <gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
 arch/arm/mach-s3c64xx/setup-usb-phy.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index 3aee778..b7d1d95 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
@@ -13,7 +13,7 @@
 #include <mach/map.h>
 #include <mach/regs-sys.h>
 
-void s5p_usb_phy_pmu_isolation(int on)
+void s5p_usb_phy_pmu_isolation(int on, int type)
 {
 	if (on) {
 		writel(readl(S3C64XX_OTHERS) & ~S3C64XX_OTHERS_USBMASK,
-- 
1.7.6.5

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/5] ARM: Exynos5250: Enabling samsung-usbphy driver
  2012-10-08 14:12 [PATCH 0/5] Adding usb2.0 host-phy support for exynos5250 Vivek Gautam
  2012-10-08 14:12 ` [PATCH 1/5] usb: phy: samsung: Add host phy support to samsung-phy driver Vivek Gautam
       [not found] ` <1349705548-15207-1-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2012-10-08 14:12 ` Vivek Gautam
  2012-10-08 14:12 ` [PATCH 4/5] usb: s5p-ehci: Adding phy driver support Vivek Gautam
  2012-10-08 14:12 ` [PATCH 5/5] usb: exynos-ohci: " Vivek Gautam
  4 siblings, 0 replies; 14+ messages in thread
From: Vivek Gautam @ 2012-10-08 14:12 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-samsung-soc, devicetree-discuss, gregkh, stern, balbi,
	rob.herring, kgene.kim, jg1.han, thomas.abraham, kishon,
	p.paneri, yulgon.kim

Adding usbphy node for Exynos5250 along with the platform data.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
---
 .../devicetree/bindings/usb/samsung-usbphy.txt     |   12 ++++-
 arch/arm/boot/dts/exynos5250.dtsi                  |    5 ++
 arch/arm/mach-exynos/Kconfig                       |    1 +
 arch/arm/mach-exynos/include/mach/map.h            |    1 +
 arch/arm/mach-exynos/mach-exynos5-dt.c             |   10 ++++
 arch/arm/mach-exynos/setup-usb-phy.c               |   45 ++++++++++++++++----
 arch/arm/plat-samsung/include/plat/usb-phy.h       |    3 +-
 7 files changed, 66 insertions(+), 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
index 7d54d59..35aaf91 100644
--- a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -1,11 +1,19 @@
 * Samsung's usb phy transceiver
 
-The Samsung's phy transceiver is used for controlling usb otg phy for
-s3c-hsotg usb device controller.
+The Samsung's phy transceiver is used for controlling usb phy for
+s3c-hsotg as well as s5p-ehci and exynos-ohci device controllers
+across Samsung SOCs.
 TODO: Adding the PHY binding with controller(s) according to the under 
 developement generic PHY driver.
 
+Exynos4210:
 Required properties:
 - compatible : should be "samsung,exynos4210-usbphy"
 - reg : base physical address of the phy registers and length of memory mapped
 	region.
+
+Exynos5250:
+Required properties:
+- compatible : should be "samsung,exynos5250-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+	region.
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index dddfd6e..82bf042 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -218,6 +218,11 @@
 		#size-cells = <0>;
 	};
 
+	usbphy {
+		compatible = "samsung,exynos5250-usbphy";
+		reg = <0x12130000 0x100>;
+	};
+
 	amba {
 		#address-cells = <1>;
 		#size-cells = <1>;
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index 4372075..e8e3d7b 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -422,6 +422,7 @@ config MACH_EXYNOS5_DT
 	select SOC_EXYNOS5250
 	select USE_OF
 	select ARM_AMBA
+	select EXYNOS4_SETUP_USB_PHY
 	help
 	  Machine support for Samsung EXYNOS5 machine with device tree enabled.
 	  Select this if a fdt blob is available for the EXYNOS5 SoC based board.
diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h
index 9694424..7f5eb03 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -195,6 +195,7 @@
 #define EXYNOS4_PA_EHCI			0x12580000
 #define EXYNOS4_PA_OHCI			0x12590000
 #define EXYNOS4_PA_HSPHY		0x125B0000
+#define EXYNOS5_PA_HSPHY		0x12130000
 #define EXYNOS4_PA_MFC			0x13400000
 
 #define EXYNOS4_PA_UART			0x13800000
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
index db1cd8e..6d9528a 100644
--- a/arch/arm/mach-exynos/mach-exynos5-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
@@ -11,6 +11,7 @@
 
 #include <linux/of_platform.h>
 #include <linux/serial_core.h>
+#include <linux/platform_data/samsung-usbphy.h>
 
 #include <asm/mach/arch.h>
 #include <asm/hardware/gic.h>
@@ -18,9 +19,16 @@
 
 #include <plat/cpu.h>
 #include <plat/regs-serial.h>
+#include <plat/usb-phy.h>
 
 #include "common.h"
 
+static struct samsung_usbphy_data exynos5_usbphy_pdata = {
+	.pmu_isolation = s5p_usb_phy_pmu_isolation,
+	.phy_cfg_sel = s5p_usb_phy_cfg_sel,
+	.type = TYPE_HOST,
+};
+
 /*
  * The following lookup table is used to override device names when devices
  * are registered from device tree. This is temporarily added to enable
@@ -72,6 +80,8 @@ static const struct of_dev_auxdata exynos5250_auxdata_lookup[] __initconst = {
 				"exynos-gsc.2", NULL),
 	OF_DEV_AUXDATA("samsung,exynos5-gsc", EXYNOS5_PA_GSC3,
 				"exynos-gsc.3", NULL),
+	OF_DEV_AUXDATA("samsung,exynos5250-usbphy", EXYNOS5_PA_HSPHY,
+					"s3c-usbphy", &exynos5_usbphy_pdata),
 	{},
 };
 
diff --git a/arch/arm/mach-exynos/setup-usb-phy.c b/arch/arm/mach-exynos/setup-usb-phy.c
index 1c62d20..039d246 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -14,10 +14,14 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/platform_data/samsung-usbphy.h>
 #include <mach/regs-pmu.h>
 #include <mach/regs-usb-phy.h>
 #include <plat/cpu.h>
 #include <plat/usb-phy.h>
+#include <plat/map-base.h>
+
+#define EXYNOS5_USB_CFG			(S3C_VA_SYS + (0x230))
 
 static atomic_t host_usage;
 
@@ -222,15 +226,40 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int type)
 	return -EINVAL;
 }
 
-void s5p_usb_phy_pmu_isolation(int on)
+void s5p_usb_phy_pmu_isolation(int on, int type)
 {
-	if (on) {
-		writel(readl(S5P_USBDEVICE_PHY_CONTROL)
-			& ~S5P_USBDEVICE_PHY_ENABLE,
-				S5P_USBDEVICE_PHY_CONTROL);
+	if (type == TYPE_HOST) {
+		if (on) {
+			writel(readl(S5P_USBHOST_PHY_CONTROL)
+				& ~S5P_USBHOST_PHY_ENABLE,
+					S5P_USBHOST_PHY_CONTROL);
+		} else {
+			writel(readl(S5P_USBHOST_PHY_CONTROL)
+				| S5P_USBHOST_PHY_ENABLE,
+					S5P_USBHOST_PHY_CONTROL);
+		}
 	} else {
-		writel(readl(S5P_USBDEVICE_PHY_CONTROL)
-			| S5P_USBDEVICE_PHY_ENABLE,
-				S5P_USBDEVICE_PHY_CONTROL);
+		if (on) {
+			writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+				& ~S5P_USBDEVICE_PHY_ENABLE,
+					S5P_USBDEVICE_PHY_CONTROL);
+		} else {
+			writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+				| S5P_USBDEVICE_PHY_ENABLE,
+					S5P_USBDEVICE_PHY_CONTROL);
+		}
 	}
 }
+
+/* Switch between HOST or OTG link from PHY_CFG */
+void s5p_usb_phy_cfg_sel(struct device *dev, int type)
+{
+	u32 is_host;
+
+	is_host = readl(EXYNOS5_USB_CFG);
+	writel(type, EXYNOS5_USB_CFG);
+
+	if (is_host != type)
+		dev_dbg(dev, "Changed USB MUX from %s to %s",
+			is_host ? "Host" : "Device", type ? "Host" : "Device");
+}
diff --git a/arch/arm/plat-samsung/include/plat/usb-phy.h b/arch/arm/plat-samsung/include/plat/usb-phy.h
index 165ffe7..a57b8bb 100644
--- a/arch/arm/plat-samsung/include/plat/usb-phy.h
+++ b/arch/arm/plat-samsung/include/plat/usb-phy.h
@@ -18,6 +18,7 @@ enum s5p_usb_phy_type {
 
 extern int s5p_usb_phy_init(struct platform_device *pdev, int type);
 extern int s5p_usb_phy_exit(struct platform_device *pdev, int type);
-extern void s5p_usb_phy_pmu_isolation(int on);
+extern void s5p_usb_phy_pmu_isolation(int on, int type);
+extern void s5p_usb_phy_cfg_sel(struct device *dev, int type);
 
 #endif /* __PLAT_SAMSUNG_USB_PHY_H */
-- 
1.7.6.5

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/5] usb: s5p-ehci: Adding phy driver support
  2012-10-08 14:12 [PATCH 0/5] Adding usb2.0 host-phy support for exynos5250 Vivek Gautam
                   ` (2 preceding siblings ...)
  2012-10-08 14:12 ` [PATCH 3/5] ARM: Exynos5250: Enabling samsung-usbphy driver Vivek Gautam
@ 2012-10-08 14:12 ` Vivek Gautam
       [not found]   ` <1349705548-15207-5-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
  2012-10-08 14:12 ` [PATCH 5/5] usb: exynos-ohci: " Vivek Gautam
  4 siblings, 1 reply; 14+ messages in thread
From: Vivek Gautam @ 2012-10-08 14:12 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-samsung-soc, devicetree-discuss, gregkh, stern, balbi,
	rob.herring, kgene.kim, jg1.han, thomas.abraham, kishon,
	p.paneri, yulgon.kim

Adding the transceiver to ehci driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
---
 drivers/usb/host/ehci-s5p.c |   62 +++++++++++++++++++++++++++++-------------
 1 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 85b74be..ac22893 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -18,6 +18,7 @@
 #include <linux/of_gpio.h>
 #include <linux/platform_data/usb-ehci-s5p.h>
 #include <plat/usb-phy.h>
+#include <linux/usb/phy.h>
 
 #define EHCI_INSNREG00(base)			(base + 0x90)
 #define EHCI_INSNREG00_ENA_INCR16		(0x1 << 25)
@@ -32,6 +33,8 @@ struct s5p_ehci_hcd {
 	struct device *dev;
 	struct usb_hcd *hcd;
 	struct clk *clk;
+	struct usb_phy *phy;
+	struct s5p_ehci_platdata *pdata;
 };
 
 static const struct hc_driver s5p_ehci_hc_driver = {
@@ -65,6 +68,26 @@ static const struct hc_driver s5p_ehci_hc_driver = {
 	.clear_tt_buffer_complete	= ehci_clear_tt_buffer_complete,
 };
 
+static void s5p_ehci_phy_enable(struct s5p_ehci_hcd *s5p_ehci)
+{
+	struct platform_device *pdev = to_platform_device(s5p_ehci->dev);
+
+	if (s5p_ehci->phy)
+		usb_phy_init(s5p_ehci->phy);
+	else if (s5p_ehci->pdata->phy_init)
+		s5p_ehci->pdata->phy_init(pdev, S5P_USB_PHY_HOST);
+}
+
+static void s5p_ehci_phy_disable(struct s5p_ehci_hcd *s5p_ehci)
+{
+	struct platform_device *pdev = to_platform_device(s5p_ehci->dev);
+
+	if (s5p_ehci->phy)
+		usb_phy_shutdown(s5p_ehci->phy);
+	else if (s5p_ehci->pdata->phy_exit)
+		s5p_ehci->pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
+}
+
 static void s5p_setup_vbus_gpio(struct platform_device *pdev)
 {
 	int err;
@@ -92,15 +115,10 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
 	struct usb_hcd *hcd;
 	struct ehci_hcd *ehci;
 	struct resource *res;
+	struct usb_phy *phy;
 	int irq;
 	int err;
 
-	pdata = pdev->dev.platform_data;
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform data defined\n");
-		return -EINVAL;
-	}
-
 	/*
 	 * Right now device-tree probed devices don't get dma_mask set.
 	 * Since shared usb code relies on it, set it here for now.
@@ -118,6 +136,20 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
 	if (!s5p_ehci)
 		return -ENOMEM;
 
+	pdata = pdev->dev.platform_data;
+	if (!pdata) {
+		/* Fallback to Phy transceiver */
+		phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
+		if (IS_ERR_OR_NULL(phy)) {
+			dev_err(&pdev->dev, "no platform data or transceiver defined\n");
+			return -EPROBE_DEFER;
+		} else {
+			s5p_ehci->phy = phy;
+		}
+	} else {
+		s5p_ehci->pdata = pdata;
+	}
+
 	s5p_ehci->dev = &pdev->dev;
 
 	hcd = usb_create_hcd(&s5p_ehci_hc_driver, &pdev->dev,
@@ -163,8 +195,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
 		goto fail_io;
 	}
 
-	if (pdata->phy_init)
-		pdata->phy_init(pdev, S5P_USB_PHY_HOST);
+	s5p_ehci_phy_enable(s5p_ehci);
 
 	ehci = hcd_to_ehci(hcd);
 	ehci->caps = hcd->regs;
@@ -184,6 +215,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
 
 fail_io:
 	clk_disable(s5p_ehci->clk);
+	s5p_ehci_phy_disable(s5p_ehci);
 fail_clk:
 	usb_put_hcd(hcd);
 	return err;
@@ -191,14 +223,12 @@ fail_clk:
 
 static int __devexit s5p_ehci_remove(struct platform_device *pdev)
 {
-	struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
 	struct s5p_ehci_hcd *s5p_ehci = platform_get_drvdata(pdev);
 	struct usb_hcd *hcd = s5p_ehci->hcd;
 
 	usb_remove_hcd(hcd);
 
-	if (pdata && pdata->phy_exit)
-		pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
+	s5p_ehci_phy_disable(s5p_ehci);
 
 	clk_disable(s5p_ehci->clk);
 
@@ -222,14 +252,11 @@ static int s5p_ehci_suspend(struct device *dev)
 	struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev);
 	struct usb_hcd *hcd = s5p_ehci->hcd;
 	bool do_wakeup = device_may_wakeup(dev);
-	struct platform_device *pdev = to_platform_device(dev);
-	struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
 	int rc;
 
 	rc = ehci_suspend(hcd, do_wakeup);
 
-	if (pdata && pdata->phy_exit)
-		pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
+	s5p_ehci_phy_disable(s5p_ehci);
 
 	clk_disable(s5p_ehci->clk);
 
@@ -240,13 +267,10 @@ static int s5p_ehci_resume(struct device *dev)
 {
 	struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev);
 	struct usb_hcd *hcd = s5p_ehci->hcd;
-	struct platform_device *pdev = to_platform_device(dev);
-	struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
 
 	clk_enable(s5p_ehci->clk);
 
-	if (pdata && pdata->phy_init)
-		pdata->phy_init(pdev, S5P_USB_PHY_HOST);
+	s5p_ehci_phy_enable(s5p_ehci);
 
 	/* DMA burst Enable */
 	writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs));
-- 
1.7.6.5

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/5] usb: exynos-ohci: Adding phy driver support
  2012-10-08 14:12 [PATCH 0/5] Adding usb2.0 host-phy support for exynos5250 Vivek Gautam
                   ` (3 preceding siblings ...)
  2012-10-08 14:12 ` [PATCH 4/5] usb: s5p-ehci: Adding phy driver support Vivek Gautam
@ 2012-10-08 14:12 ` Vivek Gautam
  2012-10-09  9:46   ` Jingoo Han
  4 siblings, 1 reply; 14+ messages in thread
From: Vivek Gautam @ 2012-10-08 14:12 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-samsung-soc, devicetree-discuss, gregkh, stern, balbi,
	rob.herring, kgene.kim, jg1.han, thomas.abraham, kishon,
	p.paneri, yulgon.kim

Adding the transceiver to ohci driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
---
 drivers/usb/host/ohci-exynos.c |   62 +++++++++++++++++++++++++++------------
 1 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 20a5008..e0ed594 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -16,13 +16,36 @@
 #include <linux/platform_device.h>
 #include <linux/platform_data/usb-exynos.h>
 #include <plat/usb-phy.h>
+#include <linux/usb/phy.h>
 
 struct exynos_ohci_hcd {
 	struct device *dev;
 	struct usb_hcd *hcd;
 	struct clk *clk;
+	struct usb_phy *phy;
+	struct exynos4_ohci_platdata *pdata;
 };
 
+static void exynos_ohci_phy_enable(struct exynos_ohci_hcd *exynos_ohci)
+{
+	struct platform_device *pdev = to_platform_device(exynos_ohci->dev);
+
+	if (exynos_ohci->phy)
+		usb_phy_init(exynos_ohci->phy);
+	else if (exynos_ohci->pdata->phy_init)
+		exynos_ohci->pdata->phy_init(pdev, S5P_USB_PHY_HOST);
+}
+
+static void exynos_ohci_phy_disable(struct exynos_ohci_hcd *exynos_ohci)
+{
+	struct platform_device *pdev = to_platform_device(exynos_ohci->dev);
+
+	if (exynos_ohci->phy)
+		usb_phy_shutdown(exynos_ohci->phy);
+	else if (exynos_ohci->pdata->phy_exit)
+		exynos_ohci->pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
+}
+
 static int ohci_exynos_start(struct usb_hcd *hcd)
 {
 	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
@@ -81,15 +104,10 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
 	struct usb_hcd *hcd;
 	struct ohci_hcd *ohci;
 	struct resource *res;
+	struct usb_phy *phy;
 	int irq;
 	int err;
 
-	pdata = pdev->dev.platform_data;
-	if (!pdata) {
-		dev_err(&pdev->dev, "No platform data defined\n");
-		return -EINVAL;
-	}
-
 	/*
 	 * Right now device-tree probed devices don't get dma_mask set.
 	 * Since shared usb code relies on it, set it here for now.
@@ -105,6 +123,20 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
 	if (!exynos_ohci)
 		return -ENOMEM;
 
+	pdata = pdev->dev.platform_data;
+	if (!pdata) {
+		/* Fallback to Phy transceiver */
+		phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
+		if (IS_ERR_OR_NULL(phy)) {
+			dev_err(&pdev->dev, "no platform data or transceiver defined\n");
+			return -EPROBE_DEFER;
+		} else {
+			exynos_ohci->phy = phy;
+		}
+	} else {
+		exynos_ohci->pdata = pdata;
+	}
+
 	exynos_ohci->dev = &pdev->dev;
 
 	hcd = usb_create_hcd(&exynos_ohci_hc_driver, &pdev->dev,
@@ -150,8 +182,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
 		goto fail_io;
 	}
 
-	if (pdata->phy_init)
-		pdata->phy_init(pdev, S5P_USB_PHY_HOST);
+	exynos_ohci_phy_enable(exynos_ohci);
 
 	ohci = hcd_to_ohci(hcd);
 	ohci_hcd_init(ohci);
@@ -168,6 +199,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
 
 fail_io:
 	clk_disable(exynos_ohci->clk);
+	exynos_ohci_phy_disable(exynos_ohci);
 fail_clken:
 	clk_put(exynos_ohci->clk);
 fail_clk:
@@ -177,14 +209,12 @@ fail_clk:
 
 static int __devexit exynos_ohci_remove(struct platform_device *pdev)
 {
-	struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
 	struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev);
 	struct usb_hcd *hcd = exynos_ohci->hcd;
 
 	usb_remove_hcd(hcd);
 
-	if (pdata && pdata->phy_exit)
-		pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
+	exynos_ohci_phy_disable(exynos_ohci);
 
 	clk_disable(exynos_ohci->clk);
 	clk_put(exynos_ohci->clk);
@@ -209,8 +239,6 @@ static int exynos_ohci_suspend(struct device *dev)
 	struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev);
 	struct usb_hcd *hcd = exynos_ohci->hcd;
 	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
-	struct platform_device *pdev = to_platform_device(dev);
-	struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
 	unsigned long flags;
 	int rc = 0;
 
@@ -229,8 +257,7 @@ static int exynos_ohci_suspend(struct device *dev)
 
 	clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
 
-	if (pdata && pdata->phy_exit)
-		pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
+	exynos_ohci_phy_disable(exynos_ohci);
 
 	clk_disable(exynos_ohci->clk);
 
@@ -244,13 +271,10 @@ static int exynos_ohci_resume(struct device *dev)
 {
 	struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev);
 	struct usb_hcd *hcd = exynos_ohci->hcd;
-	struct platform_device *pdev = to_platform_device(dev);
-	struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
 
 	clk_enable(exynos_ohci->clk);
 
-	if (pdata && pdata->phy_init)
-		pdata->phy_init(pdev, S5P_USB_PHY_HOST);
+	exynos_ohci_phy_enable(exynos_ohci);
 
 	/* Mark hardware accessible again as we are out of D3 state by now */
 	set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
-- 
1.7.6.5

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] ARM: S3C64XX: Add phy_type to pmu_isolation
  2012-10-08 14:12   ` [PATCH 2/5] ARM: S3C64XX: Add phy_type to pmu_isolation Vivek Gautam
@ 2012-10-09  5:33     ` kishon
       [not found]       ` <5073B743.9000200-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: kishon @ 2012-10-09  5:33 UTC (permalink / raw)
  To: Vivek Gautam
  Cc: linux-usb, linux-samsung-soc, devicetree-discuss, gregkh, stern,
	balbi, rob.herring, kgene.kim, jg1.han, thomas.abraham, p.paneri,
	yulgon.kim

Hi,

On Monday 08 October 2012 07:42 PM, Vivek Gautam wrote:
> It adds 'type' argument to pmu_isolation function, aligning
> with other platforms, which keeps track of usbphy_type.
>
> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
> ---
>   arch/arm/mach-s3c64xx/setup-usb-phy.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c b/arch/arm/mach-s3c64xx/setup-usb-phy.c
> index 3aee778..b7d1d95 100644
> --- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
> +++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
> @@ -13,7 +13,7 @@
>   #include <mach/map.h>
>   #include <mach/regs-sys.h>
>
> -void s5p_usb_phy_pmu_isolation(int on)
> +void s5p_usb_phy_pmu_isolation(int on, int type)

IMO, this patch should have been squashed with the previous patch. IIUC, 
you have changed the call to this function for taking two arguments in 
your previous patch. Wouldn't that introduce compilation break after 
applying your first patch?

Thanks
Kishon

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] usb: s5p-ehci: Adding phy driver support
       [not found]   ` <1349705548-15207-5-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
@ 2012-10-09  9:40     ` Jingoo Han
  2012-10-09 12:44       ` Vivek Gautam
  0 siblings, 1 reply; 14+ messages in thread
From: Jingoo Han @ 2012-10-09  9:40 UTC (permalink / raw)
  To: 'Vivek Gautam', linux-usb-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, balbi-l0cyMroinI0,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	kgene.kim-Sze3O3UU22JBDgjK7y7TUQ,
	thomas.abraham-QSEj5FYQhm4dnm+yROfE0A, kishon-l0cyMroinI0,
	p.paneri-Sze3O3UU22JBDgjK7y7TUQ,
	yulgon.kim-Sze3O3UU22JBDgjK7y7TUQ, 'Jingoo Han'

On Monday, October 08, 2012 11:12 PM Vivek Gautam wrote
> 
> Adding the transceiver to ehci driver. Keeping the platform data
> for continuing the smooth operation for boards which still uses it
> 
> Signed-off-by: Vivek Gautam <gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>

Hi Vivek Gautam,

Could you replace the patch subject with
'USB: ehci-s5p: Add phy driver support'.

I also added some comments.

> ---
>  drivers/usb/host/ehci-s5p.c |   62 +++++++++++++++++++++++++++++-------------
>  1 files changed, 43 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
> index 85b74be..ac22893 100644
> --- a/drivers/usb/host/ehci-s5p.c
> +++ b/drivers/usb/host/ehci-s5p.c
> @@ -18,6 +18,7 @@
>  #include <linux/of_gpio.h>
>  #include <linux/platform_data/usb-ehci-s5p.h>
>  #include <plat/usb-phy.h>
> +#include <linux/usb/phy.h>

Please, move header include to proper place as bellows:

#include <linux/platform_data/usb-ehci-s5p.h>
+#include <linux/usb/phy.h>
##include <plat/usb-phy.h>

> 
>  #define EHCI_INSNREG00(base)			(base + 0x90)
>  #define EHCI_INSNREG00_ENA_INCR16		(0x1 << 25)
> @@ -32,6 +33,8 @@ struct s5p_ehci_hcd {
>  	struct device *dev;
>  	struct usb_hcd *hcd;
>  	struct clk *clk;
> +	struct usb_phy *phy;
> +	struct s5p_ehci_platdata *pdata;
>  };
> 
>  static const struct hc_driver s5p_ehci_hc_driver = {
> @@ -65,6 +68,26 @@ static const struct hc_driver s5p_ehci_hc_driver = {
>  	.clear_tt_buffer_complete	= ehci_clear_tt_buffer_complete,
>  };
> 
> +static void s5p_ehci_phy_enable(struct s5p_ehci_hcd *s5p_ehci)
> +{
> +	struct platform_device *pdev = to_platform_device(s5p_ehci->dev);
> +
> +	if (s5p_ehci->phy)
> +		usb_phy_init(s5p_ehci->phy);
> +	else if (s5p_ehci->pdata->phy_init)
> +		s5p_ehci->pdata->phy_init(pdev, S5P_USB_PHY_HOST);
> +}
> +
> +static void s5p_ehci_phy_disable(struct s5p_ehci_hcd *s5p_ehci)
> +{
> +	struct platform_device *pdev = to_platform_device(s5p_ehci->dev);
> +
> +	if (s5p_ehci->phy)
> +		usb_phy_shutdown(s5p_ehci->phy);
> +	else if (s5p_ehci->pdata->phy_exit)
> +		s5p_ehci->pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
> +}
> +
>  static void s5p_setup_vbus_gpio(struct platform_device *pdev)
>  {
>  	int err;
> @@ -92,15 +115,10 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
>  	struct usb_hcd *hcd;
>  	struct ehci_hcd *ehci;
>  	struct resource *res;
> +	struct usb_phy *phy;
>  	int irq;
>  	int err;
> 
> -	pdata = pdev->dev.platform_data;
> -	if (!pdata) {
> -		dev_err(&pdev->dev, "No platform data defined\n");
> -		return -EINVAL;
> -	}
> -
>  	/*
>  	 * Right now device-tree probed devices don't get dma_mask set.
>  	 * Since shared usb code relies on it, set it here for now.
> @@ -118,6 +136,20 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
>  	if (!s5p_ehci)
>  		return -ENOMEM;
> 
> +	pdata = pdev->dev.platform_data;
> +	if (!pdata) {
> +		/* Fallback to Phy transceiver */
> +		phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
> +		if (IS_ERR_OR_NULL(phy)) {
> +			dev_err(&pdev->dev, "no platform data or transceiver defined\n");
> +			return -EPROBE_DEFER;
> +		} else {
> +			s5p_ehci->phy = phy;
> +		}
> +	} else {
> +		s5p_ehci->pdata = pdata;
> +	}
> +
>  	s5p_ehci->dev = &pdev->dev;
> 
>  	hcd = usb_create_hcd(&s5p_ehci_hc_driver, &pdev->dev,
> @@ -163,8 +195,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
>  		goto fail_io;
>  	}
> 
> -	if (pdata->phy_init)
> -		pdata->phy_init(pdev, S5P_USB_PHY_HOST);
> +	s5p_ehci_phy_enable(s5p_ehci);
> 
>  	ehci = hcd_to_ehci(hcd);
>  	ehci->caps = hcd->regs;
> @@ -184,6 +215,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
> 
>  fail_io:
>  	clk_disable(s5p_ehci->clk);
> +	s5p_ehci_phy_disable(s5p_ehci);

This is wrong path for errors.
For example, when devm_ioremap() fails, s5p_ehci_phy_disable()
is called. However, in this case, s5p_ehci_phy_enable() is not
called. So, s5p_ehci_phy_disable() should not be called.

Please fix them as follows:

	err = usb_add_hcd(hcd, irq, IRQF_SHARED);
	if (err) {
		dev_err(&pdev->dev, "Failed to add USB HCD\n");
-		goto fail_io;
+		goto fail_add_hcd;
	}

	platform_set_drvdata(pdev, s5p_ehci);

	return 0;

+fail_add_hcd:
+	s5p_ehci_phy_disable(s5p_ehci);
fail_io:
	clk_disable(s5p_ehci->clk);
fail_clk:
	usb_put_hcd(hcd);


>  fail_clk:
>  	usb_put_hcd(hcd);
>  	return err;
> @@ -191,14 +223,12 @@ fail_clk:
> 
>  static int __devexit s5p_ehci_remove(struct platform_device *pdev)
>  {
> -	struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
>  	struct s5p_ehci_hcd *s5p_ehci = platform_get_drvdata(pdev);
>  	struct usb_hcd *hcd = s5p_ehci->hcd;
> 
>  	usb_remove_hcd(hcd);
> 
> -	if (pdata && pdata->phy_exit)
> -		pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
> +	s5p_ehci_phy_disable(s5p_ehci);
> 
>  	clk_disable(s5p_ehci->clk);
> 
> @@ -222,14 +252,11 @@ static int s5p_ehci_suspend(struct device *dev)
>  	struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev);
>  	struct usb_hcd *hcd = s5p_ehci->hcd;
>  	bool do_wakeup = device_may_wakeup(dev);
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
>  	int rc;
> 
>  	rc = ehci_suspend(hcd, do_wakeup);
> 
> -	if (pdata && pdata->phy_exit)
> -		pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
> +	s5p_ehci_phy_disable(s5p_ehci);
> 
>  	clk_disable(s5p_ehci->clk);
> 
> @@ -240,13 +267,10 @@ static int s5p_ehci_resume(struct device *dev)
>  {
>  	struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev);
>  	struct usb_hcd *hcd = s5p_ehci->hcd;
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
> 
>  	clk_enable(s5p_ehci->clk);
> 
> -	if (pdata && pdata->phy_init)
> -		pdata->phy_init(pdev, S5P_USB_PHY_HOST);
> +	s5p_ehci_phy_enable(s5p_ehci);
> 
>  	/* DMA burst Enable */
>  	writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs));
> --
> 1.7.6.5

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] usb: exynos-ohci: Adding phy driver support
  2012-10-08 14:12 ` [PATCH 5/5] usb: exynos-ohci: " Vivek Gautam
@ 2012-10-09  9:46   ` Jingoo Han
  2012-10-09 12:47     ` Vivek Gautam
  0 siblings, 1 reply; 14+ messages in thread
From: Jingoo Han @ 2012-10-09  9:46 UTC (permalink / raw)
  To: 'Vivek Gautam', linux-usb
  Cc: linux-samsung-soc, devicetree-discuss, gregkh, stern, balbi,
	rob.herring, kgene.kim, thomas.abraham, kishon, p.paneri,
	yulgon.kim, 'Jingoo Han'

On Monday, October 08, 2012 11:12 PM Vivek Gautam wrote
> 
> Adding the transceiver to ohci driver. Keeping the platform data
> for continuing the smooth operation for boards which still uses it
> 
> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>

Hi Vivek Gautam,

Could you replace the patch subject with
'USB: ohci-exynos: Add phy driver support'?

I also added some comments, too.

> ---
>  drivers/usb/host/ohci-exynos.c |   62 +++++++++++++++++++++++++++------------
>  1 files changed, 43 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
> index 20a5008..e0ed594 100644
> --- a/drivers/usb/host/ohci-exynos.c
> +++ b/drivers/usb/host/ohci-exynos.c
> @@ -16,13 +16,36 @@
>  #include <linux/platform_device.h>
>  #include <linux/platform_data/usb-exynos.h>
>  #include <plat/usb-phy.h>
> +#include <linux/usb/phy.h>

Please, move header include to proper place as bellows:

#include <linux/platform_data/usb-exynos.h>
+#include <linux/usb/phy.h>
##include <plat/usb-phy.h>

> 
>  struct exynos_ohci_hcd {
>  	struct device *dev;
>  	struct usb_hcd *hcd;
>  	struct clk *clk;
> +	struct usb_phy *phy;
> +	struct exynos4_ohci_platdata *pdata;
>  };
> 
> +static void exynos_ohci_phy_enable(struct exynos_ohci_hcd *exynos_ohci)
> +{
> +	struct platform_device *pdev = to_platform_device(exynos_ohci->dev);
> +
> +	if (exynos_ohci->phy)
> +		usb_phy_init(exynos_ohci->phy);
> +	else if (exynos_ohci->pdata->phy_init)
> +		exynos_ohci->pdata->phy_init(pdev, S5P_USB_PHY_HOST);
> +}
> +
> +static void exynos_ohci_phy_disable(struct exynos_ohci_hcd *exynos_ohci)
> +{
> +	struct platform_device *pdev = to_platform_device(exynos_ohci->dev);
> +
> +	if (exynos_ohci->phy)
> +		usb_phy_shutdown(exynos_ohci->phy);
> +	else if (exynos_ohci->pdata->phy_exit)
> +		exynos_ohci->pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
> +}
> +
>  static int ohci_exynos_start(struct usb_hcd *hcd)
>  {
>  	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
> @@ -81,15 +104,10 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>  	struct usb_hcd *hcd;
>  	struct ohci_hcd *ohci;
>  	struct resource *res;
> +	struct usb_phy *phy;
>  	int irq;
>  	int err;
> 
> -	pdata = pdev->dev.platform_data;
> -	if (!pdata) {
> -		dev_err(&pdev->dev, "No platform data defined\n");
> -		return -EINVAL;
> -	}
> -
>  	/*
>  	 * Right now device-tree probed devices don't get dma_mask set.
>  	 * Since shared usb code relies on it, set it here for now.
> @@ -105,6 +123,20 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>  	if (!exynos_ohci)
>  		return -ENOMEM;
> 
> +	pdata = pdev->dev.platform_data;
> +	if (!pdata) {
> +		/* Fallback to Phy transceiver */
> +		phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
> +		if (IS_ERR_OR_NULL(phy)) {
> +			dev_err(&pdev->dev, "no platform data or transceiver defined\n");
> +			return -EPROBE_DEFER;
> +		} else {
> +			exynos_ohci->phy = phy;
> +		}
> +	} else {
> +		exynos_ohci->pdata = pdata;
> +	}
> +
>  	exynos_ohci->dev = &pdev->dev;
> 
>  	hcd = usb_create_hcd(&exynos_ohci_hc_driver, &pdev->dev,
> @@ -150,8 +182,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>  		goto fail_io;
>  	}
> 
> -	if (pdata->phy_init)
> -		pdata->phy_init(pdev, S5P_USB_PHY_HOST);
> +	exynos_ohci_phy_enable(exynos_ohci);
> 
>  	ohci = hcd_to_ohci(hcd);
>  	ohci_hcd_init(ohci);
> @@ -168,6 +199,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
> 
>  fail_io:
>  	clk_disable(exynos_ohci->clk);
> +	exynos_ohci_phy_disable(exynos_ohci);

As I mentioned, it is also wrong.

Please fix them as follows:

	err = usb_add_hcd(hcd, irq, IRQF_SHARED);
	if (err) {
		dev_err(&pdev->dev, "Failed to add USB HCD\n");
-		goto fail_io;
+		goto fail_add_hcd;
	}

	platform_set_drvdata(pdev, exynos_ohci);

	return 0;

+fail_add_hcd:
+	exynos_ohci_phy_disable(exynos_ohci);
fail_io:
	clk_disable(exynos_ohci->clk);
fail_clken:
	clk_put(exynos_ohci->clk);


>  fail_clken:
>  	clk_put(exynos_ohci->clk);
>  fail_clk:
> @@ -177,14 +209,12 @@ fail_clk:
> 
>  static int __devexit exynos_ohci_remove(struct platform_device *pdev)
>  {
> -	struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
>  	struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev);
>  	struct usb_hcd *hcd = exynos_ohci->hcd;
> 
>  	usb_remove_hcd(hcd);
> 
> -	if (pdata && pdata->phy_exit)
> -		pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
> +	exynos_ohci_phy_disable(exynos_ohci);
> 
>  	clk_disable(exynos_ohci->clk);
>  	clk_put(exynos_ohci->clk);
> @@ -209,8 +239,6 @@ static int exynos_ohci_suspend(struct device *dev)
>  	struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev);
>  	struct usb_hcd *hcd = exynos_ohci->hcd;
>  	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
>  	unsigned long flags;
>  	int rc = 0;
> 
> @@ -229,8 +257,7 @@ static int exynos_ohci_suspend(struct device *dev)
> 
>  	clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
> 
> -	if (pdata && pdata->phy_exit)
> -		pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
> +	exynos_ohci_phy_disable(exynos_ohci);
> 
>  	clk_disable(exynos_ohci->clk);
> 
> @@ -244,13 +271,10 @@ static int exynos_ohci_resume(struct device *dev)
>  {
>  	struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev);
>  	struct usb_hcd *hcd = exynos_ohci->hcd;
> -	struct platform_device *pdev = to_platform_device(dev);
> -	struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
> 
>  	clk_enable(exynos_ohci->clk);
> 
> -	if (pdata && pdata->phy_init)
> -		pdata->phy_init(pdev, S5P_USB_PHY_HOST);
> +	exynos_ohci_phy_enable(exynos_ohci);
> 
>  	/* Mark hardware accessible again as we are out of D3 state by now */
>  	set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
> --
> 1.7.6.5

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] ARM: S3C64XX: Add phy_type to pmu_isolation
       [not found]       ` <5073B743.9000200-l0cyMroinI0@public.gmane.org>
@ 2012-10-09 10:51         ` Vivek Gautam
       [not found]           ` <CAFp+6iE6Er088dYwp8q7uQuZhw9bdYbJXQDbJp66W6tD7+C-Xw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Vivek Gautam @ 2012-10-09 10:51 UTC (permalink / raw)
  To: kishon
  Cc: Vivek Gautam, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, balbi-l0cyMroinI0,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	kgene.kim-Sze3O3UU22JBDgjK7y7TUQ, jg1.han-Sze3O3UU22JBDgjK7y7TUQ,
	thomas.abraham-QSEj5FYQhm4dnm+yROfE0A,
	p.paneri-Sze3O3UU22JBDgjK7y7TUQ,
	yulgon.kim-Sze3O3UU22JBDgjK7y7TUQ

Hi Kishon,

Firstly, thanks for the quick review.

On Tue, Oct 9, 2012 at 11:03 AM, kishon <kishon-l0cyMroinI0@public.gmane.org> wrote:
> Hi,
>
>
> On Monday 08 October 2012 07:42 PM, Vivek Gautam wrote:
>>
>> It adds 'type' argument to pmu_isolation function, aligning
>> with other platforms, which keeps track of usbphy_type.
>>
>> Signed-off-by: Vivek Gautam <gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
>> ---
>>   arch/arm/mach-s3c64xx/setup-usb-phy.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c
>> b/arch/arm/mach-s3c64xx/setup-usb-phy.c
>> index 3aee778..b7d1d95 100644
>> --- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
>> +++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
>> @@ -13,7 +13,7 @@
>>   #include <mach/map.h>
>>   #include <mach/regs-sys.h>
>>
>> -void s5p_usb_phy_pmu_isolation(int on)
>> +void s5p_usb_phy_pmu_isolation(int on, int type)
>
>
> IMO, this patch should have been squashed with the previous patch. IIUC, you
> have changed the call to this function for taking two arguments in your
> previous patch. Wouldn't that introduce compilation break after applying
> your first patch?
Yes, that's right it will introduce compilation break, my fault.
Just one querry, will it be good to put this arch change in [patch 1/5]?
and then can i move similar change in [patch 3/5] as given below again
in [patch 1/5]?

diff --git a/arch/arm/mach-exynos/setup-usb-phy.c
b/arch/arm/mach-exynos/setup-usb-phy.c
index 1c62d20..039d246 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -222,15 +226,40 @@ int s5p_usb_phy_exit(struct platform_device
*pdev, int type)
        return -EINVAL;
 }

-void s5p_usb_phy_pmu_isolation(int on)
+void s5p_usb_phy_pmu_isolation(int on, int type)

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

Best regards
Vivek
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* RE: [PATCH 2/5] ARM: S3C64XX: Add phy_type to pmu_isolation
       [not found]           ` <CAFp+6iE6Er088dYwp8q7uQuZhw9bdYbJXQDbJp66W6tD7+C-Xw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-10-09 11:12             ` Jingoo Han
  2012-10-09 12:35               ` Vivek Gautam
  0 siblings, 1 reply; 14+ messages in thread
From: Jingoo Han @ 2012-10-09 11:12 UTC (permalink / raw)
  To: 'Vivek Gautam', 'kishon'
  Cc: 'Vivek Gautam',
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz, balbi-l0cyMroinI0,
	rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
	kgene.kim-Sze3O3UU22JBDgjK7y7TUQ,
	thomas.abraham-QSEj5FYQhm4dnm+yROfE0A,
	p.paneri-Sze3O3UU22JBDgjK7y7TUQ,
	yulgon.kim-Sze3O3UU22JBDgjK7y7TUQ, 'Jingoo Han'

On Tuesday, October 09, 2012 7:51 PM Vivek Gautam wrote
> 
> Hi Kishon,
> 
> Firstly, thanks for the quick review.
> 
> On Tue, Oct 9, 2012 at 11:03 AM, kishon <kishon-l0cyMroinI0@public.gmane.org> wrote:
> > Hi,
> >
> >
> > On Monday 08 October 2012 07:42 PM, Vivek Gautam wrote:
> >>
> >> It adds 'type' argument to pmu_isolation function, aligning
> >> with other platforms, which keeps track of usbphy_type.
> >>
> >> Signed-off-by: Vivek Gautam <gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> >> ---
> >>   arch/arm/mach-s3c64xx/setup-usb-phy.c |    2 +-
> >>   1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c
> >> b/arch/arm/mach-s3c64xx/setup-usb-phy.c
> >> index 3aee778..b7d1d95 100644
> >> --- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
> >> +++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
> >> @@ -13,7 +13,7 @@
> >>   #include <mach/map.h>
> >>   #include <mach/regs-sys.h>
> >>
> >> -void s5p_usb_phy_pmu_isolation(int on)
> >> +void s5p_usb_phy_pmu_isolation(int on, int type)
> >
> >
> > IMO, this patch should have been squashed with the previous patch. IIUC, you
> > have changed the call to this function for taking two arguments in your
> > previous patch. Wouldn't that introduce compilation break after applying
> > your first patch?
> Yes, that's right it will introduce compilation break, my fault.
> Just one querry, will it be good to put this arch change in [patch 1/5]?
> and then can i move similar change in [patch 3/5] as given below again
> in [patch 1/5]?

In my opinion, it would be better.
This is because it can prevent build errors.


Best regards,
Jingoo Han

> 
> diff --git a/arch/arm/mach-exynos/setup-usb-phy.c
> b/arch/arm/mach-exynos/setup-usb-phy.c
> index 1c62d20..039d246 100644
> --- a/arch/arm/mach-exynos/setup-usb-phy.c
> +++ b/arch/arm/mach-exynos/setup-usb-phy.c
> @@ -222,15 +226,40 @@ int s5p_usb_phy_exit(struct platform_device
> *pdev, int type)
>         return -EINVAL;
>  }
> 
> -void s5p_usb_phy_pmu_isolation(int on)
> +void s5p_usb_phy_pmu_isolation(int on, int type)
> 
> >
> > Thanks
> > Kishon
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> Best regards
> Vivek

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/5] ARM: S3C64XX: Add phy_type to pmu_isolation
  2012-10-09 11:12             ` Jingoo Han
@ 2012-10-09 12:35               ` Vivek Gautam
  0 siblings, 0 replies; 14+ messages in thread
From: Vivek Gautam @ 2012-10-09 12:35 UTC (permalink / raw)
  To: Jingoo Han
  Cc: kishon, Vivek Gautam, linux-usb, linux-samsung-soc,
	devicetree-discuss, gregkh, stern, balbi, rob.herring, kgene.kim,
	thomas.abraham, p.paneri, yulgon.kim

Hi,

On Tue, Oct 9, 2012 at 4:42 PM, Jingoo Han <jg1.han@samsung.com> wrote:
> On Tuesday, October 09, 2012 7:51 PM Vivek Gautam wrote
>>
>> Hi Kishon,
>>
>> Firstly, thanks for the quick review.
>>
>> On Tue, Oct 9, 2012 at 11:03 AM, kishon <kishon@ti.com> wrote:
>> > Hi,
>> >
>> >
>> > On Monday 08 October 2012 07:42 PM, Vivek Gautam wrote:
>> >>
>> >> It adds 'type' argument to pmu_isolation function, aligning
>> >> with other platforms, which keeps track of usbphy_type.
>> >>
>> >> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
>> >> ---
>> >>   arch/arm/mach-s3c64xx/setup-usb-phy.c |    2 +-
>> >>   1 files changed, 1 insertions(+), 1 deletions(-)
>> >>
>> >> diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c
>> >> b/arch/arm/mach-s3c64xx/setup-usb-phy.c
>> >> index 3aee778..b7d1d95 100644
>> >> --- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
>> >> +++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
>> >> @@ -13,7 +13,7 @@
>> >>   #include <mach/map.h>
>> >>   #include <mach/regs-sys.h>
>> >>
>> >> -void s5p_usb_phy_pmu_isolation(int on)
>> >> +void s5p_usb_phy_pmu_isolation(int on, int type)
>> >
>> >
>> > IMO, this patch should have been squashed with the previous patch. IIUC, you
>> > have changed the call to this function for taking two arguments in your
>> > previous patch. Wouldn't that introduce compilation break after applying
>> > your first patch?
>> Yes, that's right it will introduce compilation break, my fault.
>> Just one querry, will it be good to put this arch change in [patch 1/5]?
>> and then can i move similar change in [patch 3/5] as given below again
>> in [patch 1/5]?
>
> In my opinion, it would be better.
> This is because it can prevent build errors.
>
Sure, I shall update this in the next patchset.
>
> Best regards,
> Jingoo Han
>
>>
>> diff --git a/arch/arm/mach-exynos/setup-usb-phy.c
>> b/arch/arm/mach-exynos/setup-usb-phy.c
>> index 1c62d20..039d246 100644
>> --- a/arch/arm/mach-exynos/setup-usb-phy.c
>> +++ b/arch/arm/mach-exynos/setup-usb-phy.c
>> @@ -222,15 +226,40 @@ int s5p_usb_phy_exit(struct platform_device
>> *pdev, int type)
>>         return -EINVAL;
>>  }
>>
>> -void s5p_usb_phy_pmu_isolation(int on)
>> +void s5p_usb_phy_pmu_isolation(int on, int type)
>>
>> >
>> > Thanks
>> > Kishon
>> >
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe linux-usb" in
>> > the body of a message to majordomo@vger.kernel.org
>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>> Best regards
>> Vivek
>

Thanks
Vivek

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/5] usb: s5p-ehci: Adding phy driver support
  2012-10-09  9:40     ` Jingoo Han
@ 2012-10-09 12:44       ` Vivek Gautam
  0 siblings, 0 replies; 14+ messages in thread
From: Vivek Gautam @ 2012-10-09 12:44 UTC (permalink / raw)
  To: Jingoo Han
  Cc: Vivek Gautam, linux-usb, linux-samsung-soc, devicetree-discuss,
	gregkh, stern, balbi, rob.herring, kgene.kim, thomas.abraham,
	kishon, p.paneri, yulgon.kim

Hi,

On Tue, Oct 9, 2012 at 3:10 PM, Jingoo Han <jg1.han@samsung.com> wrote:
> On Monday, October 08, 2012 11:12 PM Vivek Gautam wrote
>>
>> Adding the transceiver to ehci driver. Keeping the platform data
>> for continuing the smooth operation for boards which still uses it
>>
>> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
>
> Hi Vivek Gautam,
>
> Could you replace the patch subject with
> 'USB: ehci-s5p: Add phy driver support'.
>
Yeah, sure. I shall update this in the next patchset.

> I also added some comments.
>
>> ---
>>  drivers/usb/host/ehci-s5p.c |   62 +++++++++++++++++++++++++++++-------------
>>  1 files changed, 43 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
>> index 85b74be..ac22893 100644
>> --- a/drivers/usb/host/ehci-s5p.c
>> +++ b/drivers/usb/host/ehci-s5p.c
>> @@ -18,6 +18,7 @@
>>  #include <linux/of_gpio.h>
>>  #include <linux/platform_data/usb-ehci-s5p.h>
>>  #include <plat/usb-phy.h>
>> +#include <linux/usb/phy.h>
>
> Please, move header include to proper place as bellows:
>
Sure, i will change this accordingly.

> #include <linux/platform_data/usb-ehci-s5p.h>
> +#include <linux/usb/phy.h>
> ##include <plat/usb-phy.h>
>
>>
>>  #define EHCI_INSNREG00(base)                 (base + 0x90)
>>  #define EHCI_INSNREG00_ENA_INCR16            (0x1 << 25)
>> @@ -32,6 +33,8 @@ struct s5p_ehci_hcd {
>>       struct device *dev;
>>       struct usb_hcd *hcd;
>>       struct clk *clk;
>> +     struct usb_phy *phy;
>> +     struct s5p_ehci_platdata *pdata;
>>  };
>>
>>  static const struct hc_driver s5p_ehci_hc_driver = {
>> @@ -65,6 +68,26 @@ static const struct hc_driver s5p_ehci_hc_driver = {
>>       .clear_tt_buffer_complete       = ehci_clear_tt_buffer_complete,
>>  };
>>
>> +static void s5p_ehci_phy_enable(struct s5p_ehci_hcd *s5p_ehci)
>> +{
>> +     struct platform_device *pdev = to_platform_device(s5p_ehci->dev);
>> +
>> +     if (s5p_ehci->phy)
>> +             usb_phy_init(s5p_ehci->phy);
>> +     else if (s5p_ehci->pdata->phy_init)
>> +             s5p_ehci->pdata->phy_init(pdev, S5P_USB_PHY_HOST);
>> +}
>> +
>> +static void s5p_ehci_phy_disable(struct s5p_ehci_hcd *s5p_ehci)
>> +{
>> +     struct platform_device *pdev = to_platform_device(s5p_ehci->dev);
>> +
>> +     if (s5p_ehci->phy)
>> +             usb_phy_shutdown(s5p_ehci->phy);
>> +     else if (s5p_ehci->pdata->phy_exit)
>> +             s5p_ehci->pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
>> +}
>> +
>>  static void s5p_setup_vbus_gpio(struct platform_device *pdev)
>>  {
>>       int err;
>> @@ -92,15 +115,10 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
>>       struct usb_hcd *hcd;
>>       struct ehci_hcd *ehci;
>>       struct resource *res;
>> +     struct usb_phy *phy;
>>       int irq;
>>       int err;
>>
>> -     pdata = pdev->dev.platform_data;
>> -     if (!pdata) {
>> -             dev_err(&pdev->dev, "No platform data defined\n");
>> -             return -EINVAL;
>> -     }
>> -
>>       /*
>>        * Right now device-tree probed devices don't get dma_mask set.
>>        * Since shared usb code relies on it, set it here for now.
>> @@ -118,6 +136,20 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
>>       if (!s5p_ehci)
>>               return -ENOMEM;
>>
>> +     pdata = pdev->dev.platform_data;
>> +     if (!pdata) {
>> +             /* Fallback to Phy transceiver */
>> +             phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
>> +             if (IS_ERR_OR_NULL(phy)) {
>> +                     dev_err(&pdev->dev, "no platform data or transceiver defined\n");
>> +                     return -EPROBE_DEFER;
>> +             } else {
>> +                     s5p_ehci->phy = phy;
>> +             }
>> +     } else {
>> +             s5p_ehci->pdata = pdata;
>> +     }
>> +
>>       s5p_ehci->dev = &pdev->dev;
>>
>>       hcd = usb_create_hcd(&s5p_ehci_hc_driver, &pdev->dev,
>> @@ -163,8 +195,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
>>               goto fail_io;
>>       }
>>
>> -     if (pdata->phy_init)
>> -             pdata->phy_init(pdev, S5P_USB_PHY_HOST);
>> +     s5p_ehci_phy_enable(s5p_ehci);
>>
>>       ehci = hcd_to_ehci(hcd);
>>       ehci->caps = hcd->regs;
>> @@ -184,6 +215,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev)
>>
>>  fail_io:
>>       clk_disable(s5p_ehci->clk);
>> +     s5p_ehci_phy_disable(s5p_ehci);
>
> This is wrong path for errors.
> For example, when devm_ioremap() fails, s5p_ehci_phy_disable()
> is called. However, in this case, s5p_ehci_phy_enable() is not
> called. So, s5p_ehci_phy_disable() should not be called.
>
> Please fix them as follows:
>
>         err = usb_add_hcd(hcd, irq, IRQF_SHARED);
>         if (err) {
>                 dev_err(&pdev->dev, "Failed to add USB HCD\n");
> -               goto fail_io;
> +               goto fail_add_hcd;
>         }
>
>         platform_set_drvdata(pdev, s5p_ehci);
>
>         return 0;
>
> +fail_add_hcd:
> +       s5p_ehci_phy_disable(s5p_ehci);
> fail_io:
>         clk_disable(s5p_ehci->clk);
> fail_clk:
>         usb_put_hcd(hcd);
>
Right, nice catch, thanks. I shall modify this as suggested and update.

>
>>  fail_clk:
>>       usb_put_hcd(hcd);
>>       return err;
>> @@ -191,14 +223,12 @@ fail_clk:
>>
>>  static int __devexit s5p_ehci_remove(struct platform_device *pdev)
>>  {
>> -     struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
>>       struct s5p_ehci_hcd *s5p_ehci = platform_get_drvdata(pdev);
>>       struct usb_hcd *hcd = s5p_ehci->hcd;
>>
>>       usb_remove_hcd(hcd);
>>
>> -     if (pdata && pdata->phy_exit)
>> -             pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
>> +     s5p_ehci_phy_disable(s5p_ehci);
>>
>>       clk_disable(s5p_ehci->clk);
>>
>> @@ -222,14 +252,11 @@ static int s5p_ehci_suspend(struct device *dev)
>>       struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev);
>>       struct usb_hcd *hcd = s5p_ehci->hcd;
>>       bool do_wakeup = device_may_wakeup(dev);
>> -     struct platform_device *pdev = to_platform_device(dev);
>> -     struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
>>       int rc;
>>
>>       rc = ehci_suspend(hcd, do_wakeup);
>>
>> -     if (pdata && pdata->phy_exit)
>> -             pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
>> +     s5p_ehci_phy_disable(s5p_ehci);
>>
>>       clk_disable(s5p_ehci->clk);
>>
>> @@ -240,13 +267,10 @@ static int s5p_ehci_resume(struct device *dev)
>>  {
>>       struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev);
>>       struct usb_hcd *hcd = s5p_ehci->hcd;
>> -     struct platform_device *pdev = to_platform_device(dev);
>> -     struct s5p_ehci_platdata *pdata = pdev->dev.platform_data;
>>
>>       clk_enable(s5p_ehci->clk);
>>
>> -     if (pdata && pdata->phy_init)
>> -             pdata->phy_init(pdev, S5P_USB_PHY_HOST);
>> +     s5p_ehci_phy_enable(s5p_ehci);
>>
>>       /* DMA burst Enable */
>>       writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs));
>> --
>> 1.7.6.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Thanks
Vivek

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/5] usb: exynos-ohci: Adding phy driver support
  2012-10-09  9:46   ` Jingoo Han
@ 2012-10-09 12:47     ` Vivek Gautam
  0 siblings, 0 replies; 14+ messages in thread
From: Vivek Gautam @ 2012-10-09 12:47 UTC (permalink / raw)
  To: Jingoo Han
  Cc: Vivek Gautam, linux-usb, linux-samsung-soc, devicetree-discuss,
	gregkh, stern, balbi, rob.herring, kgene.kim, thomas.abraham,
	kishon, p.paneri, yulgon.kim

Hi,

On Tue, Oct 9, 2012 at 3:16 PM, Jingoo Han <jg1.han@samsung.com> wrote:
> On Monday, October 08, 2012 11:12 PM Vivek Gautam wrote
>>
>> Adding the transceiver to ohci driver. Keeping the platform data
>> for continuing the smooth operation for boards which still uses it
>>
>> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
>
> Hi Vivek Gautam,
>
> Could you replace the patch subject with
> 'USB: ohci-exynos: Add phy driver support'?
>
Sure. I shall update this in the next patchset.
> I also added some comments, too.
>
>> ---
>>  drivers/usb/host/ohci-exynos.c |   62 +++++++++++++++++++++++++++------------
>>  1 files changed, 43 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
>> index 20a5008..e0ed594 100644
>> --- a/drivers/usb/host/ohci-exynos.c
>> +++ b/drivers/usb/host/ohci-exynos.c
>> @@ -16,13 +16,36 @@
>>  #include <linux/platform_device.h>
>>  #include <linux/platform_data/usb-exynos.h>
>>  #include <plat/usb-phy.h>
>> +#include <linux/usb/phy.h>
>
> Please, move header include to proper place as bellows:
>
> #include <linux/platform_data/usb-exynos.h>
> +#include <linux/usb/phy.h>
> ##include <plat/usb-phy.h>
>
Right, i will change this accordingly and update.
>>
>>  struct exynos_ohci_hcd {
>>       struct device *dev;
>>       struct usb_hcd *hcd;
>>       struct clk *clk;
>> +     struct usb_phy *phy;
>> +     struct exynos4_ohci_platdata *pdata;
>>  };
>>
>> +static void exynos_ohci_phy_enable(struct exynos_ohci_hcd *exynos_ohci)
>> +{
>> +     struct platform_device *pdev = to_platform_device(exynos_ohci->dev);
>> +
>> +     if (exynos_ohci->phy)
>> +             usb_phy_init(exynos_ohci->phy);
>> +     else if (exynos_ohci->pdata->phy_init)
>> +             exynos_ohci->pdata->phy_init(pdev, S5P_USB_PHY_HOST);
>> +}
>> +
>> +static void exynos_ohci_phy_disable(struct exynos_ohci_hcd *exynos_ohci)
>> +{
>> +     struct platform_device *pdev = to_platform_device(exynos_ohci->dev);
>> +
>> +     if (exynos_ohci->phy)
>> +             usb_phy_shutdown(exynos_ohci->phy);
>> +     else if (exynos_ohci->pdata->phy_exit)
>> +             exynos_ohci->pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
>> +}
>> +
>>  static int ohci_exynos_start(struct usb_hcd *hcd)
>>  {
>>       struct ohci_hcd *ohci = hcd_to_ohci(hcd);
>> @@ -81,15 +104,10 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>>       struct usb_hcd *hcd;
>>       struct ohci_hcd *ohci;
>>       struct resource *res;
>> +     struct usb_phy *phy;
>>       int irq;
>>       int err;
>>
>> -     pdata = pdev->dev.platform_data;
>> -     if (!pdata) {
>> -             dev_err(&pdev->dev, "No platform data defined\n");
>> -             return -EINVAL;
>> -     }
>> -
>>       /*
>>        * Right now device-tree probed devices don't get dma_mask set.
>>        * Since shared usb code relies on it, set it here for now.
>> @@ -105,6 +123,20 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>>       if (!exynos_ohci)
>>               return -ENOMEM;
>>
>> +     pdata = pdev->dev.platform_data;
>> +     if (!pdata) {
>> +             /* Fallback to Phy transceiver */
>> +             phy = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
>> +             if (IS_ERR_OR_NULL(phy)) {
>> +                     dev_err(&pdev->dev, "no platform data or transceiver defined\n");
>> +                     return -EPROBE_DEFER;
>> +             } else {
>> +                     exynos_ohci->phy = phy;
>> +             }
>> +     } else {
>> +             exynos_ohci->pdata = pdata;
>> +     }
>> +
>>       exynos_ohci->dev = &pdev->dev;
>>
>>       hcd = usb_create_hcd(&exynos_ohci_hc_driver, &pdev->dev,
>> @@ -150,8 +182,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>>               goto fail_io;
>>       }
>>
>> -     if (pdata->phy_init)
>> -             pdata->phy_init(pdev, S5P_USB_PHY_HOST);
>> +     exynos_ohci_phy_enable(exynos_ohci);
>>
>>       ohci = hcd_to_ohci(hcd);
>>       ohci_hcd_init(ohci);
>> @@ -168,6 +199,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev)
>>
>>  fail_io:
>>       clk_disable(exynos_ohci->clk);
>> +     exynos_ohci_phy_disable(exynos_ohci);
>
> As I mentioned, it is also wrong.
>
> Please fix them as follows:
>
>         err = usb_add_hcd(hcd, irq, IRQF_SHARED);
>         if (err) {
>                 dev_err(&pdev->dev, "Failed to add USB HCD\n");
> -               goto fail_io;
> +               goto fail_add_hcd;
>         }
>
>         platform_set_drvdata(pdev, exynos_ohci);
>
>         return 0;
>
> +fail_add_hcd:
> +       exynos_ohci_phy_disable(exynos_ohci);
> fail_io:
>         clk_disable(exynos_ohci->clk);
> fail_clken:
>         clk_put(exynos_ohci->clk);
>
Right, my mistake. I shall modify this as suggested and update.
>
>>  fail_clken:
>>       clk_put(exynos_ohci->clk);
>>  fail_clk:
>> @@ -177,14 +209,12 @@ fail_clk:
>>
>>  static int __devexit exynos_ohci_remove(struct platform_device *pdev)
>>  {
>> -     struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
>>       struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev);
>>       struct usb_hcd *hcd = exynos_ohci->hcd;
>>
>>       usb_remove_hcd(hcd);
>>
>> -     if (pdata && pdata->phy_exit)
>> -             pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
>> +     exynos_ohci_phy_disable(exynos_ohci);
>>
>>       clk_disable(exynos_ohci->clk);
>>       clk_put(exynos_ohci->clk);
>> @@ -209,8 +239,6 @@ static int exynos_ohci_suspend(struct device *dev)
>>       struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev);
>>       struct usb_hcd *hcd = exynos_ohci->hcd;
>>       struct ohci_hcd *ohci = hcd_to_ohci(hcd);
>> -     struct platform_device *pdev = to_platform_device(dev);
>> -     struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
>>       unsigned long flags;
>>       int rc = 0;
>>
>> @@ -229,8 +257,7 @@ static int exynos_ohci_suspend(struct device *dev)
>>
>>       clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
>>
>> -     if (pdata && pdata->phy_exit)
>> -             pdata->phy_exit(pdev, S5P_USB_PHY_HOST);
>> +     exynos_ohci_phy_disable(exynos_ohci);
>>
>>       clk_disable(exynos_ohci->clk);
>>
>> @@ -244,13 +271,10 @@ static int exynos_ohci_resume(struct device *dev)
>>  {
>>       struct exynos_ohci_hcd *exynos_ohci = dev_get_drvdata(dev);
>>       struct usb_hcd *hcd = exynos_ohci->hcd;
>> -     struct platform_device *pdev = to_platform_device(dev);
>> -     struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data;
>>
>>       clk_enable(exynos_ohci->clk);
>>
>> -     if (pdata && pdata->phy_init)
>> -             pdata->phy_init(pdev, S5P_USB_PHY_HOST);
>> +     exynos_ohci_phy_enable(exynos_ohci);
>>
>>       /* Mark hardware accessible again as we are out of D3 state by now */
>>       set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
>> --
>> 1.7.6.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Thanks
Vivek

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-10-09 12:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-08 14:12 [PATCH 0/5] Adding usb2.0 host-phy support for exynos5250 Vivek Gautam
2012-10-08 14:12 ` [PATCH 1/5] usb: phy: samsung: Add host phy support to samsung-phy driver Vivek Gautam
     [not found] ` <1349705548-15207-1-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-10-08 14:12   ` [PATCH 2/5] ARM: S3C64XX: Add phy_type to pmu_isolation Vivek Gautam
2012-10-09  5:33     ` kishon
     [not found]       ` <5073B743.9000200-l0cyMroinI0@public.gmane.org>
2012-10-09 10:51         ` Vivek Gautam
     [not found]           ` <CAFp+6iE6Er088dYwp8q7uQuZhw9bdYbJXQDbJp66W6tD7+C-Xw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-09 11:12             ` Jingoo Han
2012-10-09 12:35               ` Vivek Gautam
2012-10-08 14:12 ` [PATCH 3/5] ARM: Exynos5250: Enabling samsung-usbphy driver Vivek Gautam
2012-10-08 14:12 ` [PATCH 4/5] usb: s5p-ehci: Adding phy driver support Vivek Gautam
     [not found]   ` <1349705548-15207-5-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-10-09  9:40     ` Jingoo Han
2012-10-09 12:44       ` Vivek Gautam
2012-10-08 14:12 ` [PATCH 5/5] usb: exynos-ohci: " Vivek Gautam
2012-10-09  9:46   ` Jingoo Han
2012-10-09 12:47     ` Vivek Gautam

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.