Re: [PATCH v2] drivers: phy: exynos-usb2: add support for Exynos 3250

2014-07-08 Thread Tomasz Figa
On 07.07.2014 11:39, Marek Szyprowski wrote:
> This patch adds support for Exynos3250 SoC to Exynos2USB PHY driver.
> Although Exynos3250 has only one device phy interface, the register
> layout and all operations that are required to get it enabled are almost
> same as on Exynos4x12. The only different is one more register
> (REFCLKSEL) which need to be set and lack of MODE SWITCH register.
> 
> Signed-off-by: Marek Szyprowski 
> ---
> 
> Changelog:
> v2:
> - added new binding documentation
> - removed superfluous defines
> - removed mode switch for 3250, because it is not really needed
> 
> ---
>  Documentation/devicetree/bindings/phy/samsung-phy.txt |  2 ++
>  drivers/phy/Kconfig   | 12 ++--
>  drivers/phy/phy-exynos4x12-usb2.c | 17 +++--
>  drivers/phy/phy-samsung-usb2.c|  6 ++
>  drivers/phy/phy-samsung-usb2.h|  2 ++
>  5 files changed, 31 insertions(+), 8 deletions(-)
> 

Reviewed-by: Tomasz Figa 

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


[PATCH v2] drivers: phy: exynos-usb2: add support for Exynos 3250

2014-07-07 Thread Marek Szyprowski
This patch adds support for Exynos3250 SoC to Exynos2USB PHY driver.
Although Exynos3250 has only one device phy interface, the register
layout and all operations that are required to get it enabled are almost
same as on Exynos4x12. The only different is one more register
(REFCLKSEL) which need to be set and lack of MODE SWITCH register.

Signed-off-by: Marek Szyprowski 
---

Changelog:
v2:
- added new binding documentation
- removed superfluous defines
- removed mode switch for 3250, because it is not really needed

---
 Documentation/devicetree/bindings/phy/samsung-phy.txt |  2 ++
 drivers/phy/Kconfig   | 12 ++--
 drivers/phy/phy-exynos4x12-usb2.c | 17 +++--
 drivers/phy/phy-samsung-usb2.c|  6 ++
 drivers/phy/phy-samsung-usb2.h|  2 ++
 5 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt 
b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index 2049261d8c31..6099a5c94283 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,exynos3250-usb2-phy"
- "samsung,exynos4210-usb2-phy"
- "samsung,exynos4x12-usb2-phy"
- "samsung,exynos5250-usb2-phy"
@@ -46,6 +47,7 @@ and Exynos 4212) it is as follows:
   1 - USB host ("host"),
   2 - HSIC0 ("hsic0"),
   3 - HSIC1 ("hsic1"),
+Exynos3250 has only USB device phy available as phy 0.
 
 Exynos 4210 and Exynos 4212 use mode switching and require that mode switch
 register is supplied.
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 16a2f067c242..50bee8357a7f 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -141,14 +141,14 @@ config PHY_EXYNOS4210_USB2
  phys are available - device, host, HSIC0 and HSIC1.
 
 config PHY_EXYNOS4X12_USB2
-   bool "Support for Exynos 4x12"
+   bool "Support for Exynos 3250/4x12"
depends on PHY_SAMSUNG_USB2
-   depends on (SOC_EXYNOS4212 || SOC_EXYNOS4412)
+   depends on (SOC_EXYNOS3250 || SOC_EXYNOS4212 || SOC_EXYNOS4412)
help
- Enable USB PHY support for Exynos 4x12. 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 4x12 four
- phys are available - device, host, HSIC0 and HSIC1.
+ Enable USB PHY support for Exynos 3250/4x12. 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 4x12
+ four phys are available - device, host, HSIC0 and HSIC1.
 
 config PHY_EXYNOS5250_USB2
bool "Support for Exynos 5250"
diff --git a/drivers/phy/phy-exynos4x12-usb2.c 
b/drivers/phy/phy-exynos4x12-usb2.c
index 59d8dd3ff390..f26ab22bc9c7 100644
--- a/drivers/phy/phy-exynos4x12-usb2.c
+++ b/drivers/phy/phy-exynos4x12-usb2.c
@@ -67,6 +67,8 @@
 #define EXYNOS_4x12_UPHYCLK_PHYFSEL_24MHZ  (0x5 << 0)
 #define EXYNOS_4x12_UPHYCLK_PHYFSEL_50MHZ  (0x7 << 0)
 
+#define EXYNOS_3250_UPHYCLK_REFCLKSEL  (0x2 << 8)
+
 #define EXYNOS_4x12_UPHYCLK_PHY0_ID_PULLUP BIT(3)
 #define EXYNOS_4x12_UPHYCLK_PHY0_COMMON_ON BIT(4)
 #define EXYNOS_4x12_UPHYCLK_PHY1_COMMON_ON BIT(7)
@@ -197,6 +199,10 @@ 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;
+
+   if (drv->cfg->has_refclk_sel)
+   clk = EXYNOS_3250_UPHYCLK_REFCLKSEL;
+
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);
@@ -278,7 +284,7 @@ static int exynos4x12_power_on(struct 
samsung_usb2_phy_instance *inst)

exynos4x12_power_on_internal(&drv->instances[EXYNOS4x12_DEVICE]);
}
 
-   if (inst->cfg->id == EXYNOS4x12_DEVICE)
+   if (inst->cfg->id == EXYNOS4x12_DEVICE && drv->cfg->has_mode_switch)
regmap_update_bits(drv->reg_sys, EXYNOS_4x12_MODE_SWITCH_OFFSET,
EXYNOS_4x12_MODE_SWITCH_MASK,
EXYNOS_4x12_MODE_SWITCH_DEVICE);
@@ -310,7 +316,7 @@ static int exynos4x12_power_off(struct 
samsung_usb2_phy_instance *inst)
if (inst->ext_cnt-- > 1)
return 0;
 
-   if (inst->cfg->id == EXYNOS4x12_DEVICE)
+   if (inst->cfg->id == EXYNOS4x12_DEVICE && drv->cfg->has_mode_switch)
regmap_update_bits(drv->reg_sys, EXYNOS_4x12_MODE_SWITCH_OFFSET,