RE: [PATCH] phy: phy-samsung-usb2: Don't use same name for driver name and global structure

2014-12-11 Thread Kamil Debski
Hi,

 From: Vivek Gautam [mailto:gautamvivek1...@gmail.com]
 Sent: Thursday, December 11, 2014 7:30 AM
 To: Kishon Vijay Abraham I; Kamil Debski
 Cc: linux-ker...@vger.kernel.org; Linux USB Mailing List; Vivek Gautam
 Subject: Re: [PATCH] phy: phy-samsung-usb2: Don't use same name for
 driver name and global structure
 
 On Wed, Nov 12, 2014 at 3:54 PM, Vivek Gautam gautam.vi...@samsung.com
 wrote:
  Using the same driver name for platform driver and a globally defined,
  structure used throughout the file, looks a bit unpleasing.
  So changing the driver name from samsung_usb2_phy_driver to
  samsung_usb2_phy
 
  Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
  Cc: Kamil Debski k.deb...@samsung.com
  Cc: Kishon Vijay Abraham I kis...@ti.com
  ---
 
 Although just a trivial change, does it look valid ?

I can agree that the naming of this variable is a bit unfortunate.
Changing name of samsung_usb2_phy_driver to samsung_usb2_phy is, as
you said, a minor change and does not change how the driver works.

Acked-by: Kamil Debski k.deb...@samsung.com

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

 
   drivers/phy/phy-samsung-usb2.c |4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
 
  diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy-
 samsung-usb2.c
  index 908949d..2934fb7 100644
  --- a/drivers/phy/phy-samsung-usb2.c
  +++ b/drivers/phy/phy-samsung-usb2.c
  @@ -226,7 +226,7 @@ static int samsung_usb2_phy_probe(struct
 platform_device *pdev)
  return 0;
   }
 
  -static struct platform_driver samsung_usb2_phy_driver = {
  +static struct platform_driver samsung_usb2_phy = {
  .probe  = samsung_usb2_phy_probe,
  .driver = {
  .of_match_table = samsung_usb2_phy_of_match,
  @@ -234,7 +234,7 @@ static struct platform_driver
 samsung_usb2_phy_driver = {
  }
   };
 
  -module_platform_driver(samsung_usb2_phy_driver);
  +module_platform_driver(samsung_usb2_phy);
   MODULE_DESCRIPTION(Samsung S5P/EXYNOS SoC USB PHY driver);
   MODULE_AUTHOR(Kamil Debski k.deb...@samsung.com);
   MODULE_LICENSE(GPL v2);
  --
  1.7.10.4
 
  --
  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/
 
 
 
 --
 Best Regards
 Vivek Gautam
 Samsung RD Institute, Bangalore
 India

--
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] phy: phy-samsung-usb2: Change phy power on/power off sequence

2014-07-01 Thread Kamil Debski
The Exynos4412 USB 2.0 PHY hardware differs from the description provided
in the documentation. Some register bits have different function. This
patch fixes the defines of register bits and changes the way how phys are
powered on and off.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-exynos4x12-usb2.c |  112 +
 drivers/phy/phy-exynos5250-usb2.c |2 -
 drivers/phy/phy-samsung-usb2.h|3 +-
 3 files changed, 77 insertions(+), 40 deletions(-)

diff --git a/drivers/phy/phy-exynos4x12-usb2.c 
b/drivers/phy/phy-exynos4x12-usb2.c
index d92a7cc..63134d8 100644
--- a/drivers/phy/phy-exynos4x12-usb2.c
+++ b/drivers/phy/phy-exynos4x12-usb2.c
@@ -86,13 +86,23 @@
 #define EXYNOS_4x12_URSTCON_OTG_HLINK  BIT(1)
 #define EXYNOS_4x12_URSTCON_OTG_PHYLINKBIT(2)
 #define EXYNOS_4x12_URSTCON_HOST_PHY   BIT(3)
+/* The following bit defines are presented in the
+ * order taken from the Exynos4412 reference manual.
+ *
+ * During experiments with the hardware and debugging
+ * it was determined that the hardware behaves contrary
+ * to the manual.
+ *
+ * The following bit values were chaned accordingly to the
+ * results of real hardware experiments.
+ */
 #define EXYNOS_4x12_URSTCON_PHY1   BIT(4)
-#define EXYNOS_4x12_URSTCON_HSIC0  BIT(5)
-#define EXYNOS_4x12_URSTCON_HSIC1  BIT(6)
+#define EXYNOS_4x12_URSTCON_HSIC0  BIT(6)
+#define EXYNOS_4x12_URSTCON_HSIC1  BIT(5)
 #define EXYNOS_4x12_URSTCON_HOST_LINK_ALL  BIT(7)
-#define EXYNOS_4x12_URSTCON_HOST_LINK_P0   BIT(8)
+#define EXYNOS_4x12_URSTCON_HOST_LINK_P0   BIT(10)
 #define EXYNOS_4x12_URSTCON_HOST_LINK_P1   BIT(9)
-#define EXYNOS_4x12_URSTCON_HOST_LINK_P2   BIT(10)
+#define EXYNOS_4x12_URSTCON_HOST_LINK_P2   BIT(8)
 
 /* Isolation, configured in the power management unit */
 #define EXYNOS_4x12_USB_ISOL_OFFSET0x704
@@ -188,6 +198,7 @@ static void exynos4x12_setup_clk(struct 
samsung_usb2_phy_instance *inst)
clk = readl(drv-reg_phy + EXYNOS_4x12_UPHYCLK);
clk = ~EXYNOS_4x12_UPHYCLK_PHYFSEL_MASK;
clk |= drv-ref_reg_val  EXYNOS_4x12_UPHYCLK_PHYFSEL_OFFSET;
+   clk |= EXYNOS_4x12_UPHYCLK_PHY1_COMMON_ON;
writel(clk, drv-reg_phy + EXYNOS_4x12_UPHYCLK);
 }
 
@@ -198,27 +209,22 @@ static void exynos4x12_phy_pwr(struct 
samsung_usb2_phy_instance *inst, bool on)
u32 phypwr = 0;
u32 rst;
u32 pwr;
-   u32 mode = 0;
-   u32 switch_mode = 0;
 
switch (inst-cfg-id) {
case EXYNOS4x12_DEVICE:
phypwr =EXYNOS_4x12_UPHYPWR_PHY0;
rstbits =   EXYNOS_4x12_URSTCON_PHY0;
-   mode =  EXYNOS_4x12_MODE_SWITCH_DEVICE;
-   switch_mode =   1;
break;
case EXYNOS4x12_HOST:
phypwr =EXYNOS_4x12_UPHYPWR_PHY1;
-   rstbits =   EXYNOS_4x12_URSTCON_HOST_PHY;
-   mode =  EXYNOS_4x12_MODE_SWITCH_HOST;
-   switch_mode =   1;
+   rstbits =   EXYNOS_4x12_URSTCON_HOST_PHY |
+   EXYNOS_4x12_URSTCON_PHY1 |
+   EXYNOS_4x12_URSTCON_HOST_LINK_P0;
break;
case EXYNOS4x12_HSIC0:
phypwr =EXYNOS_4x12_UPHYPWR_HSIC0;
-   rstbits =   EXYNOS_4x12_URSTCON_HSIC1 |
-   EXYNOS_4x12_URSTCON_HOST_LINK_P0 |
-   EXYNOS_4x12_URSTCON_HOST_PHY;
+   rstbits =   EXYNOS_4x12_URSTCON_HSIC0 |
+   EXYNOS_4x12_URSTCON_HOST_LINK_P1;
break;
case EXYNOS4x12_HSIC1:
phypwr =EXYNOS_4x12_UPHYPWR_HSIC1;
@@ -228,11 +234,6 @@ static void exynos4x12_phy_pwr(struct 
samsung_usb2_phy_instance *inst, bool on)
};
 
if (on) {
-   if (switch_mode)
-   regmap_update_bits(drv-reg_sys,
-  EXYNOS_4x12_MODE_SWITCH_OFFSET,
-  EXYNOS_4x12_MODE_SWITCH_MASK, mode);
-
pwr = readl(drv-reg_phy + EXYNOS_4x12_UPHYPWR);
pwr = ~phypwr;
writel(pwr, drv-reg_phy + EXYNOS_4x12_UPHYPWR);
@@ -253,41 +254,78 @@ static void exynos4x12_phy_pwr(struct 
samsung_usb2_phy_instance *inst, bool on)
}
 }
 
-static int exynos4x12_power_on(struct samsung_usb2_phy_instance *inst)
+static void exynos4x12_power_on_int(struct samsung_usb2_phy_instance *inst)
 {
-   struct samsung_usb2_phy_driver *drv = inst-drv;
+   if (inst-int_cnt++  0)
+   return;
 
-   inst-enabled = 1;
exynos4x12_setup_clk(inst);
-   exynos4x12_phy_pwr(inst, 1);
exynos4x12_isol(inst, 0);
+   exynos4x12_phy_pwr(inst, 1);
+}
+
+static int exynos4x12_power_on(struct

[PATCH] phy: phy-samsung-usb2: Change phy power on/power off sequence

2014-06-24 Thread Kamil Debski
The Exynos4412 USB 2.0 PHY hardware differs from the description provided
in the documentation. Some register bits have different function. This
patch fixes the defines of register bits and changes the way how phys are
powered on and off.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-exynos4x12-usb2.c |  112 +
 drivers/phy/phy-samsung-usb2.h|3 +-
 2 files changed, 77 insertions(+), 38 deletions(-)

diff --git a/drivers/phy/phy-exynos4x12-usb2.c 
b/drivers/phy/phy-exynos4x12-usb2.c
index d92a7cc..59d8dd3 100644
--- a/drivers/phy/phy-exynos4x12-usb2.c
+++ b/drivers/phy/phy-exynos4x12-usb2.c
@@ -86,13 +86,23 @@
 #define EXYNOS_4x12_URSTCON_OTG_HLINK  BIT(1)
 #define EXYNOS_4x12_URSTCON_OTG_PHYLINKBIT(2)
 #define EXYNOS_4x12_URSTCON_HOST_PHY   BIT(3)
+/* The following bit defines are presented in the
+ * order taken from the Exynos4412 reference manual.
+ *
+ * During experiments with the hardware and debugging
+ * it was determined that the hardware behaves contrary
+ * to the manual.
+ *
+ * The following bit values were chaned accordingly to the
+ * results of real hardware experiments.
+ */
 #define EXYNOS_4x12_URSTCON_PHY1   BIT(4)
-#define EXYNOS_4x12_URSTCON_HSIC0  BIT(5)
-#define EXYNOS_4x12_URSTCON_HSIC1  BIT(6)
+#define EXYNOS_4x12_URSTCON_HSIC0  BIT(6)
+#define EXYNOS_4x12_URSTCON_HSIC1  BIT(5)
 #define EXYNOS_4x12_URSTCON_HOST_LINK_ALL  BIT(7)
-#define EXYNOS_4x12_URSTCON_HOST_LINK_P0   BIT(8)
+#define EXYNOS_4x12_URSTCON_HOST_LINK_P0   BIT(10)
 #define EXYNOS_4x12_URSTCON_HOST_LINK_P1   BIT(9)
-#define EXYNOS_4x12_URSTCON_HOST_LINK_P2   BIT(10)
+#define EXYNOS_4x12_URSTCON_HOST_LINK_P2   BIT(8)
 
 /* Isolation, configured in the power management unit */
 #define EXYNOS_4x12_USB_ISOL_OFFSET0x704
@@ -188,6 +198,7 @@ static void exynos4x12_setup_clk(struct 
samsung_usb2_phy_instance *inst)
clk = readl(drv-reg_phy + EXYNOS_4x12_UPHYCLK);
clk = ~EXYNOS_4x12_UPHYCLK_PHYFSEL_MASK;
clk |= drv-ref_reg_val  EXYNOS_4x12_UPHYCLK_PHYFSEL_OFFSET;
+   clk |= EXYNOS_4x12_UPHYCLK_PHY1_COMMON_ON;
writel(clk, drv-reg_phy + EXYNOS_4x12_UPHYCLK);
 }
 
@@ -198,27 +209,22 @@ static void exynos4x12_phy_pwr(struct 
samsung_usb2_phy_instance *inst, bool on)
u32 phypwr = 0;
u32 rst;
u32 pwr;
-   u32 mode = 0;
-   u32 switch_mode = 0;
 
switch (inst-cfg-id) {
case EXYNOS4x12_DEVICE:
phypwr =EXYNOS_4x12_UPHYPWR_PHY0;
rstbits =   EXYNOS_4x12_URSTCON_PHY0;
-   mode =  EXYNOS_4x12_MODE_SWITCH_DEVICE;
-   switch_mode =   1;
break;
case EXYNOS4x12_HOST:
phypwr =EXYNOS_4x12_UPHYPWR_PHY1;
-   rstbits =   EXYNOS_4x12_URSTCON_HOST_PHY;
-   mode =  EXYNOS_4x12_MODE_SWITCH_HOST;
-   switch_mode =   1;
+   rstbits =   EXYNOS_4x12_URSTCON_HOST_PHY |
+   EXYNOS_4x12_URSTCON_PHY1 |
+   EXYNOS_4x12_URSTCON_HOST_LINK_P0;
break;
case EXYNOS4x12_HSIC0:
phypwr =EXYNOS_4x12_UPHYPWR_HSIC0;
-   rstbits =   EXYNOS_4x12_URSTCON_HSIC1 |
-   EXYNOS_4x12_URSTCON_HOST_LINK_P0 |
-   EXYNOS_4x12_URSTCON_HOST_PHY;
+   rstbits =   EXYNOS_4x12_URSTCON_HSIC0 |
+   EXYNOS_4x12_URSTCON_HOST_LINK_P1 ;
break;
case EXYNOS4x12_HSIC1:
phypwr =EXYNOS_4x12_UPHYPWR_HSIC1;
@@ -228,11 +234,6 @@ static void exynos4x12_phy_pwr(struct 
samsung_usb2_phy_instance *inst, bool on)
};
 
if (on) {
-   if (switch_mode)
-   regmap_update_bits(drv-reg_sys,
-  EXYNOS_4x12_MODE_SWITCH_OFFSET,
-  EXYNOS_4x12_MODE_SWITCH_MASK, mode);
-
pwr = readl(drv-reg_phy + EXYNOS_4x12_UPHYPWR);
pwr = ~phypwr;
writel(pwr, drv-reg_phy + EXYNOS_4x12_UPHYPWR);
@@ -253,41 +254,78 @@ static void exynos4x12_phy_pwr(struct 
samsung_usb2_phy_instance *inst, bool on)
}
 }
 
-static int exynos4x12_power_on(struct samsung_usb2_phy_instance *inst)
+static void exynos4x12_power_on_internal(struct samsung_usb2_phy_instance 
*inst)
 {
-   struct samsung_usb2_phy_driver *drv = inst-drv;
+   if (inst-int_cnt++  0)
+   return;
 
-   inst-enabled = 1;
exynos4x12_setup_clk(inst);
-   exynos4x12_phy_pwr(inst, 1);
exynos4x12_isol(inst, 0);
+   exynos4x12_phy_pwr(inst, 1);
+}
+
+static int exynos4x12_power_on(struct samsung_usb2_phy_instance *inst)
+{
+   struct

RE: [PATCH] phy: phy-samsung-usb2: Change phy power on/power off sequence

2014-06-24 Thread Kamil Debski
Hi Daniel,

 From: Daniel Drake [mailto:dr...@endlessm.com]
 Sent: Tuesday, June 24, 2014 5:09 PM
 
 On Tue, Jun 24, 2014 at 1:54 PM, Kamil Debski k.deb...@samsung.com
 wrote:
  The Exynos4412 USB 2.0 PHY hardware differs from the description
  provided in the documentation. Some register bits have different
  function. This patch fixes the defines of register bits and changes
  the way how phys are powered on and off.
 
 I guess this replaces the patch titled drivers: phy: exynos4x12-phy:
 fix HSIC1 power on/off sequence

Yes, indeed it replaces this patch. I did some more research on how the
hardware actually behaves.

 
 Tested on ODROID-U2. Seems to be working as well as the previous patch:

Thank you very much for testing.

 - Internal SMSC hub works on boot and after reboot, tested with USB
 mouse
 - Internal SMSC ethernet device works on boot, but disappears upon
 reboot. (same as previous patch, also reproduced by Marek)

By reboot I guess that you mean typing reboot or by using SysRq magic
and not power cycling?

If so, I had experienced the same symptoms. I guess that the Ethernet
chip is not reset properly and fails to enumerate without power cycling
(it's nRESET pin is connected to P3V3).

I found that removing regulator-always-on from buck8_reg: BUCK8 in the
dts file fixes this problem.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


--
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: gadget: s3c-hsotg: fix phy disable sequence

2014-05-14 Thread Kamil Debski
Hi Vivek, Kishon,

 From: gautamvivek1...@gmail.com [mailto:gautamvivek1...@gmail.com] On
 Behalf Of Vivek Gautam
 Sent: Tuesday, May 13, 2014 12:08 PM
 To: Marek Szyprowski
 Cc: Kamil Debski; Linux USB Mailing List; r.bald...@samsung.com
 Subject: Re: [PATCH] usb: gadget: s3c-hsotg: fix phy disable sequence
 
 Hi,
 
 
 On Tue, May 13, 2014 at 12:30 PM, Marek Szyprowski
 m.szyprow...@samsung.com wrote:
  Hello,
 
 
  On 2014-05-13 08:21, Vivek Gautam wrote:
 
  On Mon, May 12, 2014 at 10:19 PM, Kamil Debski k.deb...@samsung.com
  wrote:
   When the driver is removed s3c_hsotg_phy_disable is called three
   times instead of once. This results in decreasing of the phy
   reference counter below zero and thus consecutive inserts of the
 module fails.
  
   This patch removes calls to s3c_hsotg_phy_disable from
   s3c_hsotg_remove and s3c_hsotg_udc_stop.
  
   s3c_hsotg_udc_stop is called from udc-core.c only after
   usb_gadget_disconnect, which in turn calls s3c_hsotg_pullup, which
   already calls s3c_hsotg_phy_disable.
  
   s3c_hsotg_remove must be called only after udc_stop, so there is
 no
   point in disabling phy once again there.
  
   Signed-off-by: Kamil Debski k.deb...@samsung.com
   ---
drivers/usb/gadget/s3c-hsotg.c |3 ---
 
 Please rebase on 'usb-next'. This file is moved to dwc2.
 drivers/usb/dwc2/gadget.c

I will, thank you for pointing this out.

 
1 file changed, 3 deletions(-)
  
   diff --git a/drivers/usb/gadget/s3c-hsotg.c
   b/drivers/usb/gadget/s3c-hsotg.c index 2a9cb67..29d70a7 100644
   --- a/drivers/usb/gadget/s3c-hsotg.c
   +++ b/drivers/usb/gadget/s3c-hsotg.c
   @@ -3078,8 +3078,6 @@ static int s3c_hsotg_udc_stop(struct
   usb_gadget *gadget,
  
   spin_lock_irqsave(hsotg-lock, flags);
  
   -   s3c_hsotg_phy_disable(hsotg);
   -
   if (!driver)
   hsotg-driver = NULL;
  
   @@ -3766,7 +3764,6 @@ static int s3c_hsotg_remove(struct
   platform_device
   *pdev)
   usb_gadget_unregister_driver(hsotg-driver);
   }
  
   -   s3c_hsotg_phy_disable(hsotg);
   if (hsotg-phy)
   phy_exit(hsotg-phy);
 
  We may want to remove above two lines too, isn't it ?
 
 
  Hmm, I think that more appropriate will be to remove calls to
  phy_init()/phy_exit()
  from s3c_hsotg_phy_enable()/s3c_hsotg_phy_disable() functions and
  leave
  phy_init()
  and phy_exit() only in s3c_hsotg_probe()/s3c_hsotg_remove() pair.
 
 Yea, that's one way.
 But i was just wondering, do the phy_init() and phy_exit() callbacks
 have any PHY's suspend/resume related settings.
 In that case we would still want to suspend phy when the driver is
 suspending.
 
 Although for phy-samsung-usb2 driver on exynos systems phy_inti() and
 phy_exit() are just no-ops.
 

Kishon, could you clarify us on this issue? I interpret the PHY
documentation such that phy_init/exit should be called on consumer
driver probe/remove. But I understand Vivek's point of view.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

--
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 1/3] usb: dwc2: gadget: fix phy disable sequence

2014-05-14 Thread Kamil Debski
When the driver is removed s3c_hsotg_phy_disable is called three times
instead of once. This results in decreasing of the phy reference counter
below zero and thus consecutive inserts of the module fails.

This patch removes calls to s3c_hsotg_phy_disable from s3c_hsotg_remove
and s3c_hsotg_udc_stop.

s3c_hsotg_udc_stop is called from udc-core.c only after
usb_gadget_disconnect, which in turn calls s3c_hsotg_pullup, which
already calls s3c_hsotg_phy_disable.

s3c_hsotg_remove must be called only after udc_stop, so there is no
point in disabling phy once again there.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/usb/dwc2/gadget.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 2057c38..5364a6e 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2898,8 +2898,6 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
 
spin_lock_irqsave(hsotg-lock, flags);
 
-   s3c_hsotg_phy_disable(hsotg);
-
if (!driver)
hsotg-driver = NULL;
 
@@ -3586,7 +3584,6 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
usb_gadget_unregister_driver(hsotg-driver);
}
 
-   s3c_hsotg_phy_disable(hsotg);
if (hsotg-phy)
phy_exit(hsotg-phy);
clk_disable_unprepare(hsotg-clk);
-- 
1.7.9.5

--
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/3] usb: dwc2: gadget: fix phy initialization sequence

2014-05-14 Thread Kamil Debski
In the Generic PHY Framework a NULL phy is considered to be a valid phy
thus the if (hsotg-phy) check does not give us the information whether
the Generic PHY Framework is used.

In addition to the above this patch also removes phy_init from probe and
phy_exit from remove. This is not necessary when init/exit is done in the
s3c_hsotg_phy_enable/disable functions.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/usb/dwc2/gadget.c |   27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 5364a6e..9898310 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2748,13 +2748,14 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg 
*hsotg)
 
dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
 
-   if (hsotg-phy) {
-   phy_init(hsotg-phy);
-   phy_power_on(hsotg-phy);
-   } else if (hsotg-uphy)
+   if (hsotg-uphy)
usb_phy_init(hsotg-uphy);
-   else if (hsotg-plat-phy_init)
+   else if (hsotg-plat  hsotg-plat-phy_init)
hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);
+   else {
+   phy_init(hsotg-phy);
+   phy_power_on(hsotg-phy);
+   }
 }
 
 /**
@@ -2768,13 +2769,14 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg 
*hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg-dev);
 
-   if (hsotg-phy) {
-   phy_power_off(hsotg-phy);
-   phy_exit(hsotg-phy);
-   } else if (hsotg-uphy)
+   if (hsotg-uphy)
usb_phy_shutdown(hsotg-uphy);
-   else if (hsotg-plat-phy_exit)
+   else if (hsotg-plat  hsotg-plat-phy_exit)
hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);
+   else {
+   phy_power_off(hsotg-phy);
+   phy_exit(hsotg-phy);
+   }
 }
 
 /**
@@ -3489,9 +3491,6 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
if (hsotg-phy  (phy_get_bus_width(phy) == 8))
hsotg-phyif = GUSBCFG_PHYIF8;
 
-   if (hsotg-phy)
-   phy_init(hsotg-phy);
-
/* usb phy enable */
s3c_hsotg_phy_enable(hsotg);
 
@@ -3584,8 +3583,6 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
usb_gadget_unregister_driver(hsotg-driver);
}
 
-   if (hsotg-phy)
-   phy_exit(hsotg-phy);
clk_disable_unprepare(hsotg-clk);
 
return 0;
-- 
1.7.9.5

--
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 3/3] usb: dwc2: gadget: move phy bus legth initialization

2014-05-14 Thread Kamil Debski
This patch moves the part of code that initializes the PHY bus width.
This results in simpler code and removes the need to check whether
the Generic PHY Framework is used.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/usb/dwc2/gadget.c |   22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 9898310..dbf7615 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3395,6 +3395,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
+   /* Set default UTMI width */
+   hsotg-phyif = GUSBCFG_PHYIF16;
+
/*
 * Attempt to find a generic PHY, then look for an old style
 * USB PHY, finally fall back to pdata
@@ -3413,8 +3416,15 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
hsotg-plat = plat;
} else
hsotg-uphy = uphy;
-   } else
+   } else {
hsotg-phy = phy;
+   /*
+* If using the generic PHY framework, check if the PHY bus
+* width is 8-bit and set the phyif appropriately.
+*/
+   if (phy_get_bus_width(phy) == 8)
+   hsotg-phyif = GUSBCFG_PHYIF8;
+   }
 
hsotg-dev = dev;
 
@@ -3481,16 +3491,6 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
goto err_supplies;
}
 
-   /* Set default UTMI width */
-   hsotg-phyif = GUSBCFG_PHYIF16;
-
-   /*
-* If using the generic PHY framework, check if the PHY bus
-* width is 8-bit and set the phyif appropriately.
-*/
-   if (hsotg-phy  (phy_get_bus_width(phy) == 8))
-   hsotg-phyif = GUSBCFG_PHYIF8;
-
/* usb phy enable */
s3c_hsotg_phy_enable(hsotg);
 
-- 
1.7.9.5

--
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: gadget: s3c-hsotg: fix phy disable sequence

2014-05-12 Thread Kamil Debski
When the driver is removed s3c_hsotg_phy_disable is called three times
instead of once. This results in decreasing of the phy reference counter
below zero and thus consecutive inserts of the module fails.

This patch removes calls to s3c_hsotg_phy_disable from s3c_hsotg_remove
and s3c_hsotg_udc_stop.

s3c_hsotg_udc_stop is called from udc-core.c only after
usb_gadget_disconnect, which in turn calls s3c_hsotg_pullup, which
already calls s3c_hsotg_phy_disable.

s3c_hsotg_remove must be called only after udc_stop, so there is no
point in disabling phy once again there.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/usb/gadget/s3c-hsotg.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 2a9cb67..29d70a7 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -3078,8 +3078,6 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
 
spin_lock_irqsave(hsotg-lock, flags);
 
-   s3c_hsotg_phy_disable(hsotg);
-
if (!driver)
hsotg-driver = NULL;
 
@@ -3766,7 +3764,6 @@ static int s3c_hsotg_remove(struct platform_device *pdev)
usb_gadget_unregister_driver(hsotg-driver);
}
 
-   s3c_hsotg_phy_disable(hsotg);
if (hsotg-phy)
phy_exit(hsotg-phy);
clk_disable_unprepare(hsotg-clk);
-- 
1.7.9.5

--
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 v9 3/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-06 Thread Kamil Debski
Hi Anton, Kishon,

 From: Anton Tikhomirov [mailto:av.tikhomi...@samsung.com]
 Sent: Thursday, March 06, 2014 9:26 AM
 
 Hi Kamil,
 
 ...
 
  +| 3. Supporting SoCs
  ++
  +
  +To support a new SoC a new file should be added to the drivers/phy
  +directory. Each SoC's configuration is stored in an instance of the
  +struct samsung_usb2_phy_config.
  +
  +struct samsung_usb2_phy_config {
  +   const struct samsung_usb2_common_phy *phys;
  +   unsigned int num_phys;
  +   bool has_mode_switch;
 
 You missed rate_to_clk here.

Thank you for spotting this.

Kishon: I am sorry that this omission was made. I am happy to send an
updated patchset. However, I want to give some time for any additional
comments. Do you think that we have for this? Is today evening ok with you?
 
  +};
  +
 
 ...
 
  diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy-
 samsung-
  usb2.c new file mode 100644 index 000..c3b7719
  --- /dev/null
  +++ b/drivers/phy/phy-samsung-usb2.c
  @@ -0,0 +1,222 @@
  +/*
  + * Samsung SoC USB 1.1/2.0 PHY driver
  + *
  + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  + * Author: Kamil Debski k.deb...@samsung.com
  + *
  + * This program is free software; you can redistribute it and/or
  modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + */
  +
  +#include linux/clk.h
  +#include linux/mfd/syscon.h
  +#include linux/module.h
  +#include linux/of.h
  +#include linux/of_address.h
  +#include linux/phy/phy.h
  +#include linux/platform_device.h
  +#include linux/spinlock.h
  +#include phy-samsung-usb2.h
  +
  +static int samsung_usb2_phy_power_on(struct phy *phy) {
  +   struct samsung_usb2_phy_instance *inst = phy_get_drvdata(phy);
  +   struct samsung_usb2_phy_driver *drv = inst-drv;
  +   int ret;
  +
  +   dev_dbg(drv-dev, Request to power_on \%s\ usb phy\n,
  +   inst-cfg-label);
  +   ret = clk_prepare_enable(drv-clk);
 
 clk_prepare_enable() can sleep, and therefore doesn't allow
 samusng_usb2_phy_power_on() to be used in atomic context (e.g. inside
 spin_lock-ed area), what sometimes may be desirable.
 What about to prepare clock in probe, and just enable it here
 (note: clk_enable() doesn't sleep).

From the onward discussion between you and Kishon, I draw the conclusion
that this change is not necessary. Right?

 
  +   if (ret)
  +   goto err_main_clk;
  +   ret = clk_prepare_enable(drv-ref_clk);
  +   if (ret)
  +   goto err_instance_clk;
  +   if (inst-cfg-power_on) {
  +   spin_lock(drv-lock);
  +   ret = inst-cfg-power_on(inst);
  +   spin_unlock(drv-lock);
  +   }
  +
  +   return 0;
 
 Thank you

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


--
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 v9 0/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-06 Thread Kamil Debski
Hi Tobias,

 From: Tobias Jakobi [mailto:tjak...@math.uni-bielefeld.de]
 Sent: Thursday, March 06, 2014 12:08 AM
 
 Hello Kamil,
 
 this looks very good. I just tested the patchset on my ODROID-X2
 (Exynos4412-based board) and the USB stability issues I mentioned to
 you before (with the older patchset) seem to be gone.

This problem was related to the reset procedure not being done completely. 
It is corrected now.

 
 All devices on the USB behave normally (mass storage, ethernet and
 bluetooth).

Thank you for testing these patches. Would you consider adding a Tested-by 
tag?
I am planning to send v10 soon, which will address comments to v9.

 
 With best wishes,
 Tobias

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

--
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 v10 1/4] phy: core: Add an exported of_phy_get function

2014-03-06 Thread Kamil Debski
Previously the of_phy_get function took a struct device * and
was declared static. It was impossible to call it from
another driver and thus it was impossible to get phy defined
for a given node. The old function was renamed to _of_phy_get
and was left for internal use. of_phy_get function was added
and it was exported. The function enables to get a phy for
a given device tree node.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   45 -
 include/linux/phy/phy.h |6 ++
 2 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 6c73837..7c1b0e1 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy)
 EXPORT_SYMBOL_GPL(phy_power_off);
 
 /**
- * of_phy_get() - lookup and obtain a reference to a phy by phandle
- * @dev: device that requests this phy
+ * _of_phy_get() - lookup and obtain a reference to a phy by phandle
+ * @np: device_node for which to get the phy
  * @index: the index of the phy
  *
  * Returns the phy associated with the given phandle value,
@@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
  * not yet loaded. This function uses of_xlate call back function provided
  * while registering the phy_provider to find the phy instance.
  */
-static struct phy *of_phy_get(struct device *dev, int index)
+static struct phy *_of_phy_get(struct device_node *np, int index)
 {
int ret;
struct phy_provider *phy_provider;
struct phy *phy = NULL;
struct of_phandle_args args;
 
-   ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells,
+   ret = of_parse_phandle_with_args(np, phys, #phy-cells,
index, args);
-   if (ret) {
-   dev_dbg(dev, failed to get phy in %s node\n,
-   dev-of_node-full_name);
+   if (ret)
return ERR_PTR(-ENODEV);
-   }
 
mutex_lock(phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np);
@@ -317,6 +314,36 @@ err0:
 }
 
 /**
+ * of_phy_get() - lookup and obtain a reference to a phy using a device_node.
+ * @np: device_node for which to get the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Returns the phy driver, after getting a refcount to it; or
+ * -ENODEV if there is no such phy. The caller is responsible for
+ * calling phy_put() to release that count.
+ */
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   struct phy *phy = NULL;
+   int index = 0;
+
+   if (con_id)
+   index = of_property_match_string(np, phy-names, con_id);
+
+   phy = _of_phy_get(np, index);
+   if (IS_ERR(phy))
+   return phy;
+
+   if (!try_module_get(phy-ops-owner))
+   return ERR_PTR(-EPROBE_DEFER);
+
+   get_device(phy-dev);
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(of_phy_get);
+
+/**
  * phy_put() - release the PHY
  * @phy: the phy returned by phy_get()
  *
@@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string)
if (dev-of_node) {
index = of_property_match_string(dev-of_node, phy-names,
string);
-   phy = of_phy_get(dev, index);
+   phy = _of_phy_get(dev-of_node, index);
} else {
phy = phy_lookup(dev, string);
}
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 3f83459..2fe3194 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char 
*string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
+struct phy *of_phy_get(struct device_node *np, const char *con_id);
 struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
 struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
@@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct 
phy *phy)
 {
 }
 
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args)
 {
-- 
1.7.9.5

--
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 v10 0/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-06 Thread Kamil Debski
Hi,

This is the tenth version of this patchset. The only difference since v9
is correction in the documentation.

Best wishes,
Kamil Debski

--
Changes from v9:
1) phy: core: Add an exported of_phy_get function
   - No changes since v9.
2) phy: core: Add devm_of_phy_get to phy-core
   - No changes since v9.
3) phy: Add new Exynos USB 2.0 PHY driver
   - Fixed missing callback in the documentation of the
 samsung_usb2_phy_config structure.
4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
   - No changes since v9.

--
Changes from v8:
1) phy: core: Add an exported of_phy_get function
   - No changes since v8.
2) phy: core: Add devm_of_phy_get to phy-core
   - No changes since v8.
3) phy: Add new Exynos USB 2.0 PHY driver
   - Fix empty blank line at EOF errors
4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
   - Fix empty blank line at EOF error

--
Changes from v7:
1) phy: core: Add an exported of_phy_get function
   - No changes since v7.
2) phy: core: Add devm_of_phy_get to phy-core
   - No changes since v7.
3) phy: Add new Exynos USB 2.0 PHY driver
   - Fix checkpatch errors with code indentation and corrected whitespace.
4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
   - Fix checkpatch errors with code indentation and corrected whitespace.

--
Changes from v6: (not including the change that controller patches were removed
form this patchset, also this patchset excludes S5PV210 support - it needs more
testing)
1) phy: core: Add an exported of_phy_get function
   - No changes since v6.
2) phy: core: Add devm_of_phy_get to phy-core
   - No changes since v6.
3) phy: Add new Exynos USB 2.0 PHY driver
   - Changed the way clocks are supplied to the driver. Prior to version v7
 there were reference clocks for every phy instance, now a single ref
 clock was introduced.
   - Updated documentation to match the aforementioned change.
   - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content
 defines.
   - Corrected way clock register is modified. Instead of a simple write, a
 proper read, modify, write sequence was introduced.
   - Important stability fix - added udelay after PHY reset. This fixes a bug
 causing instability in USB LAN adapters. Without the delay the DMA burst
 mode was could not be enabled.
4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
   - Changed handling of clocks to use a single ref clock.


Changes from v5:
1) phy: core: Add an exported of_phy_get function
- corrected behaviour of the modification when GENERIC_PHY is not enabled
  by adding a stub of the of_phy_get function
2) phy: core: Add devm_of_phy_get to phy-core
- corrected behaviour of the modification when GENERIC_PHY is not enabled
  by adding a stub of the devm_of_phy_get function
3) dts: Add usb2phy to Exynos 4
- no change
4) dts: Add usb2phy to Exynos 5250
- in the previous version, this patch included some phy-exynos5250-usb2.c code
  by mistake, the code has been remove and added to the proper patch
5) phy: Add new Exynos USB PHY driver
- changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is
  actually a driver for the whole Exynos 4x12 family
- added documentation to the Exynos USB 2.0 PHY driver adaptaion layer
- corrected strings HSCI - HSIC
- fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did
  not work on its own
- mode switch support was added to Exynos 4x12 (same io pins are used by host
  and device)
- support for phy_set_bus_width introduced by Matt Porter was added
6) phy: Add support for S5PV210 to the Exynos USB PHY
- setting of clk register was fixed
7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
- supoprt was added for HSIC and device
8) usb: ehci-exynos: Change to use phy provided by the generic phy framework
- DT documentation was moved from usb-ehci.txt to exynos-usb.txt


Changes from v4:
1) phy: core: Add an exported of_phy_get function
- the new exported function of_phy_get was changed to take the phy's name as a
  parameter instead of the index
2) phy: core: Add devm_of_phy_get to phy-core
- fixes made in the comments to devm_of_phy_get
3) phy: Add new Exynos USB PHY driver
- move the documentation from a new to an existing file - samsung-phy.txt
- fix typos and uppercase hex addresses
- add more explanations to Kconfig (checkpatch still complains, but I find it
  hard to think what else could I add)
- add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!)
- cleanup included headers in both *.c and .h files
- use BIT(x) macro instead of (1  x)
- replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the
  registers are described as PHYx in the documentation hence the decision to
  leave the PHYx naming
- fixed typo in exynos4210_rate_to_clk reg - *reg
- change hax_mode_switch and enabled type to bool
4) usb: ehci-s5p: Change to use phy provided

[PATCH v10 2/4] phy: core: Add devm_of_phy_get to phy-core

2014-03-06 Thread Kamil Debski
Adding devm_of_phy_get will allow to get phys by supplying a
pointer to the struct device_node instead of struct device.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   31 +++
 include/linux/phy/phy.h |8 
 2 files changed, 39 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 7c1b0e1..623b71c 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, 
const char *string)
 EXPORT_SYMBOL_GPL(devm_phy_optional_get);
 
 /**
+ * devm_of_phy_get() - lookup and obtain a reference to a phy.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Gets the phy using of_phy_get(), and associates a device with it using
+ * devres. On driver detach, release function is invoked on the devres data,
+ * then, devres data is freed.
+ */
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   struct phy **ptr, *phy;
+
+   ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   phy = of_phy_get(np, con_id);
+   if (!IS_ERR(phy)) {
+   *ptr = phy;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_get);
+
+/**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
  * @ops: function pointers for performing phy operations
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 2fe3194..bcbf96c 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string);
 struct phy *phy_optional_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 struct phy *of_phy_get(struct device_node *np, const char *con_id);
@@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct 
device *dev,
return ERR_PTR(-ENOSYS);
 }
 
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline void phy_put(struct phy *phy)
 {
 }
-- 
1.7.9.5

--
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 v10 3/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-06 Thread Kamil Debski
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic
PHY framework. The driver includes support for the Exynos 4x10 and 4x12
SoC families.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|   53 
 Documentation/phy/samsung-usb2.txt |  135 
 drivers/phy/Kconfig|   29 ++
 drivers/phy/Makefile   |3 +
 drivers/phy/phy-exynos4210-usb2.c  |  261 
 drivers/phy/phy-exynos4x12-usb2.c  |  328 
 drivers/phy/phy-samsung-usb2.c |  222 +
 drivers/phy/phy-samsung-usb2.h |   66 
 8 files changed, 1097 insertions(+)
 create mode 100644 Documentation/phy/samsung-usb2.txt
 create mode 100644 drivers/phy/phy-exynos4210-usb2.c
 create mode 100644 drivers/phy/phy-exynos4x12-usb2.c
 create mode 100644 drivers/phy/phy-samsung-usb2.c
 create mode 100644 drivers/phy/phy-samsung-usb2.h

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index c0fccaa..bf955ab 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -20,3 +20,56 @@ Required properties:
 - compatible : should be samsung,exynos5250-dp-video-phy;
 - reg : offset and length of the Display Port PHY register set;
 - #phy-cells : from the generic PHY bindings, must be 0;
+
+Samsung S5P/EXYNOS SoC series USB PHY
+-
+
+Required properties:
+- compatible : should be one of the listed compatibles:
+   - samsung,exynos4210-usb2-phy
+   - samsung,exynos4x12-usb2-phy
+- reg : a list of registers used by phy driver
+   - first and obligatory is the location of phy modules registers
+- samsung,sysreg-phandle - handle to syscon used to control the system 
registers
+- samsung,pmureg-phandle - handle to syscon used to control PMU registers
+- #phy-cells : from the generic phy bindings, must be 1;
+- clocks and clock-names:
+   - the phy clock is required by the phy module, used as a gate
+   - the ref clock is used to get the rate of the clock provided to the
+ PHY module
+
+The first phandle argument in the PHY specifier identifies the PHY, its
+meaning is compatible dependent. For the currently supported SoCs (Exynos 4210
+and Exynos 4212) it is as follows:
+  0 - USB device (device),
+  1 - USB host (host),
+  2 - HSIC0 (hsic0),
+  3 - HSIC1 (hsic1),
+
+Exynos 4210 and Exynos 4212 use mode switching and require that mode switch
+register is supplied.
+
+Example:
+
+For Exynos 4412 (compatible with Exynos 4212):
+
+usbphy: phy@125b {
+   compatible = samsung,exynos4x12-usb2-phy;
+   reg = 0x125b 0x100;
+   clocks = clock 305, clock 2;
+   clock-names = phy, ref;
+   status = okay;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_reg;
+   samsung,pmureg-phandle = pmu_reg;
+};
+
+Then the PHY can be used in other nodes such as:
+
+phy-consumer@1234 {
+   phys = usbphy 2;
+   phy-names = phy;
+};
+
+Refer to DT bindings documentation of particular PHY consumer devices for more
+information about required PHYs and the way of specification.
diff --git a/Documentation/phy/samsung-usb2.txt 
b/Documentation/phy/samsung-usb2.txt
new file mode 100644
index 000..ed12d43
--- /dev/null
+++ b/Documentation/phy/samsung-usb2.txt
@@ -0,0 +1,135 @@
+.--+
+|  Samsung USB 2.0 PHY adaptation layer   |
++-+'
+
+| 1. Description
++
+
+The architecture of the USB 2.0 PHY module in Samsung SoCs is similar
+among many SoCs. In spite of the similarities it proved difficult to
+create a one driver that would fit all these PHY controllers. Often
+the differences were minor and were found in particular bits of the
+registers of the PHY. In some rare cases the order of register writes or
+the PHY powering up process had to be altered. This adaptation layer is
+a compromise between having separate drivers and having a single driver
+with added support for many special cases.
+
+| 2. Files description
++--
+
+- phy-samsung-usb2.c
+   This is the main file of the adaptation layer. This file contains
+   the probe function and provides two callbacks to the Generic PHY
+   Framework. This two callbacks are used to power on and power off the
+   phy. They carry out the common work that has to be done on all version
+   of the PHY module. Depending on which SoC was chosen they execute SoC
+   specific callbacks. The specific SoC version is selected by choosing
+   the appropriate compatible string. In addition, this file contains

[PATCH v10 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver

2014-03-06 Thread Kamil Debski
Add support for Exynos 5250. This driver is to replace the old
USB 2.0 PHY driver.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|1 +
 drivers/phy/Kconfig|   11 +
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-exynos5250-usb2.c  |  404 
 drivers/phy/phy-samsung-usb2.c |6 +
 drivers/phy/phy-samsung-usb2.h |1 +
 6 files changed, 424 insertions(+)
 create mode 100644 drivers/phy/phy-exynos5250-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index bf955ab..28f9edb 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -28,6 +28,7 @@ Required properties:
 - compatible : should be one of the listed compatibles:
- samsung,exynos4210-usb2-phy
- samsung,exynos4x12-usb2-phy
+   - samsung,exynos5250-usb2-phy
 - reg : a list of registers used by phy driver
- first and obligatory is the location of phy modules registers
 - samsung,sysreg-phandle - handle to syscon used to control the system 
registers
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 3374836..1b607d7 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -136,4 +136,15 @@ config PHY_EXYNOS4X12_USB2
  Samsung USB 2.0 PHY driver is enabled and means that support for this
  particular SoC is compiled in the driver. In case of Exynos 4x12 four
  phys are available - device, host, HSIC0 and HSIC1.
+
+config PHY_EXYNOS5250_USB2
+   bool Support for Exynos 5250
+   depends on PHY_SAMSUNG_USB2
+   depends on SOC_EXYNOS5250
+   help
+ Enable USB PHY support for Exynos 5250. This option requires that
+ Samsung USB 2.0 PHY driver is enabled and means that support for this
+ particular SoC is compiled in the driver. In case of Exynos 5250 four
+ phys are available - device, host, HSIC0 and HSIC.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index c4ddd23..ecf0d3f 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_PHY_SUN4I_USB)   += phy-sun4i-usb.o
 obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4210_USB2)  += phy-exynos4210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4X12_USB2)  += phy-exynos4x12-usb2.o
+obj-$(CONFIG_PHY_EXYNOS5250_USB2)  += phy-exynos5250-usb2.o
diff --git a/drivers/phy/phy-exynos5250-usb2.c 
b/drivers/phy/phy-exynos5250-usb2.c
new file mode 100644
index 000..94179af
--- /dev/null
+++ b/drivers/phy/phy-exynos5250-usb2.c
@@ -0,0 +1,404 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/phy/phy.h
+#include linux/regmap.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+#define EXYNOS_5250_REFCLKSEL_CRYSTAL  0x0
+#define EXYNOS_5250_REFCLKSEL_XO   0x1
+#define EXYNOS_5250_REFCLKSEL_CLKCORE  0x2
+
+#define EXYNOS_5250_FSEL_9MHZ6 0x0
+#define EXYNOS_5250_FSEL_10MHZ 0x1
+#define EXYNOS_5250_FSEL_12MHZ 0x2
+#define EXYNOS_5250_FSEL_19MHZ20x3
+#define EXYNOS_5250_FSEL_20MHZ 0x4
+#define EXYNOS_5250_FSEL_24MHZ 0x5
+#define EXYNOS_5250_FSEL_50MHZ 0x7
+
+/* Normal host */
+#define EXYNOS_5250_HOSTPHYCTRL0   0x0
+
+#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL   BIT(31)
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT   19
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\
+   (0x3  EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \
+   (0x7  EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11)
+#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10)
+#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N   BIT(9)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST  (0x2  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND  BIT(4)
+#define

RE: [PATCH v7 3/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-05 Thread Kamil Debski
Hi Sander,

 From: Kamil Debski [mailto:k.deb...@samsung.com]
 Sent: Tuesday, March 04, 2014 4:24 PM
 
 Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the
 generic PHY framework. The driver includes support for the Exynos 4210
 and 4x12 SoC families.
 
 Signed-off-by: Kamil Debski k.deb...@samsung.com

Sander, you did test the v6 of this patch, thus I am adding your
Tested-by.
Could you confirm that this version works as well?

Tested-by: Sander Hollaar san...@humilis.net

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

 ---
  .../devicetree/bindings/phy/samsung-phy.txt|   53 
  Documentation/phy/samsung-usb2.txt |  134 
  drivers/phy/Kconfig|   29 ++
  drivers/phy/Makefile   |3 +
  drivers/phy/phy-exynos4210-usb2.c  |  262
 
  drivers/phy/phy-exynos4x12-usb2.c  |  330
 
  drivers/phy/phy-samsung-usb2.c |  223
 +
  drivers/phy/phy-samsung-usb2.h |   67 
  8 files changed, 1101 insertions(+)
  create mode 100644 Documentation/phy/samsung-usb2.txt
  create mode 100644 drivers/phy/phy-exynos4210-usb2.c  create mode
 100644 drivers/phy/phy-exynos4x12-usb2.c  create mode 100644
 drivers/phy/phy-samsung-usb2.c  create mode 100644 drivers/phy/phy-
 samsung-usb2.h
 
 diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt
 b/Documentation/devicetree/bindings/phy/samsung-phy.txt
 index c0fccaa..bf955ab 100644
 --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
 +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
 @@ -20,3 +20,56 @@ Required properties:
  - compatible : should be samsung,exynos5250-dp-video-phy;
  - reg : offset and length of the Display Port PHY register set;
  - #phy-cells : from the generic PHY bindings, must be 0;
 +
 +Samsung S5P/EXYNOS SoC series USB PHY
 +-
 +
 +Required properties:
 +- compatible : should be one of the listed compatibles:
 + - samsung,exynos4210-usb2-phy
 + - samsung,exynos4x12-usb2-phy
 +- reg : a list of registers used by phy driver
 + - first and obligatory is the location of phy modules registers
 +- samsung,sysreg-phandle - handle to syscon used to control the system
 +registers
 +- samsung,pmureg-phandle - handle to syscon used to control PMU
 +registers
 +- #phy-cells : from the generic phy bindings, must be 1;
 +- clocks and clock-names:
 + - the phy clock is required by the phy module, used as a gate
 + - the ref clock is used to get the rate of the clock provided
 to the
 +   PHY module
 +
 +The first phandle argument in the PHY specifier identifies the PHY,
 its
 +meaning is compatible dependent. For the currently supported SoCs
 +(Exynos 4210 and Exynos 4212) it is as follows:
 +  0 - USB device (device),
 +  1 - USB host (host),
 +  2 - HSIC0 (hsic0),
 +  3 - HSIC1 (hsic1),
 +
 +Exynos 4210 and Exynos 4212 use mode switching and require that mode
 +switch register is supplied.
 +
 +Example:
 +
 +For Exynos 4412 (compatible with Exynos 4212):
 +
 +usbphy: phy@125b {
 + compatible = samsung,exynos4x12-usb2-phy;
 + reg = 0x125b 0x100;
 + clocks = clock 305, clock 2;
 + clock-names = phy, ref;
 + status = okay;
 + #phy-cells = 1;
 + samsung,sysreg-phandle = sys_reg;
 + samsung,pmureg-phandle = pmu_reg;
 +};
 +
 +Then the PHY can be used in other nodes such as:
 +
 +phy-consumer@1234 {
 + phys = usbphy 2;
 + phy-names = phy;
 +};
 +
 +Refer to DT bindings documentation of particular PHY consumer devices
 +for more information about required PHYs and the way of specification.
 diff --git a/Documentation/phy/samsung-usb2.txt
 b/Documentation/phy/samsung-usb2.txt
 new file mode 100644
 index 000..0c8e260
 --- /dev/null
 +++ b/Documentation/phy/samsung-usb2.txt
 @@ -0,0 +1,134 @@
 +.-
 -
 ++
 +|Samsung USB 2.0 PHY adaptation layer
 |
 ++-
 +'
 +
 +| 1. Description
 ++
 +
 +The architecture of the USB 2.0 PHY module in Samsung SoCs is similar
 +among many SoCs. In spite of the similarities it proved difficult to
 +create a one driver that would fit all these PHY controllers. Often
 the
 +differences were minor and were found in particular bits of the
 +registers of the PHY. In some rare cases the order of register writes
 +or the PHY powering up process had to be altered. This adaptation
 layer
 +is a compromise between having separate drivers and having a single
 +driver with added support for many special cases.
 +
 +| 2. Files description
 ++--
 +
 +- phy-samsung-usb2.c
 +   This is the main file of the adaptation layer. This file contains
 +   the probe function

[PATCH v8 0/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-05 Thread Kamil Debski
Hi,

This is the eighth version of this patchset. First and most significant change
since v6 is that this patchset includes only patches touching the Generic PHY
Framework. Patches to the USB controllers were stripped as they require
additional work. S5PV210 support is also omitted - it requires more testing.

Since v7 this patch includes fixes for checkpath errors and was rebased onto
Kishon's next branch.

Best wishes,
Kamil Debski

--
Changes from v7:
1) phy: core: Add an exported of_phy_get function
   - No changes since v7.
2) phy: core: Add devm_of_phy_get to phy-core
   - No changes since v7.
3) phy: Add new Exynos USB 2.0 PHY driver
   - Fix checkpatch errors with code indentation and corrected whitespace.
4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
   - Fix checkpatch errors with code indentation and corrected whitespace.

--
Changes from v6: (not including the change that controller patches were removed
form this patchset, also this patchset excludes S5PV210 support - it needs more
testing)
1) phy: core: Add an exported of_phy_get function
   - No changes since v6.
2) phy: core: Add devm_of_phy_get to phy-core
   - No changes since v6.
3) phy: Add new Exynos USB 2.0 PHY driver
   - Changed the way clocks are supplied to the driver. Prior to version v7
 there were reference clocks for every phy instance, now a single ref
 clock was introduced.
   - Updated documentation to match the aforementioned change.
   - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content
 defines.
   - Corrected way clock register is modified. Instead of a simple write, a
 proper read, modify, write sequence was introduced.
   - Important stability fix - added udelay after PHY reset. This fixes a bug
 causing instability in USB LAN adapters. Without the delay the DMA burst
 mode was could not be enabled.
4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
   - Changed handling of clocks to use a single ref clock.


Changes from v5:
1) phy: core: Add an exported of_phy_get function
- corrected behaviour of the modification when GENERIC_PHY is not enabled
  by adding a stub of the of_phy_get function
2) phy: core: Add devm_of_phy_get to phy-core
- corrected behaviour of the modification when GENERIC_PHY is not enabled
  by adding a stub of the devm_of_phy_get function
3) dts: Add usb2phy to Exynos 4
- no change
4) dts: Add usb2phy to Exynos 5250
- in the previous version, this patch included some phy-exynos5250-usb2.c code
  by mistake, the code has been remove and added to the proper patch
5) phy: Add new Exynos USB PHY driver
- changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is
  actually a driver for the whole Exynos 4x12 family
- added documentation to the Exynos USB 2.0 PHY driver adaptaion layer
- corrected strings HSCI - HSIC
- fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did
  not work on its own
- mode switch support was added to Exynos 4x12 (same io pins are used by host
  and device)
- support for phy_set_bus_width introduced by Matt Porter was added
6) phy: Add support for S5PV210 to the Exynos USB PHY
- setting of clk register was fixed
7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
- supoprt was added for HSIC and device
8) usb: ehci-exynos: Change to use phy provided by the generic phy framework
- DT documentation was moved from usb-ehci.txt to exynos-usb.txt


Changes from v4:
1) phy: core: Add an exported of_phy_get function
- the new exported function of_phy_get was changed to take the phy's name as a
  parameter instead of the index
2) phy: core: Add devm_of_phy_get to phy-core
- fixes made in the comments to devm_of_phy_get
3) phy: Add new Exynos USB PHY driver
- move the documentation from a new to an existing file - samsung-phy.txt
- fix typos and uppercase hex addresses
- add more explanations to Kconfig (checkpatch still complains, but I find it
  hard to think what else could I add)
- add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!)
- cleanup included headers in both *.c and .h files
- use BIT(x) macro instead of (1  x)
- replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the
  registers are described as PHYx in the documentation hence the decision to
  leave the PHYx naming
- fixed typo in exynos4210_rate_to_clk reg - *reg
- change hax_mode_switch and enabled type to bool
4) usb: ehci-s5p: Change to use phy provided by the generic phy framework
- Put the issue of phy-otg in order - since the new phy driver does not provide
  this field. With the new driver the switch between host and device is done in
  power_on of the respective host and device phys.
5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy
   framework
- fixed the example in the documentation
6) phy: Add support for S5PV210 to the Exynos USB PHY driver
- include files cleanup
- use BIT(x) macro

[PATCH v8 2/4] phy: core: Add devm_of_phy_get to phy-core

2014-03-05 Thread Kamil Debski
Adding devm_of_phy_get will allow to get phys by supplying a
pointer to the struct device_node instead of struct device.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   31 +++
 include/linux/phy/phy.h |8 
 2 files changed, 39 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 7c1b0e1..623b71c 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, 
const char *string)
 EXPORT_SYMBOL_GPL(devm_phy_optional_get);
 
 /**
+ * devm_of_phy_get() - lookup and obtain a reference to a phy.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Gets the phy using of_phy_get(), and associates a device with it using
+ * devres. On driver detach, release function is invoked on the devres data,
+ * then, devres data is freed.
+ */
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   struct phy **ptr, *phy;
+
+   ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   phy = of_phy_get(np, con_id);
+   if (!IS_ERR(phy)) {
+   *ptr = phy;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_get);
+
+/**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
  * @ops: function pointers for performing phy operations
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 2fe3194..bcbf96c 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string);
 struct phy *phy_optional_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 struct phy *of_phy_get(struct device_node *np, const char *con_id);
@@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct 
device *dev,
return ERR_PTR(-ENOSYS);
 }
 
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline void phy_put(struct phy *phy)
 {
 }
-- 
1.7.9.5

--
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 v8 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver

2014-03-05 Thread Kamil Debski
Add support for Exynos 5250. This driver is to replace the old
USB 2.0 PHY driver.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|1 +
 drivers/phy/Kconfig|   11 +
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-exynos5250-usb2.c  |  405 
 drivers/phy/phy-samsung-usb2.c |6 +
 drivers/phy/phy-samsung-usb2.h |1 +
 6 files changed, 425 insertions(+)
 create mode 100644 drivers/phy/phy-exynos5250-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index bf955ab..28f9edb 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -28,6 +28,7 @@ Required properties:
 - compatible : should be one of the listed compatibles:
- samsung,exynos4210-usb2-phy
- samsung,exynos4x12-usb2-phy
+   - samsung,exynos5250-usb2-phy
 - reg : a list of registers used by phy driver
- first and obligatory is the location of phy modules registers
 - samsung,sysreg-phandle - handle to syscon used to control the system 
registers
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index fc5a44a..c206e25 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -125,4 +125,15 @@ config PHY_EXYNOS4X12_USB2
  Samsung USB 2.0 PHY driver is enabled and means that support for this
  particular SoC is compiled in the driver. In case of Exynos 4x12 four
  phys are available - device, host, HSIC0 and HSIC1.
+
+config PHY_EXYNOS5250_USB2
+   bool Support for Exynos 5250
+   depends on PHY_SAMSUNG_USB2
+   depends on SOC_EXYNOS5250
+   help
+ Enable USB PHY support for Exynos 5250. This option requires that
+ Samsung USB 2.0 PHY driver is enabled and means that support for this
+ particular SoC is compiled in the driver. In case of Exynos 5250 four
+ phys are available - device, host, HSIC0 and HSIC.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 0ea36ff..f76c239 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_PHY_SUN4I_USB)   += phy-sun4i-usb.o
 obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4210_USB2)  += phy-exynos4210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4X12_USB2)  += phy-exynos4x12-usb2.o
+obj-$(CONFIG_PHY_EXYNOS5250_USB2)  += phy-exynos5250-usb2.o
diff --git a/drivers/phy/phy-exynos5250-usb2.c 
b/drivers/phy/phy-exynos5250-usb2.c
new file mode 100644
index 000..877994e
--- /dev/null
+++ b/drivers/phy/phy-exynos5250-usb2.c
@@ -0,0 +1,405 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/phy/phy.h
+#include linux/regmap.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+#define EXYNOS_5250_REFCLKSEL_CRYSTAL  0x0
+#define EXYNOS_5250_REFCLKSEL_XO   0x1
+#define EXYNOS_5250_REFCLKSEL_CLKCORE  0x2
+
+#define EXYNOS_5250_FSEL_9MHZ6 0x0
+#define EXYNOS_5250_FSEL_10MHZ 0x1
+#define EXYNOS_5250_FSEL_12MHZ 0x2
+#define EXYNOS_5250_FSEL_19MHZ20x3
+#define EXYNOS_5250_FSEL_20MHZ 0x4
+#define EXYNOS_5250_FSEL_24MHZ 0x5
+#define EXYNOS_5250_FSEL_50MHZ 0x7
+
+/* Normal host */
+#define EXYNOS_5250_HOSTPHYCTRL0   0x0
+
+#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL   BIT(31)
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT   19
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\
+   (0x3  EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \
+   (0x7  EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11)
+#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10)
+#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N   BIT(9)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST  (0x2  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND  BIT(4)
+#define

[PATCH v8 1/4] phy: core: Add an exported of_phy_get function

2014-03-05 Thread Kamil Debski
Previously the of_phy_get function took a struct device * and
was declared static. It was impossible to call it from
another driver and thus it was impossible to get phy defined
for a given node. The old function was renamed to _of_phy_get
and was left for internal use. of_phy_get function was added
and it was exported. The function enables to get a phy for
a given device tree node.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   45 -
 include/linux/phy/phy.h |6 ++
 2 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 6c73837..7c1b0e1 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy)
 EXPORT_SYMBOL_GPL(phy_power_off);
 
 /**
- * of_phy_get() - lookup and obtain a reference to a phy by phandle
- * @dev: device that requests this phy
+ * _of_phy_get() - lookup and obtain a reference to a phy by phandle
+ * @np: device_node for which to get the phy
  * @index: the index of the phy
  *
  * Returns the phy associated with the given phandle value,
@@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
  * not yet loaded. This function uses of_xlate call back function provided
  * while registering the phy_provider to find the phy instance.
  */
-static struct phy *of_phy_get(struct device *dev, int index)
+static struct phy *_of_phy_get(struct device_node *np, int index)
 {
int ret;
struct phy_provider *phy_provider;
struct phy *phy = NULL;
struct of_phandle_args args;
 
-   ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells,
+   ret = of_parse_phandle_with_args(np, phys, #phy-cells,
index, args);
-   if (ret) {
-   dev_dbg(dev, failed to get phy in %s node\n,
-   dev-of_node-full_name);
+   if (ret)
return ERR_PTR(-ENODEV);
-   }
 
mutex_lock(phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np);
@@ -317,6 +314,36 @@ err0:
 }
 
 /**
+ * of_phy_get() - lookup and obtain a reference to a phy using a device_node.
+ * @np: device_node for which to get the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Returns the phy driver, after getting a refcount to it; or
+ * -ENODEV if there is no such phy. The caller is responsible for
+ * calling phy_put() to release that count.
+ */
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   struct phy *phy = NULL;
+   int index = 0;
+
+   if (con_id)
+   index = of_property_match_string(np, phy-names, con_id);
+
+   phy = _of_phy_get(np, index);
+   if (IS_ERR(phy))
+   return phy;
+
+   if (!try_module_get(phy-ops-owner))
+   return ERR_PTR(-EPROBE_DEFER);
+
+   get_device(phy-dev);
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(of_phy_get);
+
+/**
  * phy_put() - release the PHY
  * @phy: the phy returned by phy_get()
  *
@@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string)
if (dev-of_node) {
index = of_property_match_string(dev-of_node, phy-names,
string);
-   phy = of_phy_get(dev, index);
+   phy = _of_phy_get(dev-of_node, index);
} else {
phy = phy_lookup(dev, string);
}
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 3f83459..2fe3194 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char 
*string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
+struct phy *of_phy_get(struct device_node *np, const char *con_id);
 struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
 struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
@@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct 
phy *phy)
 {
 }
 
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args)
 {
-- 
1.7.9.5

--
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 v8 3/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-05 Thread Kamil Debski
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic
PHY framework. The driver includes support for the Exynos 4x10 and 4x12
SoC families.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|   53 
 Documentation/phy/samsung-usb2.txt |  134 
 drivers/phy/Kconfig|   29 ++
 drivers/phy/Makefile   |3 +
 drivers/phy/phy-exynos4210-usb2.c  |  262 
 drivers/phy/phy-exynos4x12-usb2.c  |  329 
 drivers/phy/phy-samsung-usb2.c |  223 +
 drivers/phy/phy-samsung-usb2.h |   67 
 8 files changed, 1100 insertions(+)
 create mode 100644 Documentation/phy/samsung-usb2.txt
 create mode 100644 drivers/phy/phy-exynos4210-usb2.c
 create mode 100644 drivers/phy/phy-exynos4x12-usb2.c
 create mode 100644 drivers/phy/phy-samsung-usb2.c
 create mode 100644 drivers/phy/phy-samsung-usb2.h

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index c0fccaa..bf955ab 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -20,3 +20,56 @@ Required properties:
 - compatible : should be samsung,exynos5250-dp-video-phy;
 - reg : offset and length of the Display Port PHY register set;
 - #phy-cells : from the generic PHY bindings, must be 0;
+
+Samsung S5P/EXYNOS SoC series USB PHY
+-
+
+Required properties:
+- compatible : should be one of the listed compatibles:
+   - samsung,exynos4210-usb2-phy
+   - samsung,exynos4x12-usb2-phy
+- reg : a list of registers used by phy driver
+   - first and obligatory is the location of phy modules registers
+- samsung,sysreg-phandle - handle to syscon used to control the system 
registers
+- samsung,pmureg-phandle - handle to syscon used to control PMU registers
+- #phy-cells : from the generic phy bindings, must be 1;
+- clocks and clock-names:
+   - the phy clock is required by the phy module, used as a gate
+   - the ref clock is used to get the rate of the clock provided to the
+ PHY module
+
+The first phandle argument in the PHY specifier identifies the PHY, its
+meaning is compatible dependent. For the currently supported SoCs (Exynos 4210
+and Exynos 4212) it is as follows:
+  0 - USB device (device),
+  1 - USB host (host),
+  2 - HSIC0 (hsic0),
+  3 - HSIC1 (hsic1),
+
+Exynos 4210 and Exynos 4212 use mode switching and require that mode switch
+register is supplied.
+
+Example:
+
+For Exynos 4412 (compatible with Exynos 4212):
+
+usbphy: phy@125b {
+   compatible = samsung,exynos4x12-usb2-phy;
+   reg = 0x125b 0x100;
+   clocks = clock 305, clock 2;
+   clock-names = phy, ref;
+   status = okay;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_reg;
+   samsung,pmureg-phandle = pmu_reg;
+};
+
+Then the PHY can be used in other nodes such as:
+
+phy-consumer@1234 {
+   phys = usbphy 2;
+   phy-names = phy;
+};
+
+Refer to DT bindings documentation of particular PHY consumer devices for more
+information about required PHYs and the way of specification.
diff --git a/Documentation/phy/samsung-usb2.txt 
b/Documentation/phy/samsung-usb2.txt
new file mode 100644
index 000..0c8e260
--- /dev/null
+++ b/Documentation/phy/samsung-usb2.txt
@@ -0,0 +1,134 @@
+.--+
+|  Samsung USB 2.0 PHY adaptation layer   |
++-+'
+
+| 1. Description
++
+
+The architecture of the USB 2.0 PHY module in Samsung SoCs is similar
+among many SoCs. In spite of the similarities it proved difficult to
+create a one driver that would fit all these PHY controllers. Often
+the differences were minor and were found in particular bits of the
+registers of the PHY. In some rare cases the order of register writes or
+the PHY powering up process had to be altered. This adaptation layer is
+a compromise between having separate drivers and having a single driver
+with added support for many special cases.
+
+| 2. Files description
++--
+
+- phy-samsung-usb2.c
+   This is the main file of the adaptation layer. This file contains
+   the probe function and provides two callbacks to the Generic PHY
+   Framework. This two callbacks are used to power on and power off the
+   phy. They carry out the common work that has to be done on all version
+   of the PHY module. Depending on which SoC was chosen they execute SoC
+   specific callbacks. The specific SoC version is selected by choosing
+   the appropriate compatible string. In addition, this file contains

[PATCH v9 1/4] phy: core: Add an exported of_phy_get function

2014-03-05 Thread Kamil Debski
Previously the of_phy_get function took a struct device * and
was declared static. It was impossible to call it from
another driver and thus it was impossible to get phy defined
for a given node. The old function was renamed to _of_phy_get
and was left for internal use. of_phy_get function was added
and it was exported. The function enables to get a phy for
a given device tree node.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   45 -
 include/linux/phy/phy.h |6 ++
 2 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 6c73837..7c1b0e1 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy)
 EXPORT_SYMBOL_GPL(phy_power_off);
 
 /**
- * of_phy_get() - lookup and obtain a reference to a phy by phandle
- * @dev: device that requests this phy
+ * _of_phy_get() - lookup and obtain a reference to a phy by phandle
+ * @np: device_node for which to get the phy
  * @index: the index of the phy
  *
  * Returns the phy associated with the given phandle value,
@@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
  * not yet loaded. This function uses of_xlate call back function provided
  * while registering the phy_provider to find the phy instance.
  */
-static struct phy *of_phy_get(struct device *dev, int index)
+static struct phy *_of_phy_get(struct device_node *np, int index)
 {
int ret;
struct phy_provider *phy_provider;
struct phy *phy = NULL;
struct of_phandle_args args;
 
-   ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells,
+   ret = of_parse_phandle_with_args(np, phys, #phy-cells,
index, args);
-   if (ret) {
-   dev_dbg(dev, failed to get phy in %s node\n,
-   dev-of_node-full_name);
+   if (ret)
return ERR_PTR(-ENODEV);
-   }
 
mutex_lock(phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np);
@@ -317,6 +314,36 @@ err0:
 }
 
 /**
+ * of_phy_get() - lookup and obtain a reference to a phy using a device_node.
+ * @np: device_node for which to get the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Returns the phy driver, after getting a refcount to it; or
+ * -ENODEV if there is no such phy. The caller is responsible for
+ * calling phy_put() to release that count.
+ */
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   struct phy *phy = NULL;
+   int index = 0;
+
+   if (con_id)
+   index = of_property_match_string(np, phy-names, con_id);
+
+   phy = _of_phy_get(np, index);
+   if (IS_ERR(phy))
+   return phy;
+
+   if (!try_module_get(phy-ops-owner))
+   return ERR_PTR(-EPROBE_DEFER);
+
+   get_device(phy-dev);
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(of_phy_get);
+
+/**
  * phy_put() - release the PHY
  * @phy: the phy returned by phy_get()
  *
@@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string)
if (dev-of_node) {
index = of_property_match_string(dev-of_node, phy-names,
string);
-   phy = of_phy_get(dev, index);
+   phy = _of_phy_get(dev-of_node, index);
} else {
phy = phy_lookup(dev, string);
}
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 3f83459..2fe3194 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char 
*string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
+struct phy *of_phy_get(struct device_node *np, const char *con_id);
 struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
 struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
@@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct 
phy *phy)
 {
 }
 
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args)
 {
-- 
1.7.9.5

--
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 v9 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver

2014-03-05 Thread Kamil Debski
Add support for Exynos 5250. This driver is to replace the old
USB 2.0 PHY driver.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|1 +
 drivers/phy/Kconfig|   11 +
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-exynos5250-usb2.c  |  404 
 drivers/phy/phy-samsung-usb2.c |6 +
 drivers/phy/phy-samsung-usb2.h |1 +
 6 files changed, 424 insertions(+)
 create mode 100644 drivers/phy/phy-exynos5250-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index bf955ab..28f9edb 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -28,6 +28,7 @@ Required properties:
 - compatible : should be one of the listed compatibles:
- samsung,exynos4210-usb2-phy
- samsung,exynos4x12-usb2-phy
+   - samsung,exynos5250-usb2-phy
 - reg : a list of registers used by phy driver
- first and obligatory is the location of phy modules registers
 - samsung,sysreg-phandle - handle to syscon used to control the system 
registers
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index fc5a44a..c206e25 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -125,4 +125,15 @@ config PHY_EXYNOS4X12_USB2
  Samsung USB 2.0 PHY driver is enabled and means that support for this
  particular SoC is compiled in the driver. In case of Exynos 4x12 four
  phys are available - device, host, HSIC0 and HSIC1.
+
+config PHY_EXYNOS5250_USB2
+   bool Support for Exynos 5250
+   depends on PHY_SAMSUNG_USB2
+   depends on SOC_EXYNOS5250
+   help
+ Enable USB PHY support for Exynos 5250. This option requires that
+ Samsung USB 2.0 PHY driver is enabled and means that support for this
+ particular SoC is compiled in the driver. In case of Exynos 5250 four
+ phys are available - device, host, HSIC0 and HSIC.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 0ea36ff..f76c239 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_PHY_SUN4I_USB)   += phy-sun4i-usb.o
 obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4210_USB2)  += phy-exynos4210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4X12_USB2)  += phy-exynos4x12-usb2.o
+obj-$(CONFIG_PHY_EXYNOS5250_USB2)  += phy-exynos5250-usb2.o
diff --git a/drivers/phy/phy-exynos5250-usb2.c 
b/drivers/phy/phy-exynos5250-usb2.c
new file mode 100644
index 000..94179af
--- /dev/null
+++ b/drivers/phy/phy-exynos5250-usb2.c
@@ -0,0 +1,404 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/phy/phy.h
+#include linux/regmap.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+#define EXYNOS_5250_REFCLKSEL_CRYSTAL  0x0
+#define EXYNOS_5250_REFCLKSEL_XO   0x1
+#define EXYNOS_5250_REFCLKSEL_CLKCORE  0x2
+
+#define EXYNOS_5250_FSEL_9MHZ6 0x0
+#define EXYNOS_5250_FSEL_10MHZ 0x1
+#define EXYNOS_5250_FSEL_12MHZ 0x2
+#define EXYNOS_5250_FSEL_19MHZ20x3
+#define EXYNOS_5250_FSEL_20MHZ 0x4
+#define EXYNOS_5250_FSEL_24MHZ 0x5
+#define EXYNOS_5250_FSEL_50MHZ 0x7
+
+/* Normal host */
+#define EXYNOS_5250_HOSTPHYCTRL0   0x0
+
+#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL   BIT(31)
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT   19
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\
+   (0x3  EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \
+   (0x7  EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11)
+#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10)
+#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N   BIT(9)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST  (0x2  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND  BIT(4)
+#define

[PATCH v9 0/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-05 Thread Kamil Debski
Hi,

This is the ninth version of this patchset. First and most significant change
since v6 is that this patchset includes only patches touching the Generic PHY
Framework. Patches to the USB controllers were stripped as they require
additional work. S5PV210 support is also omitted - it requires more testing.

Since v7 this patch includes fixes for checkpath errors and was rebased onto
Kishon's next branch. v9 brings whitespace corrections compared to v8.

Best wishes,
Kamil Debski

--
Changes from v8:
1) phy: core: Add an exported of_phy_get function
   - No changes since v8.
2) phy: core: Add devm_of_phy_get to phy-core
   - No changes since v8.
3) phy: Add new Exynos USB 2.0 PHY driver
   - Fix empty blank line at EOF errors
4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
   - Fix empty blank line at EOF error

--
Changes from v7:
1) phy: core: Add an exported of_phy_get function
   - No changes since v7.
2) phy: core: Add devm_of_phy_get to phy-core
   - No changes since v7.
3) phy: Add new Exynos USB 2.0 PHY driver
   - Fix checkpatch errors with code indentation and corrected whitespace.
4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
   - Fix checkpatch errors with code indentation and corrected whitespace.

--
Changes from v6: (not including the change that controller patches were removed
form this patchset, also this patchset excludes S5PV210 support - it needs more
testing)
1) phy: core: Add an exported of_phy_get function
   - No changes since v6.
2) phy: core: Add devm_of_phy_get to phy-core
   - No changes since v6.
3) phy: Add new Exynos USB 2.0 PHY driver
   - Changed the way clocks are supplied to the driver. Prior to version v7
 there were reference clocks for every phy instance, now a single ref
 clock was introduced.
   - Updated documentation to match the aforementioned change.
   - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content
 defines.
   - Corrected way clock register is modified. Instead of a simple write, a
 proper read, modify, write sequence was introduced.
   - Important stability fix - added udelay after PHY reset. This fixes a bug
 causing instability in USB LAN adapters. Without the delay the DMA burst
 mode was could not be enabled.
4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
   - Changed handling of clocks to use a single ref clock.


Changes from v5:
1) phy: core: Add an exported of_phy_get function
- corrected behaviour of the modification when GENERIC_PHY is not enabled
  by adding a stub of the of_phy_get function
2) phy: core: Add devm_of_phy_get to phy-core
- corrected behaviour of the modification when GENERIC_PHY is not enabled
  by adding a stub of the devm_of_phy_get function
3) dts: Add usb2phy to Exynos 4
- no change
4) dts: Add usb2phy to Exynos 5250
- in the previous version, this patch included some phy-exynos5250-usb2.c code
  by mistake, the code has been remove and added to the proper patch
5) phy: Add new Exynos USB PHY driver
- changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is
  actually a driver for the whole Exynos 4x12 family
- added documentation to the Exynos USB 2.0 PHY driver adaptaion layer
- corrected strings HSCI - HSIC
- fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did
  not work on its own
- mode switch support was added to Exynos 4x12 (same io pins are used by host
  and device)
- support for phy_set_bus_width introduced by Matt Porter was added
6) phy: Add support for S5PV210 to the Exynos USB PHY
- setting of clk register was fixed
7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
- supoprt was added for HSIC and device
8) usb: ehci-exynos: Change to use phy provided by the generic phy framework
- DT documentation was moved from usb-ehci.txt to exynos-usb.txt


Changes from v4:
1) phy: core: Add an exported of_phy_get function
- the new exported function of_phy_get was changed to take the phy's name as a
  parameter instead of the index
2) phy: core: Add devm_of_phy_get to phy-core
- fixes made in the comments to devm_of_phy_get
3) phy: Add new Exynos USB PHY driver
- move the documentation from a new to an existing file - samsung-phy.txt
- fix typos and uppercase hex addresses
- add more explanations to Kconfig (checkpatch still complains, but I find it
  hard to think what else could I add)
- add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!)
- cleanup included headers in both *.c and .h files
- use BIT(x) macro instead of (1  x)
- replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the
  registers are described as PHYx in the documentation hence the decision to
  leave the PHYx naming
- fixed typo in exynos4210_rate_to_clk reg - *reg
- change hax_mode_switch and enabled type to bool
4) usb: ehci-s5p: Change to use phy provided by the generic phy framework
- Put the issue of phy-otg in order

[PATCH v9 3/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-05 Thread Kamil Debski
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic
PHY framework. The driver includes support for the Exynos 4x10 and 4x12
SoC families.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|   53 
 Documentation/phy/samsung-usb2.txt |  134 
 drivers/phy/Kconfig|   29 ++
 drivers/phy/Makefile   |3 +
 drivers/phy/phy-exynos4210-usb2.c  |  261 
 drivers/phy/phy-exynos4x12-usb2.c  |  328 
 drivers/phy/phy-samsung-usb2.c |  222 +
 drivers/phy/phy-samsung-usb2.h |   66 
 8 files changed, 1096 insertions(+)
 create mode 100644 Documentation/phy/samsung-usb2.txt
 create mode 100644 drivers/phy/phy-exynos4210-usb2.c
 create mode 100644 drivers/phy/phy-exynos4x12-usb2.c
 create mode 100644 drivers/phy/phy-samsung-usb2.c
 create mode 100644 drivers/phy/phy-samsung-usb2.h

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index c0fccaa..bf955ab 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -20,3 +20,56 @@ Required properties:
 - compatible : should be samsung,exynos5250-dp-video-phy;
 - reg : offset and length of the Display Port PHY register set;
 - #phy-cells : from the generic PHY bindings, must be 0;
+
+Samsung S5P/EXYNOS SoC series USB PHY
+-
+
+Required properties:
+- compatible : should be one of the listed compatibles:
+   - samsung,exynos4210-usb2-phy
+   - samsung,exynos4x12-usb2-phy
+- reg : a list of registers used by phy driver
+   - first and obligatory is the location of phy modules registers
+- samsung,sysreg-phandle - handle to syscon used to control the system 
registers
+- samsung,pmureg-phandle - handle to syscon used to control PMU registers
+- #phy-cells : from the generic phy bindings, must be 1;
+- clocks and clock-names:
+   - the phy clock is required by the phy module, used as a gate
+   - the ref clock is used to get the rate of the clock provided to the
+ PHY module
+
+The first phandle argument in the PHY specifier identifies the PHY, its
+meaning is compatible dependent. For the currently supported SoCs (Exynos 4210
+and Exynos 4212) it is as follows:
+  0 - USB device (device),
+  1 - USB host (host),
+  2 - HSIC0 (hsic0),
+  3 - HSIC1 (hsic1),
+
+Exynos 4210 and Exynos 4212 use mode switching and require that mode switch
+register is supplied.
+
+Example:
+
+For Exynos 4412 (compatible with Exynos 4212):
+
+usbphy: phy@125b {
+   compatible = samsung,exynos4x12-usb2-phy;
+   reg = 0x125b 0x100;
+   clocks = clock 305, clock 2;
+   clock-names = phy, ref;
+   status = okay;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_reg;
+   samsung,pmureg-phandle = pmu_reg;
+};
+
+Then the PHY can be used in other nodes such as:
+
+phy-consumer@1234 {
+   phys = usbphy 2;
+   phy-names = phy;
+};
+
+Refer to DT bindings documentation of particular PHY consumer devices for more
+information about required PHYs and the way of specification.
diff --git a/Documentation/phy/samsung-usb2.txt 
b/Documentation/phy/samsung-usb2.txt
new file mode 100644
index 000..0c8e260
--- /dev/null
+++ b/Documentation/phy/samsung-usb2.txt
@@ -0,0 +1,134 @@
+.--+
+|  Samsung USB 2.0 PHY adaptation layer   |
++-+'
+
+| 1. Description
++
+
+The architecture of the USB 2.0 PHY module in Samsung SoCs is similar
+among many SoCs. In spite of the similarities it proved difficult to
+create a one driver that would fit all these PHY controllers. Often
+the differences were minor and were found in particular bits of the
+registers of the PHY. In some rare cases the order of register writes or
+the PHY powering up process had to be altered. This adaptation layer is
+a compromise between having separate drivers and having a single driver
+with added support for many special cases.
+
+| 2. Files description
++--
+
+- phy-samsung-usb2.c
+   This is the main file of the adaptation layer. This file contains
+   the probe function and provides two callbacks to the Generic PHY
+   Framework. This two callbacks are used to power on and power off the
+   phy. They carry out the common work that has to be done on all version
+   of the PHY module. Depending on which SoC was chosen they execute SoC
+   specific callbacks. The specific SoC version is selected by choosing
+   the appropriate compatible string. In addition, this file contains

[PATCH v9 2/4] phy: core: Add devm_of_phy_get to phy-core

2014-03-05 Thread Kamil Debski
Adding devm_of_phy_get will allow to get phys by supplying a
pointer to the struct device_node instead of struct device.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   31 +++
 include/linux/phy/phy.h |8 
 2 files changed, 39 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 7c1b0e1..623b71c 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, 
const char *string)
 EXPORT_SYMBOL_GPL(devm_phy_optional_get);
 
 /**
+ * devm_of_phy_get() - lookup and obtain a reference to a phy.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Gets the phy using of_phy_get(), and associates a device with it using
+ * devres. On driver detach, release function is invoked on the devres data,
+ * then, devres data is freed.
+ */
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   struct phy **ptr, *phy;
+
+   ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   phy = of_phy_get(np, con_id);
+   if (!IS_ERR(phy)) {
+   *ptr = phy;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_get);
+
+/**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
  * @ops: function pointers for performing phy operations
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 2fe3194..bcbf96c 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string);
 struct phy *phy_optional_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 struct phy *of_phy_get(struct device_node *np, const char *con_id);
@@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct 
device *dev,
return ERR_PTR(-ENOSYS);
 }
 
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline void phy_put(struct phy *phy)
 {
 }
-- 
1.7.9.5

--
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 v7 0/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-04 Thread Kamil Debski
Hi,

This is the seventh version of this patchset. First and most significant change
is that this patchset includes only patches touching the Generic PHY Framework.
Patches to the USB controllers were stripped as they require additional work.
S5PV210 support is also omitted - it requires more testing.

Thank you to everyone who joined the discussion, reviewed the patched and
contributed to making the code and consequently the Linux Kernel better.

Best wishes,
Kamil Debski

--
Changes from v6: (not including the change that controller patches were removed
form this patchset, also this patchset excludes S5PV210 support - it needs more
testing)
1) phy: core: Add an exported of_phy_get function
   - No changes since v6.
2) phy: core: Add devm_of_phy_get to phy-core
   - No changes since v6.
3) phy: Add new Exynos USB 2.0 PHY driver
   - Changed the way clocks are supplied to the driver. Prior to version v7
 there were reference clocks for every phy instance, now a single ref
 clock was introduced.
   - Updated documentation to match the aforementioned change.
   - Add offset EXYNOS_*_UPHYCLK_PHYFSEL_OFFSET to the clock register content
 defines.
   - Corrected way clock register is modified. Instead of a simple write, a
 proper read, modify, write sequence was introduced.
   - Important stability fix - added udelay after PHY reset. This fixes a bug
 causing instability in USB LAN adapters. Without the delay the DMA burst
 mode was could not be enabled.
4) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
   - Changed handling of clocks to use a single ref clock.


Changes from v5:
1) phy: core: Add an exported of_phy_get function
- corrected behaviour of the modification when GENERIC_PHY is not enabled
  by adding a stub of the of_phy_get function
2) phy: core: Add devm_of_phy_get to phy-core
- corrected behaviour of the modification when GENERIC_PHY is not enabled
  by adding a stub of the devm_of_phy_get function
3) dts: Add usb2phy to Exynos 4
- no change
4) dts: Add usb2phy to Exynos 5250
- in the previous version, this patch included some phy-exynos5250-usb2.c code
  by mistake, the code has been remove and added to the proper patch
5) phy: Add new Exynos USB PHY driver
- changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is
  actually a driver for the whole Exynos 4x12 family
- added documentation to the Exynos USB 2.0 PHY driver adaptaion layer
- corrected strings HSCI - HSIC
- fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did
  not work on its own
- mode switch support was added to Exynos 4x12 (same io pins are used by host
  and device)
- support for phy_set_bus_width introduced by Matt Porter was added
6) phy: Add support for S5PV210 to the Exynos USB PHY
- setting of clk register was fixed
7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
- supoprt was added for HSIC and device
8) usb: ehci-exynos: Change to use phy provided by the generic phy framework
- DT documentation was moved from usb-ehci.txt to exynos-usb.txt


Changes from v4:
1) phy: core: Add an exported of_phy_get function
- the new exported function of_phy_get was changed to take the phy's name as a
  parameter instead of the index
2) phy: core: Add devm_of_phy_get to phy-core
- fixes made in the comments to devm_of_phy_get
3) phy: Add new Exynos USB PHY driver
- move the documentation from a new to an existing file - samsung-phy.txt
- fix typos and uppercase hex addresses
- add more explanations to Kconfig (checkpatch still complains, but I find it
  hard to think what else could I add)
- add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!)
- cleanup included headers in both *.c and .h files
- use BIT(x) macro instead of (1  x)
- replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the
  registers are described as PHYx in the documentation hence the decision to
  leave the PHYx naming
- fixed typo in exynos4210_rate_to_clk reg - *reg
- change hax_mode_switch and enabled type to bool
4) usb: ehci-s5p: Change to use phy provided by the generic phy framework
- Put the issue of phy-otg in order - since the new phy driver does not provide
  this field. With the new driver the switch between host and device is done in
  power_on of the respective host and device phys.
5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy
   framework
- fixed the example in the documentation
6) phy: Add support for S5PV210 to the Exynos USB PHY driver
- include files cleanup
- use BIT(x) macro instead of (1  x)
7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
- include files cleanup
- use BIT(x) macro instead of (1  x)
8) dts: Add usb2phy to Exynos 4
- no changes
9) dts: Add usb2phy to Exynos 5250
- no changes


Changes from v3:
- using PMU and system registers indirectly via syscon
- change labelling
- change Kconfig name
- fixed typos/stray

[PATCH v7 1/4] phy: core: Add an exported of_phy_get function

2014-03-04 Thread Kamil Debski
Previously the of_phy_get function took a struct device * and
was declared static. It was impossible to call it from
another driver and thus it was impossible to get phy defined
for a given node. The old function was renamed to _of_phy_get
and was left for internal use. of_phy_get function was added
and it was exported. The function enables to get a phy for
a given device tree node.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   45 -
 include/linux/phy/phy.h |6 ++
 2 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 6c73837..7c1b0e1 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -274,8 +274,8 @@ int phy_power_off(struct phy *phy)
 EXPORT_SYMBOL_GPL(phy_power_off);
 
 /**
- * of_phy_get() - lookup and obtain a reference to a phy by phandle
- * @dev: device that requests this phy
+ * _of_phy_get() - lookup and obtain a reference to a phy by phandle
+ * @np: device_node for which to get the phy
  * @index: the index of the phy
  *
  * Returns the phy associated with the given phandle value,
@@ -284,20 +284,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
  * not yet loaded. This function uses of_xlate call back function provided
  * while registering the phy_provider to find the phy instance.
  */
-static struct phy *of_phy_get(struct device *dev, int index)
+static struct phy *_of_phy_get(struct device_node *np, int index)
 {
int ret;
struct phy_provider *phy_provider;
struct phy *phy = NULL;
struct of_phandle_args args;
 
-   ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells,
+   ret = of_parse_phandle_with_args(np, phys, #phy-cells,
index, args);
-   if (ret) {
-   dev_dbg(dev, failed to get phy in %s node\n,
-   dev-of_node-full_name);
+   if (ret)
return ERR_PTR(-ENODEV);
-   }
 
mutex_lock(phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np);
@@ -317,6 +314,36 @@ err0:
 }
 
 /**
+ * of_phy_get() - lookup and obtain a reference to a phy using a device_node.
+ * @np: device_node for which to get the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Returns the phy driver, after getting a refcount to it; or
+ * -ENODEV if there is no such phy. The caller is responsible for
+ * calling phy_put() to release that count.
+ */
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   struct phy *phy = NULL;
+   int index = 0;
+
+   if (con_id)
+   index = of_property_match_string(np, phy-names, con_id);
+
+   phy = _of_phy_get(np, index);
+   if (IS_ERR(phy))
+   return phy;
+
+   if (!try_module_get(phy-ops-owner))
+   return ERR_PTR(-EPROBE_DEFER);
+
+   get_device(phy-dev);
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(of_phy_get);
+
+/**
  * phy_put() - release the PHY
  * @phy: the phy returned by phy_get()
  *
@@ -407,7 +434,7 @@ struct phy *phy_get(struct device *dev, const char *string)
if (dev-of_node) {
index = of_property_match_string(dev-of_node, phy-names,
string);
-   phy = of_phy_get(dev, index);
+   phy = _of_phy_get(dev-of_node, index);
} else {
phy = phy_lookup(dev, string);
}
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 3f83459..2fe3194 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -151,6 +151,7 @@ struct phy *devm_phy_get(struct device *dev, const char 
*string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
+struct phy *of_phy_get(struct device_node *np, const char *con_id);
 struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
 struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
@@ -259,6 +260,11 @@ static inline void devm_phy_put(struct device *dev, struct 
phy *phy)
 {
 }
 
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args)
 {
-- 
1.7.9.5

--
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 v7 2/4] phy: core: Add devm_of_phy_get to phy-core

2014-03-04 Thread Kamil Debski
Adding devm_of_phy_get will allow to get phys by supplying a
pointer to the struct device_node instead of struct device.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   31 +++
 include/linux/phy/phy.h |8 
 2 files changed, 39 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 7c1b0e1..623b71c 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -526,6 +526,37 @@ struct phy *devm_phy_optional_get(struct device *dev, 
const char *string)
 EXPORT_SYMBOL_GPL(devm_phy_optional_get);
 
 /**
+ * devm_of_phy_get() - lookup and obtain a reference to a phy.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Gets the phy using of_phy_get(), and associates a device with it using
+ * devres. On driver detach, release function is invoked on the devres data,
+ * then, devres data is freed.
+ */
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   struct phy **ptr, *phy;
+
+   ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   phy = of_phy_get(np, con_id);
+   if (!IS_ERR(phy)) {
+   *ptr = phy;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_get);
+
+/**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
  * @ops: function pointers for performing phy operations
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 2fe3194..bcbf96c 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -149,6 +149,8 @@ struct phy *phy_get(struct device *dev, const char *string);
 struct phy *phy_optional_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_optional_get(struct device *dev, const char *string);
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 struct phy *of_phy_get(struct device_node *np, const char *con_id);
@@ -252,6 +254,12 @@ static inline struct phy *devm_phy_optional_get(struct 
device *dev,
return ERR_PTR(-ENOSYS);
 }
 
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline void phy_put(struct phy *phy)
 {
 }
-- 
1.7.9.5

--
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 v7 3/4] phy: Add new Exynos USB 2.0 PHY driver

2014-03-04 Thread Kamil Debski
Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the generic
PHY framework. The driver includes support for the Exynos 4210 and 4x12
SoC families.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|   53 
 Documentation/phy/samsung-usb2.txt |  134 
 drivers/phy/Kconfig|   29 ++
 drivers/phy/Makefile   |3 +
 drivers/phy/phy-exynos4210-usb2.c  |  262 
 drivers/phy/phy-exynos4x12-usb2.c  |  330 
 drivers/phy/phy-samsung-usb2.c |  223 +
 drivers/phy/phy-samsung-usb2.h |   67 
 8 files changed, 1101 insertions(+)
 create mode 100644 Documentation/phy/samsung-usb2.txt
 create mode 100644 drivers/phy/phy-exynos4210-usb2.c
 create mode 100644 drivers/phy/phy-exynos4x12-usb2.c
 create mode 100644 drivers/phy/phy-samsung-usb2.c
 create mode 100644 drivers/phy/phy-samsung-usb2.h

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index c0fccaa..bf955ab 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -20,3 +20,56 @@ Required properties:
 - compatible : should be samsung,exynos5250-dp-video-phy;
 - reg : offset and length of the Display Port PHY register set;
 - #phy-cells : from the generic PHY bindings, must be 0;
+
+Samsung S5P/EXYNOS SoC series USB PHY
+-
+
+Required properties:
+- compatible : should be one of the listed compatibles:
+   - samsung,exynos4210-usb2-phy
+   - samsung,exynos4x12-usb2-phy
+- reg : a list of registers used by phy driver
+   - first and obligatory is the location of phy modules registers
+- samsung,sysreg-phandle - handle to syscon used to control the system 
registers
+- samsung,pmureg-phandle - handle to syscon used to control PMU registers
+- #phy-cells : from the generic phy bindings, must be 1;
+- clocks and clock-names:
+   - the phy clock is required by the phy module, used as a gate
+   - the ref clock is used to get the rate of the clock provided to the
+ PHY module
+
+The first phandle argument in the PHY specifier identifies the PHY, its
+meaning is compatible dependent. For the currently supported SoCs (Exynos 4210
+and Exynos 4212) it is as follows:
+  0 - USB device (device),
+  1 - USB host (host),
+  2 - HSIC0 (hsic0),
+  3 - HSIC1 (hsic1),
+
+Exynos 4210 and Exynos 4212 use mode switching and require that mode switch
+register is supplied.
+
+Example:
+
+For Exynos 4412 (compatible with Exynos 4212):
+
+usbphy: phy@125b {
+   compatible = samsung,exynos4x12-usb2-phy;
+   reg = 0x125b 0x100;
+   clocks = clock 305, clock 2;
+   clock-names = phy, ref;
+   status = okay;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_reg;
+   samsung,pmureg-phandle = pmu_reg;
+};
+
+Then the PHY can be used in other nodes such as:
+
+phy-consumer@1234 {
+   phys = usbphy 2;
+   phy-names = phy;
+};
+
+Refer to DT bindings documentation of particular PHY consumer devices for more
+information about required PHYs and the way of specification.
diff --git a/Documentation/phy/samsung-usb2.txt 
b/Documentation/phy/samsung-usb2.txt
new file mode 100644
index 000..0c8e260
--- /dev/null
+++ b/Documentation/phy/samsung-usb2.txt
@@ -0,0 +1,134 @@
+.--+
+|  Samsung USB 2.0 PHY adaptation layer   |
++-+'
+
+| 1. Description
++
+
+The architecture of the USB 2.0 PHY module in Samsung SoCs is similar
+among many SoCs. In spite of the similarities it proved difficult to
+create a one driver that would fit all these PHY controllers. Often
+the differences were minor and were found in particular bits of the
+registers of the PHY. In some rare cases the order of register writes or
+the PHY powering up process had to be altered. This adaptation layer is
+a compromise between having separate drivers and having a single driver
+with added support for many special cases.
+
+| 2. Files description
++--
+
+- phy-samsung-usb2.c
+   This is the main file of the adaptation layer. This file contains
+   the probe function and provides two callbacks to the Generic PHY
+   Framework. This two callbacks are used to power on and power off the
+   phy. They carry out the common work that has to be done on all version
+   of the PHY module. Depending on which SoC was chosen they execute SoC
+   specific callbacks. The specific SoC version is selected by choosing
+   the appropriate compatible string. In addition, this file contains

[PATCH v7 4/4] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver

2014-03-04 Thread Kamil Debski
Add support for Exynos 5250. This driver is to replace the old
USB 2.0 PHY driver.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|1 +
 drivers/phy/Kconfig|   11 +
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-exynos5250-usb2.c  |  405 
 drivers/phy/phy-samsung-usb2.c |6 +
 drivers/phy/phy-samsung-usb2.h |1 +
 6 files changed, 425 insertions(+)
 create mode 100644 drivers/phy/phy-exynos5250-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index bf955ab..28f9edb 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -28,6 +28,7 @@ Required properties:
 - compatible : should be one of the listed compatibles:
- samsung,exynos4210-usb2-phy
- samsung,exynos4x12-usb2-phy
+   - samsung,exynos5250-usb2-phy
 - reg : a list of registers used by phy driver
- first and obligatory is the location of phy modules registers
 - samsung,sysreg-phandle - handle to syscon used to control the system 
registers
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 1890351..fe2663c 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -94,4 +94,15 @@ config PHY_EXYNOS4X12_USB2
  Samsung USB 2.0 PHY driver is enabled and means that support for this
  particular SoC is compiled in the driver. In case of Exynos 4x12 four
  phys are available - device, host, HSIC0 and HSIC1.
+
+config PHY_EXYNOS5250_USB2
+   bool Support for Exynos 5250
+   depends on PHY_SAMSUNG_USB2
+   depends on SOC_EXYNOS5250
+   help
+ Enable USB PHY support for Exynos 5250. This option requires that
+ Samsung USB 2.0 PHY driver is enabled and means that support for this
+ particular SoC is compiled in the driver. In case of Exynos 5250 four
+ phys are available - device, host, HSIC0 and HSIC.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 69d0b3f2..4dcd389 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o
 obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4210_USB2)  += phy-exynos4210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4X12_USB2)  += phy-exynos4x12-usb2.o
+obj-$(CONFIG_PHY_EXYNOS5250_USB2)  += phy-exynos5250-usb2.o
diff --git a/drivers/phy/phy-exynos5250-usb2.c 
b/drivers/phy/phy-exynos5250-usb2.c
new file mode 100644
index 000..1ba0bb30
--- /dev/null
+++ b/drivers/phy/phy-exynos5250-usb2.c
@@ -0,0 +1,405 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/phy/phy.h
+#include linux/regmap.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+#define EXYNOS_5250_REFCLKSEL_CRYSTAL  0x0
+#define EXYNOS_5250_REFCLKSEL_XO   0x1
+#define EXYNOS_5250_REFCLKSEL_CLKCORE  0x2
+
+#define EXYNOS_5250_FSEL_9MHZ6 0x0
+#define EXYNOS_5250_FSEL_10MHZ 0x1
+#define EXYNOS_5250_FSEL_12MHZ 0x2
+#define EXYNOS_5250_FSEL_19MHZ20x3
+#define EXYNOS_5250_FSEL_20MHZ 0x4
+#define EXYNOS_5250_FSEL_24MHZ 0x5
+#define EXYNOS_5250_FSEL_50MHZ 0x7
+
+/* Normal host */
+#define EXYNOS_5250_HOSTPHYCTRL0   0x0
+
+#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL   BIT(31)
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT   19
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\
+   (0x3  EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \
+   (0x7  EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11)
+#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10)
+#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N   BIT(9)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST  (0x2  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND  BIT(4)
+#define

RE: [PATCH v6 5/8] phy: Add new Exynos USB PHY driver

2014-03-03 Thread Kamil Debski
Hi Kishon,

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Monday, March 03, 2014 3:28 PM
 
 Hi,
 
 On Wednesday 29 January 2014 10:59 PM, Kamil Debski wrote:
  Add a new driver for the Exynos USB PHY. The new driver uses the
  generic PHY framework. The driver includes support for the Exynos
 4x10
  and 4x12 SoC families.
 
 Can the PHY part of this series be merged independently of the
 controller part?

I see no problems with merging the PHY part independently. However,
I would like to post an updated version of these patches. I am working
on them now and should send them tomorrow.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  ---
.../devicetree/bindings/phy/samsung-phy.txt|   55 
Documentation/phy/samsung-usb2.txt |  135 
drivers/phy/Kconfig|   29 ++
drivers/phy/Makefile   |3 +
drivers/phy/phy-exynos4210-usb2.c  |  257
 
drivers/phy/phy-exynos4x12-usb2.c  |  323
 
drivers/phy/phy-samsung-usb2.c |  227
 ++
drivers/phy/phy-samsung-usb2.h |   67 
8 files changed, 1096 insertions(+)
create mode 100644 Documentation/phy/samsung-usb2.txt
create mode 100644 drivers/phy/phy-exynos4210-usb2.c
create mode 100644 drivers/phy/phy-exynos4x12-usb2.c
create mode 100644 drivers/phy/phy-samsung-usb2.c
create mode 100644 drivers/phy/phy-samsung-usb2.h
 
  diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt
  b/Documentation/devicetree/bindings/phy/samsung-phy.txt
  index c0fccaa..6668c41 100644
  --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
  +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
  @@ -20,3 +20,58 @@ Required properties:
- compatible : should be samsung,exynos5250-dp-video-phy;
- reg : offset and length of the Display Port PHY register set;
- #phy-cells : from the generic PHY bindings, must be 0;
  +
  +Samsung S5P/EXYNOS SoC series USB PHY
  +-
  +
  +Required properties:
  +- compatible : should be one of the listed compatibles:
  +   - samsung,exynos4210-usb2-phy
  +   - samsung,exynos4x12-usb2-phy
  +- reg : a list of registers used by phy driver
  +   - first and obligatory is the location of phy modules registers
  +- samsung,sysreg-phandle - handle to syscon used to control the
  +system registers
  +- samsung,pmureg-phandle - handle to syscon used to control PMU
  +registers
  +- #phy-cells : from the generic phy bindings, must be 1;
  +- clocks and clock-names:
  +   - the phy clocks is required by the phy module
  +   - next for each of the phys a clock has to be assigned, this
 clock
  + will be used to determine clocking frequency for the phys
  + (the labels are specified in the paragraph below)
  +
  +The first phandle argument in the PHY specifier identifies the PHY,
  +its meaning is compatible dependent. For the currently supported
 SoCs
  +(Exynos 4210 and Exynos 4212) it is as follows:
  +  0 - USB device (device),
  +  1 - USB host (host),
  +  2 - HSIC0 (hsic0),
  +  3 - HSIC1 (hsic1),
  +
  +Exynos 4210 and Exynos 4212 use mode switching and require that mode
  +switch register is supplied.
  +
  +Example:
  +
  +For Exynos 4412 (compatible with Exynos 4212):
  +
  +usbphy: phy@125b {
  +   compatible = samsung,exynos4212-usb2-phy;
  +   reg = 0x125b 0x100 0x10020704 0x0c 0x1001021c 0x4;
  +   clocks = clock 305, clock 2, clock 2, clock 2,
  +   clock 2;
  +   clock-names = phy, device, host, hsic0, hsic1;
  +   status = okay;
  +   #phy-cells = 1;
  +   samsung,sysreg-phandle = sys_reg;
  +   samsung,pmureg-phandle = pmu_reg; };
  +
  +Then the PHY can be used in other nodes such as:
  +
  +phy-consumer@1234 {
  +   phys = usbphy 2;
  +   phy-names = phy;
  +};
  +
  +Refer to DT bindings documentation of particular PHY consumer
 devices
  +for more information about required PHYs and the way of
 specification.
  diff --git a/Documentation/phy/samsung-usb2.txt
  b/Documentation/phy/samsung-usb2.txt
  new file mode 100644
  index 000..9f5826e
  --- /dev/null
  +++ b/Documentation/phy/samsung-usb2.txt
  @@ -0,0 +1,135 @@
  +.---
 -
  +--+
  +|  Samsung USB 2.0 PHY adaptation layer
 |
  ++---
 --+'
  +
  +| 1. Description
  ++
  +
  +The architecture of the USB 2.0 PHY module in Samsung SoCs is
 similar
  +among many SoCs. In spite of the similarities it proved difficult to
  +create a one driver that would fit all these PHY controllers. Often
  +the differences were minor and were found

RE: [PATCH v6 8/8] usb: ehci-exynos: Change to use phy provided by the generic phy framework

2014-02-05 Thread Kamil Debski
Hi Olof,

Thank you for your review.

 From: Olof Johansson [mailto:o...@lixom.net]
 Sent: Wednesday, January 29, 2014 9:55 PM
 
 Hi,
 
 On Wed, Jan 29, 2014 at 9:29 AM, Kamil Debski k.deb...@samsung.com
 wrote:
  Change the phy provider used from the old one using the USB phy
  framework to a new one using the Generic phy framework.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  ---
   .../devicetree/bindings/usb/exynos-usb.txt |   13 +++
   drivers/usb/host/ehci-exynos.c |   97
 +---
   2 files changed, 76 insertions(+), 34 deletions(-)
 
  diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt
  b/Documentation/devicetree/bindings/usb/exynos-usb.txt
  index d967ba1..25e199a 100644
  --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt
  +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt
  @@ -12,6 +12,10 @@ Required properties:
- interrupts: interrupt number to the cpu.
- clocks: from common clock binding: handle to usb clock.
- clock-names: from common clock binding: Shall be usbhost.
  +  - port: if in the SoC there are EHCI phys, they should be listed
 here.
  +One phy per port. Each port should have its reg entry with a
  +consecutive number. Also it should contain phys and phy-names
 entries
  +specifying the phy used by the port.
 
   Optional properties:
- samsung,vbus-gpio:  if present, specifies the GPIO that @@ -27,6
  +31,15 @@ Example:
 
  clocks = clock 285;
  clock-names = usbhost;
  +
  +   #address-cells = 1;
  +   #size-cells = 0;
  +   port@0 {
  +   reg = 0;
  +   phys = usb2phy 1;
  +   phy-names = host;
  +   status = disabled;
  +   };
  };
 
   OHCI
 
 [...]
 
  @@ -102,14 +132,26 @@ static int exynos_ehci_probe(struct
 platform_device *pdev)
  samsung,exynos5440-ehci))
  goto skip_phy;
 
  -   phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2);
  -   if (IS_ERR(phy)) {
  -   usb_put_hcd(hcd);
  -   dev_warn(pdev-dev, no platform data or transceiver
 defined\n);
  -   return -EPROBE_DEFER;
  -   } else {
  -   exynos_ehci-phy = phy;
  -   exynos_ehci-otg = phy-otg;
  +   for_each_available_child_of_node(pdev-dev.of_node, child) {
  +   err = of_property_read_u32(child, reg,
 phy_number);
  +   if (err) {
  +   dev_err(pdev-dev, Failed to parse device
 tree\n);
  +   of_node_put(child);
  +   return err;
  +   }
  +   if (phy_number = PHY_NUMBER) {
  +   dev_err(pdev-dev, Failed to parse device
 tree - number out of range\n);
  +   of_node_put(child);
  +   return -EINVAL;
  +   }
  +   phy = devm_of_phy_get(pdev-dev, child, 0);
  +   of_node_put(child);
  +   if (IS_ERR(phy)) {
  +   dev_err(pdev-dev, Failed to get phy number
 %d,
  +
 phy_number);
  +   return PTR_ERR(phy);
  +   }
  +   exynos_ehci-phy[phy_number] = phy;
 
 this looks like it is now breaking older device trees, where ports
 might not be described. Since device tree interfaces need to be
 backwards compatible, you still need to handle the old case of not
 having ports described.
 
 There are two ways of doing this:
 
 1. Fall back to the old behavior if there are no ports 2. Use a new
 compatible value for the new model with port subnodes, and if the old
 compatible value is used, then fall back to the old behavior.
 
 I'm guessing (1) might be easiest since you can check for the presence
 of #address-cells to tell if this is just an old style node, or if it's
 a new-style node without any ports below it.

The ultimate goal is to remove the old phy driver. Unfortunately
this has to be synced with the new USB3 phy driver by Vivek Gautam. I think
he
is also close to completion. What about this case? In the end the old driver
will be removed and no longer be supported. Having backward compatibility in
mind, it is possible to have the old and the new phy driver together in one
kernel release. But do we want to have two drivers doing the same thing at
the same time?

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


--
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 v6 8/8] usb: ehci-exynos: Change to use phy provided by the generic phy framework

2014-02-05 Thread Kamil Debski
Hi Alan,

Thank you for your review.

 From: Alan Stern [mailto:st...@rowland.harvard.edu]
 Sent: Wednesday, January 29, 2014 9:43 PM
 
 On Wed, 29 Jan 2014, Kamil Debski wrote:
 
  Change the phy provider used from the old one using the USB phy
  framework to a new one using the Generic phy framework.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  ---
   .../devicetree/bindings/usb/exynos-usb.txt |   13 +++
   drivers/usb/host/ehci-exynos.c |   97
 +---
   2 files changed, 76 insertions(+), 34 deletions(-)
 
  diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt
  b/Documentation/devicetree/bindings/usb/exynos-usb.txt
  index d967ba1..25e199a 100644
  --- a/Documentation/devicetree/bindings/usb/exynos-usb.txt
  +++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt
  @@ -12,6 +12,10 @@ Required properties:
- interrupts: interrupt number to the cpu.
- clocks: from common clock binding: handle to usb clock.
- clock-names: from common clock binding: Shall be usbhost.
  +  - port: if in the SoC there are EHCI phys, they should be listed
 here.
  +One phy per port. Each port should have its reg entry with a
  +consecutive number. Also it should contain phys and phy-names
 entries
  +specifying the phy used by the port.
 
 What is the reg entry number used for?  As far as I can see, it isn't
 used for anything.  In which case, why have it at all?

Tomasz Figa already commented this. I agree with him, that this should
be better described in the documentation.

 
  @@ -42,10 +42,10 @@
   static const char hcd_name[] = ehci-exynos;  static struct
  hc_driver __read_mostly exynos_ehci_hc_driver;
 
  +#define PHY_NUMBER 3
   struct exynos_ehci_hcd {
  struct clk *clk;
  -   struct usb_phy *phy;
  -   struct usb_otg *otg;
 
 You have removed all the OTG stuff from the driver.  This wasn't
 mentioned in the patch description, and it has no connection with the
 PHY work.

Maybe I'll explain more about what are we trying to achieve. The goal
is to replace the old phy driver with the new one. In the old driver it was
difficult to add support to new SoC. It also had issues with having device
and
host working together.

You're right that until the old phy driver is removed support for the it
should
remain. To be able to remove the old driver both new USB2 and new USB3 phy
drivers
have to be ready. The USB3 driver is written by Vivek Gautam and as I see
it, he
is also close to completion.

Regarding the otg part. The old phy driver is the only provider of the otg
structure. It sets the host field of the structure. It is then used by
samsung_usb2phy_init (drivers/usb/phy/phy-samsung-usb2.c) to check which
driver is requesting the phy (is it host or device). In the new driver this
is determined by the entry in device tree. So no need to check the otg
struct
and strstr (!) to check if dev_name is ehci, ohci or other, like the old
driver.

  +   struct phy *phy[PHY_NUMBER];
   };
 
   #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd
  *)(hcd_to_ehci(hcd)-priv) @@ -69,13 +69,43 @@ static void
 exynos_setup_vbus_gpio(struct platform_device *pdev)
  dev_err(dev, can't request ehci vbus gpio %d, gpio);  }
 
  +static int exynos_phys_on(struct phy *p[]) {
  +   int i;
  +   int ret = 0;
  +
  +   for (i = 0; ret == 0  i  PHY_NUMBER; i++)
  +   if (p[i])
  +   ret = phy_power_on(p[i]);
  +   if (ret)
  +   for (i--; i  0; i--)
  +   if (p[i])
  +   phy_power_off(p[i]);
 
 This loop runs while i  0.  Therefore you will never turn off the
 power to p[0].

Ups, my bad. Thank you for spotting this.

 
  @@ -102,14 +132,26 @@ static int exynos_ehci_probe(struct
 platform_device *pdev)
  samsung,exynos5440-ehci))
  goto skip_phy;
 
  -   phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2);
  -   if (IS_ERR(phy)) {
  -   usb_put_hcd(hcd);
 
 You omitted this line from the new error returns below.

I see.

 
  -   dev_warn(pdev-dev, no platform data or transceiver
 defined\n);
  -   return -EPROBE_DEFER;
  -   } else {
  -   exynos_ehci-phy = phy;
  -   exynos_ehci-otg = phy-otg;
  +   for_each_available_child_of_node(pdev-dev.of_node, child) {
  +   err = of_property_read_u32(child, reg, phy_number);
  +   if (err) {
  +   dev_err(pdev-dev, Failed to parse device
tree\n);
  +   of_node_put(child);
  +   return err;
 
 Here, for example.  Wouldn't it be better to goto fail_clk?

Right, I will fix this. Thank you.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

--
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 v6 3/8] dts: Add usb2phy to Exynos 4

2014-02-05 Thread Kamil Debski
Hi Olof,

 From: Olof Johansson [mailto:o...@lixom.net]
 Sent: Wednesday, January 29, 2014 9:51 PM
 
 On Wed, Jan 29, 2014 at 9:29 AM, Kamil Debski k.deb...@samsung.com
 wrote:
  Add support to PHY of USB2 of the Exynos 4 SoC.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  ---
   .../devicetree/bindings/arm/samsung/pmu.txt|2 ++
   arch/arm/boot/dts/exynos4.dtsi |   31
 
   arch/arm/boot/dts/exynos4210.dtsi  |   17
 +++
   arch/arm/boot/dts/exynos4x12.dtsi  |   17
 +++
   4 files changed, 67 insertions(+)
 
  diff --git a/Documentation/devicetree/bindings/arm/samsung/pmu.txt
  b/Documentation/devicetree/bindings/arm/samsung/pmu.txt
  index 307e727..a76f91d 100644
  --- a/Documentation/devicetree/bindings/arm/samsung/pmu.txt
  +++ b/Documentation/devicetree/bindings/arm/samsung/pmu.txt
  @@ -3,6 +3,8 @@ SAMSUNG Exynos SoC series PMU Registers
   Properties:
- name : should be 'syscon';
- compatible : should contain two values. First value must be one
 from following list:
  +  - samsung,exynos4210-pmu - for Exynos4210 SoC,
  +  - samsung,exynos4x12-pmu - for Exynos4212 SoC,
 - samsung,exynos5250-pmu - for Exynos5250 SoC,
 - samsung,exynos5420-pmu - for Exynos5420 SoC.
  second value must be always syscon.
 
 This and other PMU related bindings/dts changes should probably go in
 separate patch(es) instead of being snuck in with USB changes.

O, I will move this to a separate patch.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

--
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 v6 1/8] phy: core: Add an exported of_phy_get function

2014-01-29 Thread Kamil Debski
Previously the of_phy_get function took a struct device * and
was declared static. It was impossible to call it from
another driver and thus it was impossible to get phy defined
for a given node. The old function was renamed to _of_phy_get
and was left for internal use. of_phy_get function was added
and it was exported. The function enables to get a phy for
a given device tree node.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   45 -
 include/linux/phy/phy.h |6 ++
 2 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 645c867..a1d4387 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -258,8 +258,8 @@ int phy_power_off(struct phy *phy)
 EXPORT_SYMBOL_GPL(phy_power_off);
 
 /**
- * of_phy_get() - lookup and obtain a reference to a phy by phandle
- * @dev: device that requests this phy
+ * _of_phy_get() - lookup and obtain a reference to a phy by phandle
+ * @np: device_node for which to get the phy
  * @index: the index of the phy
  *
  * Returns the phy associated with the given phandle value,
@@ -268,20 +268,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
  * not yet loaded. This function uses of_xlate call back function provided
  * while registering the phy_provider to find the phy instance.
  */
-static struct phy *of_phy_get(struct device *dev, int index)
+static struct phy *_of_phy_get(struct device_node *np, int index)
 {
int ret;
struct phy_provider *phy_provider;
struct phy *phy = NULL;
struct of_phandle_args args;
 
-   ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells,
+   ret = of_parse_phandle_with_args(np, phys, #phy-cells,
index, args);
-   if (ret) {
-   dev_dbg(dev, failed to get phy in %s node\n,
-   dev-of_node-full_name);
+   if (ret)
return ERR_PTR(-ENODEV);
-   }
 
mutex_lock(phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np);
@@ -301,6 +298,36 @@ err0:
 }
 
 /**
+ * of_phy_get() - lookup and obtain a reference to a phy using a device_node.
+ * @np: device_node for which to get the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Returns the phy driver, after getting a refcount to it; or
+ * -ENODEV if there is no such phy. The caller is responsible for
+ * calling phy_put() to release that count.
+ */
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   struct phy *phy = NULL;
+   int index = 0;
+
+   if (con_id)
+   index = of_property_match_string(np, phy-names, con_id);
+
+   phy = _of_phy_get(np, index);
+   if (IS_ERR(phy))
+   return phy;
+
+   if (!try_module_get(phy-ops-owner))
+   return ERR_PTR(-EPROBE_DEFER);
+
+   get_device(phy-dev);
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(of_phy_get);
+
+/**
  * phy_put() - release the PHY
  * @phy: the phy returned by phy_get()
  *
@@ -388,7 +415,7 @@ struct phy *phy_get(struct device *dev, const char *string)
if (dev-of_node) {
index = of_property_match_string(dev-of_node, phy-names,
string);
-   phy = of_phy_get(dev, index);
+   phy = _of_phy_get(dev-of_node, index);
if (IS_ERR(phy)) {
dev_err(dev, unable to find phy\n);
return phy;
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index e273e5a..5cffc69 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -149,6 +149,7 @@ struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
+struct phy *of_phy_get(struct device_node *np, const char *con_id);
 struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
 struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
@@ -245,6 +246,11 @@ static inline void devm_phy_put(struct device *dev, struct 
phy *phy)
 {
 }
 
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args)
 {
-- 
1.7.9.5

--
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 v6 6/8] phy: Add support for S5PV210 to the Exynos USB PHY driver

2014-01-29 Thread Kamil Debski
From: Mateusz Krawczuk mat.krawc...@gmail.com

Add support for the Samsung's S5PV210 SoC to the Exynos USB PHY driver.

Signed-off-by: Mateusz Krawczuk m.krawc...@partner.samsung.com
[k.deb...@samsung.com: cleanup and commit description]
[k.deb...@samsung.com: make changes accordingly to the mailing list
comments]
[k.deb...@samsung.com: fix bug with setting of clk register]
Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|1 +
 drivers/phy/Kconfig|   10 +
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-s5pv210-usb2.c |  199 
 drivers/phy/phy-samsung-usb2.c |6 +
 drivers/phy/phy-samsung-usb2.h |1 +
 6 files changed, 218 insertions(+)
 create mode 100644 drivers/phy/phy-s5pv210-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index 6668c41..710d41f 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -26,6 +26,7 @@ Samsung S5P/EXYNOS SoC series USB PHY
 
 Required properties:
 - compatible : should be one of the listed compatibles:
+   - samsung,s5pv210-usb2-phy
- samsung,exynos4210-usb2-phy
- samsung,exynos4x12-usb2-phy
 - reg : a list of registers used by phy driver
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 3691d24..a5554b5 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -73,6 +73,16 @@ config PHY_SAMSUNG_USB2
  particular SoCs has to be enabled in addition to this driver. Number
  and type of supported phys depends on the SoC.
 
+config PHY_S5PV210_USB2
+   bool Support for S5PV210
+   depends on PHY_SAMSUNG_USB2
+   depends on ARCH_S5PV210
+   help
+ Enable USB PHY support for S5PV210. This option requires that Samsung
+ USB 2.0 PHY driver is enabled and means that support for this
+ particular SoC is compiled in the driver. In case of S5PV210 two phys
+ are available - device and host.
+
 config PHY_EXYNOS4210_USB2
bool Support for Exynos 4210
depends on PHY_SAMSUNG_USB2
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 69d0b3f2..d738f65 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -10,5 +10,6 @@ obj-$(CONFIG_PHY_MVEBU_SATA)  += phy-mvebu-sata.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
 obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
 obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o
+obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4210_USB2)  += phy-exynos4210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4X12_USB2)  += phy-exynos4x12-usb2.o
diff --git a/drivers/phy/phy-s5pv210-usb2.c b/drivers/phy/phy-s5pv210-usb2.c
new file mode 100644
index 000..08e5094
--- /dev/null
+++ b/drivers/phy/phy-s5pv210-usb2.c
@@ -0,0 +1,199 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - S5PV210 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Authors: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/phy/phy.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+
+/* PHY power control */
+#define S5PV210_UPHYPWR0x0
+
+#define S5PV210_UPHYPWR_PHY0_SUSPEND   BIT(0)
+#define S5PV210_UPHYPWR_PHY0_PWR   BIT(3)
+#define S5PV210_UPHYPWR_PHY0_OTG_PWR   BIT(4)
+#define S5PV210_UPHYPWR_PHY0   ( \
+   S5PV210_UPHYPWR_PHY0_SUSPEND | \
+   S5PV210_UPHYPWR_PHY0_PWR | \
+   S5PV210_UPHYPWR_PHY0_OTG_PWR)
+
+#define S5PV210_UPHYPWR_PHY1_SUSPEND   BIT(6)
+#define S5PV210_UPHYPWR_PHY1_PWR   BIT(7)
+#define S5PV210_UPHYPWR_PHY1 ( \
+   S5PV210_UPHYPWR_PHY1_SUSPEND | \
+   S5PV210_UPHYPWR_PHY1_PWR)
+
+/* PHY clock control */
+#define S5PV210_UPHYCLK0x4
+
+#define S5PV210_UPHYCLK_PHYFSEL_MASK   (0x3  0)
+#define S5PV210_UPHYCLK_PHYFSEL_48MHZ  (0x0  0)
+#define S5PV210_UPHYCLK_PHYFSEL_24MHZ  (0x3  0)
+#define S5PV210_UPHYCLK_PHYFSEL_12MHZ  (0x2  0)
+
+#define S5PV210_UPHYCLK_PHY0_ID_PULLUP BIT(2)
+#define S5PV210_UPHYCLK_PHY0_COMMON_ON BIT(4)
+#define S5PV210_UPHYCLK_PHY1_COMMON_ON BIT(7)
+
+/* PHY reset control */
+#define S5PV210_UPHYRST0x8
+
+#define S5PV210_URSTCON_PHY0   BIT(0)
+#define S5PV210_URSTCON_OTG_HLINK  BIT(1)
+#define S5PV210_URSTCON_OTG_PHYLINKBIT(2)
+#define S5PV210_URSTCON_PHY1_ALL   BIT(3)
+#define S5PV210_URSTCON_HOST_LINK_ALL  BIT(4)
+
+/* Isolation, configured in the power management unit */
+#define

[PATCH v6 3/8] dts: Add usb2phy to Exynos 4

2014-01-29 Thread Kamil Debski
Add support to PHY of USB2 of the Exynos 4 SoC.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/arm/samsung/pmu.txt|2 ++
 arch/arm/boot/dts/exynos4.dtsi |   31 
 arch/arm/boot/dts/exynos4210.dtsi  |   17 +++
 arch/arm/boot/dts/exynos4x12.dtsi  |   17 +++
 4 files changed, 67 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/samsung/pmu.txt 
b/Documentation/devicetree/bindings/arm/samsung/pmu.txt
index 307e727..a76f91d 100644
--- a/Documentation/devicetree/bindings/arm/samsung/pmu.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/pmu.txt
@@ -3,6 +3,8 @@ SAMSUNG Exynos SoC series PMU Registers
 Properties:
  - name : should be 'syscon';
  - compatible : should contain two values. First value must be one from 
following list:
+  - samsung,exynos4210-pmu - for Exynos4210 SoC,
+  - samsung,exynos4x12-pmu - for Exynos4212 SoC,
   - samsung,exynos5250-pmu - for Exynos5250 SoC,
   - samsung,exynos5420-pmu - for Exynos5420 SoC.
second value must be always syscon.
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index a73eeb5..031d07a 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -253,6 +253,17 @@
status = disabled;
};
 
+   usbotg@1248 {
+   compatible = samsung,s3c6400-hsotg;
+   reg = 0x1248 0x2;
+   interrupts = 0 71 0;
+   clocks = clock 305;
+   clock-names = otg;
+   phys = usb2phy 0;
+   phy-names = usb2-phy;
+   status = disabled;
+   };
+
ehci@1258 {
compatible = samsung,exynos4210-ehci;
reg = 0x1258 0x100;
@@ -260,6 +271,26 @@
clocks = clock 304;
clock-names = usbhost;
status = disabled;
+   #address-cells = 1;
+   #size-cells = 0;
+   port@0 {
+   phys = usb2phy 1;
+   phy-names = host;
+   reg = 0;
+   status = disabled;
+   };
+   port@1 {
+   phys = usb2phy 2;
+   phy-names = hsic0;
+   reg = 1;
+   status = disabled;
+   };
+   port@2 {
+   phys = usb2phy 3;
+   phy-names = hsic1;
+   reg = 2;
+   status = disabled;
+   };
};
 
ohci@1259 {
diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
b/arch/arm/boot/dts/exynos4210.dtsi
index 057d682..f9d06bb 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -155,4 +155,21 @@
samsung,lcd-wb;
};
};
+
+   pmu_reg: syscon@1002 {
+   compatible = samsung,exynos4210-pmu, syscon;
+   reg = 0x1002 0x4000;
+   };
+
+   usb2phy: phy@125B {
+   compatible = samsung,exynos4210-usb2-phy;
+   reg = 0x125B 0x100;
+   clocks = clock 305, clock 2, clock 2, clock 2,
+   clock 2;
+   clock-names = phy, device, host, hsic0, hsic1;
+   status = disabled;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_reg;
+   samsung,pmureg-phandle = pmu_reg;
+   };
 };
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi 
b/arch/arm/boot/dts/exynos4x12.dtsi
index ad531fe..63b0fe5 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -176,4 +176,21 @@
};
};
};
+
+   pmu_reg: syscon@1002 {
+   compatible = samsung,exynos4x12-pmu, syscon;
+   reg = 0x1002 0x4000;
+   };
+
+   usb2phy: phy@125B {
+   compatible = samsung,exynos4x12-usb2-phy;
+   reg = 0x125B 0x100;
+   clocks = clock 305, clock 2, clock 2, clock 2,
+   clock 2;
+   clock-names = phy, device, host, hsic0, hsic1;
+   status = disabled;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_reg;
+   samsung,pmureg-phandle = pmu_reg;
+   };
 };
-- 
1.7.9.5

--
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 v6 4/8] dts: Add usb2phy to Exynos 5250

2014-01-29 Thread Kamil Debski
Add support to PHY of USB2 of the Exynos 5250 SoC.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 arch/arm/boot/dts/exynos5250.dtsi |   24 
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index c4480a1..efeaf87 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -163,6 +163,11 @@
interrupts = 0 47 0;
};
 
+   sys_syscon: syscon@1004 {
+   compatible = samsung,exynos5250-sys, syscon;
+   reg = 0x1005 0x5000;
+   };
+
pmu_syscon: syscon@1004 {
compatible = samsung,exynos5250-pmu, syscon;
reg = 0x1004 0x5000;
@@ -505,6 +510,14 @@
 
clocks = clock 285;
clock-names = usbhost;
+   #address-cells = 1;
+   #size-cells = 0;
+   port@0 {
+   reg = 0;
+   phys = usb2_phy_new 1;
+   phy-names = host;
+   status = ok;
+   };
};
 
usb@1212 {
@@ -531,6 +544,17 @@
};
};
 
+   usb2_phy_new: phy@1213 {
+   compatible = samsung,exynos5250-usb2-phy;
+   reg = 0x1213 0x100;
+   clocks = clock 285, clock 1, clock 1, clock 1,
+   clock 1;
+   clock-names = phy, device, host, hsic0, hsic1;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_syscon;
+   samsung,pmureg-phandle = pmu_syscon;
+   };
+
amba {
#address-cells = 1;
#size-cells = 1;
-- 
1.7.9.5

--
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 v6 8/8] usb: ehci-exynos: Change to use phy provided by the generic phy framework

2014-01-29 Thread Kamil Debski
Change the phy provider used from the old one using the USB phy
framework to a new one using the Generic phy framework.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/usb/exynos-usb.txt |   13 +++
 drivers/usb/host/ehci-exynos.c |   97 +---
 2 files changed, 76 insertions(+), 34 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt 
b/Documentation/devicetree/bindings/usb/exynos-usb.txt
index d967ba1..25e199a 100644
--- a/Documentation/devicetree/bindings/usb/exynos-usb.txt
+++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt
@@ -12,6 +12,10 @@ Required properties:
  - interrupts: interrupt number to the cpu.
  - clocks: from common clock binding: handle to usb clock.
  - clock-names: from common clock binding: Shall be usbhost.
+  - port: if in the SoC there are EHCI phys, they should be listed here.
+One phy per port. Each port should have its reg entry with a consecutive
+number. Also it should contain phys and phy-names entries specifying the
+phy used by the port.
 
 Optional properties:
  - samsung,vbus-gpio:  if present, specifies the GPIO that
@@ -27,6 +31,15 @@ Example:
 
clocks = clock 285;
clock-names = usbhost;
+
+   #address-cells = 1;
+   #size-cells = 0;
+   port@0 {
+   reg = 0;
+   phys = usb2phy 1;
+   phy-names = host;
+   status = disabled;
+   };
};
 
 OHCI
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index d1d8c47..7c35501 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -19,12 +19,12 @@
 #include linux/module.h
 #include linux/of.h
 #include linux/of_gpio.h
+#include linux/phy/phy.h
 #include linux/platform_device.h
 #include linux/usb/phy.h
 #include linux/usb/samsung_usb_phy.h
 #include linux/usb.h
 #include linux/usb/hcd.h
-#include linux/usb/otg.h
 
 #include ehci.h
 
@@ -42,10 +42,10 @@
 static const char hcd_name[] = ehci-exynos;
 static struct hc_driver __read_mostly exynos_ehci_hc_driver;
 
+#define PHY_NUMBER 3
 struct exynos_ehci_hcd {
struct clk *clk;
-   struct usb_phy *phy;
-   struct usb_otg *otg;
+   struct phy *phy[PHY_NUMBER];
 };
 
 #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)-priv)
@@ -69,13 +69,43 @@ static void exynos_setup_vbus_gpio(struct platform_device 
*pdev)
dev_err(dev, can't request ehci vbus gpio %d, gpio);
 }
 
+static int exynos_phys_on(struct phy *p[])
+{
+   int i;
+   int ret = 0;
+
+   for (i = 0; ret == 0  i  PHY_NUMBER; i++)
+   if (p[i])
+   ret = phy_power_on(p[i]);
+   if (ret)
+   for (i--; i  0; i--)
+   if (p[i])
+   phy_power_off(p[i]);
+
+   return ret;
+}
+
+static int exynos_phys_off(struct phy *p[])
+{
+   int i;
+   int ret = 0;
+
+   for (i = 0; ret == 0  i  PHY_NUMBER; i++)
+   if (p[i])
+   ret = phy_power_off(p[i]);
+
+   return ret;
+}
+
 static int exynos_ehci_probe(struct platform_device *pdev)
 {
struct exynos_ehci_hcd *exynos_ehci;
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
struct resource *res;
-   struct usb_phy *phy;
+   struct phy *phy;
+   struct device_node *child;
+   int phy_number;
int irq;
int err;
 
@@ -102,14 +132,26 @@ static int exynos_ehci_probe(struct platform_device *pdev)
samsung,exynos5440-ehci))
goto skip_phy;
 
-   phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2);
-   if (IS_ERR(phy)) {
-   usb_put_hcd(hcd);
-   dev_warn(pdev-dev, no platform data or transceiver 
defined\n);
-   return -EPROBE_DEFER;
-   } else {
-   exynos_ehci-phy = phy;
-   exynos_ehci-otg = phy-otg;
+   for_each_available_child_of_node(pdev-dev.of_node, child) {
+   err = of_property_read_u32(child, reg, phy_number);
+   if (err) {
+   dev_err(pdev-dev, Failed to parse device tree\n);
+   of_node_put(child);
+   return err;
+   }
+   if (phy_number = PHY_NUMBER) {
+   dev_err(pdev-dev, Failed to parse device tree - 
number out of range\n);
+   of_node_put(child);
+   return -EINVAL;
+   }
+   phy = devm_of_phy_get(pdev-dev, child, 0);
+   of_node_put(child);
+   if (IS_ERR(phy)) {
+   dev_err(pdev-dev, Failed to get phy number %d,
+   phy_number);
+   return PTR_ERR(phy

[PATCH v6 2/8] phy: core: Add devm_of_phy_get to phy-core

2014-01-29 Thread Kamil Debski
Adding devm_of_phy_get will allow to get phys by supplying a
pointer to the struct device_node instead of struct device.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   31 +++
 include/linux/phy/phy.h |8 
 2 files changed, 39 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index a1d4387..6e32fb0 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -468,6 +468,37 @@ struct phy *devm_phy_get(struct device *dev, const char 
*string)
 EXPORT_SYMBOL_GPL(devm_phy_get);
 
 /**
+ * devm_of_phy_get() - lookup and obtain a reference to a phy.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Gets the phy using of_phy_get(), and associates a device with it using
+ * devres. On driver detach, release function is invoked on the devres data,
+ * then, devres data is freed.
+ */
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   struct phy **ptr, *phy;
+
+   ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   phy = of_phy_get(np, con_id);
+   if (!IS_ERR(phy)) {
+   *ptr = phy;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_get);
+
+/**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
  * @ops: function pointers for performing phy operations
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 5cffc69..b17d6d2 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -147,6 +147,8 @@ static inline void phy_set_bus_width(struct phy *phy, int 
bus_width)
 }
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 struct phy *of_phy_get(struct device_node *np, const char *con_id);
@@ -238,6 +240,12 @@ static inline struct phy *devm_phy_get(struct device *dev, 
const char *string)
return ERR_PTR(-ENOSYS);
 }
 
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
 static inline void phy_put(struct phy *phy)
 {
 }
-- 
1.7.9.5

--
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 v6 5/8] phy: Add new Exynos USB PHY driver

2014-01-29 Thread Kamil Debski
Add a new driver for the Exynos USB PHY. The new driver uses the generic
PHY framework. The driver includes support for the Exynos 4x10 and 4x12
SoC families.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|   55 
 Documentation/phy/samsung-usb2.txt |  135 
 drivers/phy/Kconfig|   29 ++
 drivers/phy/Makefile   |3 +
 drivers/phy/phy-exynos4210-usb2.c  |  257 
 drivers/phy/phy-exynos4x12-usb2.c  |  323 
 drivers/phy/phy-samsung-usb2.c |  227 ++
 drivers/phy/phy-samsung-usb2.h |   67 
 8 files changed, 1096 insertions(+)
 create mode 100644 Documentation/phy/samsung-usb2.txt
 create mode 100644 drivers/phy/phy-exynos4210-usb2.c
 create mode 100644 drivers/phy/phy-exynos4x12-usb2.c
 create mode 100644 drivers/phy/phy-samsung-usb2.c
 create mode 100644 drivers/phy/phy-samsung-usb2.h

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index c0fccaa..6668c41 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -20,3 +20,58 @@ Required properties:
 - compatible : should be samsung,exynos5250-dp-video-phy;
 - reg : offset and length of the Display Port PHY register set;
 - #phy-cells : from the generic PHY bindings, must be 0;
+
+Samsung S5P/EXYNOS SoC series USB PHY
+-
+
+Required properties:
+- compatible : should be one of the listed compatibles:
+   - samsung,exynos4210-usb2-phy
+   - samsung,exynos4x12-usb2-phy
+- reg : a list of registers used by phy driver
+   - first and obligatory is the location of phy modules registers
+- samsung,sysreg-phandle - handle to syscon used to control the system 
registers
+- samsung,pmureg-phandle - handle to syscon used to control PMU registers
+- #phy-cells : from the generic phy bindings, must be 1;
+- clocks and clock-names:
+   - the phy clocks is required by the phy module
+   - next for each of the phys a clock has to be assigned, this clock
+ will be used to determine clocking frequency for the phys
+ (the labels are specified in the paragraph below)
+
+The first phandle argument in the PHY specifier identifies the PHY, its
+meaning is compatible dependent. For the currently supported SoCs (Exynos 4210
+and Exynos 4212) it is as follows:
+  0 - USB device (device),
+  1 - USB host (host),
+  2 - HSIC0 (hsic0),
+  3 - HSIC1 (hsic1),
+
+Exynos 4210 and Exynos 4212 use mode switching and require that mode switch
+register is supplied.
+
+Example:
+
+For Exynos 4412 (compatible with Exynos 4212):
+
+usbphy: phy@125b {
+   compatible = samsung,exynos4212-usb2-phy;
+   reg = 0x125b 0x100 0x10020704 0x0c 0x1001021c 0x4;
+   clocks = clock 305, clock 2, clock 2, clock 2,
+   clock 2;
+   clock-names = phy, device, host, hsic0, hsic1;
+   status = okay;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_reg;
+   samsung,pmureg-phandle = pmu_reg;
+};
+
+Then the PHY can be used in other nodes such as:
+
+phy-consumer@1234 {
+   phys = usbphy 2;
+   phy-names = phy;
+};
+
+Refer to DT bindings documentation of particular PHY consumer devices for more
+information about required PHYs and the way of specification.
diff --git a/Documentation/phy/samsung-usb2.txt 
b/Documentation/phy/samsung-usb2.txt
new file mode 100644
index 000..9f5826e
--- /dev/null
+++ b/Documentation/phy/samsung-usb2.txt
@@ -0,0 +1,135 @@
+.--+
+|  Samsung USB 2.0 PHY adaptation layer   |
++-+'
+
+| 1. Description
++
+
+The architecture of the USB 2.0 PHY module in Samsung SoCs is similar
+among many SoCs. In spite of the similarities it proved difficult to
+create a one driver that would fit all these PHY controllers. Often
+the differences were minor and were found in particular bits of the
+registers of the PHY. In some rare cases the order of register writes or
+the PHY powering up process had to be altered. This adaptation layer is
+a compromise between having separate drivers and having a single driver
+with added support for many special cases.
+
+| 2. Files description
++--
+
+- phy-samsung-usb2.c
+   This is the main file of the adaptation layer. This file contains
+   the probe function and provides two callbacks to the Generic PHY
+   Framework. This two callbacks are used to power on and power off the
+   phy. They carry out the common work that has to be done on all

[PATCH v6 7/8] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver

2014-01-29 Thread Kamil Debski
Add support for Exynos 5250. This driver is to replace the old
USB 2.0 PHY driver.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|1 +
 drivers/phy/Kconfig|   11 +
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-exynos5250-usb2.c  |  406 
 drivers/phy/phy-samsung-usb2.c |6 +
 drivers/phy/phy-samsung-usb2.h |1 +
 6 files changed, 426 insertions(+)
 create mode 100644 drivers/phy/phy-exynos5250-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index 710d41f..d1b534f 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -29,6 +29,7 @@ Required properties:
- samsung,s5pv210-usb2-phy
- samsung,exynos4210-usb2-phy
- samsung,exynos4x12-usb2-phy
+   - samsung,exynos5250-usb2-phy
 - reg : a list of registers used by phy driver
- first and obligatory is the location of phy modules registers
 - samsung,sysreg-phandle - handle to syscon used to control the system 
registers
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a5554b5..645ed66 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -102,4 +102,15 @@ config PHY_EXYNOS4X12_USB2
  Samsung USB 2.0 PHY driver is enabled and means that support for this
  particular SoC is compiled in the driver. In case of Exynos 4x12 four
  phys are available - device, host, HSIC0 and HSIC1.
+
+config PHY_EXYNOS5250_USB2
+   bool Support for Exynos 5250
+   depends on PHY_SAMSUNG_USB2
+   depends on SOC_EXYNOS5250
+   help
+ Enable USB PHY support for Exynos 5250. This option requires that
+ Samsung USB 2.0 PHY driver is enabled and means that support for this
+ particular SoC is compiled in the driver. In case of Exynos 5250 four
+ phys are available - device, host, HSIC0 and HSIC.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index d738f65..fe7aaee 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -13,3 +13,4 @@ obj-$(CONFIG_PHY_SAMSUNG_USB2)+= 
phy-samsung-usb2.o
 obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4210_USB2)  += phy-exynos4210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4X12_USB2)  += phy-exynos4x12-usb2.o
+obj-$(CONFIG_PHY_EXYNOS5250_USB2)  += phy-exynos5250-usb2.o
diff --git a/drivers/phy/phy-exynos5250-usb2.c 
b/drivers/phy/phy-exynos5250-usb2.c
new file mode 100644
index 000..2603d5e
--- /dev/null
+++ b/drivers/phy/phy-exynos5250-usb2.c
@@ -0,0 +1,406 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/phy/phy.h
+#include linux/regmap.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+#define EXYNOS_5250_REFCLKSEL_CRYSTAL  0x0
+#define EXYNOS_5250_REFCLKSEL_XO   0x1
+#define EXYNOS_5250_REFCLKSEL_CLKCORE  0x2
+
+#define EXYNOS_5250_FSEL_9MHZ6 0x0
+#define EXYNOS_5250_FSEL_10MHZ 0x1
+#define EXYNOS_5250_FSEL_12MHZ 0x2
+#define EXYNOS_5250_FSEL_19MHZ20x3
+#define EXYNOS_5250_FSEL_20MHZ 0x4
+#define EXYNOS_5250_FSEL_24MHZ 0x5
+#define EXYNOS_5250_FSEL_50MHZ 0x7
+
+/* Normal host */
+#define EXYNOS_5250_HOSTPHYCTRL0   0x0
+
+#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL   BIT(31)
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT   19
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\
+   (0x3  EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \
+   (0x7  EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11)
+#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10)
+#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N   BIT(9)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST  (0x2  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND  BIT(4)
+#define

[PATCH v6 0/8] phy: Add new Exynos USB 2.0 PHY driver

2014-01-29 Thread Kamil Debski
Hi,

This is the sixth version of the patchset. It adds a new Exynos USB 2.0 PHY
driver. The driver uses the Generic PHY Framework.

Again, I would like to thank everyone who commented and read through the fifth
version of the patchset. Your input is very much appreciated. The last version
had two alternative approaches included. This allowed a comparison between these
approaches to the Exynos USB 2.0 PHY driver. The original idea was chosen as it
gave the optimal compromise between code readability and size of the driver.

These patchset depend on a patch by Leela Krishna Amudala.
[PATCH V11 1/3] ARM: dts: Add pmu sysreg node to exynos5250 and exynos5420
dtsi files [1].

Best wishes,
Kamil Debski

[1] - http://www.spinics.net/lists/linux-samsung-soc/msg24528.html


Changes from v5:
1) phy: core: Add an exported of_phy_get function
- corrected behaviour of the modification when GENERIC_PHY is not enabled
  by adding a stub of the of_phy_get function
2) phy: core: Add devm_of_phy_get to phy-core
- corrected behaviour of the modification when GENERIC_PHY is not enabled
  by adding a stub of the devm_of_phy_get function
3) dts: Add usb2phy to Exynos 4
- no change
4) dts: Add usb2phy to Exynos 5250
- in the previous version, this patch included some phy-exynos5250-usb2.c code
  by mistake, the code has been remove and added to the proper patch
5) phy: Add new Exynos USB PHY driver
- changed strings from Exynos 4212 to Exynos 4x12, as the Exynos 4212 driver is
  actually a driver for the whole Exynos 4x12 family
- added documentation to the Exynos USB 2.0 PHY driver adaptaion layer
- corrected strings HSCI - HSIC
- fixed a problem introduced by previous change - on Exynos 4x12 the HSIC did
  not work on its own
- mode switch support was added to Exynos 4x12 (same io pins are used by host
  and device)
- support for phy_set_bus_width introduced by Matt Porter was added
6) phy: Add support for S5PV210 to the Exynos USB PHY
- setting of clk register was fixed
7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
- supoprt was added for HSIC and device
8) usb: ehci-exynos: Change to use phy provided by the generic phy framework
- DT documentation was moved from usb-ehci.txt to exynos-usb.txt


Changes from v4:
1) phy: core: Add an exported of_phy_get function
- the new exported function of_phy_get was changed to take the phy's name as a
  parameter instead of the index
2) phy: core: Add devm_of_phy_get to phy-core
- fixes made in the comments to devm_of_phy_get
3) phy: Add new Exynos USB PHY driver
- move the documentation from a new to an existing file - samsung-phy.txt
- fix typos and uppercase hex addresses
- add more explanations to Kconfig (checkpatch still complains, but I find it
  hard to think what else could I add)
- add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!)
- cleanup included headers in both *.c and .h files
- use BIT(x) macro instead of (1  x)
- replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the
  registers are described as PHYx in the documentation hence the decision to
  leave the PHYx naming
- fixed typo in exynos4210_rate_to_clk reg - *reg
- change hax_mode_switch and enabled type to bool
4) usb: ehci-s5p: Change to use phy provided by the generic phy framework
- Put the issue of phy-otg in order - since the new phy driver does not provide
  this field. With the new driver the switch between host and device is done in
  power_on of the respective host and device phys.
5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy
   framework
- fixed the example in the documentation
6) phy: Add support for S5PV210 to the Exynos USB PHY driver
- include files cleanup
- use BIT(x) macro instead of (1  x)
7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
- include files cleanup
- use BIT(x) macro instead of (1  x)
8) dts: Add usb2phy to Exynos 4
- no changes
9) dts: Add usb2phy to Exynos 5250
- no changes


Changes from v3:
- using PMU and system registers indirectly via syscon
- change labelling
- change Kconfig name
- fixed typos/stray whitespace
- move of_phy_provider_register() to the end of probe
- add a regular error return code to the rate_to_clk functions
- cleanup code and remove unused code
- change struct names to avoid collisions
- add mechanism to support multiple phys by the ehci driver


Changes from v2:
- rebase all patches to the usb-next branch
- fixes in the documentation file
  - remove wrong entries in the phy node (ranges, and #address-  #size-cells)
  - add clocks and clock-names as required properites
  - rephrase a few sentences
- fixes in the ehci-exynos.c file
  - move phy_name variable next to phy in exynos_ehci_hcd
  - remove otg from exynos_ehci_hcd as it was no longer used
  - move devm_phy_get after the Exynos5440 skip_phy check
- fixes in the s3c-hsotg.c file
  - cosmetic fixes (remove empty line that was wrongfully added)
- fixes

RE: [PATCH RFC alternative ver 1] phy: Exynos 421x USB 2.0 PHY support

2014-01-08 Thread Kamil Debski
Hi Kishon,

Thank you for your review.

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Monday, January 06, 2014 11:24 AM
 
 Hi,
 
 On Friday 20 December 2013 06:54 PM, Kamil Debski wrote:
  This the alternative version of the support for Exynos 421x USB 2.0
  PHY in the Generic PHY framework. In this version the support for
  Exynos
  4210 and 4212 was joined into one file.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  ---
  Hi,
 
  Me and Kishon were discussing for quite a long time the way how
 Exynos
  4 should be handled. I have decided to post the original patches and
  try to make an alternative version with support for Exynos 4210 and
  4212 joined in one file. I have prepared two versions. The first one
  has 506 lines (vs
  563 when two files are used). When doing the second version I was a
  little more aggresive in removing code. This was done at a cost of
  adding if's deciding which SoC version the driver is dealing with in
 some internal functions.
  This resulted in a better number of removed lines - the second
 version
  has only 452 lines (vs 563 original and 506 version 1).
 
 Alright.. If the alternate approach doesn't give too much of advantage,
 lets stick with the original one. I would recommend creating a
 documentation (Documentation/phy/?) for the samsung PHY since that
 actually creates a layer on top of generic PHY framework. That would
 help while adding new samsung PHY drivers.

Ok, I will prepare an updated set of patches with the documentation
added. Also I will fix other issues you pointed out in reply to other
patches from this series.

 
 Btw thank you for preparing alternate versions for your original
 patches.

No problem :)

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

--
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 v5 3/9] phy: Add new Exynos USB 2.0 PHY driver

2014-01-08 Thread Kamil Debski
Hi,

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Monday, January 06, 2014 11:12 AM
 
 Hi,
 
 On Friday 20 December 2013 06:54 PM, Kamil Debski wrote:
  Add a new driver for the Exynos USB 2.0 PHY. The new driver uses the
  generic PHY framework. The driver includes support for the Exynos
 4x10
  and 4x12 SoC families.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
.../devicetree/bindings/phy/samsung-phy.txt|   55 
drivers/phy/Kconfig|   29 ++
drivers/phy/Makefile   |3 +
drivers/phy/phy-exynos4210-usb2.c  |  257
 
drivers/phy/phy-exynos4212-usb2.c  |  306
 
drivers/phy/phy-samsung-usb2.c |  226
 +++
drivers/phy/phy-samsung-usb2.h |   67 +
7 files changed, 943 insertions(+)
create mode 100644 drivers/phy/phy-exynos4210-usb2.c
create mode 100644 drivers/phy/phy-exynos4212-usb2.c
create mode 100644 drivers/phy/phy-samsung-usb2.c
create mode 100644 drivers/phy/phy-samsung-usb2.h
 
 .
 .
 snip
 .
 .
 
  diff --git a/drivers/phy/phy-samsung-usb2.h
  b/drivers/phy/phy-samsung-usb2.h new file mode 100644 index
  000..ab89f91
  --- /dev/null
  +++ b/drivers/phy/phy-samsung-usb2.h
  @@ -0,0 +1,67 @@
  +/*
  + * Samsung SoC USB 1.1/2.0 PHY driver
  + *
  + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  + * Author: Kamil Debski k.deb...@samsung.com
  + *
  + * This program is free software; you can redistribute it and/or
  +modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + */
  +
  +#ifndef _PHY_EXYNOS_USB2_H
  +#define _PHY_EXYNOS_USB2_H
  +
  +#include linux/clk.h
  +#include linux/phy/phy.h
  +#include linux/device.h
  +#include linux/regmap.h
  +#include linux/spinlock.h
  +
  +#define KHZ 1000
  +#define MHZ (KHZ * KHZ)
  +
  +struct samsung_usb2_phy_driver;
  +struct samsung_usb2_phy_instance;
  +struct samsung_usb2_phy_config;
  +
  +struct samsung_usb2_phy_instance {
  +   const struct samsung_usb2_common_phy *cfg;
  +   struct clk *clk;
  +   struct phy *phy;
  +   struct samsung_usb2_phy_driver *drv;
  +   unsigned long rate;
  +   u32 clk_reg_val;
  +   bool enabled;
  +};
  +
  +struct samsung_usb2_phy_driver {
  +   const struct samsung_usb2_phy_config *cfg;
  +   struct clk *clk;
  +   struct device *dev;
  +   void __iomem *reg_phy;
  +   struct regmap *reg_pmu;
  +   struct regmap *reg_sys;
  +   spinlock_t lock;
  +   struct samsung_usb2_phy_instance instances[0];
 
 I think having instances as array here would allocate more space while
 allocating 'samsung_usb2_phy_driver' in 'samsung_usb2_phy_probe'.
 

I am not sure if I understand you correctly here. Maybe I will explain
what I intended to write. An array with size 0 at the end of a structure
takes no space in the structure. The benefit of using it is that after
the structure one can allocate a number of the array elements and
address them easily. Another option would be placing pointer in the
samsung_usb2_phy_instance and allocate memory separately, but this would
involve two allocations and a pointer would be always present in the 
structure.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland



--
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 v5 0/9] phy: Add new Exynos USB 2.0 PHY driver

2014-01-02 Thread Kamil Debski
Hi Kishon,

I wanted to ask about your comments to this patchset. As I mentioned 
there are two alternative version where the Exynos 4210 and 4212
support is merged in one file.

I would be grateful if you had some time to look at the patchset
and share your comments.

Best wishes and happy new year!
-- 
Kamil Debski
Samsung RD Institute Poland


 From: Kamil Debski [mailto:k.deb...@samsung.com]
 Sent: Friday, December 20, 2013 2:24 PM
 
 Hi,
 
 This is the fifth version of the patchset. It adds a new Exynos USB 2.0
 PHY driver. The driver uses the Generic PHY Framework.
 
 I would like to thank everyone who contributed with comments and took
 the time to read through the patches in the previous versions of this
 patchset.
 We had a lengthy discussion with Kishon about how the driver should
 look like.
 This patchset contains the updated version of my original idea, where
 support for Exynos 4210 and 4212 is done in separate files. Kishon's
 idea is to join these two into a single file. I have prepared two
 alternative version which I will send soon after this patchset.
 
 Just like the fourth version this patch depends on:
 [PATCH V11 1/3] ARM: dts: Add pmu sysreg node to exynos5250 and
 exynos5420 dtsi files [1].
 
 Best wishes,
 Kamil Debski
 
 [1] - http://www.spinics.net/lists/linux-samsung-soc/msg24528.html
 
 
 Changes from v4:
 1) phy: core: Add an exported of_phy_get function
 - the new exported function of_phy_get was changed to take the phy's
 name as a
   parameter instead of the index
 2) phy: core: Add devm_of_phy_get to phy-core
 - fixes made in the comments to devm_of_phy_get
 3) phy: Add new Exynos USB PHY driver
 - move the documentation from a new to an existing file - samsung-
 phy.txt
 - fix typos and uppercase hex addresses
 - add more explanations to Kconfig (checkpatch still complains, but I
 find it
   hard to think what else could I add)
 - add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!)
 - cleanup included headers in both *.c and .h files
 - use BIT(x) macro instead of (1  x)
 - replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c,
 the
   registers are described as PHYx in the documentation hence the
 decision to
   leave the PHYx naming
 - fixed typo in exynos4210_rate_to_clk reg - *reg
 - change hax_mode_switch and enabled type to bool
 4) usb: ehci-s5p: Change to use phy provided by the generic phy
 framework
 - Put the issue of phy-otg in order - since the new phy driver does
 not provide
   this field. With the new driver the switch between host and device is
 done in
   power_on of the respective host and device phys.
 5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic
 phy
framework
 - fixed the example in the documentation
 6) phy: Add support for S5PV210 to the Exynos USB PHY driver
 - include files cleanup
 - use BIT(x) macro instead of (1  x)
 7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
 - include files cleanup
 - use BIT(x) macro instead of (1  x)
 8) dts: Add usb2phy to Exynos 4
 - no changes
 9) dts: Add usb2phy to Exynos 5250
 - no changes
 
 
 Changes from v3:
 - using PMU and system registers indirectly via syscon
 - change labelling
 - change Kconfig name
 - fixed typos/stray whitespace
 - move of_phy_provider_register() to the end of probe
 - add a regular error return code to the rate_to_clk functions
 - cleanup code and remove unused code
 - change struct names to avoid collisions
 - add mechanism to support multiple phys by the ehci driver
 
 
 Changes from v2:
 - rebase all patches to the usb-next branch
 - fixes in the documentation file
   - remove wrong entries in the phy node (ranges, and #address- 
 #size-cells)
   - add clocks and clock-names as required properites
   - rephrase a few sentences
 - fixes in the ehci-exynos.c file
   - move phy_name variable next to phy in exynos_ehci_hcd
   - remove otg from exynos_ehci_hcd as it was no longer used
   - move devm_phy_get after the Exynos5440 skip_phy check
 - fixes in the s3c-hsotg.c file
   - cosmetic fixes (remove empty line that was wrongfully added)
 - fixes in the main driver
   - remove cpu_type in favour for a boolean flag matched with the
 compatible
 value
   - rename files, structures, variables and Kconfig entires - change
 from simple
 uphy to usb2_phy
   - fix multiline comments style
   - simplify #ifdefs in of_device_id
   - fix Kconfig description
   - change dev_info to dev_dbg where reasonable
   - cosmetic changes (remove wrongful blank lines)
   - remove unnecessary reference counting
 
 
 Changes from v1:
 - the changes include minor fixes of the hardware initialization of the
 PHY
   module
 - some other minor fixes were introduced
 
 --
 Original cover letter:
 
 Hi,
 
 This patch adds a new drive for USB PHYs for Samsung SoCs. The driver
 is using the Generic PHY Framework created by Kishon Vijay Abrahan I

RE: [PATCH v5 4/9] usb: ehci-s5p: Change to use phy provided by the generic phy framework

2013-12-30 Thread Kamil Debski
Hi Vivek,

 From: Vivek Gautam [mailto:gautamvivek1...@gmail.com]
 Sent: Thursday, December 26, 2013 11:14 AM
 
 Hi Kamil,
 
 
 On Fri, Dec 20, 2013 at 6:54 PM, Kamil Debski k.deb...@samsung.com
 wrote:
  Change the phy provider used from the old one using the USB phy
  framework to a new one using the Generic phy framework.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 
 Commit title:
 s/ehci-s5p/ehci-exynos

Thank you for spotting this.

 
  ---
   Documentation/devicetree/bindings/usb/usb-ehci.txt |   35 +++
   drivers/usb/host/ehci-exynos.c |   97
 +---
   2 files changed, 98 insertions(+), 34 deletions(-)
 
  diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt
  b/Documentation/devicetree/bindings/usb/usb-ehci.txt
  index fa18612..413f7cd 100644
  --- a/Documentation/devicetree/bindings/usb/usb-ehci.txt
  +++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt
  @@ -14,6 +14,10 @@ If controller implementation operates with big
  endian descriptors,  If both big endian registers and descriptors are
  used by the controller  implementation, big-endian property can be
  specified instead of having  both big-endian-regs and big-endian-
 desc.
  +  - port: if in the SoC there are EHCI phys, they should be listed
 here.
  +One phy per port. Each port should have its reg entry with a
  +consecutive number. Also it should contain phys and phy-names
 entries
  +specifying the phy used by the port.
 
   Example (Sequoia 440EPx):
   ehci@e300 {
  @@ -23,3 +27,34 @@ Example (Sequoia 440EPx):
 reg = 0 e300 90 0 e390 70;
 big-endian;
  };
  +
  +Example (Exynos 4212):
  +ehci@1258 {
  +compatible = samsung,exynos4210-ehci;
  +reg = 0x1258 0x2;
  +interrupts = 0 70 0;
  +clocks = clock 304, clock 305;
  +clock-names = usbhost, otg;
  +status = disabled;
  +#address-cells = 1;
  +#size-cells = 0;
  +port@0 {
  +reg = 0;
  +phys = usb2phy 1;
  +phy-names = host;
  +status = disabled;
  +};
  +port@1 {
  +reg = 1;
  +phys = usb2phy 2;
  +phy-names = hsic0;
  +status = disabled;
  +};
  +port@2 {
  +reg = 2;
  +phys = usb2phy 3;
  +phy-names = hsic1;
  +status = disabled;
  +};
  +};
 
 Should we place above documentation in
 Documentation/devicetree/bindings/usb/exynos-usb.txt ?
 or is it something that i am missing. 

Indeed, this should go to exynos-usb.txt instead of usb-ehci.txt.
Thanks!

  +
  diff --git a/drivers/usb/host/ehci-exynos.c
  b/drivers/usb/host/ehci-exynos.c index d1d8c47..7c35501 100644
  --- a/drivers/usb/host/ehci-exynos.c
  +++ b/drivers/usb/host/ehci-exynos.c
  @@ -19,12 +19,12 @@
   #include linux/module.h
   #include linux/of.h
   #include linux/of_gpio.h
  +#include linux/phy/phy.h
   #include linux/platform_device.h
   #include linux/usb/phy.h
   #include linux/usb/samsung_usb_phy.h  #include linux/usb.h
  #include linux/usb/hcd.h -#include linux/usb/otg.h
 
   #include ehci.h
 
  @@ -42,10 +42,10 @@
   static const char hcd_name[] = ehci-exynos;  static struct
  hc_driver __read_mostly exynos_ehci_hc_driver;
 
  +#define PHY_NUMBER 3
   struct exynos_ehci_hcd {
  struct clk *clk;
  -   struct usb_phy *phy;
  -   struct usb_otg *otg;
  +   struct phy *phy[PHY_NUMBER];
   };
 
   #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd
  *)(hcd_to_ehci(hcd)-priv) @@ -69,13 +69,43 @@ static void
 exynos_setup_vbus_gpio(struct platform_device *pdev)
  dev_err(dev, can't request ehci vbus gpio %d,
 gpio);
  }
 
  +static int exynos_phys_on(struct phy *p[]) {
  +   int i;
  +   int ret = 0;
  +
  +   for (i = 0; ret == 0  i  PHY_NUMBER; i++)
  +   if (p[i])
  +   ret = phy_power_on(p[i]);
  +   if (ret)
  +   for (i--; i  0; i--)
  +   if (p[i])
  +   phy_power_off(p[i]);
 
 So we are turning off, say, port0 phy in case port1 phy power_on fails;
 can't we still leave a usb2.0 phy(a normal host phy) 'on' in case the
 HSIC phy fails ?

Currently all phys are can be either switched on or off. So if powering on
one phy fails (and exynos_phy_on returns an error code), I would expect
that no phy is switched on. I think that doing otherwise could leave
the phys in strange state - some phys are on, some are off and the power_on
call returned an error.

  +
  +   return ret;
  +}
  +
  +static int exynos_phys_off(struct phy *p[]) {
  +   int i;
  +   int ret = 0;
  +
  +   for (i = 0; ret == 0  i  PHY_NUMBER; i++)
  +   if (p[i])
  +   ret = phy_power_off(p[i]);
  +
  +   return ret

RE: [PATCH v2 9/9] dts: Add usb2phy to Exynos 5250

2013-12-30 Thread Kamil Debski
Hi,

 From: Vivek Gautam [mailto:gautamvivek1...@gmail.com]
 Sent: Thursday, December 26, 2013 11:32 AM
 
 Hi Kamil,
 
 
 On Fri, Dec 20, 2013 at 6:54 PM, Kamil Debski k.deb...@samsung.com
 wrote:
  Add support to PHY of USB2 of the Exynos 5250 SoC.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  ---
   arch/arm/boot/dts/exynos5250.dtsi |   33 ---
   drivers/phy/phy-exynos5250-usb2.c |   64
 +
   2 files changed, 78 insertions(+), 19 deletions(-)
 
  diff --git a/arch/arm/boot/dts/exynos5250.dtsi
  b/arch/arm/boot/dts/exynos5250.dtsi
  index 2f264ad..922e0ed 100644
  --- a/arch/arm/boot/dts/exynos5250.dtsi
  +++ b/arch/arm/boot/dts/exynos5250.dtsi
  @@ -163,6 +163,11 @@
  interrupts = 0 47 0;
  };
 
  +   sys_syscon: syscon@1004 {
  +   compatible = samsung,exynos5250-sys, syscon;
  +   reg = 0x1005 0x5000;
  +   };
  +
  pmu_syscon: syscon@1004 {
  compatible = samsung,exynos5250-pmu, syscon;
  reg = 0x1004 0x5000; @@ -505,6 +510,14 @@
 
  clocks = clock 285;
  clock-names = usbhost;
  +   #address-cells = 1;
  +   #size-cells = 0;
  +   port@0 {
  +   reg = 0;
  +   phys = usb2_phy 1;
  +   phy-names = host;
  +   status = ok;
  +   };
  };
 
  usb@1212 {
  @@ -516,19 +529,15 @@
  clock-names = usbhost;
  };
 
  -   usb2_phy: usbphy@1213 {
  -   compatible = samsung,exynos5250-usb2phy;
  +   usb2_phy: phy@1213 {
  +   compatible = samsung,exynos5250-usb2-phy;
  reg = 0x1213 0x100;
  -   clocks = clock 1, clock 285;
  -   clock-names = ext_xtal, usbhost;
  -   #address-cells = 1;
  -   #size-cells = 1;
  -   ranges;
  -
  -   usbphy-sys {
  -   reg = 0x10040704 0x8,
  - 0x10050230 0x4;
  -   };
  +   clocks = clock 285, clock 1, clock 1,
 clock 1,
  +
 clock 1;
  +   clock-names = phy, device, host, hsic0,
 hsic1;
  +   #phy-cells = 1;
  +   samsung,sysreg-phandle = sys_syscon;
  +   samsung,pmureg-phandle = pmu_syscon;
  };
 
  amba {
  diff --git a/drivers/phy/phy-exynos5250-usb2.c
  b/drivers/phy/phy-exynos5250-usb2.c
  index b9b3b98..337bf82 100644
  --- a/drivers/phy/phy-exynos5250-usb2.c
  +++ b/drivers/phy/phy-exynos5250-usb2.c
 
 Separate patches for dt and driver ?
 I think you wanted to move these changes to :
 [PATCH v5 7/9] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY
 driver

Good point. I am planning to reorganise this patchset to prevent breaking
git bisect. I wanted to wait for more comments to this version, so I could
address any issues that may be reported.

 
  @@ -58,7 +58,13 @@
   #define EXYNOS_5250_HOSTPHYCTRL2   0x20
 
 Shouldn't we leave the naming as EXYNOS_5250_HSICPHYCTRL2 instead of
 EXYNOS_5250_HOSTPHYCTRL2 ? That will go in sync with the user-manual
 too.
 and similar for EXYNOS_5250_HOSTPHYCTRL1 and below bit definitions too
 ?

Thank you for pointing this out.

 
   #define EXYNOS_5250_HOSTPHYCTRLX_REFCLKSEL_MASK(0x3
  23)
  +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKSEL_DEFAULT (0x2  23)
   #define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_MASK(0x7f
  16)
  +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_12  (0x24  16)
  +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_15  (0x1c  16)
  +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_16  (0x1a  16)
  +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_19_2(0x15
  16)
  +#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_20  (0x14  16)
   #define EXYNOS_5250_HOSTPHYCTRLX_SIDDQ BIT(6)
   #define EXYNOS_5250_HOSTPHYCTRLX_FORCESLEEPBIT(5)
   #define EXYNOS_5250_HOSTPHYCTRLX_FORCESUSPEND  BIT(4)
  @@ -191,13 +197,14 @@ static void exynos5250_isol(struct
 samsung_usb2_phy_instance *inst, bool on)
  regmap_update_bits(drv-reg_pmu, offset, mask, on ? 0 :
 mask);
  }
 
  -static void exynos5250_phy_pwr(struct samsung_usb2_phy_instance
  *inst, bool on)
  +static int exynos5250_power_on(struct samsung_usb2_phy_instance
  +*inst)
 
 void ? we really don't have much to return in this function.

Initially the idea was to enable the return of an error code. However,
I see that for all currently supported SoCs the ops always returns 0.
So I will consider switching to void.

 
   {
  struct samsung_usb2_phy_driver *drv = inst-drv;
  u32 ctrl0;
  u32 otg;
  u32 ehci;
  u32 ohci;
  +   u32 hsic;
 
  switch (inst-cfg-id) {
  case

[PATCH v4 1/9] phy: core: Add an exported of_phy_get function

2013-12-20 Thread Kamil Debski
Previously the of_phy_get function took a struct device * and
was declared static. It was impossible to call it from
another driver and thus it was impossible to get phy defined
for a given node. The old function was renamed to _of_phy_get
and was left for internal use. of_phy_get function was added
and it was exported. The function enables to get a phy for
a given device tree node.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   45 -
 include/linux/phy/phy.h |1 +
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 03cf8fb..d6f8c34 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -240,8 +240,8 @@ out:
 EXPORT_SYMBOL_GPL(phy_power_off);
 
 /**
- * of_phy_get() - lookup and obtain a reference to a phy by phandle
- * @dev: device that requests this phy
+ * _of_phy_get() - lookup and obtain a reference to a phy by phandle
+ * @np: device_node for which to get the phy
  * @index: the index of the phy
  *
  * Returns the phy associated with the given phandle value,
@@ -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
  * not yet loaded. This function uses of_xlate call back function provided
  * while registering the phy_provider to find the phy instance.
  */
-static struct phy *of_phy_get(struct device *dev, int index)
+static struct phy *_of_phy_get(struct device_node *np, int index)
 {
int ret;
struct phy_provider *phy_provider;
struct phy *phy = NULL;
struct of_phandle_args args;
 
-   ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells,
+   ret = of_parse_phandle_with_args(np, phys, #phy-cells,
index, args);
-   if (ret) {
-   dev_dbg(dev, failed to get phy in %s node\n,
-   dev-of_node-full_name);
+   if (ret)
return ERR_PTR(-ENODEV);
-   }
 
mutex_lock(phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np);
@@ -283,6 +280,36 @@ err0:
 }
 
 /**
+ * of_phy_get() - lookup and obtain a reference to a phy using a device_node.
+ * @np: device_node for which to get the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Returns the phy driver, after getting a refcount to it; or
+ * -ENODEV if there is no such phy. The caller is responsible for
+ * calling phy_put() to release that count.
+ */
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   struct phy *phy = NULL;
+   int index = 0;
+
+   if (con_id)
+   index = of_property_match_string(np, phy-names, con_id);
+
+   phy = _of_phy_get(np, index);
+   if (IS_ERR(phy))
+   return phy;
+
+   if (!try_module_get(phy-ops-owner))
+   return ERR_PTR(-EPROBE_DEFER);
+
+   get_device(phy-dev);
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(of_phy_get);
+
+/**
  * phy_put() - release the PHY
  * @phy: the phy returned by phy_get()
  *
@@ -370,7 +397,7 @@ struct phy *phy_get(struct device *dev, const char *string)
if (dev-of_node) {
index = of_property_match_string(dev-of_node, phy-names,
string);
-   phy = of_phy_get(dev, index);
+   phy = _of_phy_get(dev-of_node, index);
if (IS_ERR(phy)) {
dev_err(dev, unable to find phy\n);
return phy;
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..bcb6274 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -131,6 +131,7 @@ struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
+struct phy *of_phy_get(struct device_node *np, const char *con_id);
 struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
 struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
-- 
1.7.9.5

--
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/9] phy: core: Add devm_of_phy_get to phy-core

2013-12-20 Thread Kamil Debski
Adding devm_of_phy_get will allow to get phys by supplying a
pointer to the struct device_node instead of struct device.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   31 +++
 include/linux/phy/phy.h |2 ++
 2 files changed, 33 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index d6f8c34..0551cc3 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -450,6 +450,37 @@ struct phy *devm_phy_get(struct device *dev, const char 
*string)
 EXPORT_SYMBOL_GPL(devm_phy_get);
 
 /**
+ * devm_of_phy_get() - lookup and obtain a reference to a phy.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Gets the phy using of_phy_get(), and associates a device with it using
+ * devres. On driver detach, release function is invoked on the devres data,
+ * then, devres data is freed.
+ */
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   struct phy **ptr, *phy;
+
+   ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   phy = of_phy_get(np, con_id);
+   if (!IS_ERR(phy)) {
+   *ptr = phy;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_get);
+
+/**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
  * @ops: function pointers for performing phy operations
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index bcb6274..864914c 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -129,6 +129,8 @@ int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 struct phy *of_phy_get(struct device_node *np, const char *con_id);
-- 
1.7.9.5

--
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 v5 0/9] phy: Add new Exynos USB 2.0 PHY driver

2013-12-20 Thread Kamil Debski
Hi,

This is the fifth version of the patchset. It adds a new Exynos USB 2.0 PHY
driver. The driver uses the Generic PHY Framework.

I would like to thank everyone who contributed with comments and took the time
to read through the patches in the previous versions of this patchset.
We had a lengthy discussion with Kishon about how the driver should look like.
This patchset contains the updated version of my original idea, where support
for Exynos 4210 and 4212 is done in separate files. Kishon's idea is to join
these two into a single file. I have prepared two alternative version which I
will send soon after this patchset.

Just like the fourth version this patch depends on:
[PATCH V11 1/3] ARM: dts: Add pmu sysreg node to exynos5250 and exynos5420 dtsi
files [1].

Best wishes,
Kamil Debski

[1] - http://www.spinics.net/lists/linux-samsung-soc/msg24528.html


Changes from v4:
1) phy: core: Add an exported of_phy_get function
- the new exported function of_phy_get was changed to take the phy's name as a
  parameter instead of the index
2) phy: core: Add devm_of_phy_get to phy-core
- fixes made in the comments to devm_of_phy_get
3) phy: Add new Exynos USB PHY driver
- move the documentation from a new to an existing file - samsung-phy.txt
- fix typos and uppercase hex addresses
- add more explanations to Kconfig (checkpatch still complains, but I find it
  hard to think what else could I add)
- add selects MFD_SYSCON as the driver needs it (Thank you, Tobias!)
- cleanup included headers in both *.c and .h files
- use BIT(x) macro instead of (1  x)
- replaced HOST and DEV with PHY0 and PHY1 in phy-exynos4212-usb2.c, the
  registers are described as PHYx in the documentation hence the decision to
  leave the PHYx naming
- fixed typo in exynos4210_rate_to_clk reg - *reg
- change hax_mode_switch and enabled type to bool
4) usb: ehci-s5p: Change to use phy provided by the generic phy framework
- Put the issue of phy-otg in order - since the new phy driver does not provide
  this field. With the new driver the switch between host and device is done in
  power_on of the respective host and device phys.
5) usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy
   framework
- fixed the example in the documentation
6) phy: Add support for S5PV210 to the Exynos USB PHY driver
- include files cleanup
- use BIT(x) macro instead of (1  x)
7) phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
- include files cleanup
- use BIT(x) macro instead of (1  x)
8) dts: Add usb2phy to Exynos 4
- no changes
9) dts: Add usb2phy to Exynos 5250
- no changes


Changes from v3:
- using PMU and system registers indirectly via syscon
- change labelling
- change Kconfig name
- fixed typos/stray whitespace
- move of_phy_provider_register() to the end of probe
- add a regular error return code to the rate_to_clk functions
- cleanup code and remove unused code
- change struct names to avoid collisions
- add mechanism to support multiple phys by the ehci driver


Changes from v2:
- rebase all patches to the usb-next branch
- fixes in the documentation file
  - remove wrong entries in the phy node (ranges, and #address-  #size-cells)
  - add clocks and clock-names as required properites
  - rephrase a few sentences
- fixes in the ehci-exynos.c file
  - move phy_name variable next to phy in exynos_ehci_hcd
  - remove otg from exynos_ehci_hcd as it was no longer used
  - move devm_phy_get after the Exynos5440 skip_phy check
- fixes in the s3c-hsotg.c file
  - cosmetic fixes (remove empty line that was wrongfully added)
- fixes in the main driver
  - remove cpu_type in favour for a boolean flag matched with the compatible
value
  - rename files, structures, variables and Kconfig entires - change from simple
uphy to usb2_phy
  - fix multiline comments style
  - simplify #ifdefs in of_device_id
  - fix Kconfig description
  - change dev_info to dev_dbg where reasonable
  - cosmetic changes (remove wrongful blank lines)
  - remove unnecessary reference counting


Changes from v1:
- the changes include minor fixes of the hardware initialization of the PHY
  module
- some other minor fixes were introduced

--
Original cover letter:

Hi,

This patch adds a new drive for USB PHYs for Samsung SoCs. The driver is
using the Generic PHY Framework created by Kishon Vijay Abrahan I. It
can be found here https://lkml.org/lkml/2013/8/21/29. This patch adds
support to Exynos4 family of SoCs. Support for Exynos3 and Exynos5 is
planned to be added in the near future.

I welcome your comments.

--

[1] https://lkml.org/lkml/2013/8/21/29

Kamil Debski (8):
  phy: core: Add an exported of_phy_get function
  phy: core: Add devm_of_phy_get to phy-core
  phy: Add new Exynos USB PHY driver
  usb: ehci-s5p: Change to use phy provided by the generic phy
framework
  usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic

[PATCH v5 6/9] phy: Add support for S5PV210 to the Exynos USB 2.0 PHY driver

2013-12-20 Thread Kamil Debski
From: Mateusz Krawczuk mat.krawc...@gmail.com

Add support for the Samsung's S5PV210 SoC to the Exynos USB 2.0 PHY driver.

Signed-off-by: Mateusz Krawczuk m.krawc...@partner.samsung.com
[k.deb...@samsung.com: cleanup and commit description]
[k.deb...@samsung.com: make changes accordingly to the mailing list
comments]
Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|1 +
 drivers/phy/Kconfig|   10 +
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-s5pv210-usb2.c |  199 
 drivers/phy/phy-samsung-usb2.c |6 +
 drivers/phy/phy-samsung-usb2.h |1 +
 6 files changed, 218 insertions(+)
 create mode 100644 drivers/phy/phy-s5pv210-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index 39d52cc..eb40460 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -26,6 +26,7 @@ Samsung S5P/EXYNOS SoC series USB PHY
 
 Required properties:
 - compatible : should be one of the listed compatibles:
+   - samsung,s5pv210-usb2-phy
- samsung,exynos4210-usb2-phy
- samsung,exynos4212-usb2-phy
 - reg : a list of registers used by phy driver
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 8e5cce1..b2c51ce 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -61,6 +61,16 @@ config PHY_SAMSUNG_USB2
  particular SoCs has to be enabled in addition to this driver. Number
  and type of supported phys depends on the SoC.
 
+config PHY_S5PV210_USB2
+   bool Support for S5PV210
+   depends on PHY_SAMSUNG_USB2
+   depends on ARCH_S5PV210
+   help
+ Enable USB PHY support for S5PV210. This option requires that Samsung
+ USB 2.0 PHY driver is enabled and means that support for this
+ particular SoC is compiled in the driver. In case of S5PV210 two phys
+ are available - device and host.
+
 config PHY_EXYNOS4210_USB2
bool Support for Exynos 4210
depends on PHY_SAMSUNG_USB2
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9f4befd..fefc6c2 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -8,5 +8,6 @@ obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += 
phy-exynos-mipi-video.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
 obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
 obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o
+obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4210_USB2)  += phy-exynos4210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4212_USB2)  += phy-exynos4212-usb2.o
diff --git a/drivers/phy/phy-s5pv210-usb2.c b/drivers/phy/phy-s5pv210-usb2.c
new file mode 100644
index 000..58797a7
--- /dev/null
+++ b/drivers/phy/phy-s5pv210-usb2.c
@@ -0,0 +1,199 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - S5PV210 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Authors: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/phy/phy.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+
+/* PHY power control */
+#define S5PV210_UPHYPWR0x0
+
+#define S5PV210_UPHYPWR_PHY0_SUSPEND   BIT(0)
+#define S5PV210_UPHYPWR_PHY0_PWR   BIT(3)
+#define S5PV210_UPHYPWR_PHY0_OTG_PWR   BIT(4)
+#define S5PV210_UPHYPWR_PHY0   ( \
+   S5PV210_UPHYPWR_PHY0_SUSPEND | \
+   S5PV210_UPHYPWR_PHY0_PWR | \
+   S5PV210_UPHYPWR_PHY0_OTG_PWR)
+
+#define S5PV210_UPHYPWR_PHY1_SUSPEND   BIT(6)
+#define S5PV210_UPHYPWR_PHY1_PWR   BIT(7)
+#define S5PV210_UPHYPWR_PHY1 ( \
+   S5PV210_UPHYPWR_PHY1_SUSPEND | \
+   S5PV210_UPHYPWR_PHY1_PWR)
+
+/* PHY clock control */
+#define S5PV210_UPHYCLK0x4
+
+#define S5PV210_UPHYCLK_PHYFSEL_MASK   (0x3  0)
+#define S5PV210_UPHYCLK_PHYFSEL_48MHZ  (0x0  0)
+#define S5PV210_UPHYCLK_PHYFSEL_24MHZ  (0x3  0)
+#define S5PV210_UPHYCLK_PHYFSEL_12MHZ  (0x2  0)
+
+#define S5PV210_UPHYCLK_PHY0_ID_PULLUP BIT(2)
+#define S5PV210_UPHYCLK_PHY0_COMMON_ON BIT(4)
+#define S5PV210_UPHYCLK_PHY1_COMMON_ON BIT(7)
+
+/* PHY reset control */
+#define S5PV210_UPHYRST0x8
+
+#define S5PV210_URSTCON_PHY0   BIT(0)
+#define S5PV210_URSTCON_OTG_HLINK  BIT(1)
+#define S5PV210_URSTCON_OTG_PHYLINKBIT(2)
+#define S5PV210_URSTCON_PHY1_ALL   BIT(3)
+#define S5PV210_URSTCON_HOST_LINK_ALL  BIT(4)
+
+/* Isolation, configured in the power management unit */
+#define S5PV210_USB_ISOL_DEVICE_OFFSET 0x704
+#define

[PATCH RFC alternative ver 1] phy: Exynos 421x USB 2.0 PHY support

2013-12-20 Thread Kamil Debski
This the alternative version of the support for Exynos 421x USB 2.0 PHY
in the Generic PHY framework. In this version the support for Exynos
4210 and 4212 was joined into one file.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
Hi,

Me and Kishon were discussing for quite a long time the way how Exynos 4
should be handled. I have decided to post the original patches and try
to make an alternative version with support for Exynos 4210 and 4212 joined
in one file. I have prepared two versions. The first one has 506 lines (vs
563 when two files are used). When doing the second version I was a little
more aggresive in removing code. This was done at a cost of adding if's
deciding which SoC version the driver is dealing with in some internal 
functions.
This resulted in a better number of removed lines - the second version has
only 452 lines (vs 563 original and 506 version 1).

Personally I like the original approach. One of my goals was to create a driver
that would be clear and easy to understand. I see that this was done at a cost 
of
having the code a little longer.

The first alternative version mostly was done by removing duplicate defines of
register values. The code clarity suffers a bit, but is still acceptable in my
opinion.

As to the second alternative version. It has the fewest lines, but I am not an
enthusiast of using if this is SoC in functions.

Anyway - please have a look at these two alternative versions in addition to
looking at the original patch phy: Add new Exynos USB PHY driver.

Best wishes,
Kamil Debski
---
 drivers/phy/phy-exynos4212-usb2.c |  506 +
 1 file changed, 506 insertions(+)
 create mode 100644 drivers/phy/phy-exynos4212-usb2.c

diff --git a/drivers/phy/phy-exynos4212-usb2.c 
b/drivers/phy/phy-exynos4212-usb2.c
new file mode 100644
index 000..3fa22d0
--- /dev/null
+++ b/drivers/phy/phy-exynos4212-usb2.c
@@ -0,0 +1,506 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 4210 and 4212 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/phy/phy.h
+#include linux/regmap.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+
+/* PHY power control */
+#define EXYNOS_421x_UPHYPWR0x0
+
+#define EXYNOS_421x_UPHYPWR_PHY0_SUSPEND   BIT(0)
+#define EXYNOS_421x_UPHYPWR_PHY0_PWR   BIT(3)
+#define EXYNOS_421x_UPHYPWR_PHY0_OTG_PWR   BIT(4)
+#define EXYNOS_421x_UPHYPWR_PHY0_SLEEP BIT(5)
+#define EXYNOS_421x_UPHYPWR_PHY0 ( \
+   EXYNOS_421x_UPHYPWR_PHY0_SUSPEND | \
+   EXYNOS_421x_UPHYPWR_PHY0_PWR | \
+   EXYNOS_421x_UPHYPWR_PHY0_OTG_PWR | \
+   EXYNOS_421x_UPHYPWR_PHY0_SLEEP)
+
+#define EXYNOS_421x_UPHYPWR_PHY1_SUSPEND   BIT(6)
+#define EXYNOS_421x_UPHYPWR_PHY1_PWR   BIT(7)
+#define EXYNOS_421x_UPHYPWR_PHY1_SLEEP BIT(8)
+#define EXYNOS_421x_UPHYPWR_PHY1 ( \
+   EXYNOS_421x_UPHYPWR_PHY1_SUSPEND | \
+   EXYNOS_421x_UPHYPWR_PHY1_PWR | \
+   EXYNOS_421x_UPHYPWR_PHY1_SLEEP)
+
+#define EXYNOS_4210_UPHYPWR_HSCI0_SUSPEND  BIT(9)
+#define EXYNOS_4210_UPHYPWR_HSCI0_SLEEPBIT(10)
+#define EXYNOS_4210_UPHYPWR_HSCI0 ( \
+   EXYNOS_4210_UPHYPWR_HSCI0_SUSPEND | \
+   EXYNOS_4210_UPHYPWR_HSCI0_SLEEP)
+
+#define EXYNOS_4210_UPHYPWR_HSCI1_SUSPEND  BIT(11)
+#define EXYNOS_4210_UPHYPWR_HSCI1_SLEEPBIT(12)
+#define EXYNOS_4210_UPHYPWR_HSCI1 ( \
+   EXYNOS_4210_UPHYPWR_HSCI1_SUSPEND | \
+   EXYNOS_4210_UPHYPWR_HSCI1_SLEEP)
+
+#define EXYNOS_4212_UPHYPWR_HSCI0_SUSPEND  BIT(9)
+#define EXYNOS_4212_UPHYPWR_HSCI0_PWR  BIT(10)
+#define EXYNOS_4212_UPHYPWR_HSCI0_SLEEPBIT(11)
+#define EXYNOS_4212_UPHYPWR_HSCI0 ( \
+   EXYNOS_4212_UPHYPWR_HSCI0_SUSPEND | \
+   EXYNOS_4212_UPHYPWR_HSCI0_PWR | \
+   EXYNOS_4212_UPHYPWR_HSCI0_SLEEP)
+
+#define EXYNOS_4212_UPHYPWR_HSCI1_SUSPEND  BIT(12)
+#define EXYNOS_4212_UPHYPWR_HSCI1_PWR  BIT(13)
+#define EXYNOS_4212_UPHYPWR_HSCI1_SLEEPBIT(14)
+#define EXYNOS_4212_UPHYPWR_HSCI1 ( \
+   EXYNOS_4212_UPHYPWR_HSCI1_SUSPEND | \
+   EXYNOS_4212_UPHYPWR_HSCI1_PWR | \
+   EXYNOS_4212_UPHYPWR_HSCI1_SLEEP)
+
+/* PHY clock control */
+#define EXYNOS_421x_UPHYCLK0x4
+
+#define EXYNOS_421x_UPHYCLK_PHY0_COMMON_ON BIT(4)
+#define EXYNOS_421x_UPHYCLK_PHY1_COMMON_ON BIT(7)
+
+#define EXYNOS_4210_UPHYCLK_PHYFSEL_MASK   (0x3  0)
+#define EXYNOS_4210_UPHYCLK_PHYFSEL_48MHZ  (0x0  0)
+#define EXYNOS_4210_UPHYCLK_PHYFSEL_24MHZ  (0x3  0)
+#define EXYNOS_4210_UPHYCLK_PHYFSEL_12MHZ  (0x2  0)
+
+#define EXYNOS_4210_UPHYCLK_PHY0_ID_PULLUP BIT(2)
+
+#define

[PATCH RFC alternative ver 2] phy: Exynos 421x USB 2.0 PHY support

2013-12-20 Thread Kamil Debski
This the alternative version of the support for Exynos 421x USB 2.0 PHY
in the Generic PHY framework. In this version the support for Exynos
4210 and 4212 was joined into one file.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
Hi,

This is the second alternative version. Please look at
[PATCH RFC alternative ver 1] phy: Exynos 421x USB 2.0 PHY support for
detailed description.

Best wishes,
Kamil Debski
---
 drivers/phy/phy-exynos4212-usb2.c |  452 +
 drivers/phy/phy-samsung-usb2.h|1 +
 2 files changed, 453 insertions(+)
 create mode 100644 drivers/phy/phy-exynos4212-usb2.c

diff --git a/drivers/phy/phy-exynos4212-usb2.c 
b/drivers/phy/phy-exynos4212-usb2.c
new file mode 100644
index 000..8f7578a
--- /dev/null
+++ b/drivers/phy/phy-exynos4212-usb2.c
@@ -0,0 +1,452 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 4210 and 4212 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/phy/phy.h
+#include linux/regmap.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+
+/* PHY power control */
+#define EXYNOS_421x_UPHYPWR0x0
+
+#define EXYNOS_421x_UPHYPWR_PHY0_SUSPEND   BIT(0)
+#define EXYNOS_421x_UPHYPWR_PHY0_PWR   BIT(3)
+#define EXYNOS_421x_UPHYPWR_PHY0_OTG_PWR   BIT(4)
+#define EXYNOS_421x_UPHYPWR_PHY0_SLEEP BIT(5)
+#define EXYNOS_421x_UPHYPWR_PHY0 ( \
+   EXYNOS_421x_UPHYPWR_PHY0_SUSPEND | \
+   EXYNOS_421x_UPHYPWR_PHY0_PWR | \
+   EXYNOS_421x_UPHYPWR_PHY0_OTG_PWR | \
+   EXYNOS_421x_UPHYPWR_PHY0_SLEEP)
+
+#define EXYNOS_421x_UPHYPWR_PHY1_SUSPEND   BIT(6)
+#define EXYNOS_421x_UPHYPWR_PHY1_PWR   BIT(7)
+#define EXYNOS_421x_UPHYPWR_PHY1_SLEEP BIT(8)
+#define EXYNOS_421x_UPHYPWR_PHY1 ( \
+   EXYNOS_421x_UPHYPWR_PHY1_SUSPEND | \
+   EXYNOS_421x_UPHYPWR_PHY1_PWR | \
+   EXYNOS_421x_UPHYPWR_PHY1_SLEEP)
+
+#define EXYNOS_4210_UPHYPWR_HSCI0_SUSPEND  BIT(9)
+#define EXYNOS_4210_UPHYPWR_HSCI0_SLEEPBIT(10)
+#define EXYNOS_4210_UPHYPWR_HSCI0 ( \
+   EXYNOS_4210_UPHYPWR_HSCI0_SUSPEND | \
+   EXYNOS_4210_UPHYPWR_HSCI0_SLEEP)
+
+#define EXYNOS_4210_UPHYPWR_HSCI1_SUSPEND  BIT(11)
+#define EXYNOS_4210_UPHYPWR_HSCI1_SLEEPBIT(12)
+#define EXYNOS_4210_UPHYPWR_HSCI1 ( \
+   EXYNOS_4210_UPHYPWR_HSCI1_SUSPEND | \
+   EXYNOS_4210_UPHYPWR_HSCI1_SLEEP)
+
+#define EXYNOS_4212_UPHYPWR_HSCI0_SUSPEND  BIT(9)
+#define EXYNOS_4212_UPHYPWR_HSCI0_PWR  BIT(10)
+#define EXYNOS_4212_UPHYPWR_HSCI0_SLEEPBIT(11)
+#define EXYNOS_4212_UPHYPWR_HSCI0 ( \
+   EXYNOS_4212_UPHYPWR_HSCI0_SUSPEND | \
+   EXYNOS_4212_UPHYPWR_HSCI0_PWR | \
+   EXYNOS_4212_UPHYPWR_HSCI0_SLEEP)
+
+#define EXYNOS_4212_UPHYPWR_HSCI1_SUSPEND  BIT(12)
+#define EXYNOS_4212_UPHYPWR_HSCI1_PWR  BIT(13)
+#define EXYNOS_4212_UPHYPWR_HSCI1_SLEEPBIT(14)
+#define EXYNOS_4212_UPHYPWR_HSCI1 ( \
+   EXYNOS_4212_UPHYPWR_HSCI1_SUSPEND | \
+   EXYNOS_4212_UPHYPWR_HSCI1_PWR | \
+   EXYNOS_4212_UPHYPWR_HSCI1_SLEEP)
+
+/* PHY clock control */
+#define EXYNOS_421x_UPHYCLK0x4
+
+#define EXYNOS_421x_UPHYCLK_PHY0_COMMON_ON BIT(4)
+#define EXYNOS_421x_UPHYCLK_PHY1_COMMON_ON BIT(7)
+
+#define EXYNOS_4210_UPHYCLK_PHYFSEL_MASK   (0x3  0)
+#define EXYNOS_4210_UPHYCLK_PHYFSEL_48MHZ  (0x0  0)
+#define EXYNOS_4210_UPHYCLK_PHYFSEL_24MHZ  (0x3  0)
+#define EXYNOS_4210_UPHYCLK_PHYFSEL_12MHZ  (0x2  0)
+
+#define EXYNOS_4210_UPHYCLK_PHY0_ID_PULLUP BIT(2)
+
+#define EXYNOS_4212_UPHYCLK_PHYFSEL_MASK   (0x7  0)
+#define EXYNOS_4212_UPHYCLK_PHYFSEL_9MHZ6  (0x0  0)
+#define EXYNOS_4212_UPHYCLK_PHYFSEL_10MHZ  (0x1  0)
+#define EXYNOS_4212_UPHYCLK_PHYFSEL_12MHZ  (0x2  0)
+#define EXYNOS_4212_UPHYCLK_PHYFSEL_19MHZ2 (0x3  0)
+#define EXYNOS_4212_UPHYCLK_PHYFSEL_20MHZ  (0x4  0)
+#define EXYNOS_4212_UPHYCLK_PHYFSEL_24MHZ  (0x5  0)
+#define EXYNOS_4212_UPHYCLK_PHYFSEL_50MHZ  (0x7  0)
+
+#define EXYNOS_4212_UPHYCLK_PHY0_ID_PULLUP BIT(3)
+
+#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_MASK   (0x7f  10)
+#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_12MHZ  (0x24  10)
+#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_15MHZ  (0x1c  10)
+#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_16MHZ  (0x1a  10)
+#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_19MHZ2 (0x15  10)
+#define EXYNOS_4212_UPHYCLK_HSIC_REFCLK_20MHZ  (0x14  10)
+
+/* PHY reset control */
+#define EXYNOS_421x_UPHYRST0x8
+
+#define EXYNOS_421x_URSTCON_PHY0   BIT(0)
+#define EXYNOS_421x_URSTCON_OTG_HLINK  BIT(1)
+#define EXYNOS_421x_URSTCON_OTG_PHYLINKBIT

[PATCH v2 9/9] dts: Add usb2phy to Exynos 5250

2013-12-20 Thread Kamil Debski
Add support to PHY of USB2 of the Exynos 5250 SoC.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 arch/arm/boot/dts/exynos5250.dtsi |   33 ---
 drivers/phy/phy-exynos5250-usb2.c |   64 +
 2 files changed, 78 insertions(+), 19 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index 2f264ad..922e0ed 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -163,6 +163,11 @@
interrupts = 0 47 0;
};
 
+   sys_syscon: syscon@1004 {
+   compatible = samsung,exynos5250-sys, syscon;
+   reg = 0x1005 0x5000;
+   };
+
pmu_syscon: syscon@1004 {
compatible = samsung,exynos5250-pmu, syscon;
reg = 0x1004 0x5000;
@@ -505,6 +510,14 @@
 
clocks = clock 285;
clock-names = usbhost;
+   #address-cells = 1;
+   #size-cells = 0;
+   port@0 {
+   reg = 0;
+   phys = usb2_phy 1;
+   phy-names = host;
+   status = ok;
+   };
};
 
usb@1212 {
@@ -516,19 +529,15 @@
clock-names = usbhost;
};
 
-   usb2_phy: usbphy@1213 {
-   compatible = samsung,exynos5250-usb2phy;
+   usb2_phy: phy@1213 {
+   compatible = samsung,exynos5250-usb2-phy;
reg = 0x1213 0x100;
-   clocks = clock 1, clock 285;
-   clock-names = ext_xtal, usbhost;
-   #address-cells = 1;
-   #size-cells = 1;
-   ranges;
-
-   usbphy-sys {
-   reg = 0x10040704 0x8,
- 0x10050230 0x4;
-   };
+   clocks = clock 285, clock 1, clock 1, clock 1,
+   clock 1;
+   clock-names = phy, device, host, hsic0, hsic1;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_syscon;
+   samsung,pmureg-phandle = pmu_syscon;
};
 
amba {
diff --git a/drivers/phy/phy-exynos5250-usb2.c 
b/drivers/phy/phy-exynos5250-usb2.c
index b9b3b98..337bf82 100644
--- a/drivers/phy/phy-exynos5250-usb2.c
+++ b/drivers/phy/phy-exynos5250-usb2.c
@@ -58,7 +58,13 @@
 #define EXYNOS_5250_HOSTPHYCTRL2   0x20
 
 #define EXYNOS_5250_HOSTPHYCTRLX_REFCLKSEL_MASK(0x3  23)
+#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKSEL_DEFAULT (0x2  23)
 #define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_MASK(0x7f  16)
+#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_12  (0x24  16)
+#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_15  (0x1c  16)
+#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_16  (0x1a  16)
+#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_19_2(0x15  16)
+#define EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_20  (0x14  16)
 #define EXYNOS_5250_HOSTPHYCTRLX_SIDDQ BIT(6)
 #define EXYNOS_5250_HOSTPHYCTRLX_FORCESLEEPBIT(5)
 #define EXYNOS_5250_HOSTPHYCTRLX_FORCESUSPEND  BIT(4)
@@ -191,13 +197,14 @@ static void exynos5250_isol(struct 
samsung_usb2_phy_instance *inst, bool on)
regmap_update_bits(drv-reg_pmu, offset, mask, on ? 0 : mask);
 }
 
-static void exynos5250_phy_pwr(struct samsung_usb2_phy_instance *inst, bool on)
+static int exynos5250_power_on(struct samsung_usb2_phy_instance *inst)
 {
struct samsung_usb2_phy_driver *drv = inst-drv;
u32 ctrl0;
u32 otg;
u32 ehci;
u32 ohci;
+   u32 hsic;
 
switch (inst-cfg-id) {
case EXYNOS5250_DEVICE:
@@ -234,6 +241,8 @@ static void exynos5250_phy_pwr(struct 
samsung_usb2_phy_instance *inst, bool on)
 
break;
case EXYNOS5250_HOST:
+   case EXYNOS5250_HSIC0:
+   case EXYNOS5250_HSIC1:
/* Host registers configuration */
ctrl0 = readl(drv-reg_phy + EXYNOS_5250_HOSTPHYCTRL0);
/* The clock */
@@ -279,6 +288,18 @@ static void exynos5250_phy_pwr(struct 
samsung_usb2_phy_instance *inst, bool on)
EXYNOS_5250_USBOTGSYS_LINK_SW_RST_UOTG |
EXYNOS_5250_USBOTGSYS_PHYLINK_SW_RESET);
 
+   /* HSIC phy configuration */
+   hsic = (EXYNOS_5250_HOSTPHYCTRLX_REFCLKDIV_12 |
+   EXYNOS_5250_HOSTPHYCTRLX_REFCLKSEL_DEFAULT |
+   EXYNOS_5250_HOSTPHYCTRLX_PHYSWRST);
+   writel(hsic, drv-reg_phy + EXYNOS_5250_HOSTPHYCTRL1);
+   writel(hsic, drv-reg_phy + EXYNOS_5250_HOSTPHYCTRL2);
+   udelay(10);
+   hsic = ~EXYNOS_5250_HOSTPHYCTRLX_PHYSWRST;
+   writel(hsic, drv-reg_phy + EXYNOS_5250_HOSTPHYCTRL1);
+   writel

[PATCH v5 7/9] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver

2013-12-20 Thread Kamil Debski
Add support for Exynos 5250. This driver is to replace the old
USB 2.0 PHY driver.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/phy/samsung-phy.txt|1 +
 drivers/phy/Kconfig|   11 +
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-exynos5250-usb2.c  |  356 
 drivers/phy/phy-samsung-usb2.c |6 +
 drivers/phy/phy-samsung-usb2.h |1 +
 6 files changed, 376 insertions(+)
 create mode 100644 drivers/phy/phy-exynos5250-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index eb40460..afc47c2 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -29,6 +29,7 @@ Required properties:
- samsung,s5pv210-usb2-phy
- samsung,exynos4210-usb2-phy
- samsung,exynos4212-usb2-phy
+   - samsung,exynos5250-usb2-phy
 - reg : a list of registers used by phy driver
- first and obligatory is the location of phy modules registers
 - samsung,sysreg-phandle - handle to syscon used to control the system 
registers
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index b2c51ce..726410f 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -90,4 +90,15 @@ config PHY_EXYNOS4212_USB2
  Samsung USB 2.0 PHY driver is enabled and means that support for this
  particular SoC is compiled in the driver. In case of Exynos 4212 four
  phys are available - device, host, HSIC0 and HSIC1.
+
+config PHY_EXYNOS5250_USB2
+   bool Support for Exynos 5250
+   depends on PHY_SAMSUNG_USB2
+   depends on SOC_EXYNOS5250
+   help
+ Enable USB PHY support for Exynos 5250. This option requires that
+ Samsung USB 2.0 PHY driver is enabled and means that support for this
+ particular SoC is compiled in the driver. In case of Exynos 5250 four
+ phys are available - device, host, HSIC0 and HSIC.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index fefc6c2..33c3ac1 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_PHY_SAMSUNG_USB2)+= 
phy-samsung-usb2.o
 obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4210_USB2)  += phy-exynos4210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4212_USB2)  += phy-exynos4212-usb2.o
+obj-$(CONFIG_PHY_EXYNOS5250_USB2)  += phy-exynos5250-usb2.o
diff --git a/drivers/phy/phy-exynos5250-usb2.c 
b/drivers/phy/phy-exynos5250-usb2.c
new file mode 100644
index 000..b9b3b98
--- /dev/null
+++ b/drivers/phy/phy-exynos5250-usb2.c
@@ -0,0 +1,356 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/phy/phy.h
+#include linux/regmap.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+#define EXYNOS_5250_REFCLKSEL_CRYSTAL  0x0
+#define EXYNOS_5250_REFCLKSEL_XO   0x1
+#define EXYNOS_5250_REFCLKSEL_CLKCORE  0x2
+
+#define EXYNOS_5250_FSEL_9MHZ6 0x0
+#define EXYNOS_5250_FSEL_10MHZ 0x1
+#define EXYNOS_5250_FSEL_12MHZ 0x2
+#define EXYNOS_5250_FSEL_19MHZ20x3
+#define EXYNOS_5250_FSEL_20MHZ 0x4
+#define EXYNOS_5250_FSEL_24MHZ 0x5
+#define EXYNOS_5250_FSEL_50MHZ 0x7
+
+/* Normal host */
+#define EXYNOS_5250_HOSTPHYCTRL0   0x0
+
+#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL   BIT(31)
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT   19
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\
+   (0x3  EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \
+   (0x7  EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNINBIT(11)
+#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE BIT(10)
+#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N   BIT(9)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST  (0x2  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ BIT(6)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEPBIT(5)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND

[PATCH v5 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework

2013-12-20 Thread Kamil Debski
Change the used phy driver to the new Exynos USB phy driver that uses the
generic phy framework.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/usb/samsung-hsotg.txt  |4 
 drivers/usb/gadget/s3c-hsotg.c |   11 ++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt 
b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
index b83d428..75edb9d 100644
--- a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
+++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
@@ -24,6 +24,8 @@ Required properties:
 - first entry: must be otg
 - vusb_d-supply: phandle to voltage regulator of digital section,
 - vusb_a-supply: phandle to voltage regulator of analog section.
+- phys: from general PHY binding: phandle to the PHY device
+- phy-names: from general PHY binding: should be usb2-phy
 
 Example
 -
@@ -36,5 +38,7 @@ Example
clock-names = otg;
vusb_d-supply = vusb_reg;
vusb_a-supply = vusbdac_reg;
+   phys = usb2phy 0;
+   phy-names = usb2-phy;
};
 
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 7aedaaf..a05c2f9 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -31,6 +31,7 @@
 #include linux/regulator/consumer.h
 #include linux/of.h
 #include linux/of_platform.h
+#include linux/phy/phy.h
 
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
@@ -162,7 +163,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
-   struct usb_phy  *phy;
+   struct phy   *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2910,7 +2911,7 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
 
if (hsotg-phy)
-   usb_phy_init(hsotg-phy);
+   phy_power_on(hsotg-phy);
else if (hsotg-plat-phy_init)
hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);
 }
@@ -2927,7 +2928,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg-dev);
 
if (hsotg-phy)
-   usb_phy_shutdown(hsotg-phy);
+   phy_power_off(hsotg-phy);
else if (hsotg-plat-phy_exit)
hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);
 }
@@ -3534,7 +3535,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg 
*hsotg)
 static int s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev);
-   struct usb_phy *phy;
+   struct phy *phy;
struct device *dev = pdev-dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3549,7 +3550,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   phy = devm_phy_get(pdev-dev, usb2-phy);
if (IS_ERR(phy)) {
/* Fallback for pdata */
plat = dev_get_platdata(pdev-dev);
-- 
1.7.9.5

--
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 v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework

2013-12-17 Thread Kamil Debski
Hi Matt,

I am afraid it is not possible. This patch cannot go in without the 
new  phy driver. It would break Exynos USB functionality. This
is because it changes s3c-hsotg to use the new phy driver.

I am working on an updated patch series addressing all the comments.
time permitting I want to post an alternative version - integrating
as much as possible in a single file. This way it would be possible
to have a hands-on comparison of the two approaches we were
discussing with Kishon. 

I estimate that I post it this week.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


 -Original Message-
 From: Matt Porter [mailto:mpor...@linaro.org]
 Sent: Monday, December 16, 2013 10:40 PM
 To: Kamil Debski
 Cc: linux-ker...@vger.kernel.org; linux-samsung-...@vger.kernel.org;
 linux-usb@vger.kernel.org; devicet...@vger.kernel.org;
 kyungmin.p...@samsung.com; kis...@ti.com; t.f...@samsung.com;
 s.nawro...@samsung.com; m.szyprow...@samsung.com;
 gautam.vi...@samsung.com; mat.krawc...@gmail.com;
 yulgon@samsung.com; p.pan...@samsung.com; av.tikhomi...@samsung.com;
 jg1@samsung.com; ga...@codeaurora.org; Felipe Balbi
 Subject: Re: [PATCH v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy
 driver with the generic phy framework
 
 On Thu, Dec 05, 2013 at 01:29:35PM +0100, Kamil Debski wrote:
  Change the used phy driver to the new Exynos USB phy driver that uses
  the generic phy framework.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   .../devicetree/bindings/usb/samsung-hsotg.txt  |4 
   drivers/usb/gadget/s3c-hsotg.c |   11 ++
 -
   2 files changed, 10 insertions(+), 5 deletions(-)
 
 Kamil,
 
 Can we separate this patch out of this series? My bcm281xx series is
 ready to go except for this dependency. Felipe has noted that there's
 only a week until he locks his tree down for 3.14 [1]. I'm willing to
 update this versus the comment Kishon made on fixing the example if you
 don't have time before then. Let me know.
 
 [1] https://lkml.org/lkml/2013/12/16/555
 
 Thanks,
 Matt
 
  diff --git a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
  b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
  index b83d428..9340d06 100644
  --- a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
  +++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
  @@ -24,6 +24,8 @@ Required properties:
   - first entry: must be otg
   - vusb_d-supply: phandle to voltage regulator of digital section,
   - vusb_a-supply: phandle to voltage regulator of analog section.
  +- phys: from general PHY binding: phandle to the PHY device
  +- phy-names: from general PHY binding: should be usb2-phy
 
   Example
   -
  @@ -36,5 +38,7 @@ Example
  clock-names = otg;
  vusb_d-supply = vusb_reg;
  vusb_a-supply = vusbdac_reg;
  +   phys = usb2phy 0;
  +   phy-names = device;
  };
 
  diff --git a/drivers/usb/gadget/s3c-hsotg.c
  b/drivers/usb/gadget/s3c-hsotg.c index eccb147..db096fd 100644
  --- a/drivers/usb/gadget/s3c-hsotg.c
  +++ b/drivers/usb/gadget/s3c-hsotg.c
  @@ -31,6 +31,7 @@
   #include linux/regulator/consumer.h  #include linux/of.h
  #include linux/of_platform.h
  +#include linux/phy/phy.h
 
   #include linux/usb/ch9.h
   #include linux/usb/gadget.h
  @@ -162,7 +163,7 @@ struct s3c_hsotg_ep {  struct s3c_hsotg {
  struct device*dev;
  struct usb_gadget_driver *driver;
  -   struct usb_phy  *phy;
  +   struct phy   *phy;
  struct s3c_hsotg_plat*plat;
 
  spinlock_t  lock;
  @@ -2905,7 +2906,7 @@ static void s3c_hsotg_phy_enable(struct
 s3c_hsotg *hsotg)
  dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
 
  if (hsotg-phy)
  -   usb_phy_init(hsotg-phy);
  +   phy_power_on(hsotg-phy);
  else if (hsotg-plat-phy_init)
  hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);  } @@ -
 2922,7
  +2923,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
  struct platform_device *pdev = to_platform_device(hsotg-dev);
 
  if (hsotg-phy)
  -   usb_phy_shutdown(hsotg-phy);
  +   phy_power_off(hsotg-phy);
  else if (hsotg-plat-phy_exit)
  hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);  } @@ -
 3529,7
  +3530,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg)
  static int s3c_hsotg_probe(struct platform_device *pdev)  {
  struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev);
  -   struct usb_phy *phy;
  +   struct phy *phy;
  struct device *dev = pdev-dev;
  struct s3c_hsotg_ep *eps;
  struct s3c_hsotg *hsotg;
  @@ -3544,7 +3545,7 @@ static int s3c_hsotg_probe(struct
 platform_device *pdev)
  return -ENOMEM;
  }
 
  -   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
  +   phy = devm_phy_get(pdev-dev, usb2-phy);
  if (IS_ERR(phy

RE: [PATCH v4 3/9] phy: Add new Exynos USB PHY driver

2013-12-17 Thread Kamil Debski
Hi Anton,

 From: Anton Tikhomirov [mailto:av.tikhomi...@samsung.com]
 Sent: Tuesday, December 10, 2013 3:43 AM
 
 Hi Kamil,
 
 Same USB2.0 PHY may be used by several HCDs, for example EHCI and OHCI.
 Consider the situation, when EHCI stops using the PHY and calls
 power_off, then OHCI becomes non-operational. In other words, PHY
 power_on and power_off calls must be balanced.
 
 Shall we handle it in your driver? (usage count?)

Please look in the drivers/phy/phy-core.c file. Usage count is handled
there - see phy_power_on and phy_power_off functions. I understand that
after both EHCI and OHCI power on the phy, the usage count is 2. So
powering off one of them (EHCI for instance) the usage count is still
1, so the OHCI should still work properly.

[snip]

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


--
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 1/2] phy: core: Add an exported of_phy_get function

2013-12-16 Thread Kamil Debski
Previously the of_phy_get function took a struct device * and
was declared static. It was impossible to call it from
another driver and thus it was impossible to get phy defined
for a given node. The old function was renamed to _of_phy_get
and was left for internal use. of_phy_get function was added
and it was exported. The function enables to get a phy for
a given device tree node.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   45 -
 include/linux/phy/phy.h |1 +
 2 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 03cf8fb..0107f71 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -240,8 +240,8 @@ out:
 EXPORT_SYMBOL_GPL(phy_power_off);
 
 /**
- * of_phy_get() - lookup and obtain a reference to a phy by phandle
- * @dev: device that requests this phy
+ * _of_phy_get() - lookup and obtain a reference to a phy by phandle
+ * @np: device_node for which to get the phy
  * @index: the index of the phy
  *
  * Returns the phy associated with the given phandle value,
@@ -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
  * not yet loaded. This function uses of_xlate call back function provided
  * while registering the phy_provider to find the phy instance.
  */
-static struct phy *of_phy_get(struct device *dev, int index)
+static struct phy *_of_phy_get(struct device_node *np, int index)
 {
int ret;
struct phy_provider *phy_provider;
struct phy *phy = NULL;
struct of_phandle_args args;
 
-   ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells,
+   ret = of_parse_phandle_with_args(np, phys, #phy-cells,
index, args);
-   if (ret) {
-   dev_dbg(dev, failed to get phy in %s node\n,
-   dev-of_node-full_name);
+   if (ret)
return ERR_PTR(-ENODEV);
-   }
 
mutex_lock(phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np);
@@ -283,6 +280,36 @@ err0:
 }
 
 /**
+ * of_phy_get() - lookup and obtain a reference to a phy using a device_node.
+ * @np: device_node for which to get the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Returns the phy driver, after getting a refcount to it; or
+ * -ENODEV if there is no such phy.  The caller is responsible for
+ * calling phy_put() to release that count.
+ */
+struct phy *of_phy_get(struct device_node *np, const char *con_id)
+{
+   struct phy *phy = NULL;
+   int index = 0;
+
+   if (con_id)
+   index = of_property_match_string(np, phy-names, con_id);
+
+   phy = _of_phy_get(np, index);
+   if (IS_ERR(phy))
+   return phy;
+
+   if (!try_module_get(phy-ops-owner))
+   return ERR_PTR(-EPROBE_DEFER);
+
+   get_device(phy-dev);
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(of_phy_get);
+
+/**
  * phy_put() - release the PHY
  * @phy: the phy returned by phy_get()
  *
@@ -370,7 +397,7 @@ struct phy *phy_get(struct device *dev, const char *string)
if (dev-of_node) {
index = of_property_match_string(dev-of_node, phy-names,
string);
-   phy = of_phy_get(dev, index);
+   phy = _of_phy_get(dev-of_node, index);
if (IS_ERR(phy)) {
dev_err(dev, unable to find phy\n);
return phy;
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..bcb6274 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -131,6 +131,7 @@ struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
+struct phy *of_phy_get(struct device_node *np, const char *con_id);
 struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
 struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
-- 
1.7.9.5

--
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 2/2] phy: core: Add devm_of_phy_get to phy-core

2013-12-16 Thread Kamil Debski
Adding devm_of_phy_get will allow to get phys by supplying the
device_node instead of by name.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
 drivers/phy/phy-core.c  |   31 +++
 include/linux/phy/phy.h |2 ++
 2 files changed, 33 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 0107f71..d45ad87 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -450,6 +450,37 @@ struct phy *devm_phy_get(struct device *dev, const char 
*string)
 EXPORT_SYMBOL_GPL(devm_phy_get);
 
 /**
+ * devm_of_phy_get() - lookup and obtain a reference to a phy.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @con_id: name of the phy from device's point of view
+ *
+ * Gets the phy using phy_get(), and associates a device with it using
+ * devres. On driver detach, release function is invoked on the devres data,
+ * then, devres data is freed.
+ */
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id)
+{
+   struct phy **ptr, *phy;
+
+   ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   phy = of_phy_get(np, con_id);
+   if (!IS_ERR(phy)) {
+   *ptr = phy;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_get);
+
+/**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
  * @ops: function pointers for performing phy operations
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index bcb6274..864914c 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -129,6 +129,8 @@ int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   const char *con_id);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 struct phy *of_phy_get(struct device_node *np, const char *con_id);
-- 
1.7.9.5

--
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 RESEND v2 1/2] phy: core: Add an exported of_phy_get function

2013-12-16 Thread Kamil Debski
Hi,

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Monday, December 16, 2013 10:01 AM
 
 On Friday 13 December 2013 08:56 PM, Kamil Debski wrote:
  Hi Kishon,
 
  From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
  Sent: Friday, December 13, 2013 3:45 PM
 
  Hi,
 
  On Friday 13 December 2013 07:32 PM, Kamil Debski wrote:
  Previously the of_phy_get function took a struct device * and was
  declared static. It was impossible to call it from another driver
  and thus it was impossible to get phy defined for a given node. The
  old function was renamed to _of_phy_get and was left for internal
 use.
  of_phy_get function was added and it was exported. The function
  enables to get a phy for a given device tree node.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  ---
  It seems that my git send-email is playing up and sent the previous
  emails without from. This is a resend. Sorry for any confusion.
  ---
   drivers/phy/phy-core.c  |   41 ---
 --
  
   include/linux/phy/phy.h |1 +
   2 files changed, 33 insertions(+), 9 deletions(-)
 
  diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index
  03cf8fb..f0dbd42 100644
  --- a/drivers/phy/phy-core.c
  +++ b/drivers/phy/phy-core.c
  @@ -240,8 +240,8 @@ out:
   EXPORT_SYMBOL_GPL(phy_power_off);
 
   /**
  - * of_phy_get() - lookup and obtain a reference to a phy by
 phandle
  - * @dev: device that requests this phy
  + * _of_phy_get() - lookup and obtain a reference to a phy by
  + phandle
  + * @np: device_node for which to get the phy
* @index: the index of the phy
*
* Returns the phy associated with the given phandle value, @@
  -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
* not yet loaded. This function uses of_xlate call back function
  provided
* while registering the phy_provider to find the phy instance.
*/
  -static struct phy *of_phy_get(struct device *dev, int index)
  +static struct phy *_of_phy_get(struct device_node *np, int index)
   {
int ret;
struct phy_provider *phy_provider;
struct phy *phy = NULL;
struct of_phandle_args args;
 
  - ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-
  cells,
  + ret = of_parse_phandle_with_args(np, phys, #phy-cells,
index, args);
  - if (ret) {
  - dev_dbg(dev, failed to get phy in %s node\n,
  - dev-of_node-full_name);
  + if (ret)
return ERR_PTR(-ENODEV);
  - }
 
mutex_lock(phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np); @@ -283,6 +280,32
  @@
  err0:
   }
 
   /**
  + * of_phy_get() - lookup and obtain a reference to a phy using a
  device_node.
  + * @np: device_node for which to get the phy
  + * @index: the index of the phy
 
  Would be better if the user can get the PHY by string instead of
 index.
 
  Ok, this sounds doable. I will add of_phy_get_by_name analogous to
 the
  clk framework.
 
 Nope. It was decided initially to have minimal no of APIs exported to
 get PHYs.
 So you can just get string as argument instead of index and leave the
 name of the API to just of_phy_get.

If you say so. I just sent a new version taking a string id instead of
an index. I hope you find it satisfying.

 Thanks
 Kishon
 
 
  + *
  + * Returns the phy driver, after getting a refcount to it; or
  + * -ENODEV if there is no such phy.  The caller is responsible for
  + * calling phy_put() to release that count.
  + */
  +struct phy *of_phy_get(struct device_node *np, int index) {
  + struct phy *phy = NULL;
  +
  + phy = _of_phy_get(np, index);
  + if (IS_ERR(phy))
  dev_err here?
 
  dev_err requires a dev, so it is not possible with the arguments used.
  And we do not want to add any extra parameters to keep the function
  call analogous to other of_*_get (as for example of_clk_get).
 
  Best wishes,
 

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


--
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/2] phy: core: Add devm_of_phy_get to phy-core

2013-12-13 Thread Kamil Debski
Adding devm_of_phy_get will allow to get phys by supplying the
device_node instead of by name.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
It seems that my git send-email is playing up and sent the previous emails
without from. This is a resend. Sorry for any confusion.
---
 drivers/phy/phy-core.c  |   31 +++
 include/linux/phy/phy.h |2 ++
 2 files changed, 33 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index f0dbd42..661f7ab 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -446,6 +446,37 @@ struct phy *devm_phy_get(struct device *dev, const char 
*string)
 EXPORT_SYMBOL_GPL(devm_phy_get);
 
 /**
+ * devm_of_phy_get() - lookup and obtain a reference to a phy.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @index: the index of the phy
+ *
+ * Gets the phy using phy_get(), and associates a device with it using
+ * devres. On driver detach, release function is invoked on the devres data,
+ * then, devres data is freed.
+ */
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   int index)
+{
+   struct phy **ptr, *phy;
+
+   ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   phy = of_phy_get(np, index);
+   if (!IS_ERR(phy)) {
+   *ptr = phy;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_get);
+
+/**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
  * @ops: function pointers for performing phy operations
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 169f572..db36d81 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -129,6 +129,8 @@ int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
+   int index);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 struct phy *of_phy_get(struct device_node *np, int index);
-- 
1.7.9.5

--
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 v2 1/2] phy: core: Add an exported of_phy_get function

2013-12-13 Thread Kamil Debski
Previously the of_phy_get function took a struct device * and
was declared static. It was impossible to call it from
another driver and thus it was impossible to get phy defined
for a given node. The old function was renamed to _of_phy_get
and was left for internal use. of_phy_get function was added
and it was exported. The function enables to get a phy for
a given device tree node.

Signed-off-by: Kamil Debski k.deb...@samsung.com
---
It seems that my git send-email is playing up and sent the previous emails
without from. This is a resend. Sorry for any confusion.
---
 drivers/phy/phy-core.c  |   41 -
 include/linux/phy/phy.h |1 +
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 03cf8fb..f0dbd42 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -240,8 +240,8 @@ out:
 EXPORT_SYMBOL_GPL(phy_power_off);
 
 /**
- * of_phy_get() - lookup and obtain a reference to a phy by phandle
- * @dev: device that requests this phy
+ * _of_phy_get() - lookup and obtain a reference to a phy by phandle
+ * @np: device_node for which to get the phy
  * @index: the index of the phy
  *
  * Returns the phy associated with the given phandle value,
@@ -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
  * not yet loaded. This function uses of_xlate call back function provided
  * while registering the phy_provider to find the phy instance.
  */
-static struct phy *of_phy_get(struct device *dev, int index)
+static struct phy *_of_phy_get(struct device_node *np, int index)
 {
int ret;
struct phy_provider *phy_provider;
struct phy *phy = NULL;
struct of_phandle_args args;
 
-   ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells,
+   ret = of_parse_phandle_with_args(np, phys, #phy-cells,
index, args);
-   if (ret) {
-   dev_dbg(dev, failed to get phy in %s node\n,
-   dev-of_node-full_name);
+   if (ret)
return ERR_PTR(-ENODEV);
-   }
 
mutex_lock(phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np);
@@ -283,6 +280,32 @@ err0:
 }
 
 /**
+ * of_phy_get() - lookup and obtain a reference to a phy using a device_node.
+ * @np: device_node for which to get the phy
+ * @index: the index of the phy
+ *
+ * Returns the phy driver, after getting a refcount to it; or
+ * -ENODEV if there is no such phy.  The caller is responsible for
+ * calling phy_put() to release that count.
+ */
+struct phy *of_phy_get(struct device_node *np, int index)
+{
+   struct phy *phy = NULL;
+
+   phy = _of_phy_get(np, index);
+   if (IS_ERR(phy))
+   return phy;
+
+   if (!try_module_get(phy-ops-owner))
+   return ERR_PTR(-EPROBE_DEFER);
+
+   get_device(phy-dev);
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(of_phy_get);
+
+/**
  * phy_put() - release the PHY
  * @phy: the phy returned by phy_get()
  *
@@ -370,7 +393,7 @@ struct phy *phy_get(struct device *dev, const char *string)
if (dev-of_node) {
index = of_property_match_string(dev-of_node, phy-names,
string);
-   phy = of_phy_get(dev, index);
+   phy = _of_phy_get(dev-of_node, index);
if (IS_ERR(phy)) {
dev_err(dev, unable to find phy\n);
return phy;
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..169f572 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -131,6 +131,7 @@ struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
+struct phy *of_phy_get(struct device_node *np, int index);
 struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
 struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
-- 
1.7.9.5

--
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/9] phy: core: Change the way of_phy_get is called

2013-12-13 Thread Kamil Debski
Hi, 

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Monday, December 09, 2013 8:23 AM
 
 On Friday 06 December 2013 04:22 PM, Kamil Debski wrote:
  Hi,
 
  From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
  Sent: Friday, December 06, 2013 6:31 AM
 
  Hi,
 
  On Thursday 05 December 2013 05:59 PM, Kamil Debski wrote:
  Previously the of_phy_get function took a struct device * and was
  declared static. It was impossible to call it from another driver
  and thus it was impossible to get phy defined
 
  It was never intended to be called from other drivers. What's up
 with
  the wrapper of of_phy_get, phy_get()/devm_phy_get()? Why isn't that
  enough?
 
  Implementing support for multiple phys in the ehci driver is a bit
 tricky.
  Especially when we want to do it right. Please have a look at this
  part of the dts file:
 
  +ehci@1258 {
  +compatible = samsung,exynos4210-ehci;
  +reg = 0x1258 0x2;
  +interrupts = 0 70 0;
  +clocks = clock 304, clock 305;
  +clock-names = usbhost, otg;
  +status = disabled;
  +#address-cells = 1;
  +#size-cells = 0;
  +port@0 {
  +reg = 0;
  +phys = usb2phy 1;
  +phy-names = host;
  +status = disabled;
  +};
  +port@1 {
  +reg = 1;
  +phys = usb2phy 2;
  +phy-names = hsic0;
  +status = disabled;
  +};
  +port@2 {
  +reg = 2;
  +phys = usb2phy 3;
  +phy-names = hsic1;
  +status = disabled;
  +};
  +};
 
  With the above we have a clear specification of ports and their
  respective phys. But to do this properly the ehci driver has to
  iterate over port nodes. It is much easier to use devm_of_phy_get by
  giving the node as its argument.
 
 I see. There are a couple of more things we do in the wrapper that gets
 missed while exporting of_phy_get (get_device and try_module_get). You
 might want to re-work that one.

Thank you for the review. I have just sent an updated version of the core
patches.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland



--
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 RESEND v2 1/2] phy: core: Add an exported of_phy_get function

2013-12-13 Thread Kamil Debski
Hi Kishon,

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Friday, December 13, 2013 3:45 PM
 
 Hi,
 
 On Friday 13 December 2013 07:32 PM, Kamil Debski wrote:
  Previously the of_phy_get function took a struct device * and was
  declared static. It was impossible to call it from another driver and
  thus it was impossible to get phy defined for a given node. The old
  function was renamed to _of_phy_get and was left for internal use.
  of_phy_get function was added and it was exported. The function
  enables to get a phy for a given device tree node.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  ---
  It seems that my git send-email is playing up and sent the previous
  emails without from. This is a resend. Sorry for any confusion.
  ---
   drivers/phy/phy-core.c  |   41 -
 
   include/linux/phy/phy.h |1 +
   2 files changed, 33 insertions(+), 9 deletions(-)
 
  diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index
  03cf8fb..f0dbd42 100644
  --- a/drivers/phy/phy-core.c
  +++ b/drivers/phy/phy-core.c
  @@ -240,8 +240,8 @@ out:
   EXPORT_SYMBOL_GPL(phy_power_off);
 
   /**
  - * of_phy_get() - lookup and obtain a reference to a phy by phandle
  - * @dev: device that requests this phy
  + * _of_phy_get() - lookup and obtain a reference to a phy by phandle
  + * @np: device_node for which to get the phy
* @index: the index of the phy
*
* Returns the phy associated with the given phandle value, @@
  -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
* not yet loaded. This function uses of_xlate call back function
 provided
* while registering the phy_provider to find the phy instance.
*/
  -static struct phy *of_phy_get(struct device *dev, int index)
  +static struct phy *_of_phy_get(struct device_node *np, int index)
   {
  int ret;
  struct phy_provider *phy_provider;
  struct phy *phy = NULL;
  struct of_phandle_args args;
 
  -   ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-
 cells,
  +   ret = of_parse_phandle_with_args(np, phys, #phy-cells,
  index, args);
  -   if (ret) {
  -   dev_dbg(dev, failed to get phy in %s node\n,
  -   dev-of_node-full_name);
  +   if (ret)
  return ERR_PTR(-ENODEV);
  -   }
 
  mutex_lock(phy_provider_mutex);
  phy_provider = of_phy_provider_lookup(args.np); @@ -283,6 +280,32
 @@
  err0:
   }
 
   /**
  + * of_phy_get() - lookup and obtain a reference to a phy using a
 device_node.
  + * @np: device_node for which to get the phy
  + * @index: the index of the phy
 
 Would be better if the user can get the PHY by string instead of index.

Ok, this sounds doable. I will add of_phy_get_by_name analogous to the clk
framework.

  + *
  + * Returns the phy driver, after getting a refcount to it; or
  + * -ENODEV if there is no such phy.  The caller is responsible for
  + * calling phy_put() to release that count.
  + */
  +struct phy *of_phy_get(struct device_node *np, int index) {
  +   struct phy *phy = NULL;
  +
  +   phy = _of_phy_get(np, index);
  +   if (IS_ERR(phy))
 dev_err here?

dev_err requires a dev, so it is not possible with the arguments used.
And we do not want to add any extra parameters to keep the function call
analogous to other of_*_get (as for example of_clk_get).

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


--
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 v4 3/9] phy: Add new Exynos USB PHY driver

2013-12-09 Thread Kamil Debski
Hi, 

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Monday, December 09, 2013 8:56 AM
 
 Hi,
 
 On Friday 06 December 2013 09:58 PM, Kamil Debski wrote:
  Hi Kishon,
 
  Thank you for the review.
 
  From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
  Sent: Friday, December 06, 2013 11:59 AM
 
  Hi,
 
  On Thursday 05 December 2013 05:59 PM, Kamil Debski wrote:
  Add a new driver for the Exynos USB PHY. The new driver uses the
  generic PHY framework. The driver includes support for the Exynos
  4x10
  and 4x12 SoC families.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
 
 
 snip
 .
 .
  diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index
  d0caae9..9f4befd 100644
  --- a/drivers/phy/Makefile
  +++ b/drivers/phy/Makefile
  @@ -7,3 +7,6 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO) += phy-
 exynos-dp-
  video.o
obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += phy-exynos-mipi-
 video.o
obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o
obj-$(CONFIG_TWL4030_USB)   += phy-twl4030-usb.o
  +obj-$(CONFIG_PHY_SAMSUNG_USB2)   += phy-samsung-usb2.o
  +obj-$(CONFIG_PHY_EXYNOS4210_USB2)+= phy-exynos4210-usb2.o
  +obj-$(CONFIG_PHY_EXYNOS4212_USB2)+= phy-exynos4212-usb2.o
  diff --git a/drivers/phy/phy-exynos4210-usb2.c
  b/drivers/phy/phy-exynos4210-usb2.c
  new file mode 100644
  index 000..a02e5c2
  --- /dev/null
  +++ b/drivers/phy/phy-exynos4210-usb2.c
  @@ -0,0 +1,264 @@
  +/*
  + * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 4210 support
  + *
  + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  + * Author: Kamil Debski k.deb...@samsung.com
  + *
  + * This program is free software; you can redistribute it and/or
  +modify
  + * it under the terms of the GNU General Public License version 2
  +as
  + * published by the Free Software Foundation.
  + */
  +
  +#include linux/clk.h
  +#include linux/delay.h
  +#include linux/io.h
  +#include linux/kernel.h
  +#include linux/module.h
  +#include linux/of.h
  +#include linux/of_address.h
  +#include linux/phy/phy.h
  +#include linux/platform_device.h
  +#include linux/regmap.h
  +#include linux/spinlock.h
 
  You've included most of the above header files in phy-samsung-usb2.h
  which you are including below.
 
  I agree that includes in phy-samsung-usb2.h could use a cleanup. On
  the other hand my opinion is that a .c file should include all .h
  files that are used in this .c file. Relaying on .h file to include
  another .h doesn't seem good to me.
 
 then remove it in .h file.
 
  +#include phy-samsung-usb2.h
  +
  +/* Exynos USB PHY registers */
  +
  +/* PHY power control */
  +#define EXYNOS_4210_UPHYPWR  0x0
  +
  +#define EXYNOS_4210_UPHYPWR_PHY0_SUSPEND (1  0)
 
  use BIT() here and everywhere below.
 
 
 snip
 .
 .
 
  +#ifdef CONFIG_PHY_EXYNOS4212_USB2
  + {
  + .compatible = samsung,exynos4212-usb2-phy,
  + .data = exynos4212_usb2_phy_config,
  + },
  +#endif
  + { },
  +};
 
  I think we've had enough discussion about this approach. Let's get
  the opinion of others too. Felipe? Greg?
 
  Good idea.
 
  Summary:
  We have two drivers PHY_EXYNOS4210_USB2 and PHY_EXYNOS4212_USB2 with
  almost similar register map [1] and a samsung helper driver for
 these
  two drivers.
 
  I would not call them separate drivers. It's a single USB 2.0 driver
  with the option to include support for various SoCs. This patchset
 adds:
  Exynos 4210, Exynos 4212, Exynos 5250 and S5PCV210. I know that
  another person is working on supporting S3C6410.
 
  These two PHY drivers populate the function pointers in the helper
  driver. So any phy_ops will first invoke the helper driver which
 will
  then invoke the corresponding phy driver.
 
  [1] - http://www.diffchecker.com/7yno1uvk
 
  Come on, this diff only includes the registers part of the file.
  The following functions are also different:
  - exynos421*_rate_to_clk
  - exynos421*_isol
  - exynos421*_phy_pwr
  - exynos421*_power_on
  - exynos421*_power_on
 
 But most of the differences is because your 4212 has additional
 features in HSIC and supports more clock rates.
 
  It seems that the file is too large for the tool. But still this
 makes
  a false impression that only registers are different.
 
  Advantages:
  * (more) clean and readable
  * helper driver can be used with other PHY drivers which will be
  added soon
 
  Disadvantages:
  * code duplication
 
  I would say that actually in this case less code is duplicated.
 Having
  Separate drivers would mean that most of the phy-samsung-usb2.c file
  has
 
 I actually meant a single driver for 4210 and 4212.
 
 your current code has separate drivers for different versions of the
 same IP. If you have a single driver for the different versions, it
 will lead to a lot less code duplication (hint: I'v given the exact
 'same'
 comment at-least twice in this patch).

You wrote more than

[PATCH v4 6/9] phy: Add support for S5PV210 to the Exynos USB PHY driver

2013-12-06 Thread Kamil Debski
From: Mateusz Krawczuk mat.krawc...@gmail.com

Add support for the Samsung's S5PV210 SoC to the Exynos USB PHY driver.

Signed-off-by: Mateusz Krawczuk m.krawc...@partner.samsung.com
[k.deb...@samsung.com: cleanup and commit description]
[k.deb...@samsung.com: make changes accordingly to the mailing list
comments]
Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/phy/samsung-usbphy.txt |1 +
 drivers/phy/Kconfig|7 +
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-s5pv210-usb2.c |  206 
 drivers/phy/phy-samsung-usb2.c |6 +
 drivers/phy/phy-samsung-usb2.h |1 +
 6 files changed, 222 insertions(+)
 create mode 100644 drivers/phy/phy-s5pv210-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
index cadbf70..77a8e9c 100644
--- a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
@@ -3,6 +3,7 @@ Samsung S5P/EXYNOS SoC series USB PHY
 
 Required properties:
 - compatible : should be one of the listed compatibles:
+   - samsung,s5pv210-usb2-phy
- samsung,exynos4210-usb2-phy
- samsung,exynos4212-usb2-phy
 - reg : a list of registers used by phy driver
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index b29018f..2e433cd 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -58,6 +58,13 @@ config PHY_SAMSUNG_USB2
  This driver provides common interface to interact, for Samsung
  USB 2.0 PHY driver.
 
+config PHY_S5PV210_USB2
+   bool Support for S5PV210
+   depends on PHY_SAMSUNG_USB2
+   depends on ARCH_S5PV210
+   help
+ Enable USB PHY support for S5PV210
+
 config PHY_EXYNOS4210_USB2
bool Support for Exynos 4210
depends on PHY_SAMSUNG_USB2
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9f4befd..fefc6c2 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -8,5 +8,6 @@ obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO) += 
phy-exynos-mipi-video.o
 obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
 obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
 obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o
+obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4210_USB2)  += phy-exynos4210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4212_USB2)  += phy-exynos4212-usb2.o
diff --git a/drivers/phy/phy-s5pv210-usb2.c b/drivers/phy/phy-s5pv210-usb2.c
new file mode 100644
index 000..528a114
--- /dev/null
+++ b/drivers/phy/phy-s5pv210-usb2.c
@@ -0,0 +1,206 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - S5PV210 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Authors: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/spinlock.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+
+/* PHY power control */
+#define S5PV210_UPHYPWR0x0
+
+#define S5PV210_UPHYPWR_PHY0_SUSPEND   (1  0)
+#define S5PV210_UPHYPWR_PHY0_PWR   (1  3)
+#define S5PV210_UPHYPWR_PHY0_OTG_PWR   (1  4)
+#define S5PV210_UPHYPWR_PHY0   ( \
+   S5PV210_UPHYPWR_PHY0_SUSPEND | \
+   S5PV210_UPHYPWR_PHY0_PWR | \
+   S5PV210_UPHYPWR_PHY0_OTG_PWR)
+
+#define S5PV210_UPHYPWR_PHY1_SUSPEND   (1  6)
+#define S5PV210_UPHYPWR_PHY1_PWR   (1  7)
+#define S5PV210_UPHYPWR_PHY1 ( \
+   S5PV210_UPHYPWR_PHY1_SUSPEND | \
+   S5PV210_UPHYPWR_PHY1_PWR)
+
+/* PHY clock control */
+#define S5PV210_UPHYCLK0x4
+
+#define S5PV210_UPHYCLK_PHYFSEL_MASK   (0x3  0)
+#define S5PV210_UPHYCLK_PHYFSEL_48MHZ  (0x0  0)
+#define S5PV210_UPHYCLK_PHYFSEL_24MHZ  (0x3  0)
+#define S5PV210_UPHYCLK_PHYFSEL_12MHZ  (0x2  0)
+
+#define S5PV210_UPHYCLK_PHY0_ID_PULLUP (0x1  2)
+#define S5PV210_UPHYCLK_PHY0_COMMON_ON (0x1  4)
+#define S5PV210_UPHYCLK_PHY1_COMMON_ON (0x1  7)
+
+/* PHY reset control */
+#define S5PV210_UPHYRST0x8
+
+#define S5PV210_URSTCON_PHY0   (1  0)
+#define S5PV210_URSTCON_OTG_HLINK  (1  1)
+#define S5PV210_URSTCON_OTG_PHYLINK(1  2)
+#define S5PV210_URSTCON_PHY1_ALL   (1  3)
+#define S5PV210_URSTCON_HOST_LINK_ALL  (1  4)
+
+/* Isolation, configured in the power management unit */
+#define S5PV210_USB_ISOL_DEVICE_OFFSET 0x704

[PATCH v4 7/9] phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver

2013-12-06 Thread Kamil Debski
Add support for Exynos 5250. This driver is to replace the old
USB 2.0 PHY driver.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/phy/samsung-usbphy.txt |1 +
 drivers/phy/Kconfig|8 +
 drivers/phy/Makefile   |1 +
 drivers/phy/phy-exynos5250-usb2.c  |  363 
 drivers/phy/phy-samsung-usb2.c |6 +
 drivers/phy/phy-samsung-usb2.h |1 +
 6 files changed, 380 insertions(+)
 create mode 100644 drivers/phy/phy-exynos5250-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
index 77a8e9c..94096fc 100644
--- a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
@@ -6,6 +6,7 @@ Required properties:
- samsung,s5pv210-usb2-phy
- samsung,exynos4210-usb2-phy
- samsung,exynos4212-usb2-phy
+   - samsung,exynos5250-usb2-phy
 - reg : a list of registers used by phy driver
- first and obligatory is the location of phy modules registers
 - samsung,sysreg-phandle - handle to syscon used to control the system 
registers
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 2e433cd..74e9064 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -78,4 +78,12 @@ config PHY_EXYNOS4212_USB2
depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412)
help
  Enable USB PHY support for Exynos 4212
+
+config PHY_EXYNOS5250_USB2
+   bool Support for Exynos 5250
+   depends on PHY_SAMSUNG_USB2
+   depends on SOC_EXYNOS5250
+   help
+ Enable USB PHY support for Exynos 5250
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index fefc6c2..33c3ac1 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_PHY_SAMSUNG_USB2)+= 
phy-samsung-usb2.o
 obj-$(CONFIG_PHY_S5PV210_USB2) += phy-s5pv210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4210_USB2)  += phy-exynos4210-usb2.o
 obj-$(CONFIG_PHY_EXYNOS4212_USB2)  += phy-exynos4212-usb2.o
+obj-$(CONFIG_PHY_EXYNOS5250_USB2)  += phy-exynos5250-usb2.o
diff --git a/drivers/phy/phy-exynos5250-usb2.c 
b/drivers/phy/phy-exynos5250-usb2.c
new file mode 100644
index 000..7aeebc8
--- /dev/null
+++ b/drivers/phy/phy-exynos5250-usb2.c
@@ -0,0 +1,363 @@
+/*
+ * Samsung SoC USB 1.1/2.0 PHY driver - Exynos 5250 support
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/clk.h
+#include linux/delay.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/regmap.h
+#include linux/spinlock.h
+#include phy-samsung-usb2.h
+
+/* Exynos USB PHY registers */
+#define EXYNOS_5250_REFCLKSEL_CRYSTAL  0x0
+#define EXYNOS_5250_REFCLKSEL_XO   0x1
+#define EXYNOS_5250_REFCLKSEL_CLKCORE  0x2
+
+#define EXYNOS_5250_FSEL_9MHZ6 0x0
+#define EXYNOS_5250_FSEL_10MHZ 0x1
+#define EXYNOS_5250_FSEL_12MHZ 0x2
+#define EXYNOS_5250_FSEL_19MHZ20x3
+#define EXYNOS_5250_FSEL_20MHZ 0x4
+#define EXYNOS_5250_FSEL_24MHZ 0x5
+#define EXYNOS_5250_FSEL_50MHZ 0x7
+
+/* Normal host */
+#define EXYNOS_5250_HOSTPHYCTRL0   0x0
+
+#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL   (0x1  31)
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT   19
+#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\
+   (0x3  EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16
+#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \
+   (0x7  EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT)
+#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNIN(0x1  11)
+#define EXYNOS_5250_HOSTPHYCTRL0_RETENABLE (0x1  10)
+#define EXYNOS_5250_HOSTPHYCTRL0_COMMON_ON_N   (0x1  9)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_MASK(0x3  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_DUAL(0x0  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ID0 (0x1  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_VATESTENB_ANALOGTEST  (0x2  7)
+#define EXYNOS_5250_HOSTPHYCTRL0_SIDDQ (0x1  6)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESLEEP(0x1  5)
+#define EXYNOS_5250_HOSTPHYCTRL0_FORCESUSPEND  (0x1  4)
+#define EXYNOS_5250_HOSTPHYCTRL0_WORDINTERFACE (0x1  3)
+#define EXYNOS_5250_HOSTPHYCTRL0_UTMISWRST (0x1  2)
+#define

[PATCH 8/9] dts: Add usb2phy to Exynos 4

2013-12-06 Thread Kamil Debski
Add support of new USB 2.0 phy driver to Exynos 4 SoC device tree.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/arm/samsung/pmu.txt|2 ++
 arch/arm/boot/dts/exynos4.dtsi |   31 
 arch/arm/boot/dts/exynos4210.dtsi  |   17 +++
 arch/arm/boot/dts/exynos4x12.dtsi  |   17 +++
 4 files changed, 67 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/samsung/pmu.txt 
b/Documentation/devicetree/bindings/arm/samsung/pmu.txt
index 307e727..bfccab0 100644
--- a/Documentation/devicetree/bindings/arm/samsung/pmu.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/pmu.txt
@@ -3,6 +3,8 @@ SAMSUNG Exynos SoC series PMU Registers
 Properties:
  - name : should be 'syscon';
  - compatible : should contain two values. First value must be one from 
following list:
+  - samsung,exynos4210-pmu - for Exynos4210 SoC,
+  - samsung,exynos4212-pmu - for Exynos4212 SoC,
   - samsung,exynos5250-pmu - for Exynos5250 SoC,
   - samsung,exynos5420-pmu - for Exynos5420 SoC.
second value must be always syscon.
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index a73eeb5..031d07a 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -253,6 +253,17 @@
status = disabled;
};
 
+   usbotg@1248 {
+   compatible = samsung,s3c6400-hsotg;
+   reg = 0x1248 0x2;
+   interrupts = 0 71 0;
+   clocks = clock 305;
+   clock-names = otg;
+   phys = usb2phy 0;
+   phy-names = usb2-phy;
+   status = disabled;
+   };
+
ehci@1258 {
compatible = samsung,exynos4210-ehci;
reg = 0x1258 0x100;
@@ -260,6 +271,26 @@
clocks = clock 304;
clock-names = usbhost;
status = disabled;
+   #address-cells = 1;
+   #size-cells = 0;
+   port@0 {
+   phys = usb2phy 1;
+   phy-names = host;
+   reg = 0;
+   status = disabled;
+   };
+   port@1 {
+   phys = usb2phy 2;
+   phy-names = hsic0;
+   reg = 1;
+   status = disabled;
+   };
+   port@2 {
+   phys = usb2phy 3;
+   phy-names = hsic1;
+   reg = 2;
+   status = disabled;
+   };
};
 
ohci@1259 {
diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
b/arch/arm/boot/dts/exynos4210.dtsi
index 057d682..f9d06bb 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -155,4 +155,21 @@
samsung,lcd-wb;
};
};
+
+   pmu_reg: syscon@1002 {
+   compatible = samsung,exynos4210-pmu, syscon;
+   reg = 0x1002 0x4000;
+   };
+
+   usb2phy: phy@125B {
+   compatible = samsung,exynos4210-usb2-phy;
+   reg = 0x125B 0x100;
+   clocks = clock 305, clock 2, clock 2, clock 2,
+   clock 2;
+   clock-names = phy, device, host, hsic0, hsic1;
+   status = disabled;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_reg;
+   samsung,pmureg-phandle = pmu_reg;
+   };
 };
diff --git a/arch/arm/boot/dts/exynos4x12.dtsi 
b/arch/arm/boot/dts/exynos4x12.dtsi
index ad531fe..712 100644
--- a/arch/arm/boot/dts/exynos4x12.dtsi
+++ b/arch/arm/boot/dts/exynos4x12.dtsi
@@ -176,4 +176,21 @@
};
};
};
+
+   pmu_reg: syscon@1002 {
+   compatible = samsung,exynos4212-pmu, syscon;
+   reg = 0x1002 0x4000;
+   };
+
+   usb2phy: phy@125B {
+   compatible = samsung,exynos4212-usb2-phy;
+   reg = 0x125B 0x100;
+   clocks = clock 305, clock 2, clock 2, clock 2,
+   clock 2;
+   clock-names = phy, device, host, hsic0, hsic1;
+   status = disabled;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_reg;
+   samsung,pmureg-phandle = pmu_reg;
+   };
 };
-- 
1.7.9.5

--
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 9/9] dts: Add usb2phy to Exynos 5250

2013-12-06 Thread Kamil Debski
Add support of new USB 2.0 phy driver to the Exynos 5250 SoC device tree.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 arch/arm/boot/dts/exynos5250.dtsi |   33 +
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
b/arch/arm/boot/dts/exynos5250.dtsi
index 2f264ad..922e0ed 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -163,6 +163,11 @@
interrupts = 0 47 0;
};
 
+   sys_syscon: syscon@1004 {
+   compatible = samsung,exynos5250-sys, syscon;
+   reg = 0x1005 0x5000;
+   };
+
pmu_syscon: syscon@1004 {
compatible = samsung,exynos5250-pmu, syscon;
reg = 0x1004 0x5000;
@@ -505,6 +510,14 @@
 
clocks = clock 285;
clock-names = usbhost;
+   #address-cells = 1;
+   #size-cells = 0;
+   port@0 {
+   reg = 0;
+   phys = usb2_phy 1;
+   phy-names = host;
+   status = ok;
+   };
};
 
usb@1212 {
@@ -516,19 +529,15 @@
clock-names = usbhost;
};
 
-   usb2_phy: usbphy@1213 {
-   compatible = samsung,exynos5250-usb2phy;
+   usb2_phy: phy@1213 {
+   compatible = samsung,exynos5250-usb2-phy;
reg = 0x1213 0x100;
-   clocks = clock 1, clock 285;
-   clock-names = ext_xtal, usbhost;
-   #address-cells = 1;
-   #size-cells = 1;
-   ranges;
-
-   usbphy-sys {
-   reg = 0x10040704 0x8,
- 0x10050230 0x4;
-   };
+   clocks = clock 285, clock 1, clock 1, clock 1,
+   clock 1;
+   clock-names = phy, device, host, hsic0, hsic1;
+   #phy-cells = 1;
+   samsung,sysreg-phandle = sys_syscon;
+   samsung,pmureg-phandle = pmu_syscon;
};
 
amba {
-- 
1.7.9.5

--
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 v4 0/9] phy: Add new Exynos USB 2.0 PHY driver

2013-12-06 Thread Kamil Debski
Hi,

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Thursday, December 05, 2013 4:07 PM
 
 Hi,
 
 On Thursday 05 December 2013 05:59 PM, Kamil Debski wrote:
  Hi,
 
  This is the fourth version of the patchset adding the new Exynos USB
  2.0 PHY driver. The driver uses the Generic PHY Framework.
 
  A month has passed since the last version. I have addressed numerous
  comments that appeared on the mailing list in this patch. I would
 like
  to specially thank Kishon, Tomasz, Matt and Vivek for their comments.
 
  This patch contains two necessary patches to the phy core.
  It is very useful to be able to get phy using a device tree node.
 
  In addition this patch depends on:
  [PATCH V11 1/3] ARM: dts: Add pmu sysreg node to exynos5250 and
  exynos5420 dtsi files [1].
 
  Best wishes,
  Kamil Debski
 
 The last four patches are missing [1]

I am sorry, git send-email failed on the 6th patch thus that and the
Following patches were not sent. I guess it is the Murphy's law,
sending patches just before leaving office had high chances of such
a mishap.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland
 
 [1] - https://lkml.org/lkml/2013/12/5/166
 
 Thanks
 Kishon
 
  [1] - http://www.spinics.net/lists/linux-samsung-soc/msg24528.html
 
  
  Changes from v3:
  - using PMU and system registers indirectly via syscon
  - change labelling
  - change Kconfig name
  - fixed typos/stray whitespace
  - move of_phy_provider_register() to the end of probe
  - add a regular error return code to the rate_to_clk functions
  - cleanup code and remove unused code
  - change struct names to avoid collisions
  - add mechanism to support multiple phys by the ehci driver
 
  
  Changes from v2:
  - rebase all patches to the usb-next branch
  - fixes in the documentation file
- remove wrong entries in the phy node (ranges, and #address- 
 #size-cells)
- add clocks and clock-names as required properites
- rephrase a few sentences
  - fixes in the ehci-exynos.c file
- move phy_name variable next to phy in exynos_ehci_hcd
- remove otg from exynos_ehci_hcd as it was no longer used
- move devm_phy_get after the Exynos5440 skip_phy check
  - fixes in the s3c-hsotg.c file
- cosmetic fixes (remove empty line that was wrongfully added)
  - fixes in the main driver
- remove cpu_type in favour for a boolean flag matched with the
 compatible
  value
- rename files, structures, variables and Kconfig entires - change
 from simple
  uphy to usb2_phy
- fix multiline comments style
- simplify #ifdefs in of_device_id
- fix Kconfig description
- change dev_info to dev_dbg where reasonable
- cosmetic changes (remove wrongful blank lines)
- remove unnecessary reference counting
 
  
  Changes from v1:
  - the changes include minor fixes of the hardware initialization of
 the PHY
module
  - some other minor fixes were introduced
 
  --
  Original cover letter:
 
  Hi,
 
  This patch adds a new drive for USB PHYs for Samsung SoCs. The driver
  is using the Generic PHY Framework created by Kishon Vijay Abrahan I.
  It can be found here https://lkml.org/lkml/2013/8/21/29. This patch
  adds support to Exynos4 family of SoCs. Support for Exynos3 and
  Exynos5 is planned to be added in the near future.
 
  I welcome your comments.
 
  --
 
  [1] https://lkml.org/lkml/2013/8/21/29
 
 
  Kamil Debski (8):
phy: core: Change the way of_phy_get is called
phy: core: Add devm_of_phy_get to phy-core
phy: Add new Exynos USB PHY driver
usb: ehci-s5p: Change to use phy provided by the generic phy
  framework
usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic
  phy framework
phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
dts: Add usb2phy to Exynos 4
dts: Add usb2phy to Exynos 5250
 
  Mateusz Krawczuk (1):
phy: Add support for S5PV210 to the Exynos USB PHY driver
 
   .../devicetree/bindings/arm/samsung/pmu.txt|2 +
   .../devicetree/bindings/phy/samsung-usbphy.txt |   56 +++
   .../devicetree/bindings/usb/samsung-hsotg.txt  |4 +
   Documentation/devicetree/bindings/usb/usb-ehci.txt |   35 ++
   arch/arm/boot/dts/exynos4.dtsi |   31 ++
   arch/arm/boot/dts/exynos4210.dtsi  |   17 +
   arch/arm/boot/dts/exynos4x12.dtsi  |   17 +
   arch/arm/boot/dts/exynos5250.dtsi  |   33 +-
   drivers/phy/Kconfig|   35 ++
   drivers/phy/Makefile   |5 +
   drivers/phy/phy-core.c |   43 ++-
   drivers/phy/phy-exynos4210-usb2.c  |  264
 ++
   drivers/phy/phy-exynos4212-usb2.c  |  312
 +
   drivers/phy/phy-exynos5250-usb2.c  |  363
 
   drivers/phy/phy-s5pv210

RE: [PATCH 1/9] phy: core: Change the way of_phy_get is called

2013-12-06 Thread Kamil Debski
Hi,

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Friday, December 06, 2013 6:31 AM
 
 Hi,
 
 On Thursday 05 December 2013 05:59 PM, Kamil Debski wrote:
  Previously the of_phy_get function took a struct device * and was
  declared static. It was impossible to call it from another driver and
  thus it was impossible to get phy defined
 
 It was never intended to be called from other drivers. What's up with
 the wrapper of of_phy_get, phy_get()/devm_phy_get()? Why isn't that
 enough?

Implementing support for multiple phys in the ehci driver is a bit tricky.
Especially when we want to do it right. Please have a look at this part of
the dts file:

+ehci@1258 {
+compatible = samsung,exynos4210-ehci;
+reg = 0x1258 0x2;
+interrupts = 0 70 0;
+clocks = clock 304, clock 305;
+clock-names = usbhost, otg;
+status = disabled;
+#address-cells = 1;
+#size-cells = 0;
+port@0 {
+reg = 0;
+phys = usb2phy 1;
+phy-names = host;
+status = disabled;
+};
+port@1 {
+reg = 1;
+phys = usb2phy 2;
+phy-names = hsic0;
+status = disabled;
+};
+port@2 {
+reg = 2;
+phys = usb2phy 3;
+phy-names = hsic1;
+status = disabled;
+};
+};

With the above we have a clear specification of ports and their respective
phys. But to do this properly the ehci driver has to iterate over port
nodes. It is much easier to use devm_of_phy_get by giving the node as its
argument.

[snip]

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


--
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 v4 4/9] usb: ehci-s5p: Change to use phy provided by the generic phy framework

2013-12-06 Thread Kamil Debski
Hi Alan,

Thank you for the review. Please find my replies inline.

 From: Alan Stern [mailto:st...@rowland.harvard.edu]
 Sent: Thursday, December 05, 2013 7:53 PM
 
 On Thu, 5 Dec 2013, Kamil Debski wrote:
 
  Change the phy provider used from the old usb phy specific to a new
  one using the generic phy framework.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 
  --- a/drivers/usb/host/ehci-exynos.c
  +++ b/drivers/usb/host/ehci-exynos.c
 
  @@ -42,10 +42,10 @@
   static const char hcd_name[] = ehci-exynos;  static struct
  hc_driver __read_mostly exynos_ehci_hc_driver;
 
  +#define PHY_NUMBER 3
   struct exynos_ehci_hcd {
  struct clk *clk;
  -   struct usb_phy *phy;
  -   struct usb_otg *otg;
 
 Are you sure you want to remove that line?

Yes, I am. The new generic phy interface does not have the otg field in it.
 
  +   struct phy *phy[PHY_NUMBER];
   };
 
   #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd
  *)(hcd_to_ehci(hcd)-priv)
 
  @@ -102,13 +132,24 @@ static int exynos_ehci_probe(struct
 platform_device *pdev)
  samsung,exynos5440-ehci))
  goto skip_phy;
 
  -   phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2);
  -   if (IS_ERR(phy)) {
  -   usb_put_hcd(hcd);
  -   dev_warn(pdev-dev, no platform data or transceiver
 defined\n);
  -   return -EPROBE_DEFER;
  -   } else {
  -   exynos_ehci-phy = phy;
  +   for_each_available_child_of_node(pdev-dev.of_node, child) {
  +   err = of_property_read_u32(child, reg, phy_number);
  +   if (err) {
  +   dev_err(pdev-dev, Failed to parse device
tree\n);
  +   return err;
  +   }
  +   if (phy_number = PHY_NUMBER) {
  +   dev_err(pdev-dev, Failed to parse device tree -
 number out of range\n);
  +   return -EINVAL;
 
 Do you need to call of_node_put(child) before each of these return
 statements?

You are right, thank you for spotting this.

 
  +   }
  +   phy = devm_of_phy_get(pdev-dev, child, 0);
  +   of_node_put(child);
  +   if (IS_ERR(phy)) {
  +   dev_err(pdev-dev, Failed to get phy number %d,
  +   phy_number);
  +   return PTR_ERR(phy);
  +   }
  +   exynos_ehci-phy[phy_number] = phy;
  exynos_ehci-otg = phy-otg;
 
 Did you intend to remove this line?  Above, you removed the
 exynos_ehci-otg field.  I can't see how this patch would ever compile
 without an error.

Yes, I had this in a separate fix patch which I forgot to squash. Sorry for
this.

  }
 
  @@ -149,11 +190,11 @@ skip_phy:
  goto fail_io;
  }
 
  -   if (exynos_ehci-otg)
  -   exynos_ehci-otg-set_host(exynos_ehci-otg, hcd-self);
  -
  -   if (exynos_ehci-phy)
  -   usb_phy_init(exynos_ehci-phy);
  +   err = exynos_phys_on(exynos_ehci-phy);
  +   if (err) {
  +   dev_err(pdev-dev, Failed to enabled phys\n);
  +   goto fail_phys_on;
 
 Why add a new statement label?  Just goto fail_io.

To me it seemed better to add a new label. I will drop it and use
goto fail_io, as you suggested.

 
  +   }
 
  ehci = hcd_to_ehci(hcd);
  ehci-caps = hcd-regs;
  @@ -172,8 +213,8 @@ skip_phy:
  return 0;
 
   fail_add_hcd:
  -   if (exynos_ehci-phy)
  -   usb_phy_shutdown(exynos_ehci-phy);
  +   exynos_phys_off(exynos_ehci-phy);
  +fail_phys_on:
   fail_io:
  clk_disable_unprepare(exynos_ehci-clk);
   fail_clk:
 
 Alan Stern

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

--
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 v4 3/9] phy: Add new Exynos USB PHY driver

2013-12-06 Thread Kamil Debski
Hi Kishon,

Thank you for the review.

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Friday, December 06, 2013 11:59 AM
 
 Hi,
 
 On Thursday 05 December 2013 05:59 PM, Kamil Debski wrote:
  Add a new driver for the Exynos USB PHY. The new driver uses the
  generic PHY framework. The driver includes support for the Exynos
 4x10
  and 4x12 SoC families.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   .../devicetree/bindings/phy/samsung-usbphy.txt |   54 
   drivers/phy/Kconfig|   20 ++
   drivers/phy/Makefile   |3 +
   drivers/phy/phy-exynos4210-usb2.c  |  264
 +
   drivers/phy/phy-exynos4212-usb2.c  |  312
 
   drivers/phy/phy-samsung-usb2.c |  228
 ++
   drivers/phy/phy-samsung-usb2.h |   72 +
   7 files changed, 953 insertions(+)
   create mode 100644
  Documentation/devicetree/bindings/phy/samsung-usbphy.txt
   create mode 100644 drivers/phy/phy-exynos4210-usb2.c  create mode
  100644 drivers/phy/phy-exynos4212-usb2.c  create mode 100644
  drivers/phy/phy-samsung-usb2.c  create mode 100644
  drivers/phy/phy-samsung-usb2.h
 
  diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
  b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
  new file mode 100644
  index 000..cadbf70
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
 
 use the existing samsung-phy.txt.

Ok.

  @@ -0,0 +1,54 @@
  +Samsung S5P/EXYNOS SoC series USB PHY
  +-
  +
  +Required properties:
  +- compatible : should be one of the listed compatibles:
  +   - samsung,exynos4210-usb2-phy
  +   - samsung,exynos4212-usb2-phy
  +- reg : a list of registers used by phy driver
  +   - first and obligatory is the location of phy modules registers
  +- samsung,sysreg-phandle - handle to syscon used to control the
  +system registers
  +- samsung,pmureg-phandle - handle to syscon used to control PMU
  +registers
  +- #phy-cells : from the generic phy bindings, must be 1;
  +- clocks and clock-names:
  +   - the phy clocks is required by the phy module
  +   - next for each of the phys a clock has to be assidned, this
 clock
 
 %s/assidned/assigned/

Thank you for spotting this.

  + will be used to determine clocking frequency for the phys
  + (the labels are specified in the paragraph below)
  +
  +The first phandle argument in the PHY specifier identifies the PHY,
  +its meaning is compatible dependent. For the currently supported
 SoCs
  +(Exynos 4210 and Exynos 4212) it is as follows:
  +  0 - USB device (device),
  +  1 - USB host (host),
  +  2 - HSIC0 (hsic0),
  +  3 - HSIC1 (hsic1),
  +
  +Exynos 4210 and Exynos 4212 use mode switching and require that mode
  +switch register is supplied.
  +
  +Example:
  +
  +For Exynos 4412 (compatible with Exynos 4212):
  +
  +usbphy: phy@125B {
 
 use lower case for address here...

Ok.

  +   compatible = samsung,exynos4212-usb2-phy;
  +   reg = 0x125B 0x100 0x10020704 0x0c 0x1001021c 0x4;
 and here..
  +   clocks = clock 305, clock 2, clock 2, clock 2,
  +   clock 2;
  +   clock-names = phy, device, host, hsic0, hsic1;
  +   status = okay;
  +   #phy-cells = 1;
  +   samsung,sysreg-phandle = sys_reg;
  +   samsung,pmureg-phandle = pmu_reg; };
  +
  +Then the PHY can be used in other nodes such as:
  +
  +phy-consumer@1234 {
  +   phys = usbphy 2;
  +   phy-names = phy;
  +};
  +
  +Refer to DT bindings documentation of particular PHY consumer
 devices
  +for more information about required PHYs and the way of
 specification.
  diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index
  a344f3d..b29018f 100644
  --- a/drivers/phy/Kconfig
  +++ b/drivers/phy/Kconfig
  @@ -51,4 +51,24 @@ config PHY_EXYNOS_DP_VIDEO
  help
Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
  +config PHY_SAMSUNG_USB2
  +   tristate Samsung USB 2.0 PHY driver
  +   help
  + Enable this to support Samsung USB phy helper driver for
 Samsung SoCs.
  + This driver provides common interface to interact, for Samsung
  + USB 2.0 PHY driver.
  +
  +config PHY_EXYNOS4210_USB2
  +   bool Support for Exynos 4210
  +   depends on PHY_SAMSUNG_USB2
  +   depends on CPU_EXYNOS4210
 
 select GENERIC_PHY here?

I think that depends on PHY_SAMSUNG_USB2 is better in this place.
However, I agree that I should add select GENERIC_PHY to PHY_SAMSUNG_USB2.

The reason why I am saying this is that I like how it looks in
menuconfig. Selecting PHY_SAMSUNG_USB2 expands more options and if
unselected the menu looks tidier.

  +   help
  + Enable USB PHY support for Exynos 4210
 
 Add more explanation here and make checkpatch happy.

Here I think we should not treat

RE: [PATCH v4 5/9] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework

2013-12-06 Thread Kamil Debski
Hi,

 From: Matt Porter [mailto:matt.por...@linaro.org]
 Sent: Friday, December 06, 2013 4:01 PM
 
 On Fri, Dec 06, 2013 at 04:41:51PM +0530, Kishon Vijay Abraham I wrote:
  Hi,
 
  On Thursday 05 December 2013 05:59 PM, Kamil Debski wrote:
   Change the used phy driver to the new Exynos USB phy driver that
   uses the generic phy framework.
  
   Signed-off-by: Kamil Debski k.deb...@samsung.com
   Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
   ---
.../devicetree/bindings/usb/samsung-hsotg.txt  |4 
drivers/usb/gadget/s3c-hsotg.c |   11 ++--
 ---
2 files changed, 10 insertions(+), 5 deletions(-)
  
   diff --git a/Documentation/devicetree/bindings/usb/samsung-
 hsotg.txt
   b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
   index b83d428..9340d06 100644
   --- a/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
   +++ b/Documentation/devicetree/bindings/usb/samsung-hsotg.txt
   @@ -24,6 +24,8 @@ Required properties:
- first entry: must be otg
- vusb_d-supply: phandle to voltage regulator of digital section,
- vusb_a-supply: phandle to voltage regulator of analog section.
   +- phys: from general PHY binding: phandle to the PHY device
   +- phy-names: from general PHY binding: should be usb2-phy
 
  are you sure it's usb2-phy. The example below seems to have a
 different value.
 
 I requested this be changed to usb2-phy, looks like he just missed the
 update to the example.

This is true. I missed the change in the example part of the file.

 
 
  
Example
-
   @@ -36,5 +38,7 @@ Example
 clock-names = otg;
 vusb_d-supply = vusb_reg;
 vusb_a-supply = vusbdac_reg;
   + phys = usb2phy 0;
   + phy-names = device;
 };

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

--
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 0/9] phy: Add new Exynos USB 2.0 PHY driver

2013-12-05 Thread Kamil Debski
Hi,

This is the fourth version of the patchset adding the new Exynos USB 2.0 PHY
driver. The driver uses the Generic PHY Framework.

A month has passed since the last version. I have addressed numerous comments
that appeared on the mailing list in this patch. I would like to specially
thank Kishon, Tomasz, Matt and Vivek for their comments.

This patch contains two necessary patches to the phy core.
It is very useful to be able to get phy using a device tree node.

In addition this patch depends on:
[PATCH V11 1/3] ARM: dts: Add pmu sysreg node to exynos5250 and exynos5420 dtsi
files [1].

Best wishes,
Kamil Debski

[1] - http://www.spinics.net/lists/linux-samsung-soc/msg24528.html


Changes from v3:
- using PMU and system registers indirectly via syscon
- change labelling
- change Kconfig name
- fixed typos/stray whitespace
- move of_phy_provider_register() to the end of probe
- add a regular error return code to the rate_to_clk functions
- cleanup code and remove unused code
- change struct names to avoid collisions
- add mechanism to support multiple phys by the ehci driver


Changes from v2:
- rebase all patches to the usb-next branch
- fixes in the documentation file
  - remove wrong entries in the phy node (ranges, and #address-  #size-cells)
  - add clocks and clock-names as required properites
  - rephrase a few sentences
- fixes in the ehci-exynos.c file
  - move phy_name variable next to phy in exynos_ehci_hcd
  - remove otg from exynos_ehci_hcd as it was no longer used
  - move devm_phy_get after the Exynos5440 skip_phy check
- fixes in the s3c-hsotg.c file
  - cosmetic fixes (remove empty line that was wrongfully added)
- fixes in the main driver
  - remove cpu_type in favour for a boolean flag matched with the compatible
value
  - rename files, structures, variables and Kconfig entires - change from simple
uphy to usb2_phy
  - fix multiline comments style
  - simplify #ifdefs in of_device_id
  - fix Kconfig description
  - change dev_info to dev_dbg where reasonable
  - cosmetic changes (remove wrongful blank lines)
  - remove unnecessary reference counting


Changes from v1:
- the changes include minor fixes of the hardware initialization of the PHY
  module
- some other minor fixes were introduced

--
Original cover letter:

Hi,

This patch adds a new drive for USB PHYs for Samsung SoCs. The driver is
using the Generic PHY Framework created by Kishon Vijay Abrahan I. It
can be found here https://lkml.org/lkml/2013/8/21/29. This patch adds
support to Exynos4 family of SoCs. Support for Exynos3 and Exynos5 is
planned to be added in the near future.

I welcome your comments.

--

[1] https://lkml.org/lkml/2013/8/21/29


Kamil Debski (8):
  phy: core: Change the way of_phy_get is called
  phy: core: Add devm_of_phy_get to phy-core
  phy: Add new Exynos USB PHY driver
  usb: ehci-s5p: Change to use phy provided by the generic phy
framework
  usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic
phy framework
  phy: Add Exynos 5250 support to the Exynos USB 2.0 PHY driver
  dts: Add usb2phy to Exynos 4
  dts: Add usb2phy to Exynos 5250

Mateusz Krawczuk (1):
  phy: Add support for S5PV210 to the Exynos USB PHY driver

 .../devicetree/bindings/arm/samsung/pmu.txt|2 +
 .../devicetree/bindings/phy/samsung-usbphy.txt |   56 +++
 .../devicetree/bindings/usb/samsung-hsotg.txt  |4 +
 Documentation/devicetree/bindings/usb/usb-ehci.txt |   35 ++
 arch/arm/boot/dts/exynos4.dtsi |   31 ++
 arch/arm/boot/dts/exynos4210.dtsi  |   17 +
 arch/arm/boot/dts/exynos4x12.dtsi  |   17 +
 arch/arm/boot/dts/exynos5250.dtsi  |   33 +-
 drivers/phy/Kconfig|   35 ++
 drivers/phy/Makefile   |5 +
 drivers/phy/phy-core.c |   43 ++-
 drivers/phy/phy-exynos4210-usb2.c  |  264 ++
 drivers/phy/phy-exynos4212-usb2.c  |  312 +
 drivers/phy/phy-exynos5250-usb2.c  |  363 
 drivers/phy/phy-s5pv210-usb2.c |  206 +++
 drivers/phy/phy-samsung-usb2.c |  240 +
 drivers/phy/phy-samsung-usb2.h |   74 
 drivers/usb/gadget/s3c-hsotg.c |   11 +-
 drivers/usb/host/ehci-exynos.c |   95 +++--
 include/linux/phy/phy.h|3 +
 20 files changed, 1789 insertions(+), 57 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt
 create mode 100644 drivers/phy/phy-exynos4210-usb2.c
 create mode 100644 drivers/phy/phy-exynos4212-usb2.c
 create mode 100644 drivers/phy/phy-exynos5250-usb2.c
 create mode 100644 drivers/phy/phy-s5pv210-usb2.c
 create mode 100644 drivers/phy/phy-samsung

[PATCH v4 4/9] usb: ehci-s5p: Change to use phy provided by the generic phy framework

2013-12-05 Thread Kamil Debski
Change the phy provider used from the old usb phy specific to a new one
using the generic phy framework.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 Documentation/devicetree/bindings/usb/usb-ehci.txt |   35 
 drivers/usb/host/ehci-exynos.c |   95 +---
 2 files changed, 97 insertions(+), 33 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt 
b/Documentation/devicetree/bindings/usb/usb-ehci.txt
index fa18612..413f7cd 100644
--- a/Documentation/devicetree/bindings/usb/usb-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt
@@ -14,6 +14,10 @@ If controller implementation operates with big endian 
descriptors,
 If both big endian registers and descriptors are used by the controller
 implementation, big-endian property can be specified instead of having
 both big-endian-regs and big-endian-desc.
+  - port: if in the SoC there are EHCI phys, they should be listed here.
+One phy per port. Each port should have its reg entry with a consecutive
+number. Also it should contain phys and phy-names entries specifying the
+phy used by the port.
 
 Example (Sequoia 440EPx):
 ehci@e300 {
@@ -23,3 +27,34 @@ Example (Sequoia 440EPx):
   reg = 0 e300 90 0 e390 70;
   big-endian;
};
+
+Example (Exynos 4212):
+ehci@1258 {
+compatible = samsung,exynos4210-ehci;
+reg = 0x1258 0x2;
+interrupts = 0 70 0;
+clocks = clock 304, clock 305;
+clock-names = usbhost, otg;
+status = disabled;
+#address-cells = 1;
+#size-cells = 0;
+port@0 {
+reg = 0;
+phys = usb2phy 1;
+phy-names = host;
+status = disabled;
+};
+port@1 {
+reg = 1;
+phys = usb2phy 2;
+phy-names = hsic0;
+status = disabled;
+};
+port@2 {
+reg = 2;
+phys = usb2phy 3;
+phy-names = hsic1;
+status = disabled;
+};
+};
+
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index e97c198..bb81809 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -19,12 +19,12 @@
 #include linux/module.h
 #include linux/of.h
 #include linux/of_gpio.h
+#include linux/phy/phy.h
 #include linux/platform_device.h
 #include linux/usb/phy.h
 #include linux/usb/samsung_usb_phy.h
 #include linux/usb.h
 #include linux/usb/hcd.h
-#include linux/usb/otg.h
 
 #include ehci.h
 
@@ -42,10 +42,10 @@
 static const char hcd_name[] = ehci-exynos;
 static struct hc_driver __read_mostly exynos_ehci_hc_driver;
 
+#define PHY_NUMBER 3
 struct exynos_ehci_hcd {
struct clk *clk;
-   struct usb_phy *phy;
-   struct usb_otg *otg;
+   struct phy *phy[PHY_NUMBER];
 };
 
 #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)-priv)
@@ -69,13 +69,43 @@ static void exynos_setup_vbus_gpio(struct platform_device 
*pdev)
dev_err(dev, can't request ehci vbus gpio %d, gpio);
 }
 
+static int exynos_phys_on(struct phy *p[])
+{
+   int i;
+   int ret = 0;
+
+   for (i = 0; ret == 0  i  PHY_NUMBER; i++)
+   if (p[i])
+   ret = phy_power_on(p[i]);
+   if (ret)
+   for (i--; i  0; i--)
+   if (p[i])
+   phy_power_off(p[i]);
+
+   return ret;
+}
+
+static int exynos_phys_off(struct phy *p[])
+{
+   int i;
+   int ret = 0;
+
+   for (i = 0; ret == 0  i  PHY_NUMBER; i++)
+   if (p[i])
+   ret = phy_power_off(p[i]);
+
+   return ret;
+}
+
 static int exynos_ehci_probe(struct platform_device *pdev)
 {
struct exynos_ehci_hcd *exynos_ehci;
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
struct resource *res;
-   struct usb_phy *phy;
+   struct phy *phy;
+   struct device_node *child;
+   int phy_number;
int irq;
int err;
 
@@ -102,13 +132,24 @@ static int exynos_ehci_probe(struct platform_device *pdev)
samsung,exynos5440-ehci))
goto skip_phy;
 
-   phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2);
-   if (IS_ERR(phy)) {
-   usb_put_hcd(hcd);
-   dev_warn(pdev-dev, no platform data or transceiver 
defined\n);
-   return -EPROBE_DEFER;
-   } else {
-   exynos_ehci-phy = phy;
+   for_each_available_child_of_node(pdev-dev.of_node, child) {
+   err = of_property_read_u32(child, reg, phy_number);
+   if (err) {
+   dev_err(pdev-dev, Failed to parse device tree\n);
+   return err;
+   }
+   if (phy_number = PHY_NUMBER) {
+   dev_err(pdev-dev

[PATCH 1/9] phy: core: Change the way of_phy_get is called

2013-12-05 Thread Kamil Debski
Previously the of_phy_get function took a struct device * and
was declared static. It was impossible to call it from
another driver and thus it was impossible to get phy defined
for a given node.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/phy/phy-core.c  |   12 +---
 include/linux/phy/phy.h |1 +
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 03cf8fb..7fb3474 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -250,20 +250,17 @@ EXPORT_SYMBOL_GPL(phy_power_off);
  * not yet loaded. This function uses of_xlate call back function provided
  * while registering the phy_provider to find the phy instance.
  */
-static struct phy *of_phy_get(struct device *dev, int index)
+struct phy *of_phy_get(struct device_node *np, int index)
 {
int ret;
struct phy_provider *phy_provider;
struct phy *phy = NULL;
struct of_phandle_args args;
 
-   ret = of_parse_phandle_with_args(dev-of_node, phys, #phy-cells,
+   ret = of_parse_phandle_with_args(np, phys, #phy-cells,
index, args);
-   if (ret) {
-   dev_dbg(dev, failed to get phy in %s node\n,
-   dev-of_node-full_name);
+   if (ret)
return ERR_PTR(-ENODEV);
-   }
 
mutex_lock(phy_provider_mutex);
phy_provider = of_phy_provider_lookup(args.np);
@@ -281,6 +278,7 @@ err0:
 
return phy;
 }
+EXPORT_SYMBOL_GPL(of_phy_get);
 
 /**
  * phy_put() - release the PHY
@@ -370,7 +368,7 @@ struct phy *phy_get(struct device *dev, const char *string)
if (dev-of_node) {
index = of_property_match_string(dev-of_node, phy-names,
string);
-   phy = of_phy_get(dev, index);
+   phy = of_phy_get(dev-of_node, index);
if (IS_ERR(phy)) {
dev_err(dev, unable to find phy\n);
return phy;
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 6d72269..169f572 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -131,6 +131,7 @@ struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
+struct phy *of_phy_get(struct device_node *np, int index);
 struct phy *of_phy_simple_xlate(struct device *dev,
struct of_phandle_args *args);
 struct phy *phy_create(struct device *dev, const struct phy_ops *ops,
-- 
1.7.9.5

--
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/9] phy: core: Add devm_of_phy_get to phy-core

2013-12-05 Thread Kamil Debski
Adding devm_of_phy_get will allow to get phys by supplying the
device_node instead of by name.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/phy/phy-core.c  |   31 +++
 include/linux/phy/phy.h |2 ++
 2 files changed, 33 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 7fb3474..b39b48c 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -421,6 +421,37 @@ struct phy *devm_phy_get(struct device *dev, const char 
*string)
 EXPORT_SYMBOL_GPL(devm_phy_get);
 
 /**
+ * devm_of_phy_get() - lookup and obtain a reference to a phy.
+ * @dev: device that requests this phy
+ * @np: node containing the phy
+ * @index: the index of the phy
+ *
+ * Gets the phy using phy_get(), and associates a device with it using
+ * devres. On driver detach, release function is invoked on the devres data,
+ * then, devres data is freed.
+ */
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, int
+   index)
+{
+   struct phy **ptr, *phy;
+
+   ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
+   if (!ptr)
+   return ERR_PTR(-ENOMEM);
+
+   phy = of_phy_get(np, index);
+   if (!IS_ERR(phy)) {
+   *ptr = phy;
+   devres_add(dev, ptr);
+   } else {
+   devres_free(ptr);
+   }
+
+   return phy;
+}
+EXPORT_SYMBOL_GPL(devm_of_phy_get);
+
+/**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
  * @ops: function pointers for performing phy operations
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index 169f572..f143ee8 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -129,6 +129,8 @@ int phy_power_on(struct phy *phy);
 int phy_power_off(struct phy *phy);
 struct phy *phy_get(struct device *dev, const char *string);
 struct phy *devm_phy_get(struct device *dev, const char *string);
+struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, int
+   index);
 void phy_put(struct phy *phy);
 void devm_phy_put(struct device *dev, struct phy *phy);
 struct phy *of_phy_get(struct device_node *np, int index);
-- 
1.7.9.5

--
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 5/9] usb: gadget: s3c-hsotg: use generic phy_init()/phy_exit() support

2013-11-28 Thread Kamil Debski
Hi Matt,

 From: Matt Porter [mailto:matt.por...@linaro.org]
 Sent: Thursday, November 28, 2013 5:42 PM
 
 On Thu, Nov 28, 2013 at 11:23:52AM +0530, Kishon Vijay Abraham I wrote:
  On Thursday 28 November 2013 04:06 AM, Matt Porter wrote:
   On Wed, Nov 27, 2013 at 12:13:25PM -0500, Matt Porter wrote:
   On Tue, Nov 26, 2013 at 03:53:32PM +0530, Kishon Vijay Abraham I
 wrote:
   Hi,
  
   On Monday 25 November 2013 11:46 PM, Matt Porter wrote:
   If a generic phy is present, call phy_init()/phy_exit(). This
   supports generic phys that must be soft reset before power on.
  
   Signed-off-by: Matt Porter matt.por...@linaro.org
   ---
drivers/usb/gadget/s3c-hsotg.c | 5 +
1 file changed, 5 insertions(+)
  
   diff --git a/drivers/usb/gadget/s3c-hsotg.c
   b/drivers/usb/gadget/s3c-hsotg.c index da3879b..8dfe33f 100644
   --- a/drivers/usb/gadget/s3c-hsotg.c
   +++ b/drivers/usb/gadget/s3c-hsotg.c
   @@ -3622,6 +3622,9 @@ static int s3c_hsotg_probe(struct
 platform_device *pdev)
  goto err_supplies;
  }
  
   +  if (hsotg-phy)
  
   IS_ERR? If your phy_get fails *phy* will have a error value..
  
   Yes, thanks. I'll fix these and also note that the same issue
   exists in Kamil's patch for these same hsotg-phy conditional uses.
   I'll work with Kamil to either get those addressed there or in a
 follow on fix.
  
   I spoke too soon. If devm_phy_get fails, we don't set hsotg-phy
 and
   probe defer thus not reaching this point. Since hsotg-phy is
 either
   NULL or a valid struct phy *, this is correct as is throughout the
 driver.
  
  
   +  phy_init(hsotg-phy);
   +
  /* usb phy enable */
  s3c_hsotg_phy_enable(hsotg);
  
   @@ -3715,6 +3718,8 @@ static int s3c_hsotg_remove(struct
 platform_device *pdev)
  }
  
  s3c_hsotg_phy_disable(hsotg);
   +  if (hsotg-phy)
  
   same here.
  
   Ok.
  
   Same above, this will be NULL on failure (but is only applicable at
   this point on the platform data path.
 
  Ah ok.. Btw where is phy_get being called? Is it not part of this
 series?
 
 It's in the Kamil's Exynos USB Phy - generic phy series [1] which I
 depend on here. I mentioned it in the cover letter toward the end so
 it's a bit buried.
 
 I have some outstanding, but trivial, comments on that series but I
 hear Kamil will be posting an update in the coming days. I'll wait a
 few days to post v4 addressing your comments so I can hopefully rebase
 against his updated s3c-hsotg patch.
 

I am sorry to keep you waiting. I was doing some urgent non USB work 
lately and that is the reason for the delay. Thank you for the review of
the last version, by the way. I should post the new version on Wednesday
(or Tuesday afternoon, time permitting). Also, I will have no access to
my Samsung email until Tuesday.

Best wishes,
Kamil Debski


--
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 1/3] phy: Add new Exynos USB PHY driver

2013-11-06 Thread Kamil Debski
Hi,

 From: Jingoo Han [mailto:jg1@samsung.com]
 Sent: Wednesday, November 06, 2013 2:03 AM
 
 On Wednesday, November 06, 2013 1:13 AM, Kamil Debski wrote:
 
  Add a new driver for the Exynos USB PHY. The new driver uses the
  generic PHY framework. The driver includes support for the Exynos
 4x10
  and 4x12 SoC families.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   .../devicetree/bindings/phy/samsung-usbphy.txt |   52 
   drivers/phy/Kconfig|   23 +-
   drivers/phy/Makefile   |4 +
   drivers/phy/phy-exynos-usb2.c  |  234
 ++
   drivers/phy/phy-exynos-usb2.h  |   87 ++
   drivers/phy/phy-exynos4210-usb2.c  |  272
 
   drivers/phy/phy-exynos4212-usb2.c  |  324
 
   7 files changed, 995 insertions(+), 1 deletion(-)  create mode
 100644
  Documentation/devicetree/bindings/phy/samsung-usbphy.txt
   create mode 100644 drivers/phy/phy-exynos-usb2.c  create mode 100644
  drivers/phy/phy-exynos-usb2.h  create mode 100644
  drivers/phy/phy-exynos4210-usb2.c  create mode 100644
  drivers/phy/phy-exynos4212-usb2.c
 
 []
 
  diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index
  d0caae9..c87bc65 100644
  --- a/drivers/phy/Makefile
  +++ b/drivers/phy/Makefile
  @@ -7,3 +7,7 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)   += phy-exynos-dp-
 video.o
   obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
   obj-$(CONFIG_OMAP_USB2)+= phy-omap-usb2.o
   obj-$(CONFIG_TWL4030_USB)  += phy-twl4030-usb.o
  +obj-$(CONFIG_PHY_EXYNOS5250_USB)   += phy-exynos5250-usb.o
 
 Hi Kamil,
 
 Would you add 'phy-exynos5250-usb.c' file? :-)
 
 Now, I am testing Exynos5250 USB HOST with your patchset.
 However, it makes error because there is no PHY driver for Exynos5250.
 
   WARNING: CPU: 0 PID: 18 at drivers/phy/phy-core.c:366
 phy_get+0x1e8/0x224()
   Device: exynos-ehci
   missing string
   .

I have to rewrite the power_on/power_off function in Exynos 5250 and I will
include it in the next version.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


--
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 RFC 1/4] phy: Add new Exynos5 USB 3.0 PHY driver

2013-11-05 Thread Kamil Debski
Hi,

 From: Vivek Gautam [mailto:gautamvivek1...@gmail.com]
 Sent: Tuesday, November 05, 2013 8:20 AM
 To: Kishon Vijay Abraham I
 Cc: Kamil Debski; Vivek Gautam; Linux USB Mailing List; linux-samsung-
 s...@vger.kernel.org; linux-ker...@vger.kernel.org;
 devicet...@vger.kernel.org; linux-arm-ker...@lists.infradead.org;
 linux-...@vger.kernel.org; Greg KH; Kukjin Kim; Sylwester Nawrocki;
 Tomasz Figa; Felipe Balbi; Julius Werner; Jingoo Han
 Subject: Re: [PATCH RFC 1/4] phy: Add new Exynos5 USB 3.0 PHY driver
 
 Hi Kishon,
 
 
 
 On Mon, Nov 4, 2013 at 6:42 PM, Kishon Vijay Abraham I kis...@ti.com
 wrote:
  Hi,
 
 
  On Monday 04 November 2013 03:45 PM, Kamil Debski wrote:
 
  Hi Kishon,
 
  From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
  Sent: Monday, November 04, 2013 7:55 AM
 
  Hi Vivek,
 
  On Thursday 31 October 2013 01:15 PM, Vivek Gautam wrote:
 
  Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs.
  The new driver uses the generic PHY framework and will interact
  with
  DWC3 controller present on Exynos5 series of SoCs.
 
 
  In Exynos, you have a single IP that supports both USB3 and USB2
 PHY
  right? I think that needs to be mentioned here.
 
 
  As far as I know the IP is different.
 
 
  Ok. Sometime back Vivek was mentioning about a single IP for both
 USB3
  and USB2. Thought it should be this driver. Anyway thanks for the
 clarification.
 
 Right Kishon, I had mentioned that Exynos5's dwc3 controller have a
 single IP for USB2 and USB3 phy.
 From what i see, on exynos5 systems the dwc3 controller uses a combo of
 usb 2 (utmi+) and usb 3 (pipe 3) phy (with base address starting
 0x1210).
 
 Kamil, Tomasz,
 
 Please correct me if i am wrong.

I have the Exynos 5250 documentation and I found two phy register ranges:
1) USB 2.0 PHY having the base address of 0x1213 
Chapter 33. USB 2.0 Host Controller
Subchapter 33.5.2 Phy Control Register p. 1696
First register's description is
USB2.0 phy control register
2) USB 3.0 PHY (I guess) with the base address 0x1210 
Chapter 35. USB 3.0 DRD Controller
Subchapter 35.4.6 PHY Control Register p. 1872

Jingoo, could you comment on the above? You may know more than we do :)

In addition, I have a question to you Vivek - does your USB 3.0
PHY support both host and device?

[snip]

Best wishes,
Kamil Debski

--
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 1/3] phy: Add new Exynos USB PHY driver

2013-11-05 Thread Kamil Debski
Add a new driver for the Exynos USB PHY. The new driver uses the generic
PHY framework. The driver includes support for the Exynos 4x10 and 4x12
SoC families.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/phy/samsung-usbphy.txt |   52 
 drivers/phy/Kconfig|   23 +-
 drivers/phy/Makefile   |4 +
 drivers/phy/phy-exynos-usb2.c  |  234 ++
 drivers/phy/phy-exynos-usb2.h  |   87 ++
 drivers/phy/phy-exynos4210-usb2.c  |  272 
 drivers/phy/phy-exynos4212-usb2.c  |  324 
 7 files changed, 995 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt
 create mode 100644 drivers/phy/phy-exynos-usb2.c
 create mode 100644 drivers/phy/phy-exynos-usb2.h
 create mode 100644 drivers/phy/phy-exynos4210-usb2.c
 create mode 100644 drivers/phy/phy-exynos4212-usb2.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
new file mode 100644
index 000..c8fbc70
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
@@ -0,0 +1,52 @@
+Samsung S5P/EXYNOS SoC series USB PHY
+-
+
+Required properties:
+- compatible : should be one of the listed compatibles:
+   - samsung,exynos4210-usbphy
+   - samsung,exynos4212-usbphy
+- reg : a list of registers used by phy driver
+   - first and obligatory is the location of phy modules registers
+   - second and also required is the location of isolation registers
+ (isolation registers control the physical connection between the in
+ SoC modules and outside of the SoC, this also can be called enable
+ control in the documentation of the SoC)
+   - third is the location of the mode switch register, this only applies
+ to SoCs that have such a feature; mode switching enables to have
+ both host and device used the same SoC pins and is commonly used
+ when OTG is supported
+- #phy-cells : from the generic phy bindings, must be 1;
+- clocks and clock-names:
+   - the phy clocks is required by the phy module
+   - other clocks are associated by name with their respective phys and
+ are used to determine the value of the clock settings register
+
+The second cell in the PHY specifier identifies the PHY, its  meaning is
+compatible dependent. For the currently supported SoCs (Exynos 4210 and
+Exynos 4212) it is as follows:
+  0 - USB device,
+  1 - USB host,
+  2 - HSIC0,
+  3 - HSIC1,
+
+Example:
+
+For Exynos 4412 (compatible with Exynos 4212):
+
+exynos_usbphy: exynos-usbphy@125B {
+   compatible = samsung,exynos4212-usbphy;
+   reg = 0x125B 0x100 0x10020704 0x0c 0x1001021c 0x4;
+   clocks = clock 305, clock 2, clock 2, clock 2,
+   clock 2;
+   clock-names = phy, device, host, hsic0, hsic1;
+   status = okay;
+   #phy-cells = 1;
+};
+
+Then the PHY can be used in other nodes such as:
+
+ehci@1258 {
+   status = okay;
+   phys = exynos_usbphy 2;
+   phy-names = hsic0;
+};
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index a344f3d..bdf0fab 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -14,7 +14,7 @@ config GENERIC_PHY
  API by which phy drivers can create PHY using the phy framework and
  phy users can obtain reference to the PHY. All the users of this
  framework should select this config.
-
+ 
 config PHY_EXYNOS_MIPI_VIDEO
tristate S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver
help
@@ -51,4 +51,25 @@ config PHY_EXYNOS_DP_VIDEO
help
  Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
+config PHY_EXYNOS_USB2
+   tristate Samsung USB 2.0 PHY driver
+   help
+ Enable this to support Samsung USB phy helper driver for Samsung SoCs.
+ This driver provides common interface to interact, for Samsung
+ USB 2.0 PHY driver.
+
+config PHY_EXYNOS4210_USB2
+   bool Support for Exynos 4210
+   depends on PHY_EXYNOS_USB2
+   depends on CPU_EXYNOS4210
+   help
+ Enable USB PHY support for Exynos 4210
+
+config PHY_EXYNOS4212_USB2
+   bool Support for Exynos 4212
+   depends on PHY_EXYNOS_USB2
+   depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412)
+   help
+ Enable USB PHY support for Exynos 4212
+ 
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index d0caae9..c87bc65 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -7,3 +7,7 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)   += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi

[PATCH v3 0/3] phy: Add new Exynos USB 2.0 PHY driver

2013-11-05 Thread Kamil Debski
Hi,

This is the third version of the patchset adding the new Exynos USB 2.0 PHY
driver, which uses the Generic PHY Framework.

It contains numerous fixes and cleanups, which are the results of the feedback
to the second version.

Best wishes,
Kamil Debski


Changes from v2:
- rebase all patches to the usb-next branch
- fixes in the documentation file
  - remove wrong entries in the phy node (ranges, and #address-  #size-cells)
  - add clocks and clock-names as required properites
  - rephrase a few sentences
- fixes in the ehci-exynos.c file
  - move phy_name variable next to phy in exynos_ehci_hcd
  - remove otg from exynos_ehci_hcd as it was no longer used
  - move devm_phy_get after the Exynos5440 skip_phy check
- fixes in the s3c-hsotg.c file
  - cosmetic fixes (remove empty line that was wrongfully added)
- fixes in the main driver
  - remove cpu_type in favour for a boolean flag matched with the compatible
value
  - rename files, structures, variables and Kconfig entires - change from simple
uphy to usb2_phy
  - fix multiline comments style
  - simplify #ifdefs in of_device_id
  - fix Kconfig description
  - change dev_info to dev_dbg where reasonable
  - cosmetic changes (remove wrongful blank lines)
  - remove unnecessary reference counting


Changes from v1:
- the changes include minor fixes of the hardware initialization of the PHY
  module
- some other minor fixes were introduced

--
Original cover letter:

Hi,

This patch adds a new drive for USB PHYs for Samsung SoCs. The driver is
using the Generic PHY Framework created by Kishon Vijay Abrahan I. It can
be found here https://lkml.org/lkml/2013/8/21/29. This patch adds support
to Exynos4 family of SoCs. Support for Exynos3 and Exynos5 is planned to
be added in the near future.

I welcome your comments.

--

[1] https://lkml.org/lkml/2013/8/21/29

*** BLURB HERE ***

Kamil Debski (3):
  phy: Add new Exynos USB PHY driver
  usb: ehci-s5p: Change to use phy provided by the generic phy
framework
  usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic
phy framework

 .../devicetree/bindings/phy/samsung-usbphy.txt |   52 
 drivers/phy/Kconfig|   23 +-
 drivers/phy/Makefile   |4 +
 drivers/phy/phy-exynos-usb2.c  |  234 ++
 drivers/phy/phy-exynos-usb2.h  |   87 ++
 drivers/phy/phy-exynos4210-usb2.c  |  272 
 drivers/phy/phy-exynos4212-usb2.c  |  324 
 drivers/usb/gadget/s3c-hsotg.c |   12 +-
 drivers/usb/host/ehci-exynos.c |   34 +-
 9 files changed, 1013 insertions(+), 29 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt
 create mode 100644 drivers/phy/phy-exynos-usb2.c
 create mode 100644 drivers/phy/phy-exynos-usb2.h
 create mode 100644 drivers/phy/phy-exynos4210-usb2.c
 create mode 100644 drivers/phy/phy-exynos4212-usb2.c

-- 
1.7.9.5

--
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 2/3] usb: ehci-s5p: Change to use phy provided by the generic phy framework

2013-11-05 Thread Kamil Debski
Change the phy provider used from the old usb phy specific to a new one
using the generic phy framework.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/host/ehci-exynos.c |   34 +++---
 1 file changed, 11 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index 8898c01..974001b 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -19,12 +19,12 @@
 #include linux/module.h
 #include linux/of.h
 #include linux/of_gpio.h
+#include linux/phy/phy.h
 #include linux/platform_device.h
 #include linux/usb/phy.h
 #include linux/usb/samsung_usb_phy.h
 #include linux/usb.h
 #include linux/usb/hcd.h
-#include linux/usb/otg.h
 
 #include ehci.h
 
@@ -44,8 +44,7 @@ static struct hc_driver __read_mostly exynos_ehci_hc_driver;
 
 struct exynos_ehci_hcd {
struct clk *clk;
-   struct usb_phy *phy;
-   struct usb_otg *otg;
+   struct phy *phy;
 };
 
 #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)-priv)
@@ -75,7 +74,8 @@ static int exynos_ehci_probe(struct platform_device *pdev)
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
struct resource *res;
-   struct usb_phy *phy;
+   struct phy *phy;
+   const char *phy_name;
int irq;
int err;
 
@@ -98,12 +98,12 @@ static int exynos_ehci_probe(struct platform_device *pdev)
return -ENOMEM;
}
exynos_ehci = to_exynos_ehci(hcd);
-
if (of_device_is_compatible(pdev-dev.of_node,
samsung,exynos5440-ehci))
goto skip_phy;
 
-   phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2);
+   phy_name = of_get_property(pdev-dev.of_node, phy-names, NULL);
+   phy =  devm_phy_get(pdev-dev, phy_name);
if (IS_ERR(phy)) {
usb_put_hcd(hcd);
dev_warn(pdev-dev, no platform data or transceiver 
defined\n);
@@ -149,11 +149,8 @@ skip_phy:
goto fail_io;
}
 
-   if (exynos_ehci-otg)
-   exynos_ehci-otg-set_host(exynos_ehci-otg, hcd-self);
-
if (exynos_ehci-phy)
-   usb_phy_init(exynos_ehci-phy);
+   phy_power_on(exynos_ehci-phy);
 
ehci = hcd_to_ehci(hcd);
ehci-caps = hcd-regs;
@@ -173,7 +170,7 @@ skip_phy:
 
 fail_add_hcd:
if (exynos_ehci-phy)
-   usb_phy_shutdown(exynos_ehci-phy);
+   phy_power_off(exynos_ehci-phy);
 fail_io:
clk_disable_unprepare(exynos_ehci-clk);
 fail_clk:
@@ -188,11 +185,8 @@ static int exynos_ehci_remove(struct platform_device *pdev)
 
usb_remove_hcd(hcd);
 
-   if (exynos_ehci-otg)
-   exynos_ehci-otg-set_host(exynos_ehci-otg, hcd-self);
-
if (exynos_ehci-phy)
-   usb_phy_shutdown(exynos_ehci-phy);
+   phy_power_off(exynos_ehci-phy);
 
clk_disable_unprepare(exynos_ehci-clk);
 
@@ -212,11 +206,8 @@ static int exynos_ehci_suspend(struct device *dev)
 
rc = ehci_suspend(hcd, do_wakeup);
 
-   if (exynos_ehci-otg)
-   exynos_ehci-otg-set_host(exynos_ehci-otg, hcd-self);
-
if (exynos_ehci-phy)
-   usb_phy_shutdown(exynos_ehci-phy);
+   phy_power_off(exynos_ehci-phy);
 
clk_disable_unprepare(exynos_ehci-clk);
 
@@ -230,11 +221,8 @@ static int exynos_ehci_resume(struct device *dev)
 
clk_prepare_enable(exynos_ehci-clk);
 
-   if (exynos_ehci-otg)
-   exynos_ehci-otg-set_host(exynos_ehci-otg, hcd-self);
-
if (exynos_ehci-phy)
-   usb_phy_init(exynos_ehci-phy);
+   phy_power_on(exynos_ehci-phy);
 
/* DMA burst Enable */
writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd-regs));
-- 
1.7.9.5

--
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 3/3] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework

2013-11-05 Thread Kamil Debski
Change the used phy driver to the new Exynos USB phy driver that uses the
generic phy framework.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/s3c-hsotg.c |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index bb31262..dc7f20c 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -31,6 +31,7 @@
 #include linux/regulator/consumer.h
 #include linux/of.h
 #include linux/of_platform.h
+#include linux/phy/phy.h
 
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
@@ -162,7 +163,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
-   struct usb_phy  *phy;
+   struct phy   *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2905,9 +2906,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
 
if (hsotg-phy)
-   usb_phy_init(hsotg-phy);
+   phy_power_on(hsotg-phy);
else if (hsotg-plat-phy_init)
hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);
+
 }
 
 /**
@@ -2922,7 +2924,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg-dev);
 
if (hsotg-phy)
-   usb_phy_shutdown(hsotg-phy);
+   phy_power_off(hsotg-phy);
else if (hsotg-plat-phy_exit)
hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);
 }
@@ -3529,7 +3531,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg 
*hsotg)
 static int s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = dev_get_platdata(pdev-dev);
-   struct usb_phy *phy;
+   struct phy *phy;
struct device *dev = pdev-dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3544,7 +3546,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   phy = devm_phy_get(pdev-dev, device);
if (IS_ERR(phy)) {
/* Fallback for pdata */
plat = dev_get_platdata(pdev-dev);
-- 
1.7.9.5

--
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 RFC 1/4] phy: Add new Exynos5 USB 3.0 PHY driver

2013-11-04 Thread Kamil Debski
Hi Kishon,

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Monday, November 04, 2013 7:55 AM
 
 Hi Vivek,
 
 On Thursday 31 October 2013 01:15 PM, Vivek Gautam wrote:
  Add a new driver for the USB 3.0 PHY on Exynos5 series of SoCs.
  The new driver uses the generic PHY framework and will interact with
  DWC3 controller present on Exynos5 series of SoCs.
 
 In Exynos, you have a single IP that supports both USB3 and USB2 PHY
 right? I think that needs to be mentioned here.

As far as I know the IP is different. 

 Do you have separate registers that should be used for
 initializing/powerin_on/powering_off etc.. for usb2 phy and usb3 phy?
 If so, then you should model this driver as a single driver that
 supports two PHYs similar to what Sylwester has done before?

Best wishes,
Kamil

 Cheers
 Kishon
 
 
  Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
  ---
.../devicetree/bindings/phy/samsung-phy.txt|   20 +
drivers/phy/Kconfig|7 +
drivers/phy/Makefile   |1 +
drivers/phy/phy-exynos5-usb3.c |  562
 
4 files changed, 590 insertions(+), 0 deletions(-)
create mode 100644 drivers/phy/phy-exynos5-usb3.c
 
  diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt
  b/Documentation/devicetree/bindings/phy/samsung-phy.txt
  index c0fccaa..9b5c111 100644
  --- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
  +++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
  @@ -20,3 +20,23 @@ Required properties:
- compatible : should be samsung,exynos5250-dp-video-phy;
- reg : offset and length of the Display Port PHY register set;
- #phy-cells : from the generic PHY bindings, must be 0;
  +
  +Samsung Exynos5 SoC seiries USB 3.0 PHY controller
  +--
  +
  +Required properties:
  +- compatible :
  +   should be samsung,exynos5250-usb3phy for exynos5250 SoC
  +   should be samsung,exynos5420-usb3phy for exynos5420 SoC
  +- reg : Register offset and length array
  +   - first field corresponds to USB 3.0 PHY register set;
  +   - second field corresponds to PHY power isolation register
  + present in PMU;
  +- clocks: Clock IDs array as required by the controller
  +- clock-names: names of clocks correseponding to IDs in the clock
 property;
  +   Required clocks:
  +   - first clock is main PHY clock (same as USB 3.0 controller IP
 clock)
  +   - second clock is reference clock (usually crystal clock)
  +   optional clock:
  +   - third clock is special clock used by PHY for operation
  +- #phy-cells : from the generic PHY bindings, must be 0;
  diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index
  a344f3d..9a100c6 100644
  --- a/drivers/phy/Kconfig
  +++ b/drivers/phy/Kconfig
  @@ -51,4 +51,11 @@ config PHY_EXYNOS_DP_VIDEO
  help
Support for Display Port PHY found on Samsung EXYNOS SoCs.
 
  +config PHY_EXYNOS5_USB3
  +   tristate Exynos5 SoC series USB 3.0 PHY driver
  +   depends on ARCH_EXYNOS5
  +   select GENERIC_PHY
  +   help
  + Enable USB 3.0 PHY support for Exynos 5 SoC series
  +
endmenu
  diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index
  d0caae9..9c06a61 100644
  --- a/drivers/phy/Makefile
  +++ b/drivers/phy/Makefile
  @@ -7,3 +7,4 @@ obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)   += phy-exynos-dp-
 video.o
obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)   += phy-exynos-mipi-video.o
obj-$(CONFIG_OMAP_USB2)   += phy-omap-usb2.o
obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o
  +obj-$(CONFIG_PHY_EXYNOS5_USB3) += phy-exynos5-usb3.o
  diff --git a/drivers/phy/phy-exynos5-usb3.c
  b/drivers/phy/phy-exynos5-usb3.c new file mode 100644 index
  000..b9a2674
  --- /dev/null
  +++ b/drivers/phy/phy-exynos5-usb3.c
  @@ -0,0 +1,562 @@
  +/*
  + * Samsung EXYNOS5 SoC series USB 3.0 PHY driver
  + *
  + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  + * Author: Vivek Gautam gautam.vi...@samsung.com
  + *
  + * This program is free software; you can redistribute it and/or
  +modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + */
  +
  +#include linux/clk.h
  +#include linux/delay.h
  +#include linux/io.h
  +#include linux/kernel.h
  +#include linux/module.h
  +#include linux/of.h
  +#include linux/of_address.h
  +#include linux/phy/phy.h
  +#include linux/platform_device.h
  +#include linux/mutex.h
  +
  +/* Exynos USB PHY registers */
  +#define EXYNOS5_FSEL_9MHZ6 0x0
  +#define EXYNOS5_FSEL_10MHZ 0x1
  +#define EXYNOS5_FSEL_12MHZ 0x2
  +#define EXYNOS5_FSEL_19MHZ20x3
  +#define EXYNOS5_FSEL_20MHZ 0x4
  +#define EXYNOS5_FSEL_24MHZ 0x5
  +#define EXYNOS5_FSEL_50MHZ 0x7
  +
  +/* EXYNOS5: USB 3.0 DRD PHY registers */
  +#define EXYNOS5_DRD_LINKSYSTEM 

RE: [RFC PATCH 2/5] phy: Add WIP Exynos 5250 support to the Exynos USB PHY driver

2013-10-29 Thread Kamil Debski
Hi,

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Tuesday, October 29, 2013 10:55 AM
 
 Hi,
 
 On Monday 28 October 2013 08:11 PM, Vivek Gautam wrote:
  Hi Kishon,
 
 
  On Fri, Oct 25, 2013 at 9:13 PM, Kishon Vijay Abraham I
 kis...@ti.com wrote:
  Hi,
 
  On Friday 25 October 2013 07:45 PM, Kamil Debski wrote:
  Add support for Exynos 5250. This is work-in-progress commit. Not
  for merging.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   drivers/phy/Kconfig  |7 +
   drivers/phy/Makefile |1 +
   drivers/phy/phy-exynos-usb.c |   10 +
   drivers/phy/phy-exynos-usb.h |1 +
   drivers/phy/phy-exynos5250-usb.c |  411
  ++
   5 files changed, 430 insertions(+)
   create mode 100644 drivers/phy/phy-exynos5250-usb.c
 
  diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index
  2f7ac0a..0f598d0 100644
  --- a/drivers/phy/Kconfig
  +++ b/drivers/phy/Kconfig
  @@ -36,4 +36,11 @@ config PHY_EXYNOS4212_USB
help
  Enable USB PHY support for Exynos 4212
 
  +config PHY_EXYNOS5250_USB
  + bool Support for Exynos 5250
  + depends on PHY_EXYNOS_USB
 
  This should be a separate driver. Not necessary to use
 PHY_EXYNOS_USB.
  + depends on SOC_EXYNOS5250
  + help
  +   Enable USB PHY support for Exynos 5250
  +
   endmenu
  diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index
  ca3dc82..0dff0dd 100644
  --- a/drivers/phy/Makefile
  +++ b/drivers/phy/Makefile
  @@ -6,3 +6,4 @@ obj-$(CONFIG_GENERIC_PHY) += phy-core.o
   obj-$(CONFIG_PHY_EXYNOS_USB) += phy-exynos-usb.o
   obj-$(CONFIG_PHY_EXYNOS4210_USB) += phy-exynos4210-usb.o
   obj-$(CONFIG_PHY_EXYNOS4212_USB) += phy-exynos4212-usb.o
  +obj-$(CONFIG_PHY_EXYNOS5250_USB) += phy-exynos5250-usb.o
  diff --git a/drivers/phy/phy-exynos-usb.c
  b/drivers/phy/phy-exynos-usb.c index d4a26df..172b774 100644
  --- a/drivers/phy/phy-exynos-usb.c
  +++ b/drivers/phy/phy-exynos-usb.c
  @@ -212,6 +212,10 @@ extern const struct uphy_config
  exynos4210_uphy_config;  extern const struct uphy_config
  exynos4212_uphy_config;  #endif
 
  +#ifdef CONFIG_PHY_EXYNOS5250_USB
  +extern const struct uphy_config exynos5250_uphy_config; #endif
  +
   static const struct of_device_id exynos_uphy_of_match[] =
 {  #ifdef
  CONFIG_PHY_EXYNOS4210_USB
{
  @@ -225,6 +229,12 @@ static const struct of_device_id
 exynos_uphy_of_match[] = {
.data = exynos4212_uphy_config,
},
   #endif
  +#ifdef CONFIG_PHY_EXYNOS5250_USB
  + {
  + .compatible = samsung,exynos5250-usbphy,
  + .data = exynos5250_uphy_config,
  + },
  +#endif
{ },
   };
 
  diff --git a/drivers/phy/phy-exynos-usb.h
  b/drivers/phy/phy-exynos-usb.h index f45cb3c..a9febfa 100644
  --- a/drivers/phy/phy-exynos-usb.h
  +++ b/drivers/phy/phy-exynos-usb.h
  @@ -42,6 +42,7 @@ enum samsung_cpu_type {
TYPE_S3C64XX,
TYPE_EXYNOS4210,
TYPE_EXYNOS4212,
  + TYPE_EXYNOS5250,
 
  No cpu types here.
 
  One question here.
  In case we move to single driver for Exynos4 SoCs (4210, 4212 and
 4412
  later) as well as S5PV210,
  there will be certain things changing from one SoC to another, how
  should we target that in case we don't have CPU types ?
  May be i am misinterpreting your suggestion ?
 
 We should be using the IP revision register or check for compatible
 values.
 

In case of this driver the compatible is checked. Maybe it is not as
straight forward, but the choice is based on compatible value.
Compatible is matched to an appropriate data entry in the of_device_id
table. The data entry contains a cpu field which contains the information
which PHY version we have. Maybe the cpu name is confusing and should be
changed to something like version or revision.

For example:
samsung,exynos4212-usbphy compatible is matched to exynos4212_uphy_config
via data field of of_device_id, and the cpu field of exynos4212_uphy_config
is equal to TYPE_EXYNOS4212.
This way in the code all what is needed is to check the value of cpu field.
It already got matched through the compatible.

Still, Tomasz Figa's idea sound good - using a boolean flag
has_mode_switch.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

--
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 1/5] phy: Add new Exynos USB PHY driver

2013-10-29 Thread Kamil Debski
Hi,

 From: Tomasz Figa [mailto:tomasz.f...@gmail.com]
 Sent: Monday, October 28, 2013 9:00 PM
 
 Hi Kamil,
 
 On Monday 28 of October 2013 14:52:19 Kamil Debski wrote:
  Hi Kishon,
 
  Thank you for your review! I will answer your comments below.
 [snip]
+
+   switch (drv-cfg-cpu) {
+   case TYPE_EXYNOS4210:
  
+   case TYPE_EXYNOS4212:
   Lets not add such cpu checks inside driver.
 
  Some SoC have a special register, which switches the OTG lines
 between
  device and host modes. I understand that it might not be the
 prettiest
  code. I see this as a good compromise between having a single huge
  driver for all Exynos SoCs and having a multiple drivers for each SoC
  version. PHY IPs in these chips very are similar but have to be
  handled differently. Any other ideas to solve this issue?
 
 Maybe adding a flag in drv-cfg called, for example, .has_mode_switch
 could solve this problem without having to check the SoC type
 explicitly?

Sounds like a good idea.
 
 [snip]
+#ifdef CONFIG_PHY_EXYNOS4210_USB
  
   Do we really need this?
 
  No we don't. The driver can always support all Exynos SoC versions.
  These config options were added for flexibility.
 
+extern const struct uphy_config exynos4210_uphy_config; #endif
+
+#ifdef CONFIG_PHY_EXYNOS4212_USB
  
   Same here.
  
+extern const struct uphy_config exynos4212_uphy_config; #endif
+
+static const struct of_device_id exynos_uphy_of_match[] = {
+#ifdef CONFIG_PHY_EXYNOS4210_USB
  
   #if not needed here.
 
  If the #ifdef CONFIG_PHY_EXYNOS4210_USB is removed then yes.
 Otherwise
  it is necessary - exynos4210_uphy_config may be undefined.
 
 I believe this and other ifdefs below are needed, otherwise, with
 support for one of the SoCs disabled, the driver could still bind to
 its compatible value.
 

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


--
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 1/5] phy: Add new Exynos USB PHY driver

2013-10-28 Thread Kamil Debski
Hi Kishon,

Thank you for your review! I will answer your comments below.

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Friday, October 25, 2013 5:40 PM
 
 Hi,
 
 On Friday 25 October 2013 07:45 PM, Kamil Debski wrote:
  Add a new driver for the Exynos USB PHY. The new driver uses the
  generic PHY framework. The driver includes support for the Exynos
 4x10
  and 4x12 SoC families.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   .../devicetree/bindings/phy/samsung-usbphy.txt |   51 +++
   drivers/phy/Kconfig|   21 ++
   drivers/phy/Makefile   |3 +
   drivers/phy/phy-exynos-usb.c   |  245
 ++
   drivers/phy/phy-exynos-usb.h   |   94 ++
   drivers/phy/phy-exynos4210-usb.c   |  295
 +
   drivers/phy/phy-exynos4212-usb.c   |  343
 
   7 files changed, 1052 insertions(+)
   create mode 100644
  Documentation/devicetree/bindings/phy/samsung-usbphy.txt
   create mode 100644 drivers/phy/phy-exynos-usb.c  create mode 100644
  drivers/phy/phy-exynos-usb.h  create mode 100644
  drivers/phy/phy-exynos4210-usb.c  create mode 100644
  drivers/phy/phy-exynos4212-usb.c
 
  diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
  b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
  new file mode 100644
  index 000..f112b37
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
  @@ -0,0 +1,51 @@
  +Samsung S5P/EXYNOS SoC series USB PHY
  +-
  +
  +Required properties:
  +- compatible : should be one of the listed compatibles:
  +   - samsung,exynos4210-usbphy
  +   - samsung,exynos4212-usbphy
  +- reg : a list of registers used by phy driver
  +   - first and obligatory is the location of phy modules registers
  +   - second and also required is the location of isolation registers
  + (isolation registers control the physical connection between
 the in
  + SoC modules and outside of the SoC, this also can be called
 enable
  + control in the documentation of the SoC)
  +   - third is the location of the mode switch register, this only
 applies
  + to SoCs that have such a feature; mode switching enables to
 have
  + both host and device used the same SoC pins and is commonly
 used
  + when OTG is supported
  +- #phy-cells : from the generic phy bindings, must be 1;
  +
  +The second cell in the PHY specifier identifies the PHY its meaning
  +is SoC dependent. For the currently supported SoCs (Exynos 4210 and
  +Exynos 4212) it is as follows:
  +  0 - USB device,
  +  1 - USB host,
  +  2 - HSIC0,
  +  3 - HSIC1,
 
 HSIC is supposedly to be transceiver less no? You have to program
 something in the digital side?
 You have a single IP that have all these functionalities?

There is a single USB PHY controller for all the above functionalities
(i.e. host, device, hsic 0 and 1).

  +
  +Example:
  +
  +For Exynos 4412 (compatible with Exynos 4212):
  +
  +exynos_usbphy: exynos-usbphy@125B {
  +   compatible = samsung,exynos4212-usbphy;
  +   reg = 0x125B 0x100 0x10020704 0x0c 0x1001021c 0x4;
  +   ranges;
  +   #address-cells = 1;
  +   #size-cells = 1;
 
 The above 3 properties aren't documented? Are they needed here?

My bad. I was working on two branches and corrected it in only one
of them.

  +   clocks = clock 305, clock 2, clock 2, clock 2,
  +   clock 2;
  +   clock-names = phy, device, host, hsic0, hsic1;
  +   status = okay;
  +   #phy-cells = 1;
  +};
  +
  +Then the PHY can be used in other nodes such as:
  +
  +ehci@1258 {
  +   status = okay;
  +   phys = exynos_usbphy 2;
  +   phy-names = hsic0;
  +};
  diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index
  349bef2..2f7ac0a 100644
  --- a/drivers/phy/Kconfig
  +++ b/drivers/phy/Kconfig
  @@ -15,4 +15,25 @@ config GENERIC_PHY
phy users can obtain reference to the PHY. All the users of
 this
framework should select this config.
 
  +config PHY_EXYNOS_USB
  +   tristate Samsung USB PHY driver (using the Generic PHY
 Framework)
 Mentioning *Generic PHY Framework* is not necessary.
 *select GENERIC_PHY* here

This was added to distinguish this driver from the ols USB PHY driver.
I agree that in the final version it should be removed. I understand that
the correct way to do this is by removing the old driver when the new gets
merged. Yes?

  +   help
  + Enable this to support Samsung USB phy helper driver for
 Samsung SoCs.
  + This driver provides common interface to interact, for Samsung
  + USB 2.0 PHY driver.
 
 If it's going to be used only for usb2, name it PHY_EXYNOS_USB2.

I agree.

  +
  +config PHY_EXYNOS4210_USB
  +   bool Support for Exynos 4210
  +   depends

RE: [PATCH v2 1/5] phy: Add new Exynos USB PHY driver

2013-10-28 Thread Kamil Debski
Hi Kumar Gala,

 From: Kumar Gala [mailto:ga...@codeaurora.org]
 Sent: Friday, October 25, 2013 11:36 PM
 
 On Oct 25, 2013, at 9:15 AM, Kamil Debski wrote:
 
  Add a new driver for the Exynos USB PHY. The new driver uses the
  generic PHY framework. The driver includes support for the Exynos
 4x10
  and 4x12 SoC families.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
  .../devicetree/bindings/phy/samsung-usbphy.txt |   51 +++
  drivers/phy/Kconfig|   21 ++
  drivers/phy/Makefile   |3 +
  drivers/phy/phy-exynos-usb.c   |  245
 ++
  drivers/phy/phy-exynos-usb.h   |   94 ++
  drivers/phy/phy-exynos4210-usb.c   |  295
 +
  drivers/phy/phy-exynos4212-usb.c   |  343
 
  7 files changed, 1052 insertions(+)
  create mode 100644
  Documentation/devicetree/bindings/phy/samsung-usbphy.txt
  create mode 100644 drivers/phy/phy-exynos-usb.c create mode 100644
  drivers/phy/phy-exynos-usb.h create mode 100644
  drivers/phy/phy-exynos4210-usb.c create mode 100644
  drivers/phy/phy-exynos4212-usb.c
 
  diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
  b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
  new file mode 100644
  index 000..f112b37
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
  @@ -0,0 +1,51 @@
  +Samsung S5P/EXYNOS SoC series USB PHY
  +-
  +
  +Required properties:
  +- compatible : should be one of the listed compatibles:
  +   - samsung,exynos4210-usbphy
  +   - samsung,exynos4212-usbphy
  +- reg : a list of registers used by phy driver
  +   - first and obligatory is the location of phy modules registers
  +   - second and also required is the location of isolation registers
  + (isolation registers control the physical connection between
 the in
  + SoC modules and outside of the SoC, this also can be called
 enable
  + control in the documentation of the SoC)
  +   - third is the location of the mode switch register, this only
 applies
  + to SoCs that have such a feature; mode switching enables to
 have
  + both host and device used the same SoC pins and is commonly
 used
  + when OTG is supported
  +- #phy-cells : from the generic phy bindings, must be 1;
 
 Please add if clock  clock-names are required properties.

Ok, thanks for pointing this out.

 
  +
  +The second cell in the PHY specifier identifies the PHY its meaning
  +is SoC dependent. For the currently supported SoCs (Exynos 4210 and
  +Exynos 4212) it is as follows:
 
 Can we say instead of 'its meaning is SoC dependent...' something like
 'its meaning is compatible dependent?

Ok, this sounds better in deed.
 
  +  0 - USB device,
  +  1 - USB host,
  +  2 - HSIC0,
  +  3 - HSIC1,
  +
  +Example:
  +
  +For Exynos 4412 (compatible with Exynos 4212):
  +
  +exynos_usbphy: exynos-usbphy@125B {
  +   compatible = samsung,exynos4212-usbphy;
  +   reg = 0x125B 0x100 0x10020704 0x0c 0x1001021c 0x4;
  +   ranges;
  +   #address-cells = 1;
  +   #size-cells = 1;
 
 Why do you have ranges, and #address-cells  #size-cells here?

As, I mentioned in my reply to Kishon. I worked on two branches
and I forgot to remove this in the one used to generate patches.

 
  +   clocks = clock 305, clock 2, clock 2, clock 2,
  +   clock 2;
  +   clock-names = phy, device, host, hsic0, hsic1;
  +   status = okay;
  +   #phy-cells = 1;
  +};
  +
  +Then the PHY can be used in other nodes such as:
  +
  +ehci@1258 {
  +   status = okay;
  +   phys = exynos_usbphy 2;
  +   phy-names = hsic0;
  +};
 

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

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


RE: [RFC PATCH 2/5] phy: Add WIP Exynos 5250 support to the Exynos USB PHY driver

2013-10-28 Thread Kamil Debski
Hi Kishon,

 From: Kishon Vijay Abraham I [mailto:kis...@ti.com]
 Sent: Friday, October 25, 2013 5:44 PM
 
 Hi,
 
 On Friday 25 October 2013 07:45 PM, Kamil Debski wrote:
  Add support for Exynos 5250. This is work-in-progress commit. Not for
  merging.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   drivers/phy/Kconfig  |7 +
   drivers/phy/Makefile |1 +
   drivers/phy/phy-exynos-usb.c |   10 +
   drivers/phy/phy-exynos-usb.h |1 +
   drivers/phy/phy-exynos5250-usb.c |  411
  ++
   5 files changed, 430 insertions(+)
   create mode 100644 drivers/phy/phy-exynos5250-usb.c
 
  diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index
  2f7ac0a..0f598d0 100644
  --- a/drivers/phy/Kconfig
  +++ b/drivers/phy/Kconfig
  @@ -36,4 +36,11 @@ config PHY_EXYNOS4212_USB
  help
Enable USB PHY support for Exynos 4212
 
  +config PHY_EXYNOS5250_USB
  +   bool Support for Exynos 5250
  +   depends on PHY_EXYNOS_USB
 
 This should be a separate driver. Not necessary to use PHY_EXYNOS_USB.
  +   depends on SOC_EXYNOS5250
  +   help
  + Enable USB PHY support for Exynos 5250
  +
   endmenu
  diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index
  ca3dc82..0dff0dd 100644
  --- a/drivers/phy/Makefile
  +++ b/drivers/phy/Makefile
  @@ -6,3 +6,4 @@ obj-$(CONFIG_GENERIC_PHY)   += phy-core.o
   obj-$(CONFIG_PHY_EXYNOS_USB)   += phy-exynos-usb.o
   obj-$(CONFIG_PHY_EXYNOS4210_USB)   += phy-exynos4210-usb.o
   obj-$(CONFIG_PHY_EXYNOS4212_USB)   += phy-exynos4212-usb.o
  +obj-$(CONFIG_PHY_EXYNOS5250_USB)   += phy-exynos5250-usb.o
  diff --git a/drivers/phy/phy-exynos-usb.c
  b/drivers/phy/phy-exynos-usb.c index d4a26df..172b774 100644
  --- a/drivers/phy/phy-exynos-usb.c
  +++ b/drivers/phy/phy-exynos-usb.c
  @@ -212,6 +212,10 @@ extern const struct uphy_config
  exynos4210_uphy_config;  extern const struct uphy_config
  exynos4212_uphy_config;  #endif
 
  +#ifdef CONFIG_PHY_EXYNOS5250_USB
  +extern const struct uphy_config exynos5250_uphy_config; #endif
  +
   static const struct of_device_id exynos_uphy_of_match[] = {  #ifdef
  CONFIG_PHY_EXYNOS4210_USB
  {
  @@ -225,6 +229,12 @@ static const struct of_device_id
 exynos_uphy_of_match[] = {
  .data = exynos4212_uphy_config,
  },
   #endif
  +#ifdef CONFIG_PHY_EXYNOS5250_USB
  +   {
  +   .compatible = samsung,exynos5250-usbphy,
  +   .data = exynos5250_uphy_config,
  +   },
  +#endif
  { },
   };
 
  diff --git a/drivers/phy/phy-exynos-usb.h
  b/drivers/phy/phy-exynos-usb.h index f45cb3c..a9febfa 100644
  --- a/drivers/phy/phy-exynos-usb.h
  +++ b/drivers/phy/phy-exynos-usb.h
  @@ -42,6 +42,7 @@ enum samsung_cpu_type {
  TYPE_S3C64XX,
  TYPE_EXYNOS4210,
  TYPE_EXYNOS4212,
  +   TYPE_EXYNOS5250,
 
 No cpu types here.
   };
 
   enum uphy_state {
  diff --git a/drivers/phy/phy-exynos5250-usb.c
  b/drivers/phy/phy-exynos5250-usb.c
  new file mode 100644
  index 000..156093b
  --- /dev/null
  +++ b/drivers/phy/phy-exynos5250-usb.c
  @@ -0,0 +1,411 @@
  +/*
  + * Samsung S5P/EXYNOS SoC series USB PHY driver
  + *
  + * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  + * Author: Kamil Debski k.deb...@samsung.com
  + *
  + * This program is free software; you can redistribute it and/or
  +modify
  + * it under the terms of the GNU General Public License version 2 as
  + * published by the Free Software Foundation.
  + */
  +
  +#include linux/clk.h
  +#include linux/delay.h
  +#include linux/io.h
  +#include linux/kernel.h
  +#include linux/module.h
  +#include linux/of.h
  +#include linux/of_address.h
  +#include linux/phy/phy.h
  +#include linux/platform_device.h
  +#include linux/spinlock.h
  +#include phy-exynos-usb.h
  +
  +/* Exynos USB PHY registers */
  +#define EXYNOS_5250_REFCLKSEL_CRYSTAL  0x0
  +#define EXYNOS_5250_REFCLKSEL_XO   0x1
  +#define EXYNOS_5250_REFCLKSEL_CLKCORE  0x2
  +
  +#define EXYNOS_5250_FSEL_9MHZ6 0x0
  +#define EXYNOS_5250_FSEL_10MHZ 0x1
  +#define EXYNOS_5250_FSEL_12MHZ 0x2
  +#define EXYNOS_5250_FSEL_19MHZ20x3
  +#define EXYNOS_5250_FSEL_20MHZ 0x4
  +#define EXYNOS_5250_FSEL_24MHZ 0x5
  +#define EXYNOS_5250_FSEL_50MHZ 0x7
  +
  +/* Normal host */
  +#define EXYNOS_5250_HOSTPHYCTRL0   0x0
  +
  +#define EXYNOS_5250_HOSTPHYCTRL0_PHYSWRSTALL   (0x1  31)
  +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT   19
  +#define EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_MASK\
  +   (0x3  EXYNOS_5250_HOSTPHYCTRL0_REFCLKSEL_SHIFT)
  +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT16
  +#define EXYNOS_5250_HOSTPHYCTRL0_FSEL_MASK \
  +   (0x7  EXYNOS_5250_HOSTPHYCTRL0_FSEL_SHIFT)
  +#define EXYNOS_5250_HOSTPHYCTRL0_TESTBURNIN(0x1  11)
  +#define

RE: [PATCH 4/5] usb: ehci-s5p: Change to use phy provided by the generic phy framework

2013-10-28 Thread Kamil Debski
Hi Jingoo,

 From: Jingoo Han [mailto:jg1@samsung.com]
 Sent: Saturday, October 26, 2013 3:27 AM
 
 On Friday, October 25, 2013 11:15 PM, Kamil Debski wrote:
 
  Change the phy provider used from the old usb phy specific to a new
  one using the generic phy framework.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   drivers/usb/host/ehci-s5p.c |   21 +++--
   1 file changed, 11 insertions(+), 10 deletions(-)
 
 Hi Kamil Debski,
 It looks good. :-)

Thank you.
 
 However, could you re-basing against Greg's 'usb-next' branch?
 Now, the file name of 'ehci-s5p.c' is renamed to 'ehci-exynos.c'.
 Also, 'Generic PHY Framework' was already merged to Greg's 'usb-next'
 branch.

Thanks for pointing out this.

 
 Thank you.
 
 Best regards,
 Jingoo Han

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland

--
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 4/5] usb: ehci-s5p: Change to use phy provided by the generic phy framework

2013-10-28 Thread Kamil Debski
Hi Vivek,

 From: Vivek Gautam [mailto:gautamvivek1...@gmail.com]
 Sent: Saturday, October 26, 2013 11:41 AM
 
 Hi Kamil,
 
 
 On Fri, Oct 25, 2013 at 7:45 PM, Kamil Debski k.deb...@samsung.com
 wrote:
  Change the phy provider used from the old usb phy specific to a new
  one using the generic phy framework.
 
  Signed-off-by: Kamil Debski k.deb...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   drivers/usb/host/ehci-s5p.c |   21 +++--
   1 file changed, 11 insertions(+), 10 deletions(-)
 
  diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-
 s5p.c
  index 7cc26e6..76606ff 100644
  --- a/drivers/usb/host/ehci-s5p.c
  +++ b/drivers/usb/host/ehci-s5p.c
  @@ -19,6 +19,7 @@
   #include linux/module.h
   #include linux/of.h
   #include linux/of_gpio.h
  +#include linux/phy/phy.h
   #include linux/platform_device.h
   #include linux/platform_data/usb-ehci-s5p.h
   #include linux/usb/phy.h
  @@ -45,7 +46,7 @@ static struct hc_driver __read_mostly
  s5p_ehci_hc_driver;
 
   struct s5p_ehci_hcd {
  struct clk *clk;
  -   struct usb_phy *phy;
  +   struct phy *phy;
  struct usb_otg *otg;
  struct s5p_ehci_platdata *pdata;  }; @@ -77,10 +78,11 @@
  static int s5p_ehci_probe(struct platform_device *pdev)  {
  struct s5p_ehci_platdata *pdata = pdev-dev.platform_data;
  struct s5p_ehci_hcd *s5p_ehci;
  +   struct phy *phy;
 
 just a nit here:
 Lets keep the pointer to 'phy' and 'phy_name' together ?
 and move this above phy_name ?

Thanks for pointing this out.
 
  struct usb_hcd *hcd;
  struct ehci_hcd *ehci;
  struct resource *res;
  -   struct usb_phy *phy;
  +   const char *phy_name;
  int irq;
  int err;
 
  @@ -103,14 +105,14 @@ static int s5p_ehci_probe(struct
 platform_device *pdev)
  return -ENOMEM;
  }
  s5p_ehci = to_s5p_ehci(hcd);
  -
  +   phy_name = of_get_property(pdev-dev.of_node, phy-names,
 NULL);
  +   phy =  devm_phy_get(pdev-dev, phy_name);
 
 Below check for exynos5440 was supposed to skip any request phy.
 So shouldn't we place above two assignments to the original place where
 devm_usb_get_phy() was called ?
 May be i am not getting you intention of changing the place.

Hm... You are right - if we want to leave this check and skip phy request
for
5450 then I should leave the order as it was. And if we want to use the new
phy driver for 5450 then the check to skip phy requesting should be simply
removed.

 
  if (of_device_is_compatible(pdev-dev.of_node,
  samsung,exynos5440-ehci)) {
  s5p_ehci-pdata = empty_platdata;
  goto skip_phy;
  }
 
  -   phy = devm_usb_get_phy(pdev-dev, USB_PHY_TYPE_USB2);
  if (IS_ERR(phy)) {
  /* Fallback to pdata */
  if (!pdata) {
  @@ -122,7 +124,6 @@ static int s5p_ehci_probe(struct platform_device
 *pdev)
  }
  } else {
  s5p_ehci-phy = phy;
  -   s5p_ehci-otg = phy-otg;
  }
 
   skip_phy:
  @@ -166,7 +167,7 @@ skip_phy:
  s5p_ehci-otg-set_host(s5p_ehci-otg, hcd-self);
 
 Lets remove this line and similar calls to 'set_host()' in the driver,
 since we don't have s5p_ehci-otg anymore after the same is removed
 above.
 Anyways this was helping the old phy-samsung-usb2 driver, and not
 needed now.

Ok, I will.

 
 
  if (s5p_ehci-phy)
  -   usb_phy_init(s5p_ehci-phy);
  +   phy_power_on(s5p_ehci-phy);
  else if (s5p_ehci-pdata-phy_init)
  s5p_ehci-pdata-phy_init(pdev, USB_PHY_TYPE_HOST);
 
  @@ -188,7 +189,7 @@ skip_phy:
 
   fail_add_hcd:
  if (s5p_ehci-phy)
  -   usb_phy_shutdown(s5p_ehci-phy);
  +   phy_power_off(s5p_ehci-phy);
  else if (s5p_ehci-pdata-phy_exit)
  s5p_ehci-pdata-phy_exit(pdev, USB_PHY_TYPE_HOST);
   fail_io:
  @@ -209,7 +210,7 @@ static int s5p_ehci_remove(struct platform_device
 *pdev)
  s5p_ehci-otg-set_host(s5p_ehci-otg, hcd-self);
 
 ditto
 
 
  if (s5p_ehci-phy)
  -   usb_phy_shutdown(s5p_ehci-phy);
  +   phy_power_off(s5p_ehci-phy);
  else if (s5p_ehci-pdata-phy_exit)
  s5p_ehci-pdata-phy_exit(pdev, USB_PHY_TYPE_HOST);
 
  @@ -244,7 +245,7 @@ static int s5p_ehci_suspend(struct device *dev)
  s5p_ehci-otg-set_host(s5p_ehci-otg, hcd-self);
 ditto
 
 
  if (s5p_ehci-phy)
  -   usb_phy_shutdown(s5p_ehci-phy);
  +   phy_power_off(s5p_ehci-phy);
  else if (s5p_ehci-pdata-phy_exit)
  s5p_ehci-pdata-phy_exit(pdev, USB_PHY_TYPE_HOST);
 
  @@ -265,7 +266,7 @@ static int s5p_ehci_resume(struct device *dev)
  s5p_ehci-otg-set_host(s5p_ehci-otg, hcd-self);
 ditto

[PATCH 0/5] phy: Add new Exynos USB PHY driver

2013-10-25 Thread Kamil Debski
Hi,

This is the second version of the patch adding support for USB PHY module
of the Exynos series of SoCs by Samsung. The driver is utilising the newly
added Generic PHY Framework by Kishon Vijay Abraham I [1].

In addition to the PHY driver this patchset contains:
- work in progress support for Exynos 5250
  (based on the drivers/usb/phy/phy-samsung-usb2.c driver)
- support for S5PV210 added by Mateusz Krawczuk during his summer internship at
  Samsung
- change to the ehci-s5p driver which modifies the driver to use the General
  PHY Framework
- change to the s3c-hsotg driver which modifies the driver to use the General
  PHY Framework

Best wishes,
Kamil Debski

Changes from v1:
- the changes include minor fixes of the hardware initialization of the PHY
  module
- some other minor fixes were introduced

--
Original cover letter:

Hi,

This patch adds a new drive for USB PHYs for Samsung SoCs. The driver is using
the Generic PHY Framework created by Kishon Vijay Abrahan I. It can be found
here https://lkml.org/lkml/2013/8/21/29. This patch adds support to Exynos4
family of SoCs. Support for Exynos3 and Exynos5 is planned to be added in the
near future.

I welcome your comments.

--

[1] https://lkml.org/lkml/2013/8/21/29

Kamil Debski (4):
  phy: Add new Exynos USB PHY driver
  phy: Add WIP Exynos 5250 support to the Exynos USB PHY driver
  usb: ehci-s5p: Change to use phy provided by the generic phy
framework
  usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic
phy framework

Mateusz Krawczuk (1):
  phy: Add support for S5PV210 to the Exynos USB PHY driver

 .../devicetree/bindings/phy/samsung-usbphy.txt |   51 +++
 drivers/phy/Kconfig|   35 ++
 drivers/phy/Makefile   |4 +
 drivers/phy/phy-exynos-usb.c   |  265 +
 drivers/phy/phy-exynos-usb.h   |   96 +
 drivers/phy/phy-exynos4210-usb.c   |  295 ++
 drivers/phy/phy-exynos4212-usb.c   |  343 
 drivers/phy/phy-exynos5250-usb.c   |  411 
 drivers/phy/phy-s5pv210-usb.c  |  236 +++
 drivers/usb/gadget/s3c-hsotg.c |   13 +-
 drivers/usb/host/ehci-s5p.c|   21 +-
 11 files changed, 1755 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt
 create mode 100644 drivers/phy/phy-exynos-usb.c
 create mode 100644 drivers/phy/phy-exynos-usb.h
 create mode 100644 drivers/phy/phy-exynos4210-usb.c
 create mode 100644 drivers/phy/phy-exynos4212-usb.c
 create mode 100644 drivers/phy/phy-exynos5250-usb.c
 create mode 100644 drivers/phy/phy-s5pv210-usb.c

-- 
1.7.9.5

--
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 1/5] phy: Add new Exynos USB PHY driver

2013-10-25 Thread Kamil Debski
Add a new driver for the Exynos USB PHY. The new driver uses the generic
PHY framework. The driver includes support for the Exynos 4x10 and 4x12
SoC families.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/phy/samsung-usbphy.txt |   51 +++
 drivers/phy/Kconfig|   21 ++
 drivers/phy/Makefile   |3 +
 drivers/phy/phy-exynos-usb.c   |  245 ++
 drivers/phy/phy-exynos-usb.h   |   94 ++
 drivers/phy/phy-exynos4210-usb.c   |  295 +
 drivers/phy/phy-exynos4212-usb.c   |  343 
 7 files changed, 1052 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/samsung-usbphy.txt
 create mode 100644 drivers/phy/phy-exynos-usb.c
 create mode 100644 drivers/phy/phy-exynos-usb.h
 create mode 100644 drivers/phy/phy-exynos4210-usb.c
 create mode 100644 drivers/phy/phy-exynos4212-usb.c

diff --git a/Documentation/devicetree/bindings/phy/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
new file mode 100644
index 000..f112b37
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/samsung-usbphy.txt
@@ -0,0 +1,51 @@
+Samsung S5P/EXYNOS SoC series USB PHY
+-
+
+Required properties:
+- compatible : should be one of the listed compatibles:
+   - samsung,exynos4210-usbphy
+   - samsung,exynos4212-usbphy
+- reg : a list of registers used by phy driver
+   - first and obligatory is the location of phy modules registers
+   - second and also required is the location of isolation registers
+ (isolation registers control the physical connection between the in
+ SoC modules and outside of the SoC, this also can be called enable
+ control in the documentation of the SoC)
+   - third is the location of the mode switch register, this only applies
+ to SoCs that have such a feature; mode switching enables to have
+ both host and device used the same SoC pins and is commonly used
+ when OTG is supported
+- #phy-cells : from the generic phy bindings, must be 1;
+
+The second cell in the PHY specifier identifies the PHY its meaning is SoC
+dependent. For the currently supported SoCs (Exynos 4210 and Exynos 4212) it
+is as follows:
+  0 - USB device,
+  1 - USB host,
+  2 - HSIC0,
+  3 - HSIC1,
+
+Example:
+
+For Exynos 4412 (compatible with Exynos 4212):
+
+exynos_usbphy: exynos-usbphy@125B {
+   compatible = samsung,exynos4212-usbphy;
+   reg = 0x125B 0x100 0x10020704 0x0c 0x1001021c 0x4;
+   ranges;
+   #address-cells = 1;
+   #size-cells = 1;
+   clocks = clock 305, clock 2, clock 2, clock 2,
+   clock 2;
+   clock-names = phy, device, host, hsic0, hsic1;
+   status = okay;
+   #phy-cells = 1;
+};
+
+Then the PHY can be used in other nodes such as:
+
+ehci@1258 {
+   status = okay;
+   phys = exynos_usbphy 2;
+   phy-names = hsic0;
+};
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 349bef2..2f7ac0a 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -15,4 +15,25 @@ config GENERIC_PHY
  phy users can obtain reference to the PHY. All the users of this
  framework should select this config.
 
+config PHY_EXYNOS_USB
+   tristate Samsung USB PHY driver (using the Generic PHY Framework)
+   help
+ Enable this to support Samsung USB phy helper driver for Samsung SoCs.
+ This driver provides common interface to interact, for Samsung
+ USB 2.0 PHY driver.
+
+config PHY_EXYNOS4210_USB
+   bool Support for Exynos 4210
+   depends on PHY_EXYNOS_USB
+   depends on CPU_EXYNOS4210
+   help
+ Enable USB PHY support for Exynos 4210
+
+config PHY_EXYNOS4212_USB
+   bool Support for Exynos 4212
+   depends on PHY_EXYNOS_USB
+   depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412)
+   help
+ Enable USB PHY support for Exynos 4212
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9e9560f..ca3dc82 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,3 +3,6 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_PHY_EXYNOS_USB)   += phy-exynos-usb.o
+obj-$(CONFIG_PHY_EXYNOS4210_USB)   += phy-exynos4210-usb.o
+obj-$(CONFIG_PHY_EXYNOS4212_USB)   += phy-exynos4212-usb.o
diff --git a/drivers/phy/phy-exynos-usb.c b/drivers/phy/phy-exynos-usb.c
new file mode 100644
index 000..d4a26df
--- /dev/null
+++ b/drivers/phy/phy-exynos-usb.c
@@ -0,0 +1,245 @@
+/*
+ * Samsung S5P/EXYNOS SoC series USB PHY driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Author: Kamil Debski k.deb...@samsung.com
+ *
+ * This program is free software; you

[PATCH 5/5] usb: s3c-hsotg: Use the new Exynos USB phy driver with the generic phy framework

2013-10-25 Thread Kamil Debski
Change the used phy driver to the new Exynos USB phy driver that uses the
generic phy framework.

Signed-off-by: Kamil Debski k.deb...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/s3c-hsotg.c |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 7705c41..2ce84a5 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -29,6 +29,7 @@
 #include linux/slab.h
 #include linux/clk.h
 #include linux/regulator/consumer.h
+#include linux/phy/phy.h
 
 #include linux/usb/ch9.h
 #include linux/usb/gadget.h
@@ -131,6 +132,7 @@ struct s3c_hsotg_ep {
 /**
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
+
  * @driver: USB gadget driver
  * @phy: The otg phy transceiver structure for phy control.
  * @plat: The platform specific configuration data. This can be removed once
@@ -154,7 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
-   struct usb_phy  *phy;
+   struct phy   *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2858,9 +2860,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
dev_dbg(hsotg-dev, pdev 0x%p\n, pdev);
 
if (hsotg-phy)
-   usb_phy_init(hsotg-phy);
+   phy_power_on(hsotg-phy);
else if (hsotg-plat-phy_init)
hsotg-plat-phy_init(pdev, hsotg-plat-phy_type);
+
 }
 
 /**
@@ -2875,7 +2878,7 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg-dev);
 
if (hsotg-phy)
-   usb_phy_shutdown(hsotg-phy);
+   phy_power_off(hsotg-phy);
else if (hsotg-plat-phy_exit)
hsotg-plat-phy_exit(pdev, hsotg-plat-phy_type);
 }
@@ -3485,7 +3488,7 @@ static void s3c_hsotg_delete_debug(struct s3c_hsotg 
*hsotg)
 static int s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev-dev.platform_data;
-   struct usb_phy *phy;
+   struct phy *phy;
struct device *dev = pdev-dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3500,7 +3503,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   phy = devm_phy_get(pdev-dev, device);
if (IS_ERR(phy)) {
/* Fallback for pdata */
plat = pdev-dev.platform_data;
-- 
1.7.9.5

--
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


  1   2   >