Fwd: [PATCH] usb: phy: samsung: Add support for EXYNOS4210

2013-06-05 Thread Praveen Paneri
Hi,

On Tue, May 28, 2013 at 2:34 PM, Jingoo Han  wrote:
> Add support for EXYNOS4210 that includes USB EHCI/OHCI.
> Previous PHY initialization code is not correct; thus, it is modifed
 ^ You might
want to say "previous PHY init code does not support HOST and HSIC
PHY."

> to support EXYNOS4210 PHY. Also, after common clock framework for
> Samsung is added, clock name is defined as 'usb_device'.
>
> Signed-off-by: Jingoo Han 
> ---
> Tested on Exynos4210.
>
>  drivers/usb/phy/phy-samsung-usb.h  |   35 ++---
>  drivers/usb/phy/phy-samsung-usb2.c |   74 
> +---
>  2 files changed, 98 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-samsung-usb.h 
> b/drivers/usb/phy/phy-samsung-usb.h
> index 70a9cae..34c35e8 100644
> --- a/drivers/usb/phy/phy-samsung-usb.h
> +++ b/drivers/usb/phy/phy-samsung-usb.h
> @@ -22,13 +22,22 @@
>
>  #define SAMSUNG_PHYPWR (0x00)
>
> +#define PHYPWR_PHY1_HSIC_NORMAL_MASK   (0xf << 9)
> +#define PHYPWR_PHY1_HSIC1_SLEEP(1 << 12)
> +#define PHYPWR_PHY1_HSIC1_FORCE_SUSPEND(1 << 11)
> +#define PHYPWR_PHY1_HSIC0_SLEEP(1 << 10)
> +#define PHYPWR_PHY1_HSIC0_FORCE_SUSPEND(1 << 9)
> +#define PHYPWR_PHY1_STD_NORMAL_MASK(0x7 << 6)
> +#define PHYPWR_PHY1_STD_SLEEP  (1 << 8)
> +#define PHYPWR_PHY1_STD_ANALOG_POWERDOWN   (1 << 7)
> +#define PHYPWR_PHY1_STD_FORCE_SUSPEND  (1 << 6)
>  #define PHYPWR_NORMAL_MASK (0x19 << 0)
>  #define PHYPWR_OTG_DISABLE (0x1 << 4)
>  #define PHYPWR_ANALOG_POWERDOWN(0x1 << 3)
>  #define PHYPWR_FORCE_SUSPEND   (0x1 << 1)
>  /* For Exynos4 */
This comment is misplaced?

> -#define PHYPWR_NORMAL_MASK_PHY0(0x39 << 0)
> -#define PHYPWR_SLEEP_PHY0  (0x1 << 5)
> +#define PHYPWR_PHY0_NORMAL_MASK(0x39 << 0)
> +#define PHYPWR_PHY0_SLEEP  (0x1 << 5)
>
>  #define SAMSUNG_PHYCLK (0x04)
>
> @@ -43,9 +52,25 @@
>
>  #define SAMSUNG_RSTCON (0x08)
>
> -#define RSTCON_PHYLINK_SWRST   (0x1 << 2)
> -#define RSTCON_HLINK_SWRST (0x1 << 1)
> -#define RSTCON_SWRST   (0x1 << 0)
> +#define RSTCON_HOST_LINK_PORT_SWRST_MASK   (0xf << 6)
> +#define RSTCON_HOST_LINK_PORT2_SWRST   (0x1 << 9)
> +#define RSTCON_HOST_LINK_PORT1_SWRST   (0x1 << 8)
> +#define RSTCON_HOST_LINK_PORT0_SWRST   (0x1 << 7)
> +#define RSTCON_HOST_LINK_ALL_SWRST (0x1 << 6)
> +#define RSTCON_PHY1_SWRST_MASK (0x7 << 3)
> +#define RSTCON_PHY1_HSIC_SWRST (0x1 << 5)
> +#define RSTCON_PHY1_STD_SWRST  (0x1 << 4)
> +#define RSTCON_PHY1_ALL_SWRST  (0x1 << 3)
> +#define RSTCON_PHY0_SWRST_MASK (0x7 << 0)
> +#define RSTCON_PHY0_PHYLINK_SWRST  (0x1 << 2)
> +#define RSTCON_PHY0_HLINK_SWRST(0x1 << 1)
> +#define RSTCON_PHY0_SWRST  (0x1 << 0)
> +
> +/* EXYNOS4 */
> +#define EXYNOS4_PHY1CON(0x34)
> +
> +#define PHY1CON_FPENABLEN  (0x1 << 0)
> +
>
>  /* EXYNOS5 */
>  #define EXYNOS5_PHY_HOST_CTRL0 (0x00)
> diff --git a/drivers/usb/phy/phy-samsung-usb2.c 
> b/drivers/usb/phy/phy-samsung-usb2.c
> index 9d5e273..4f93d84 100644
> --- a/drivers/usb/phy/phy-samsung-usb2.c
> +++ b/drivers/usb/phy/phy-samsung-usb2.c
> @@ -158,6 +158,15 @@ static void samsung_exynos5_usb2phy_enable(struct 
> samsung_usbphy *sphy)
> writel(ohcictrl, regs + EXYNOS5_PHY_HOST_OHCICTRL);
>  }
>
> +static bool exynos4_phyhost_is_on(void __iomem *regs)
> +{
> +   u32 reg;
> +
> +   reg = readl(regs + SAMSUNG_PHYPWR);
> +
> +   return !(reg & PHYPWR_PHY1_STD_ANALOG_POWERDOWN);
> +}
> +
>  static void samsung_usb2phy_enable(struct samsung_usbphy *sphy)
>  {
> void __iomem *regs = sphy->regs;
> @@ -165,6 +174,18 @@ static void samsung_usb2phy_enable(struct samsung_usbphy 
> *sphy)
> u32 phyclk;
> u32 rstcon;
>
> +   switch (sphy->drv_data->cpu_type) {
> +   case TYPE_EXYNOS4210:
> +   atomic_inc(&sphy->phy_usage);
> +
> +   if (exynos4_phyhost_is_on(regs)) {
> +   dev_info(sphy->dev, "Already power on PHY\n");
> +   return;
> +   }
> +   default:
> +   break;
> +   }
> +
> /* set clock frequency for PLL */
> phyclk = sphy->ref_clk_freq;
> phypwr = readl(regs + SAMSUNG_PHYPWR);
> @@ -174,22 +195,48 @@ static void samsung_usb2phy_enable(struct 
> samsung_usbphy *sphy)
> case TYPE_S3C64XX:
> phyclk &= ~PHYCLK_COMMON_ON

Re: [PATCH 1/2] usb: phy: Add USB host phy support on Exyno4412

2013-02-05 Thread Praveen Paneri
Hi,

On Tue, Feb 5, 2013 at 6:55 AM, Dongjin Kim  wrote:
> This patch adds host phy support for Samsung's Exynos4412 SoC to
> samsung-usbphy driver. This patch is created upon 
> "http://git.kernel.org/?p=linux/kernel/git/balbi/usb.git;a=commit;h=2564b526b8cf01e6c36285edfd40a438e683c2b8";
>
> Cc: Praveen Paneri 
> Signed-off-by: Dongjin Kim 
> ---
>  drivers/usb/phy/samsung-usbphy.c |  156 
> +-
>  1 file changed, 154 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/phy/samsung-usbphy.c 
> b/drivers/usb/phy/samsung-usbphy.c
> index 6ea5537..c800fa4 100644
> --- a/drivers/usb/phy/samsung-usbphy.c
> +++ b/drivers/usb/phy/samsung-usbphy.c
> @@ -47,7 +47,7 @@
>
>  #define PHYCLK_MODE_USB11  (0x1 << 6)
>  #define PHYCLK_EXT_OSC (0x1 << 5)
> -#define PHYCLK_COMMON_ON_N (0x1 << 4)
> +#define PHYCLK_COMMON_ON_N_PHY0(0x1 << 4)
>  #define PHYCLK_ID_PULL (0x1 << 2)
>  #define PHYCLK_CLKSEL_MASK (0x3 << 0)
>  #define PHYCLK_CLKSEL_48M  (0x0 << 0)
> @@ -60,6 +60,22 @@
>  #define RSTCON_HLINK_SWRST (0x1 << 1)
>  #define RSTCON_SWRST   (0x1 << 0)
>
> +/* For Exynos4412 */
> +#define PHYCLK_COMMON_ON_N_PHY1(0x1 << 7)
> +
> +#define PHYPWR_NORMAL_MASK_HSIC1   (0x7 << 12)
> +#define PHYPWR_NORMAL_MASK_HSIC0   (0x7 << 9)
> +#define PHYPWR_NORMAL_MASK_PHY1(0x7 << 6)
> +
> +#define PHYPWR_ANALOG_POWERDOWN_PHY1   (0x1 << 7)
> +
> +#define RSTCON_HLINK_SWRST_MASK(0xf << 7)
> +#define RSTCON_PHY1_SWRST_MASK (0xf << 3)
> +#define RSTCON_PHY0_SWRST_MASK (0x7 << 0)
> +
> +#define EXYNOS4_PHY_HSIC_CTRL0 (0x04)
> +#define EXYNOS4_PHY_HSIC_CTRL1 (0x08)
> +
>  /* EXYNOS5 */
>  #define EXYNOS5_PHY_HOST_CTRL0 (0x00)
>
> @@ -174,6 +190,7 @@
>  enum samsung_cpu_type {
> TYPE_S3C64XX,
> TYPE_EXYNOS4210,
> +   TYPE_EXYNOS4412,
Shouldn't you add it under the TYPE_EXYNOS4X12. We will have to add a
separate support for 4212 then.
> TYPE_EXYNOS5250,
>  };
>
> @@ -322,6 +339,17 @@ static void samsung_usbphy_set_isolation(struct 
> samsung_usbphy *sphy, bool on)
> en_mask = sphy->drv_data->hostphy_en_mask;
> }
> break;
> +   case TYPE_EXYNOS4412:
> +   if (sphy->phy_type == USB_PHY_TYPE_DEVICE) {
> +   reg = sphy->pmuregs +
> +   sphy->drv_data->devphy_reg_offset;
> +   en_mask = sphy->drv_data->devphy_en_mask;
> +   } else if (sphy->phy_type == USB_PHY_TYPE_HOST) {
> +   reg = sphy->pmuregs +
> +   sphy->drv_data->hostphy_reg_offset;
> +   en_mask = sphy->drv_data->hostphy_en_mask;
> +   }
> +   break;
> default:
> dev_err(sphy->dev, "Invalid SoC type\n");
> return;
> @@ -422,6 +450,29 @@ static int samsung_usbphy_get_refclk_freq(struct 
> samsung_usbphy *sphy)
> refclk_freq = FSEL_CLKSEL_24M;
> break;
> }
> +   } else if (sphy->drv_data->cpu_type == TYPE_EXYNOS4412) {
> +   switch (clk_get_rate(ref_clk)) {
> +   case 9600 * KHZ:
> +   refclk_freq = FSEL_CLKSEL_9600K;
> +   break;
> +   case 10 * MHZ:
> +   refclk_freq = FSEL_CLKSEL_10M;
> +   break;
> +   case 12 * MHZ:
> +   refclk_freq = FSEL_CLKSEL_12M;
> +   break;
> +   case 19200 * KHZ:
> +   refclk_freq = FSEL_CLKSEL_19200K;
> +   break;
> +   case 20 * MHZ:
> +   refclk_freq = FSEL_CLKSEL_20M;
> +   break;
> +   case 24 * MHZ:
> +   default:
> +   /* default reference clock */
> +   refclk_freq = FSEL_CLKSEL_24M;
> +   break;
> +   }
> } else {
> switch (clk_get_rate(ref_clk)) {
> case 12 * MHZ:
&g

Re: [RESEND PATCH v9 0/2] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2013-01-20 Thread Praveen Paneri
Hi Felipe,

On Sat, Jan 19, 2013 at 12:16 AM, Felipe Balbi  wrote:
> Hi,
>
> On Fri, Jan 18, 2013 at 02:30:21PM +0530, Praveen Paneri wrote:
>> Changes from v8:
>> Resending this patch series after rebasing to the latest usb-next branch.
>> Rewording inline comments for better readability.
>> Removed IS_ENABLED(CONFIG_OF) as pdev->dev.of_node is enough to check for dt 
>> support.
>> Using of_match_ptr to add of_match_table to platform_driver structure.
>> Removed unnecessary variables.
>>
>> Changes from v7:
>> Rebased to the latest usb-next branch.
>> Separating arch patches from these driver patches.
>>
>> Changes from v6:
>> Modified register definitions according to the existing ones.
>> Changed default PHY clk selection for SoCs.
>> Improved binding text and rebased to the latest usb-next.
>>
>> Changes from v5:
>> Moved clk_get() to driver's probe function. Now reference clock frequency
>> selection value is stored in samsung_usbphy structure for later use. Used
>> IS_ENABLED() instead of #ifdef in samsung_usbphy_get_driver_data().
>>
>> Changes from v4:
>> Moved header file contents to driver's source file
>> Removed unnecessary print message from driver's probe function
>> Dropped the Free Software Foundation address from the header
>>
>> Changes from v3:
>> Replaced susbsys_initcall()/module_exit() by module_platform_driver().
>> Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
>> is registered
>> Removed unnecessary devm_usb_put_phy() call from the hsotg driver remove.
>>
>> Changes from v2:
>> Changed the driver filenames to samsung-usbphy
>> Rectified coding style related errors
>>
>> Changes from v1:
>> Rebased patches to latest usb-next branch
>> Changed the name 'sec_usbphy' to 'samsung_usbphy'
>>
>> This patch set introduces a phy driver for samsung SoCs. It uses the existing
>> transceiver infrastructure to provide phy control functions. Use of this 
>> driver
>> can be extended for usb host phy as well. Over the period of time all the phy
>> related code for most of the samsung SoCs can be integrated here.
>> Removing the existing phy code from mach-s3c64xx. Same can be done for other 
>> SoCs
>> when they start supporting this phy driver.
>> This driver is tested with smdk6410 and Exynos4210(with DT).
>>
>> Praveen Paneri (2):
>>   usb: phy: samsung: Introducing usb phy driver for hsotg
>>   usb: s3c-hsotg: Adding phy driver support
>
> Can you check on my xceiv branch if this is applied correctly ?
Yes! It is applied fine.

Thanks :)

Praveen
>
> thanks
>
> --
> balbi
--
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


[RESEND PATCH v9 2/2] usb: s3c-hsotg: Adding phy driver support

2013-01-18 Thread Praveen Paneri
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Praveen Paneri 
Acked-by: Kyungmin Park 
---
 drivers/usb/gadget/s3c-hsotg.c |   37 +++--
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 439c3f9..c8ed7f1 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transceiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
-   if (hsotg->plat->phy_init)
+
+   if (hsotg->phy)
+   usb_phy_init(hsotg->phy);
+   else if (hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->plat->phy_exit)
+   if (hsotg->phy)
+   usb_phy_shutdown(hsotg->phy);
+   else if (hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3492,6 +3501,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = &pdev->dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3500,20 +3510,27 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
int ret;
int i;
 
-   plat = pdev->dev.platform_data;
-   if (!plat) {
-   dev_err(&pdev->dev, "no platform data defined\n");
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
 
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR_OR_NULL(phy)) {
+   /* Fallback for pdata */
+   plat = pdev->dev.platform_data;
+   if (!plat) {
+   dev_err(&pdev->dev, "no platform data or transceiver 
defined\n");
+   return -EPROBE_DEFER;
+   } else {
+   hsotg->plat = plat;
+   }
+   } else {
+   hsotg->phy = phy;
+   }
+
hsotg->dev = dev;
-   hsotg->plat = plat;
 
hsotg->clk = devm_clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
-- 
1.7.1

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


[RESEND PATCH v9 1/2] usb: phy: samsung: Introducing usb phy driver for hsotg

2013-01-18 Thread Praveen Paneri
This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable usb phy. Support
will be extended to host controllers and more Samsung SoCs.

Signed-off-by: Praveen Paneri 
Acked-by: Heiko Stuebner 
Acked-by: Kyungmin Park 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  354 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 5 files changed, 401 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..7b26e2d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,11 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+TODO: Adding the PHY binding with controller(s) according to the under
+developement generic PHY driver.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 5de6e7f..36a85b6 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -45,3 +45,11 @@ config USB_RCAR_PHY
 
  To compile this driver as a module, choose M here: the
  module will be called rcar-phy.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 1a579a8..ec304f6 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_USB_ISP1301)   += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
 obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
new file mode 100644
index 000..5c5e1bb
--- /dev/null
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -0,0 +1,354 @@
+/* linux/drivers/usb/phy/samsung-usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register definitions */
+
+#define SAMSUNG_PHYPWR (0x00)
+
+#define PHYPWR_NORMAL_MASK (0x19 << 0)
+#define PHYPWR_OTG_DISABLE (0x1 << 4)
+#define PHYPWR_ANALOG_POWERDOWN(0x1 << 3)
+#define PHYPWR_FORCE_SUSPEND   (0x1 << 1)
+/* For Exynos4 */
+#define PHYPWR_NORMAL_MASK_PHY0(0x39 << 0)
+#define PHYPWR_SLEEP_PHY0  (0x1 << 5)
+
+#define SAMSUNG_PHYCLK (0x04)
+
+#define PHYCLK_MODE_USB11  (0x1 << 6)
+#define PHYCLK_EXT_OSC (0x1 << 5)
+#define PHYCLK_COMMON_ON_N (0x1 << 4)
+#define PHYCLK_ID_PULL (0x1 << 2)
+#define PHYCLK_CLKSEL_MASK (0x3 << 0)
+#define PHYCLK_CLKSEL_48M  (0x0 << 0)
+#define PHYCLK_CLKSEL_12M  (0x2 << 0)
+#define PHYCLK_CLKSEL_24M  (0x3 << 0)
+
+#define SAMSUNG_RSTCON (0x08)
+
+#define RSTCON_PHYLINK_SWRST   (0x1 << 2)
+#define RSTCON_HLINK_SWRST (0x1 << 1)
+#define RSTCON_SWRST   (0x1 << 0)
+
+#ifndef MHZ
+#define MHZ (1000*1000)
+#endif
+
+enum samsung_cpu_type {

[RESEND PATCH v9 0/2] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2013-01-18 Thread Praveen Paneri
Changes from v8:
Resending this patch series after rebasing to the latest usb-next branch.
Rewording inline comments for better readability.
Removed IS_ENABLED(CONFIG_OF) as pdev->dev.of_node is enough to check for dt 
support.
Using of_match_ptr to add of_match_table to platform_driver structure.
Removed unnecessary variables.

Changes from v7:
Rebased to the latest usb-next branch.
Separating arch patches from these driver patches.

Changes from v6:
Modified register definitions according to the existing ones.
Changed default PHY clk selection for SoCs.
Improved binding text and rebased to the latest usb-next.

Changes from v5:
Moved clk_get() to driver's probe function. Now reference clock frequency
selection value is stored in samsung_usbphy structure for later use. Used
IS_ENABLED() instead of #ifdef in samsung_usbphy_get_driver_data().

Changes from v4:
Moved header file contents to driver's source file
Removed unnecessary print message from driver's probe function
Dropped the Free Software Foundation address from the header

Changes from v3:
Replaced susbsys_initcall()/module_exit() by module_platform_driver().
Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
is registered
Removed unnecessary devm_usb_put_phy() call from the hsotg driver remove.

Changes from v2:
Changed the driver filenames to samsung-usbphy
Rectified coding style related errors

Changes from v1:
Rebased patches to latest usb-next branch
Changed the name 'sec_usbphy' to 'samsung_usbphy'

This patch set introduces a phy driver for samsung SoCs. It uses the existing
transceiver infrastructure to provide phy control functions. Use of this driver
can be extended for usb host phy as well. Over the period of time all the phy
related code for most of the samsung SoCs can be integrated here.
Removing the existing phy code from mach-s3c64xx. Same can be done for other 
SoCs
when they start supporting this phy driver. 
This driver is tested with smdk6410 and Exynos4210(with DT).

Praveen Paneri (2):
  usb: phy: samsung: Introducing usb phy driver for hsotg
  usb: s3c-hsotg: Adding phy driver support

 .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
 drivers/usb/gadget/s3c-hsotg.c |   37 ++-
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  354 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 6 files changed, 428 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

--
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 1/2] usb: phy: samsung: Introducing usb phy driver for hsotg

2013-01-08 Thread Praveen Paneri
Hi Kukjin,

It has been a long time since I posted these patches. It will be very
kind of you to express your views about this series.
If this looks fine to you, please ack.

Thanks,
Praveen

On Fri, Nov 23, 2012 at 4:03 PM, Praveen Paneri  wrote:
> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
> phy_init and phy_shutdown functions to enable/disable usb phy. Support
> will be extended to host controllers and more Samsung SoCs.
>
> Signed-off-by: Praveen Paneri 
> Acked-by: Heiko Stuebner 
> Acked-by: Kyungmin Park 
> ---
>  .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
>  drivers/usb/phy/Kconfig|8 +
>  drivers/usb/phy/Makefile   |1 +
>  drivers/usb/phy/samsung-usbphy.c   |  354 
> 
>  include/linux/platform_data/samsung-usbphy.h   |   27 ++
>  5 files changed, 401 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>  create mode 100644 drivers/usb/phy/samsung-usbphy.c
>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>
> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
> new file mode 100644
> index 000..7b26e2d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
> @@ -0,0 +1,11 @@
> +* Samsung's usb phy transceiver
> +
> +The Samsung's phy transceiver is used for controlling usb otg phy for
> +s3c-hsotg usb device controller.
> +TODO: Adding the PHY binding with controller(s) according to the under
> +developement generic PHY driver.
> +
> +Required properties:
> +- compatible : should be "samsung,exynos4210-usbphy"
> +- reg : base physical address of the phy registers and length of memory 
> mapped
> +   region.
> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> index 7eb73c5..17ad743 100644
> --- a/drivers/usb/phy/Kconfig
> +++ b/drivers/usb/phy/Kconfig
> @@ -44,3 +44,11 @@ config USB_RCAR_PHY
>
>   To compile this driver as a module, choose M here: the
>   module will be called rcar-phy.
> +
> +config SAMSUNG_USBPHY
> +   bool "Samsung USB PHY controller Driver"
> +   depends on USB_S3C_HSOTG
> +   select USB_OTG_UTILS
> +   help
> + Enable this to support Samsung USB phy controller for samsung
> + SoCs.
> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> index 1a579a8..ec304f6 100644
> --- a/drivers/usb/phy/Makefile
> +++ b/drivers/usb/phy/Makefile
> @@ -9,3 +9,4 @@ obj-$(CONFIG_USB_ISP1301)   += isp1301.o
>  obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
>  obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
>  obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
> +obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
> diff --git a/drivers/usb/phy/samsung-usbphy.c 
> b/drivers/usb/phy/samsung-usbphy.c
> new file mode 100644
> index 000..5c5e1bb
> --- /dev/null
> +++ b/drivers/usb/phy/samsung-usbphy.c
> @@ -0,0 +1,354 @@
> +/* linux/drivers/usb/phy/samsung-usbphy.c
> + *
> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> + *  http://www.samsung.com
> + *
> + * Author: Praveen Paneri 
> + *
> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
> + *
> + * 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.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* Register definitions */
> +
> +#define SAMSUNG_PHYPWR (0x00)
> +
> +#define PHYPWR_NORMAL_MASK (0x19 << 0)
> +#define PHYPWR_OTG_DISABLE (0x1 << 4)
> +#define PHYPWR_ANALOG_POWERDOWN(0x1 << 3)
> +#define PHYPWR_FORCE_SUSPEND   (0x1 << 1)
> +/* For Exynos4 */
> +#define PHYPWR_NORMAL_MASK_PHY0(0x39 << 0)
> +#define PHYPWR_SLEEP_PHY0  (0x1 << 5)
> +
> +#define SAMSUNG_PHYCLK (0x04)
> +
> +#define PHYCLK_MODE_USB11 

Re: [PATCH v8 1/2] usb: phy: samsung: Introducing usb phy driver for hsotg

2013-01-08 Thread Praveen Paneri
Hi Tomasz,

On Wed, Jan 9, 2013 at 11:28 AM, Praveen Paneri  wrote:
> Hi Tomasz,
>
> Sorry! I I missed this comment of yours. Is it okay if we keep
> pmu_isolation as it is (as it does not seem much out of the line). We
> have already gone through a lot of rework and there has been no
> fruitful result :(
> Also after Viveks work, this is only milited to non DT SoCs.
>
> Thanks,
> Praveen
>
> On Wed, Nov 28, 2012 at 6:32 PM, Tomasz Figa  wrote:
>> Hi Praveen,
>>
>> On Friday 23 of November 2012 09:56:37 Praveen Paneri wrote:
>>> >> +static void samsung_usbphy_enable(struct samsung_usbphy *sphy)
>>> >> +{
>>> >> + void __iomem *regs = sphy->regs;
>>> >> + u32 phypwr;
>>> >> + u32 phyclk;
>>> >> + u32 rstcon;
>>> >> +
>>> >> + /* set clock frequency for PLL */
>>> >> + phyclk = sphy->ref_clk_freq;
>>> >> + phypwr = readl(regs + SAMSUNG_PHYPWR);
>>> >> + rstcon = readl(regs + SAMSUNG_RSTCON);
>>> >> +
>>> >> + switch (sphy->cpu_type) {
>>> >> + case TYPE_S3C64XX:
>>> >> + phyclk &= ~PHYCLK_COMMON_ON_N;
>>> >> + phypwr &= ~PHYPWR_NORMAL_MASK;
>>> >> + rstcon |= RSTCON_SWRST;
>>> >> + break;
>>> >> + case TYPE_EXYNOS4210:
>>> >> + phypwr &= ~PHYPWR_NORMAL_MASK_PHY0;
>>> >> + rstcon |= RSTCON_SWRST;
>>> >> + default:
>>> >> + break;
>>> >> + }
>>> >> +
>>> >> + writel(phyclk, regs + SAMSUNG_PHYCLK);
>>> >> + /* set to normal of PHY0 */
>>> >
>>> > I don't understand this comment.
>>>
>>> Will change it to " Configure PHY0 for normal operation"
>>> That should be more clear, I suppose.
>>
>> Yes, much better.
>>
>>> >> + */
>>> >> +
>>> >> +#ifndef __SAMSUNG_USBPHY_PLATFORM_H
>>> >> +#define __SAMSUNG_USBPHY_PLATFORM_H
>>> >> +
>>> >> +/**
>>> >> + * samsung_usbphy_data - Platform data for USB PHY driver.
>>> >> + * @pmu_isolation: Function to control usb phy isolation in PMU.
>>> >> + */
>>> >> +struct samsung_usbphy_data {
>>> >> + void (*pmu_isolation)(int on);
>>> >
>>> > I believe this should be named in a generic way. This is called PMU
>>> > isolation on Exynos SoCs, but on S3C64xx it's USB PHY mask.
>>>
>>> Yes! I am aware of it. The fact that this ( MASK or ISOLATION) has
>>> always been part of the PMU, pmu_isolation seems quite generic that
>>> way. Though you can suggest a better name.
>>
>> What do you think about set_isolation(int on) or power_isolation(int on)?
Please ignore the below text. I did not plan to send this :P
It was just an old draft written in a bad mood :(

Regards,
Praveen
> Sorry! I don't understand the point here.Why to invest so much of time
> and evergy on things we want to remove soon.
> I am a bit reluctant to change this now, after sending 9 versions of
> the same code.
> Lets concentrate on more important things like AUXDATA removal or
> adding support for all DT enabled machines.
>>
>> Best regards,
>> --
>> Tomasz Figa
>> Samsung Poland R&D Center
>> SW Solution Development, Linux Platform
>>
>> --
>> 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
--
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 v8 1/2] usb: phy: samsung: Introducing usb phy driver for hsotg

2013-01-08 Thread Praveen Paneri
Hi Tomasz,

Sorry! I I missed this comment of yours. Is it okay if we keep
pmu_isolation as it is (as it does not seem much out of the line). We
have already gone through a lot of rework and there has been no
fruitful result :(
Also after Viveks work, this is only milited to non DT SoCs.

Thanks,
Praveen

On Wed, Nov 28, 2012 at 6:32 PM, Tomasz Figa  wrote:
> Hi Praveen,
>
> On Friday 23 of November 2012 09:56:37 Praveen Paneri wrote:
>> >> +static void samsung_usbphy_enable(struct samsung_usbphy *sphy)
>> >> +{
>> >> + void __iomem *regs = sphy->regs;
>> >> + u32 phypwr;
>> >> + u32 phyclk;
>> >> + u32 rstcon;
>> >> +
>> >> + /* set clock frequency for PLL */
>> >> + phyclk = sphy->ref_clk_freq;
>> >> + phypwr = readl(regs + SAMSUNG_PHYPWR);
>> >> + rstcon = readl(regs + SAMSUNG_RSTCON);
>> >> +
>> >> + switch (sphy->cpu_type) {
>> >> + case TYPE_S3C64XX:
>> >> + phyclk &= ~PHYCLK_COMMON_ON_N;
>> >> + phypwr &= ~PHYPWR_NORMAL_MASK;
>> >> + rstcon |= RSTCON_SWRST;
>> >> + break;
>> >> + case TYPE_EXYNOS4210:
>> >> + phypwr &= ~PHYPWR_NORMAL_MASK_PHY0;
>> >> + rstcon |= RSTCON_SWRST;
>> >> + default:
>> >> + break;
>> >> + }
>> >> +
>> >> + writel(phyclk, regs + SAMSUNG_PHYCLK);
>> >> + /* set to normal of PHY0 */
>> >
>> > I don't understand this comment.
>>
>> Will change it to " Configure PHY0 for normal operation"
>> That should be more clear, I suppose.
>
> Yes, much better.
>
>> >> + */
>> >> +
>> >> +#ifndef __SAMSUNG_USBPHY_PLATFORM_H
>> >> +#define __SAMSUNG_USBPHY_PLATFORM_H
>> >> +
>> >> +/**
>> >> + * samsung_usbphy_data - Platform data for USB PHY driver.
>> >> + * @pmu_isolation: Function to control usb phy isolation in PMU.
>> >> + */
>> >> +struct samsung_usbphy_data {
>> >> + void (*pmu_isolation)(int on);
>> >
>> > I believe this should be named in a generic way. This is called PMU
>> > isolation on Exynos SoCs, but on S3C64xx it's USB PHY mask.
>>
>> Yes! I am aware of it. The fact that this ( MASK or ISOLATION) has
>> always been part of the PMU, pmu_isolation seems quite generic that
>> way. Though you can suggest a better name.
>
> What do you think about set_isolation(int on) or power_isolation(int on)?
Sorry! I don't understand the point here.Why to invest so much of time
and evergy on things we want to remove soon.
I am a bit reluctant to change this now, after sending 9 versions of
the same code.
Lets concentrate on more important things like AUXDATA removal or
adding support for all DT enabled machines.
>
> Best regards,
> --
> Tomasz Figa
> Samsung Poland R&D Center
> SW Solution Development, Linux Platform
>
> --
> 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
--
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 v8 2/2] usb: s3c-hsotg: Adding phy driver support

2012-11-30 Thread Praveen Paneri
On Wed, Nov 28, 2012 at 6:50 PM, Tomasz Figa  wrote:
> Hi Praveen,
>
> On Friday 23 of November 2012 09:54:51 Praveen Paneri wrote:
>> We will anyway remove the platform data part soon. If you say I can
>> resend it again.
>
> I think that the requirement for platform data on DT-enabled systems
> should be removed before this series get merged, because there are already
> patches being worked on to remove auxdata tables (common clock framework
> support by Thomas Abraham).
Next is to add support for 4210, 4x12 and Exynos5 (patches were sent
by vivek Gautam already). Not only s3c-hsotg but ehci, ohci and dwc
will start using phy driver.
This will remove phy related platform data passed to these drivers and...
>
> Adding next auxdata entry (containing platform data that must be provided)
> would make them depend on phy platform data removal patch, which would
> complicate things.
s3c-hsotg platform data is also passing "is_osc" (Clock source info)
and "dma" (dma mode info) from platform_data. IT seems they both are
not used as on now. May be Lukasz can tell if we can move that to
config option and get rid of s3c-hsotg_plat completely.

Once that is done only AUXDATA entry, which will be remaining, will be
that of phy driver and I understand that we have to work towards
removal of that as well but I guess this is a good first step towards
the goal.

>
> Best regards,
> --
> Tomasz Figa
> Samsung Poland R&D Center
> SW Solution Development, Linux Platform
>
> --
> 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
--
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 1/2] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-11-23 Thread Praveen Paneri
This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable usb phy. Support
will be extended to host controllers and more Samsung SoCs.

Signed-off-by: Praveen Paneri 
Acked-by: Heiko Stuebner 
Acked-by: Kyungmin Park 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  354 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 5 files changed, 401 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..7b26e2d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,11 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+TODO: Adding the PHY binding with controller(s) according to the under
+developement generic PHY driver.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 7eb73c5..17ad743 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -44,3 +44,11 @@ config USB_RCAR_PHY
 
  To compile this driver as a module, choose M here: the
  module will be called rcar-phy.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 1a579a8..ec304f6 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_USB_ISP1301)   += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
 obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
new file mode 100644
index 000..5c5e1bb
--- /dev/null
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -0,0 +1,354 @@
+/* linux/drivers/usb/phy/samsung-usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register definitions */
+
+#define SAMSUNG_PHYPWR (0x00)
+
+#define PHYPWR_NORMAL_MASK (0x19 << 0)
+#define PHYPWR_OTG_DISABLE (0x1 << 4)
+#define PHYPWR_ANALOG_POWERDOWN(0x1 << 3)
+#define PHYPWR_FORCE_SUSPEND   (0x1 << 1)
+/* For Exynos4 */
+#define PHYPWR_NORMAL_MASK_PHY0(0x39 << 0)
+#define PHYPWR_SLEEP_PHY0  (0x1 << 5)
+
+#define SAMSUNG_PHYCLK (0x04)
+
+#define PHYCLK_MODE_USB11  (0x1 << 6)
+#define PHYCLK_EXT_OSC (0x1 << 5)
+#define PHYCLK_COMMON_ON_N (0x1 << 4)
+#define PHYCLK_ID_PULL (0x1 << 2)
+#define PHYCLK_CLKSEL_MASK (0x3 << 0)
+#define PHYCLK_CLKSEL_48M  (0x0 << 0)
+#define PHYCLK_CLKSEL_12M  (0x2 << 0)
+#define PHYCLK_CLKSEL_24M  (0x3 << 0)
+
+#define SAMSUNG_RSTCON (0x08)
+
+#define RSTCON_PHYLINK_SWRST   (0x1 << 2)
+#define RSTCON_HLINK_SWRST (0x1 << 1)
+#define RSTCON_SWRST   (0x1 << 0)
+
+#ifndef MHZ
+#define MHZ (1000*1000)
+#endif
+
+enum samsung_cpu_type {

Re: [PATCH v8 1/2] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-11-22 Thread Praveen Paneri
Hi Tomasz,

On Thu, Nov 22, 2012 at 1:36 AM, Tomasz Figa  wrote:
> Hi Praveen,
>
> See some minor comments inline.
Thanks for your comments
>
> On Wednesday 14 of November 2012 15:57:15 Praveen Paneri wrote:
>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>> phy_init and phy_shutdown functions to enable/disable usb phy. Support
>> will be extended to host controllers and more Samsung SoCs.
>>
>> Signed-off-by: Praveen Paneri 
>> Acked-by: Heiko Stuebner 
>> Acked-by: Kyungmin Park 
>> ---
>>  .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
>>  drivers/usb/phy/Kconfig|8 +
>>  drivers/usb/phy/Makefile   |1 +
>>  drivers/usb/phy/samsung-usbphy.c   |  360
>>  include/linux/platform_data/samsung-usbphy.h
>> |   27 ++
>>  5 files changed, 407 insertions(+), 0 deletions(-)
>>  create mode 100644
>> Documentation/devicetree/bindings/usb/samsung-usbphy.txt create mode
>> 100644 drivers/usb/phy/samsung-usbphy.c
>>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>>
>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt new file
>> mode 100644
>> index 000..7b26e2d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> @@ -0,0 +1,11 @@
>> +* Samsung's usb phy transceiver
>> +
>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>> +s3c-hsotg usb device controller.
>> +TODO: Adding the PHY binding with controller(s) according to the under
>> +developement generic PHY driver.
>> +
>> +Required properties:
>> +- compatible : should be "samsung,exynos4210-usbphy"
>> +- reg : base physical address of the phy registers and length of memory
>> mapped +  region.
>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>> index 7eb73c5..17ad743 100644
>> --- a/drivers/usb/phy/Kconfig
>> +++ b/drivers/usb/phy/Kconfig
>> @@ -44,3 +44,11 @@ config USB_RCAR_PHY
>>
>> To compile this driver as a module, choose M here: the
>> module will be called rcar-phy.
>> +
>> +config SAMSUNG_USBPHY
>> + bool "Samsung USB PHY controller Driver"
>> + depends on USB_S3C_HSOTG
>> + select USB_OTG_UTILS
>> + help
>> +   Enable this to support Samsung USB phy controller for samsung
>> +   SoCs.
>> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
>> index 1a579a8..ec304f6 100644
>> --- a/drivers/usb/phy/Makefile
>> +++ b/drivers/usb/phy/Makefile
>> @@ -9,3 +9,4 @@ obj-$(CONFIG_USB_ISP1301) += isp1301.o
>>  obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o
>>  obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
>>  obj-$(CONFIG_USB_RCAR_PHY)   += rcar-phy.o
>> +obj-$(CONFIG_SAMSUNG_USBPHY)     += samsung-usbphy.o
>> diff --git a/drivers/usb/phy/samsung-usbphy.c
>> b/drivers/usb/phy/samsung-usbphy.c new file mode 100644
>> index 000..3c84aab
>> --- /dev/null
>> +++ b/drivers/usb/phy/samsung-usbphy.c
>> @@ -0,0 +1,360 @@
>> +/* linux/drivers/usb/phy/samsung-usbphy.c
>> + *
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *  http://www.samsung.com
>> + *
>> + * Author: Praveen Paneri 
>> + *
>> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG
>> controller + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/* Register definitions */
>> +
>> +#define SAMSUNG_PHYPWR   (0x00)
>> +
>> +#define PHYPWR_NORMAL_MASK   (0x19 << 0)
>> +#define PHYPWR_OTG_DISABLE   (0x1 << 4)
>> +#define PHYPWR_ANALOG_POWERDOWN  (0x1 << 

Re: [PATCH v8 2/2] usb: s3c-hsotg: Adding phy driver support

2012-11-22 Thread Praveen Paneri
On Thu, Nov 22, 2012 at 1:41 AM, Tomasz Figa  wrote:
> Hi Praveen,
>
> On Wednesday 14 of November 2012 15:57:16 Praveen Paneri wrote:
>> Adding the transceiver to hsotg driver. Keeping the platform data
>> for continuing the smooth operation for boards which still uses it
>>
>> Signed-off-by: Praveen Paneri 
>> Acked-by: Kyungmin Park 
>> ---
>>  drivers/usb/gadget/s3c-hsotg.c |   37
>> +++-- 1 files changed, 27
>> insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/s3c-hsotg.c
>> b/drivers/usb/gadget/s3c-hsotg.c index 6f696ee..bc30a2d 100644
>> --- a/drivers/usb/gadget/s3c-hsotg.c
>> +++ b/drivers/usb/gadget/s3c-hsotg.c
>> @@ -32,6 +32,7 @@
>>
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>
>>  #include 
>> @@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
>>   * struct s3c_hsotg - driver state.
>>   * @dev: The parent device supplied to the probe function
>>   * @driver: USB gadget driver
>> - * @plat: The platform specific configuration data.
>> + * @phy: The otg phy transceiver structure for phy control.
>> + * @plat: The platform specific configuration data. This can be removed
>> once + * all SoCs support usb transceiver.
>>   * @regs: The memory area mapped for accessing registers.
>>   * @irq: The IRQ number we are using
>>   * @supplies: Definition of USB power supplies
>> @@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
>>  struct s3c_hsotg {
>>   struct device*dev;
>>   struct usb_gadget_driver *driver;
>> + struct usb_phy  *phy;
>>   struct s3c_hsotg_plat*plat;
>>
>>   spinlock_t  lock;
>> @@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg
>> *hsotg) struct platform_device *pdev = to_platform_device(hsotg->dev);
>>
>>   dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
>> - if (hsotg->plat->phy_init)
>> +
>> + if (hsotg->phy)
>> + usb_phy_init(hsotg->phy);
>> + else if (hsotg->plat->phy_init)
>>   hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
>>  }
>>
>> @@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg
>> *hsotg) {
>>   struct platform_device *pdev = to_platform_device(hsotg->dev);
>>
>> - if (hsotg->plat->phy_exit)
>> + if (hsotg->phy)
>> + usb_phy_shutdown(hsotg->phy);
>> + else if (hsotg->plat->phy_exit)
>>   hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
>>  }
>>
>> @@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
>>  static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
>>  {
>>   struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
>> + struct usb_phy *phy;
>>   struct device *dev = &pdev->dev;
>>   struct s3c_hsotg_ep *eps;
>>   struct s3c_hsotg *hsotg;
>> @@ -3501,20 +3511,27 @@ static int __devinit s3c_hsotg_probe(struct
>> platform_device *pdev) int ret;
>>   int i;
>>
>> - plat = pdev->dev.platform_data;
>> - if (!plat) {
>> - dev_err(&pdev->dev, "no platform data defined\n");
>> - return -EINVAL;
>> - }
>> -
>>   hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg),
>> GFP_KERNEL); if (!hsotg) {
>>   dev_err(dev, "cannot get memory\n");
>>   return -ENOMEM;
>>   }
>>
>> + phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
>> + if (IS_ERR_OR_NULL(phy)) {
>> + /* Fallback for pdata */
>> + plat = pdev->dev.platform_data;
>> + if (!plat) {
>> + dev_err(&pdev->dev, "no platform data or transceiver
> defined\n");
>> + return -EPROBE_DEFER;
>> + } else {
>> + hsotg->plat = plat;
>> + }
>
> nitpick: The hsotg->plat = plat; assignment can be made without the else
> statement as well.
True!
We will anyway remove the platform data part soon. If you say I can
resend it again.

>
> Best regards,
> Tomasz Figa
>
> --
> 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
--
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 2/2] usb: s3c-hsotg: Adding phy driver support

2012-11-14 Thread Praveen Paneri
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Praveen Paneri 
Acked-by: Kyungmin Park 
---
 drivers/usb/gadget/s3c-hsotg.c |   37 +++--
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 6f696ee..bc30a2d 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transceiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
-   if (hsotg->plat->phy_init)
+
+   if (hsotg->phy)
+   usb_phy_init(hsotg->phy);
+   else if (hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->plat->phy_exit)
+   if (hsotg->phy)
+   usb_phy_shutdown(hsotg->phy);
+   else if (hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = &pdev->dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3501,20 +3511,27 @@ static int __devinit s3c_hsotg_probe(struct 
platform_device *pdev)
int ret;
int i;
 
-   plat = pdev->dev.platform_data;
-   if (!plat) {
-   dev_err(&pdev->dev, "no platform data defined\n");
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
 
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR_OR_NULL(phy)) {
+   /* Fallback for pdata */
+   plat = pdev->dev.platform_data;
+   if (!plat) {
+   dev_err(&pdev->dev, "no platform data or transceiver 
defined\n");
+   return -EPROBE_DEFER;
+   } else {
+   hsotg->plat = plat;
+   }
+   } else {
+   hsotg->phy = phy;
+   }
+
hsotg->dev = dev;
-   hsotg->plat = plat;
 
hsotg->clk = devm_clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
-- 
1.7.1

--
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 1/2] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-11-14 Thread Praveen Paneri
This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable usb phy. Support
will be extended to host controllers and more Samsung SoCs.

Signed-off-by: Praveen Paneri 
Acked-by: Heiko Stuebner 
Acked-by: Kyungmin Park 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  360 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 5 files changed, 407 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..7b26e2d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,11 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+TODO: Adding the PHY binding with controller(s) according to the under
+developement generic PHY driver.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 7eb73c5..17ad743 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -44,3 +44,11 @@ config USB_RCAR_PHY
 
  To compile this driver as a module, choose M here: the
  module will be called rcar-phy.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index 1a579a8..ec304f6 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_USB_ISP1301)   += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
 obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
new file mode 100644
index 000..3c84aab
--- /dev/null
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -0,0 +1,360 @@
+/* linux/drivers/usb/phy/samsung-usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register definitions */
+
+#define SAMSUNG_PHYPWR (0x00)
+
+#define PHYPWR_NORMAL_MASK (0x19 << 0)
+#define PHYPWR_OTG_DISABLE (0x1 << 4)
+#define PHYPWR_ANALOG_POWERDOWN(0x1 << 3)
+#define PHYPWR_FORCE_SUSPEND   (0x1 << 1)
+/* For Exynos4 */
+#define PHYPWR_NORMAL_MASK_PHY0(0x39 << 0)
+#define PHYPWR_SLEEP_PHY0  (0x1 << 5)
+
+#define SAMSUNG_PHYCLK (0x04)
+
+#define PHYCLK_MODE_USB11  (0x1 << 6)
+#define PHYCLK_EXT_OSC (0x1 << 5)
+#define PHYCLK_COMMON_ON_N (0x1 << 4)
+#define PHYCLK_ID_PULL (0x1 << 2)
+#define PHYCLK_CLKSEL_MASK (0x3 << 0)
+#define PHYCLK_CLKSEL_48M  (0x0 << 0)
+#define PHYCLK_CLKSEL_12M  (0x2 << 0)
+#define PHYCLK_CLKSEL_24M  (0x3 << 0)
+
+#define SAMSUNG_RSTCON (0x08)
+
+#define RSTCON_PHYLINK_SWRST   (0x1 << 2)
+#define RSTCON_HLINK_SWRST (0x1 << 1)
+#define RSTCON_SWRST   (0x1 << 0)
+
+#ifndef MHZ
+#define MHZ (1000*1000)
+#endif
+
+enum samsung_cpu_type {

[PATCH v8 0/2] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-11-14 Thread Praveen Paneri
Changes from v7:
Rebased to the latest usb-next branch.
Separating arch patches from these driver patches.

Changes from v6:
Modified register definitions according to the existing ones.
Changed default PHY clk selection for SoCs.
Improved binding text and rebased to the latest usb-next.

Changes from v5:
Moved clk_get() to driver's probe function. Now reference clock frequency
selection value is stored in samsung_usbphy structure for later use. Used
IS_ENABLED() instead of #ifdef in samsung_usbphy_get_driver_data().

Changes from v4:
Moved header file contents to driver's source file
Removed unnecessary print message from driver's probe function
Dropped the Free Software Foundation address from the header

Changes from v3:
Replaced susbsys_initcall()/module_exit() by module_platform_driver().
Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
is registered
Removed unnecessary devm_usb_put_phy() call from the hsotg driver remove.

Changes from v2:
Changed the driver filenames to samsung-usbphy
Rectified coding style related errors

Changes from v1:
Rebased patches to latest usb-next branch
Changed the name 'sec_usbphy' to 'samsung_usbphy'

This patch set introduces a phy driver for samsung SoCs. It uses the existing
transceiver infrastructure to provide phy control functions. Use of this driver
can be extended for usb host phy as well. Over the period of time all the phy
related code for most of the samsung SoCs can be integrated here.
Removing the existing phy code from mach-s3c64xx. Same can be done for other 
SoCs
when they start supporting this phy driver. 
This driver is tested with smdk6410 and Exynos4210(with DT).

Praveen Paneri (2):
  usb: phy: samsung: Introducing usb phy driver for hsotg
  usb: s3c-hsotg: Adding phy driver support

 .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
 drivers/usb/gadget/s3c-hsotg.c |   37 ++-
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  360 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 6 files changed, 434 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

--
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 v7 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-11-13 Thread Praveen Paneri
Hi Kukjin, Felipe,

Since the issue is only with arch patches, which I am going to resolve
asap, Will it be possible for you to consider taking only driver
patches? I can resend arch patches separately to linux-samsung after
updating if Kukjin is also fine with that?

Thanks,
Praveen

On Wed, Nov 14, 2012 at 9:38 AM, Praveen Paneri  wrote:
> Hi,
>
> On Mon, Nov 12, 2012 at 10:11 AM, Kukjin Kim  wrote:
>> Felipe Balbi wrote:
>>>
>>> Hi,
>>>
>> Hi :-)
>>
>> [...]
>>
>>> Sure, but I still need Kukjin's 'say-so' for the arch/arm/plat-samsung
>>> and arch/arm/mach-exynos part.
>>>
>> Basically, this approach looks OK to me.
>>
>> BTW, I have some comments and need to update...
> Thanks! I highly appreciate your comments. It would have been even
> better if I had got these before the closing bell.
>>
>> From 4th patch...
>>
>>> diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-
>>> s3c64xx/mach-smdk6410.c
>>
>> [...]
>>
>>> @@ -72,6 +73,8 @@
>>>  #include 
>>>  #include 
>>>  #include 
>>> +#include 
> Well it comes from an older state where without this it was giving a
> build error. Although it shouldn't have been here. Will fix it.
>>
>> Why? In addition, this causes build error with s3c6400_defconfig.
>>
>> [...]
>>
>>> diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
>>> index 03f654d..9cdb666 100644
>>
>> [...]
>>
>>> @@ -1370,6 +1371,30 @@ struct platform_device s5p_device_mixer = {
>>>
>>>  /* USB */
>>>
>>> +#ifdef CONFIG_S3C_DEV_USB_HSOTG
>>> +/* USB PHY*/
>>> +static struct resource samsung_usbphy_resource[] = {
>>> + [0] = {
>>> + .start = S3C_PA_USB_PHY,
>>> + .end   = S3C_PA_USB_PHY + SZ_16 - 1,
>>> + .flags = IORESOURCE_MEM,
>>> + },
>>> +};
>>
>> +static struct resource samsung_usbphy_resource[] = {
>> +   [0] = DEFINED_RES_MEM(S3C_PA_USB_PHY, SZ_16),
>> +};
>>
>> [...]
>>
>> Happens build error with s5pv210_defconfig
>>
>> arch/arm/plat-samsung/devs.c:1375: error: 'S3C_PA_USB_PHY' undeclared here
>> (not in a function)
>> make[2]: *** [arch/arm/plat-samsung/devs.o] Error 1
>> make[1]: *** [arch/arm/plat-samsung] Error 2
>> make[1]: *** Waiting for unfinished jobs
>>
>> And another build error with exynos_defconfig...
> Will check for both the configs and resolve it.
>
> Thanks,
> Praveen
>>
>> arch/arm/mach-exynos/built-in.o: In function `.LANCHOR1':
>> setup-i2c0.c:(.data+0x8080): undefined reference to
>> `s5p_usb_phy_pmu_isolation'
>>
>> From 5th patch
>>
>> If possible, please to use 'ARM: [sub-arch dir name]: [subject]' format.
>> So I preferred to use 'ARM: EXYNOS: Enabling samsung-usbphy driver for
>> EXYNOS4210' on that.
>>
>> Please make sure your patch has no problem for kernel compilation before
>> submitting...
>>
>> Thanks.
>>
>> Best regards,
>> Kgene.
>> --
>> Kukjin Kim , Senior Engineer,
>> SW Solution Development Team, Samsung Electronics Co., Ltd.
>>
>> --
>> 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
--
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 v7 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-11-13 Thread Praveen Paneri
Hi,

On Mon, Nov 12, 2012 at 10:11 AM, Kukjin Kim  wrote:
> Felipe Balbi wrote:
>>
>> Hi,
>>
> Hi :-)
>
> [...]
>
>> Sure, but I still need Kukjin's 'say-so' for the arch/arm/plat-samsung
>> and arch/arm/mach-exynos part.
>>
> Basically, this approach looks OK to me.
>
> BTW, I have some comments and need to update...
Thanks! I highly appreciate your comments. It would have been even
better if I had got these before the closing bell.
>
> From 4th patch...
>
>> diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-
>> s3c64xx/mach-smdk6410.c
>
> [...]
>
>> @@ -72,6 +73,8 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
Well it comes from an older state where without this it was giving a
build error. Although it shouldn't have been here. Will fix it.
>
> Why? In addition, this causes build error with s3c6400_defconfig.
>
> [...]
>
>> diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
>> index 03f654d..9cdb666 100644
>
> [...]
>
>> @@ -1370,6 +1371,30 @@ struct platform_device s5p_device_mixer = {
>>
>>  /* USB */
>>
>> +#ifdef CONFIG_S3C_DEV_USB_HSOTG
>> +/* USB PHY*/
>> +static struct resource samsung_usbphy_resource[] = {
>> + [0] = {
>> + .start = S3C_PA_USB_PHY,
>> + .end   = S3C_PA_USB_PHY + SZ_16 - 1,
>> + .flags = IORESOURCE_MEM,
>> + },
>> +};
>
> +static struct resource samsung_usbphy_resource[] = {
> +   [0] = DEFINED_RES_MEM(S3C_PA_USB_PHY, SZ_16),
> +};
>
> [...]
>
> Happens build error with s5pv210_defconfig
>
> arch/arm/plat-samsung/devs.c:1375: error: 'S3C_PA_USB_PHY' undeclared here
> (not in a function)
> make[2]: *** [arch/arm/plat-samsung/devs.o] Error 1
> make[1]: *** [arch/arm/plat-samsung] Error 2
> make[1]: *** Waiting for unfinished jobs
>
> And another build error with exynos_defconfig...
Will check for both the configs and resolve it.

Thanks,
Praveen
>
> arch/arm/mach-exynos/built-in.o: In function `.LANCHOR1':
> setup-i2c0.c:(.data+0x8080): undefined reference to
> `s5p_usb_phy_pmu_isolation'
>
> From 5th patch
>
> If possible, please to use 'ARM: [sub-arch dir name]: [subject]' format.
> So I preferred to use 'ARM: EXYNOS: Enabling samsung-usbphy driver for
> EXYNOS4210' on that.
>
> Please make sure your patch has no problem for kernel compilation before
> submitting...
>
> Thanks.
>
> Best regards,
> Kgene.
> --
> Kukjin Kim , Senior Engineer,
> SW Solution Development Team, Samsung Electronics Co., Ltd.
>
> --
> 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
--
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 v7 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-11-09 Thread Praveen Paneri
Hi,

On Fri, Nov 9, 2012 at 6:06 PM, Kyungmin Park  wrote:
> On Fri, Nov 9, 2012 at 8:54 PM, Felipe Balbi  wrote:
>> Hi,
>>
>> On Tue, Oct 30, 2012 at 10:27:32AM +0530, Praveen Paneri wrote:
>>> Changes from v6:
>>> Modified register definitions according to the existing ones.
>>> Changed default PHY clk selection for SoCs.
>>> Improved binding text and rebased to the latest usb-next.
>>>
>>> Changes from v5:
>>> Moved clk_get() to driver's probe function. Now reference clock frequency
>>> selection value is stored in samsung_usbphy structure for later use. Used
>>> IS_ENABLED() instead of #ifdef in samsung_usbphy_get_driver_data().
>>>
>>> Changes from v4:
>>> Moved header file contents to driver's source file
>>> Removed unnecessary print message from driver's probe function
>>> Dropped the Free Software Foundation address from the header
>>> Changed the platform data code to use __initdata
>>>
>>> Changes from v3:
>>> Replaced susbsys_initcall()/module_exit() by module_platform_driver().
>>> Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
>>> is registered
>>> Removed unnecessary devm_usb_put_phy() call from the hsotg driver remove.
>>>
>>> Changes from v2:
>>> Changed the driver filenames to samsung-usbphy
>>> Changed 's3c' to 'samsung' for platform device as well as platform data
>>> Moved platform data structure to a separate file
>>> Rectified coding style related errors
>>>
>>> Changes from v1:
>>> Rebased patches to latest usb-next branch
>>> Changed the name 'sec_usbphy' to 'samsung_usbphy'
>>>
>>> This patch set introduces a phy driver for samsung SoCs. It uses the 
>>> existing
>>> transceiver infrastructure to provide phy control functions. Use of this 
>>> driver
>>> can be extended for usb host phy as well. Over the period of time all the 
>>> phy
>>> related code for most of the samsung SoCs can be integrated here.
>>> Removing the existing phy code from mach-s3c64xx. Same can be done for 
>>> other SoCs
>>> when they start supporting this phy driver.
>>> This driver is tested with smdk6410 and Exynos4210(with DT).
>>>
>>> Praveen Paneri (5):
>>>   usb: phy: samsung: Introducing usb phy driver for hsotg
>>>   usb: s3c-hsotg: Adding phy driver support
> For usb parts:
> Acked-by: Kyungmin Park 
Thanks for the ack.
>
>>>   ARM: S3C64XX: Removing old phy setup code
>>>   ARM: S3C64XX: Enabling samsung-usbphy driver
>>>   ARM: Exynos4210: Enabling samsung-usbphy driver
>>
>> guys I can't wait any longer. If I don't get proper Acks today, I will
>> go ahead without all the PHY changes from Samsung :-s
>
> To Praveen,
>
> To remove these dependency and merge issue, please send patches for
> each subsystem. In this case, usb patches for usb tree and others are
> for arm arch.
I will surely take care of this from now onwards. Hope these can be
taken as it is for now.

Thanks,
Praveen
>
> Thank you,
> Kyungmin Park
>>
>> --
>> balbi
>>
>> ___
>> linux-arm-kernel mailing list
>> linux-arm-ker...@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-11-09 Thread Praveen Paneri
Hi Kukjin,

On Fri, Nov 9, 2012 at 5:24 PM, Felipe Balbi  wrote:
> Hi,
>
> On Tue, Oct 30, 2012 at 10:27:32AM +0530, Praveen Paneri wrote:
>> Changes from v6:
>> Modified register definitions according to the existing ones.
>> Changed default PHY clk selection for SoCs.
>> Improved binding text and rebased to the latest usb-next.
>>
>> Changes from v5:
>> Moved clk_get() to driver's probe function. Now reference clock frequency
>> selection value is stored in samsung_usbphy structure for later use. Used
>> IS_ENABLED() instead of #ifdef in samsung_usbphy_get_driver_data().
>>
>> Changes from v4:
>> Moved header file contents to driver's source file
>> Removed unnecessary print message from driver's probe function
>> Dropped the Free Software Foundation address from the header
>> Changed the platform data code to use __initdata
>>
>> Changes from v3:
>> Replaced susbsys_initcall()/module_exit() by module_platform_driver().
>> Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
>> is registered
>> Removed unnecessary devm_usb_put_phy() call from the hsotg driver remove.
>>
>> Changes from v2:
>> Changed the driver filenames to samsung-usbphy
>> Changed 's3c' to 'samsung' for platform device as well as platform data
>> Moved platform data structure to a separate file
>> Rectified coding style related errors
>>
>> Changes from v1:
>> Rebased patches to latest usb-next branch
>> Changed the name 'sec_usbphy' to 'samsung_usbphy'
>>
>> This patch set introduces a phy driver for samsung SoCs. It uses the existing
>> transceiver infrastructure to provide phy control functions. Use of this 
>> driver
>> can be extended for usb host phy as well. Over the period of time all the phy
>> related code for most of the samsung SoCs can be integrated here.
>> Removing the existing phy code from mach-s3c64xx. Same can be done for other 
>> SoCs
>> when they start supporting this phy driver.
>> This driver is tested with smdk6410 and Exynos4210(with DT).
>>
>> Praveen Paneri (5):
>>   usb: phy: samsung: Introducing usb phy driver for hsotg
>>   usb: s3c-hsotg: Adding phy driver support
>>   ARM: S3C64XX: Removing old phy setup code
>>   ARM: S3C64XX: Enabling samsung-usbphy driver
>>   ARM: Exynos4210: Enabling samsung-usbphy driver
>
> guys I can't wait any longer. If I don't get proper Acks today, I will
> go ahead without all the PHY changes from Samsung :-s

Can you please ack this patch series.

Thanks,

Praveen
>
> --
> balbi
--
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/5] usb: s3c-hsotg: Adding phy driver support

2012-11-01 Thread Praveen Paneri
Adding the phy driver support to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it.

Signed-off-by: Praveen Paneri 
---
 drivers/usb/gadget/s3c-hsotg.c |   37 +++--
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 6f696ee..bc30a2d 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transceiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
-   if (hsotg->plat->phy_init)
+
+   if (hsotg->phy)
+   usb_phy_init(hsotg->phy);
+   else if (hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->plat->phy_exit)
+   if (hsotg->phy)
+   usb_phy_shutdown(hsotg->phy);
+   else if (hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = &pdev->dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3501,20 +3511,27 @@ static int __devinit s3c_hsotg_probe(struct 
platform_device *pdev)
int ret;
int i;
 
-   plat = pdev->dev.platform_data;
-   if (!plat) {
-   dev_err(&pdev->dev, "no platform data defined\n");
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
 
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR_OR_NULL(phy)) {
+   /* Fallback for pdata */
+   plat = pdev->dev.platform_data;
+   if (!plat) {
+   dev_err(&pdev->dev, "no platform data or transceiver 
defined\n");
+   return -EPROBE_DEFER;
+   } else {
+   hsotg->plat = plat;
+   }
+   } else {
+   hsotg->phy = phy;
+   }
+
hsotg->dev = dev;
-   hsotg->plat = plat;
 
hsotg->clk = devm_clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
-- 
1.7.1

--
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 v7 2/5] usb: s3c-hsotg: Adding phy driver support

2012-11-01 Thread Praveen Paneri
On Wed, Oct 31, 2012 at 8:14 PM, Lukasz Majewski  wrote:
> Hi Felipe,
>
>> Hi,
>>
>> On Tue, Oct 30, 2012 at 10:27:34AM +0530, Praveen Paneri wrote:
>> > @@ -3501,20 +3511,27 @@ static int __devinit s3c_hsotg_probe(struct
>> > platform_device *pdev) int ret;
>> > int i;
>> >
>> > -   plat = pdev->dev.platform_data;
>> > -   if (!plat) {
>> > -   dev_err(&pdev->dev, "no platform data defined\n");
>> > -   return -EINVAL;
>> > -   }
>> > -
>> > hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg),
>> > GFP_KERNEL); if (!hsotg) {
>> > dev_err(dev, "cannot get memory\n");
>> > return -ENOMEM;
>> > }
>> >
>> > +   plat = pdev->dev.platform_data;
>> > +   if (!plat) {
>> > +   /* Fallback for transceiver */
>> > +   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
>> > +   if (IS_ERR_OR_NULL(phy)) {
>> > +   dev_err(&pdev->dev, "no platform data or
>> > transceiver defined\n");
>> > +   return -EPROBE_DEFER;
>> > +   } else {
>> > +   hsotg->phy = phy;
>> > +   }
>> > +   } else {
>> > +   hsotg->plat = plat;
>> > +   }
>>
>> I think this should be the other way around, meaning you try to grab
>> the phy, if you can't, then you fallback to pdata.
Agreed! Will swap it

regards,
Praveen
>>
>
> I agree.
>
> The new approach is to use new PHY driver. And only when failed we
> shall use legacy approach.
>
> --
> Best regards,
>
> Lukasz Majewski
>
> Samsung Poland R&D Center | Linux Platform Group
> --
> 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
--
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 5/5] ARM: Exynos4210: Enabling samsung-usbphy driver

2012-10-29 Thread Praveen Paneri
Adding usbphy node for Exynos4210 along with the platform data.

Signed-off-by: Praveen Paneri 
---
 arch/arm/boot/dts/exynos4210-smdkv310.dts |5 +
 arch/arm/mach-exynos/include/mach/map.h   |1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c|8 
 arch/arm/mach-exynos/setup-usb-phy.c  |   13 +
 4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210-smdkv310.dts 
b/arch/arm/boot/dts/exynos4210-smdkv310.dts
index 63610c3..f59e255 100644
--- a/arch/arm/boot/dts/exynos4210-smdkv310.dts
+++ b/arch/arm/boot/dts/exynos4210-smdkv310.dts
@@ -43,6 +43,11 @@
status = "okay";
};
 
+   usbphy@125B {
+   compatible = "samsung,exynos4210-usbphy";
+   reg = <0x125B 0x100>;
+   };
+
keypad@100A {
samsung,keypad-num-rows = <2>;
samsung,keypad-num-columns = <8>;
diff --git a/arch/arm/mach-exynos/include/mach/map.h 
b/arch/arm/mach-exynos/include/mach/map.h
index 8480849..9694424 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -242,6 +242,7 @@
 #define S3C_PA_SPI1EXYNOS4_PA_SPI1
 #define S3C_PA_SPI2EXYNOS4_PA_SPI2
 #define S3C_PA_USB_HSOTG   EXYNOS4_PA_HSOTG
+#define S3C_PA_USB_PHY EXYNOS4_PA_HSPHY
 
 #define S5P_PA_EHCIEXYNOS4_PA_EHCI
 #define S5P_PA_FIMC0   EXYNOS4_PA_FIMC0
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c 
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index e58d786..a9e0a0d 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -20,9 +21,14 @@
 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
+static struct samsung_usbphy_data exynos4_usbphy_pdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
+
 /*
  * The following lookup table is used to override device names when devices
  * are registered from device tree. This is temporarily added to enable
@@ -77,6 +83,8 @@ static const struct of_dev_auxdata exynos4_auxdata_lookup[] 
__initconst = {
"exynos4210-spi.2", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA0, "dma-pl330.0", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA1, "dma-pl330.1", NULL),
+   OF_DEV_AUXDATA("samsung,exynos4210-usbphy", EXYNOS4_PA_HSPHY,
+   "s3c-usbphy", &exynos4_usbphy_pdata),
{},
 };
 
diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index b81cc56..1c62d20 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -221,3 +221,16 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int 
type)
 
return -EINVAL;
 }
+
+void s5p_usb_phy_pmu_isolation(int on)
+{
+   if (on) {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   & ~S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   } else {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   | S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   }
+}
-- 
1.7.1

--
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 4/5] ARM: S3C64XX: Enabling samsung-usbphy driver

2012-10-29 Thread Praveen Paneri
Adding platform device for samsung-usbphy driver. Enabling it for
s3c64xx based machines using s3c-hsotg.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/include/mach/map.h |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c|7 ++
 arch/arm/mach-s3c64xx/mach-smartq.c  |8 +++
 arch/arm/mach-s3c64xx/mach-smdk6410.c|8 +++
 arch/arm/mach-s3c64xx/setup-usb-phy.c|   14 +
 arch/arm/plat-samsung/devs.c |   28 ++
 arch/arm/plat-samsung/include/plat/devs.h|1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h |1 +
 8 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/include/mach/map.h 
b/arch/arm/mach-s3c64xx/include/mach/map.h
index 8e2097b..dc482bb 100644
--- a/arch/arm/mach-s3c64xx/include/mach/map.h
+++ b/arch/arm/mach-s3c64xx/include/mach/map.h
@@ -65,6 +65,7 @@
 
 #define S3C64XX_PA_NAND(0x7020)
 #define S3C64XX_PA_FB  (0x7710)
+#define S3C64XX_PA_USB_HSPHY   (0x7C10)
 #define S3C64XX_PA_USB_HSOTG   (0x7C00)
 #define S3C64XX_PA_WATCHDOG(0x7E004000)
 #define S3C64XX_PA_RTC (0x7E005000)
@@ -113,6 +114,7 @@
 #define S3C_PA_FB  S3C64XX_PA_FB
 #define S3C_PA_USBHOST S3C64XX_PA_USBHOST
 #define S3C_PA_USB_HSOTG   S3C64XX_PA_USB_HSOTG
+#define S3C_PA_USB_PHY S3C64XX_PA_USB_HSPHY
 #define S3C_PA_RTC S3C64XX_PA_RTC
 #define S3C_PA_WDT S3C64XX_PA_WATCHDOG
 #define S3C_PA_SPI0S3C64XX_PA_SPI0
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index d738783..9ea99a7 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -31,6 +31,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -69,6 +70,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
@@ -346,6 +348,7 @@ static struct platform_device wallvdd_device = {
 };
 
 static struct platform_device *crag6410_devices[] __initdata = {
+   &samsung_device_usbphy,
&s3c_device_hsmmc0,
&s3c_device_hsmmc2,
&s3c_device_i2c0,
@@ -777,6 +780,9 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
+static struct samsung_usbphy_data crag6410_usbphy_pdata __initdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
 
 static void __init crag6410_machine_init(void)
 {
@@ -802,6 +808,7 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
+   samsung_usbphy_set_pdata(&crag6410_usbphy_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index 59bb34c..f18a0ab 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -36,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -234,6 +236,7 @@ static struct i2c_board_info smartq_i2c_devs[] __initdata = 
{
 };
 
 static struct platform_device *smartq_devices[] __initdata = {
+   &samsung_device_usbphy,
&s3c_device_hsmmc1, /* Init iNAND first, ... */
&s3c_device_hsmmc0, /* ... then the external SD card */
&s3c_device_hsmmc2,
@@ -380,9 +383,14 @@ void __init smartq_map_io(void)
smartq_lcd_mode_set();
 }
 
+static struct samsung_usbphy_data smartq_usbphy_pdata __initdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
+
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
+   samsung_usbphy_set_pdata(&smartq_usbphy_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index 123f452..cef2c95 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include 
@@ -72,6 +73,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "common.h"
 
@@ -263,6 +266,7 @@ static struct samsung_keypad_platdata smdk6410_keypad_data 
__initdata = {
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
+   &samsung_device_usbphy,
 #ifdef CONFIG_SMDK6410_SD_CH0
&s3c_device_hsmmc0,
 #endif
@@ -626,6 +

[PATCH v7 3/5] ARM: S3C64XX: Removing old phy setup code

2012-10-29 Thread Praveen Paneri
This patch removes old phy code from platform side. 'setup-usb-phy.c'
will be used for providing transceiver platform data in next
patch. Not all of the platform data code is removed as there are others
making use of platform_data defined for hsotg. That can be removed once
all the SoCs start using the new transceiver for usb phy setup.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/mach-crag6410.c |3 -
 arch/arm/mach-s3c64xx/mach-smartq.c   |3 -
 arch/arm/mach-s3c64xx/mach-smdk6410.c |3 -
 arch/arm/mach-s3c64xx/setup-usb-phy.c |   79 -
 4 files changed, 0 insertions(+), 88 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 13b7eaa..d738783 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -31,7 +31,6 @@
 #include 
 
 #include 
-#include 
 
 #include 
 
@@ -778,7 +777,6 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
-static struct s3c_hsotg_plat crag6410_hsotg_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -804,7 +802,6 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&crag6410_hsotg_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index c6d7390..59bb34c 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -187,7 +186,6 @@ static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata 
= {
},
 };
 
-static struct s3c_hsotg_plat smartq_hsotg_pdata;
 
 static int __init smartq_lcd_setup_gpio(void)
 {
@@ -385,7 +383,6 @@ void __init smartq_map_io(void)
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
-   s3c_hsotg_set_platdata(&smartq_hsotg_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index da1a771..123f452 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include 
@@ -627,7 +626,6 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
-static struct s3c_hsotg_plat smdk6410_hsotg_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -657,7 +655,6 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&smdk6410_hsotg_pdata);
 
samsung_keypad_set_platdata(&smdk6410_keypad_data);
 
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c 
b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index f6757e0..7a09553 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
@@ -9,82 +9,3 @@
  *
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static int s3c_usb_otgphy_init(struct platform_device *pdev)
-{
-   struct clk *xusbxti;
-   u32 phyclk;
-
-   writel(readl(S3C64XX_OTHERS) | S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS);
-
-   /* set clock frequency for PLL */
-   phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK;
-
-   xusbxti = clk_get(&pdev->dev, "xusbxti");
-   if (xusbxti && !IS_ERR(xusbxti)) {
-   switch (clk_get_rate(xusbxti)) {
-   case 12 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_12M;
-   break;
-   case 24 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_24M;
-   break;
-   default:
-   case 48 * MHZ:
-   /* default reference clock */
-   break;
-   }
-   clk_put(xusbxti);
-   }
-
-   /* TODO: select external clock/oscillator */
-   writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK);
-
-   /* set to normal OTG PHY */
-   writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR);
-   mdelay(1);
-
-   /* reset OTG PHY and Link */
-   writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK,
-   S3C_RSTCON);
- 

[PATCH v7 2/5] usb: s3c-hsotg: Adding phy driver support

2012-10-29 Thread Praveen Paneri
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Praveen Paneri 
---
 drivers/usb/gadget/s3c-hsotg.c |   37 +++--
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 6f696ee..29815b9 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transceiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
-   if (hsotg->plat->phy_init)
+
+   if (hsotg->phy)
+   usb_phy_init(hsotg->phy);
+   else if (hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->plat->phy_exit)
+   if (hsotg->phy)
+   usb_phy_shutdown(hsotg->phy);
+   else if (hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = &pdev->dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3501,20 +3511,27 @@ static int __devinit s3c_hsotg_probe(struct 
platform_device *pdev)
int ret;
int i;
 
-   plat = pdev->dev.platform_data;
-   if (!plat) {
-   dev_err(&pdev->dev, "no platform data defined\n");
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
 
+   plat = pdev->dev.platform_data;
+   if (!plat) {
+   /* Fallback for transceiver */
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR_OR_NULL(phy)) {
+   dev_err(&pdev->dev, "no platform data or transceiver 
defined\n");
+   return -EPROBE_DEFER;
+   } else {
+   hsotg->phy = phy;
+   }
+   } else {
+   hsotg->plat = plat;
+   }
+
hsotg->dev = dev;
-   hsotg->plat = plat;
 
hsotg->clk = devm_clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
-- 
1.7.1

--
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 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-10-29 Thread Praveen Paneri
This driver uses usb phy framework to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable usb phy. Support
will be extended to host controllers and more Samsung SoCs.

Signed-off-by: Praveen Paneri 
Acked-by: Heiko Stuebner 
Acked-by: Kyungmin Park 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  360 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 5 files changed, 407 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..7b26e2d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,11 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+TODO: Adding the PHY binding with controller(s) according to the under
+developement generic PHY driver.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 63c339b..313685f 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -32,3 +32,11 @@ config MV_U3D_PHY
help
  Enable this to support Marvell USB 3.0 phy controller for Marvell
  SoC.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..55dcfc1 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
new file mode 100644
index 000..3c84aab
--- /dev/null
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -0,0 +1,360 @@
+/* linux/drivers/usb/phy/samsung-usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register definitions */
+
+#define SAMSUNG_PHYPWR (0x00)
+
+#define PHYPWR_NORMAL_MASK (0x19 << 0)
+#define PHYPWR_OTG_DISABLE (0x1 << 4)
+#define PHYPWR_ANALOG_POWERDOWN(0x1 << 3)
+#define PHYPWR_FORCE_SUSPEND   (0x1 << 1)
+/* For Exynos4 */
+#define PHYPWR_NORMAL_MASK_PHY0(0x39 << 0)
+#define PHYPWR_SLEEP_PHY0  (0x1 << 5)
+
+#define SAMSUNG_PHYCLK (0x04)
+
+#define PHYCLK_MODE_USB11  (0x1 << 6)
+#define PHYCLK_EXT_OSC (0x1 << 5)
+#define PHYCLK_COMMON_ON_N (0x1 << 4)
+#define PHYCLK_ID_PULL (0x1 << 2)
+#define PHYCLK_CLKSEL_MASK (0x3 << 0)
+#define PHYCLK_CLKSEL_48M  (0x0 << 0)
+#define PHYCLK_CLKSEL_12M  (0x2 << 0)
+#define PHYCLK_CLKSEL_24M  (0x3 << 0)
+
+#define SAMSUNG_RSTCON (0x08)
+
+#define RSTCON_PHYLINK_SWRST   (0x1 << 2)
+#define RSTCON_HLINK_SWRST (0x1 << 1)
+#define RSTCON_SWRST   (0x1 << 0)
+
+#ifndef MHZ
+#define MHZ (1000*1000)
+#endif
+
+enum samsung_cpu_type {
+   T

[PATCH v7 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-10-29 Thread Praveen Paneri
Changes from v6:
Modified register definitions according to the existing ones.
Changed default PHY clk selection for SoCs.
Improved binding text and rebased to the latest usb-next.

Changes from v5:
Moved clk_get() to driver's probe function. Now reference clock frequency
selection value is stored in samsung_usbphy structure for later use. Used
IS_ENABLED() instead of #ifdef in samsung_usbphy_get_driver_data().

Changes from v4:
Moved header file contents to driver's source file
Removed unnecessary print message from driver's probe function
Dropped the Free Software Foundation address from the header
Changed the platform data code to use __initdata

Changes from v3:
Replaced susbsys_initcall()/module_exit() by module_platform_driver().
Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
is registered
Removed unnecessary devm_usb_put_phy() call from the hsotg driver remove.

Changes from v2:
Changed the driver filenames to samsung-usbphy
Changed 's3c' to 'samsung' for platform device as well as platform data
Moved platform data structure to a separate file
Rectified coding style related errors

Changes from v1:
Rebased patches to latest usb-next branch
Changed the name 'sec_usbphy' to 'samsung_usbphy'

This patch set introduces a phy driver for samsung SoCs. It uses the existing
transceiver infrastructure to provide phy control functions. Use of this driver
can be extended for usb host phy as well. Over the period of time all the phy
related code for most of the samsung SoCs can be integrated here.
Removing the existing phy code from mach-s3c64xx. Same can be done for other 
SoCs
when they start supporting this phy driver. 
This driver is tested with smdk6410 and Exynos4210(with DT).

Praveen Paneri (5):
  usb: phy: samsung: Introducing usb phy driver for hsotg
  usb: s3c-hsotg: Adding phy driver support
  ARM: S3C64XX: Removing old phy setup code
  ARM: S3C64XX: Enabling samsung-usbphy driver
  ARM: Exynos4210: Enabling samsung-usbphy driver

 .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
 arch/arm/boot/dts/exynos4210-smdkv310.dts  |5 +
 arch/arm/mach-exynos/include/mach/map.h|1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c |8 +
 arch/arm/mach-exynos/setup-usb-phy.c   |   13 +
 arch/arm/mach-s3c64xx/include/mach/map.h   |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c  |   10 +-
 arch/arm/mach-s3c64xx/mach-smartq.c|   11 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c  |   11 +-
 arch/arm/mach-s3c64xx/setup-usb-phy.c  |   79 +
 arch/arm/plat-samsung/devs.c   |   28 ++
 arch/arm/plat-samsung/include/plat/devs.h  |1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h   |1 +
 drivers/usb/gadget/s3c-hsotg.c |   37 ++-
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  360 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 18 files changed, 523 insertions(+), 91 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

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


Re: [PATCH] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-10-21 Thread Praveen Paneri
Hi,

On Sun, Oct 21, 2012 at 12:49 AM, Pavel Machek  wrote:
> Hi!
>
>> > +#define S3C_PHYPWR (0x00)
> ...
>> > +#define S3C_PHYCLK (0x04)
>> > +
>> > +#define S3C_PHYCLK_MODE_SERIAL (1 << 6)
>> > +#define S3C_PHYCLK_EXT_OSC (1 << 5)
>> > +#define S3C_PHYCLK_COMMON_ON_N (1 << 4)
>> > +#define S3C_PHYCLK_ID_PULL (1 << 2)
>> > +#define S3C_PHYCLK_CLKSEL_MASK (0x3 << 0)
>> > +#define S3C_PHYCLK_CLKSEL_SHIFT(0)
>> > +#define S3C_PHYCLK_CLKSEL_48M  (0x0 << 0)
>> > +#define S3C_PHYCLK_CLKSEL_12M  (0x2 << 0)
>> > +#define S3C_PHYCLK_CLKSEL_24M  (0x3 << 0)
>
> I believe these 0x 's should be removed. Ouch and << 0 is interesting,
> too, just remove it.
Yes it makes sense to maintain a uniform pattern across all the
definition. How about maintaining hex values everywhere instead of
dropping 0x's? It will make it easier to add big values to the
definitions tomorrow, if needed.
About "<< 0", IMHO people must have started using it to maintain a
parallelism with other definitions. I do not mind changing it if you
still feel that it's very much needed
thanks :)

Praveen
>
> Pavel
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) 
> http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
> --
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-10-17 Thread Praveen Paneri
Hi,

On Wed, Oct 17, 2012 at 4:30 PM, Kukjin Kim  wrote:
> Praveen Paneri wrote:
>>
>> platform_set_drvdata() required for driver's remove function, so adding
>> it back.
>>
>> From v6:
>> Added TODO for phy bindings with controller
>> Dropped platform_set_drvdata() from driver probe
>>
>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>> smdk6410 and smdkv310. More SoCs can be brought under later.
>>
>> Signed-off-by: Praveen Paneri 
>> Acked-by: Heiko Stuebner 
>> ---
>>  .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
>>  drivers/usb/phy/Kconfig|8 +
>>  drivers/usb/phy/Makefile   |1 +
>>  drivers/usb/phy/samsung-usbphy.c   |  357
> 
>>  include/linux/platform_data/samsung-usbphy.h   |   27 ++
>>  5 files changed, 404 insertions(+), 0 deletions(-)
>>  create mode 100644 Documentation/devicetree/bindings/usb/samsung-
>> usbphy.txt
>>  create mode 100644 drivers/usb/phy/samsung-usbphy.c
>>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>>
>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> new file mode 100644
>> index 000..7b26e2d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> @@ -0,0 +1,11 @@
>> +* Samsung's usb phy transceiver
>> +
>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>> +s3c-hsotg usb device controller.
>> +TODO: Adding the PHY binding with controller(s) according to the under
>> +developement generic PHY driver.
>> +
>> +Required properties:
>> +- compatible : should be "samsung,exynos4210-usbphy"
>> +- reg : base physical address of the phy registers and length of memory
>> mapped
>> + region.
>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>> index 63c339b..313685f 100644
>> --- a/drivers/usb/phy/Kconfig
>> +++ b/drivers/usb/phy/Kconfig
>> @@ -32,3 +32,11 @@ config MV_U3D_PHY
>>   help
>> Enable this to support Marvell USB 3.0 phy controller for Marvell
>> SoC.
>> +
>> +config SAMSUNG_USBPHY
>> + bool "Samsung USB PHY controller Driver"
>> + depends on USB_S3C_HSOTG
>> + select USB_OTG_UTILS
>> + help
>> +   Enable this to support Samsung USB phy controller for samsung
>> +   SoCs.
>> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
>> index b069f29..55dcfc1 100644
>> --- a/drivers/usb/phy/Makefile
>> +++ b/drivers/usb/phy/Makefile
>> @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2)   +=
> omap-usb2.o
>>  obj-$(CONFIG_USB_ISP1301)+= isp1301.o
>>  obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o
>>  obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
>> +obj-$(CONFIG_SAMSUNG_USBPHY) += samsung-usbphy.o
>> diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-
>> usbphy.c
>> new file mode 100644
>> index 000..14c182f
>> --- /dev/null
>> +++ b/drivers/usb/phy/samsung-usbphy.c
>
> Hi,
>
> Basically I agree and this is a good approach to support usb phy for Samsung
> stuff...but there are some comments ;)
>
>> @@ -0,0 +1,357 @@
>> +/* linux/drivers/usb/phy/samsung-usbphy.c
>> + *
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *  http://www.samsung.com
>> + *
>> + * Author: Praveen Paneri 
>> + *
>> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG
>> controller
>> + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/* Register definitions */
>> +
>> +#define S3C_

Re: [PATCH] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-10-15 Thread Praveen Paneri
On Mon, Oct 15, 2012 at 6:58 PM, Felipe Balbi  wrote:
> On Fri, Oct 12, 2012 at 03:45:34PM +0530, Praveen Paneri wrote:
>> platform_set_drvdata() required for driver's remove function, so adding
>> it back.
>>
>> From v6:
>> Added TODO for phy bindings with controller
>> Dropped platform_set_drvdata() from driver probe
>>
>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>> smdk6410 and smdkv310. More SoCs can be brought under later.
>>
>
> this commit log needs improvement. There are stuff there which shouldn't
> go to git's history.
I will resend the patches with improved commit log.

Thanks,
Praveen
>
> I would like to get Tested-bys and Acked-by from DT maintainers.
>
>> Signed-off-by: Praveen Paneri 
>> Acked-by: Heiko Stuebner 
>> ---
>>  .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
>>  drivers/usb/phy/Kconfig|8 +
>>  drivers/usb/phy/Makefile   |1 +
>>  drivers/usb/phy/samsung-usbphy.c   |  357 
>> 
>>  include/linux/platform_data/samsung-usbphy.h   |   27 ++
>>  5 files changed, 404 insertions(+), 0 deletions(-)
>>  create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>  create mode 100644 drivers/usb/phy/samsung-usbphy.c
>>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>>
>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> new file mode 100644
>> index 000..7b26e2d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> @@ -0,0 +1,11 @@
>> +* Samsung's usb phy transceiver
>> +
>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>> +s3c-hsotg usb device controller.
>> +TODO: Adding the PHY binding with controller(s) according to the under
>> +developement generic PHY driver.
>> +
>> +Required properties:
>> +- compatible : should be "samsung,exynos4210-usbphy"
>> +- reg : base physical address of the phy registers and length of memory 
>> mapped
>> + region.
>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>> index 63c339b..313685f 100644
>> --- a/drivers/usb/phy/Kconfig
>> +++ b/drivers/usb/phy/Kconfig
>> @@ -32,3 +32,11 @@ config MV_U3D_PHY
>>   help
>> Enable this to support Marvell USB 3.0 phy controller for Marvell
>> SoC.
>> +
>> +config SAMSUNG_USBPHY
>> + bool "Samsung USB PHY controller Driver"
>> + depends on USB_S3C_HSOTG
>> + select USB_OTG_UTILS
>> + help
>> +   Enable this to support Samsung USB phy controller for samsung
>> +   SoCs.
>> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
>> index b069f29..55dcfc1 100644
>> --- a/drivers/usb/phy/Makefile
>> +++ b/drivers/usb/phy/Makefile
>> @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2)   += omap-usb2.o
>>  obj-$(CONFIG_USB_ISP1301)+= isp1301.o
>>  obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o
>>  obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
>> +obj-$(CONFIG_SAMSUNG_USBPHY) += samsung-usbphy.o
>> diff --git a/drivers/usb/phy/samsung-usbphy.c 
>> b/drivers/usb/phy/samsung-usbphy.c
>> new file mode 100644
>> index 000..14c182f
>> --- /dev/null
>> +++ b/drivers/usb/phy/samsung-usbphy.c
>> @@ -0,0 +1,357 @@
>> +/* linux/drivers/usb/phy/samsung-usbphy.c
>> + *
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *  http://www.samsung.com
>> + *
>> + * Author: Praveen Paneri 
>> + *
>> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
>> + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>>

[PATCH] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-10-12 Thread Praveen Paneri
platform_set_drvdata() required for driver's remove function, so adding
it back.

>From v6:
Added TODO for phy bindings with controller
Dropped platform_set_drvdata() from driver probe

This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable phy. Tested with
smdk6410 and smdkv310. More SoCs can be brought under later.

Signed-off-by: Praveen Paneri 
Acked-by: Heiko Stuebner 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  357 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 5 files changed, 404 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..7b26e2d
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,11 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+TODO: Adding the PHY binding with controller(s) according to the under
+developement generic PHY driver.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 63c339b..313685f 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -32,3 +32,11 @@ config MV_U3D_PHY
help
  Enable this to support Marvell USB 3.0 phy controller for Marvell
  SoC.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..55dcfc1 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
new file mode 100644
index 000..14c182f
--- /dev/null
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -0,0 +1,357 @@
+/* linux/drivers/usb/phy/samsung-usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register definitions */
+
+#define S3C_PHYPWR (0x00)
+
+#define S3C_PHYPWR_NORMAL_MASK (0x19 << 0)
+#define S3C_PHYPWR_OTG_DISABLE (1 << 4)
+#define S3C_PHYPWR_ANALOG_POWERDOWN(1 << 3)
+#define S3C_PHYPWR_FORCE_SUSPEND   (1 << 1)
+/* For Exynos4 */
+#define EXYNOS4_PHYPWR_NORMAL_MASK (0x39 << 0)
+#define EXYNOS4_PHYPWR_SLEEP   (1 << 5)
+
+#define S3C_PHYCLK (0x04)
+
+#define S3C_PHYCLK_MODE_SERIAL (1 << 6)
+#define S3C_PHYCLK_EXT_OSC (1 << 5)
+#define S3C_PHYCLK_COMMON_ON_N (1 << 4)
+#define S3C_PHYCLK_ID_PULL (1 << 2)
+#define S3C_PHYCLK_CLKSEL_MASK (0x3 << 0)
+#define S3C_PHYCLK_CLKSEL_SHIFT(0)
+#define S3C_PHYCLK_CLKSEL_48M  (0x0 << 0)
+#define S3C_PHYCLK_CLKSEL_12M  (0x2 << 0)
+#define S3C_PHYCLK_CLKSEL_24M  (0x3 << 0)
+
+#define S3C_RSTCON (0x08)
+
+#define S3C_RSTCON_PHYCLK  (1 << 2)
+#define S3C_RSTC

[PATCH 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-10-03 Thread Praveen Paneri
>From v6:
Added TODO for phy bindings with controller
Dropped platform_set_drvdata() from driver probe

This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable phy. Tested with
smdk6410 and smdkv310. More SoCs can be brought under later.

Signed-off-by: Praveen Paneri 
Acked-by: Heiko Stuebner 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |   11 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  355 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 5 files changed, 402 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..7d54d59
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,11 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+TODO: Adding the PHY binding with controller(s) according to the under 
+developement generic PHY driver.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 63c339b..313685f 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -32,3 +32,11 @@ config MV_U3D_PHY
help
  Enable this to support Marvell USB 3.0 phy controller for Marvell
  SoC.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..55dcfc1 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
new file mode 100644
index 000..ee2dee0
--- /dev/null
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -0,0 +1,355 @@
+/* linux/drivers/usb/phy/samsung-usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register definitions */
+
+#define S3C_PHYPWR (0x00)
+
+#define S3C_PHYPWR_NORMAL_MASK (0x19 << 0)
+#define S3C_PHYPWR_OTG_DISABLE (1 << 4)
+#define S3C_PHYPWR_ANALOG_POWERDOWN(1 << 3)
+#define S3C_PHYPWR_FORCE_SUSPEND   (1 << 1)
+/* For Exynos4 */
+#define EXYNOS4_PHYPWR_NORMAL_MASK (0x39 << 0)
+#define EXYNOS4_PHYPWR_SLEEP   (1 << 5)
+
+#define S3C_PHYCLK (0x04)
+
+#define S3C_PHYCLK_MODE_SERIAL (1 << 6)
+#define S3C_PHYCLK_EXT_OSC (1 << 5)
+#define S3C_PHYCLK_COMMON_ON_N (1 << 4)
+#define S3C_PHYCLK_ID_PULL (1 << 2)
+#define S3C_PHYCLK_CLKSEL_MASK (0x3 << 0)
+#define S3C_PHYCLK_CLKSEL_SHIFT(0)
+#define S3C_PHYCLK_CLKSEL_48M  (0x0 << 0)
+#define S3C_PHYCLK_CLKSEL_12M  (0x2 << 0)
+#define S3C_PHYCLK_CLKSEL_24M  (0x3 << 0)
+
+#define S3C_RSTCON (0x08)
+
+#define S3C_RSTCON_PHYCLK  (1 << 2)
+#define S3C_RSTCON_HCLK(1 << 1)
+#define S3C_RSTCON_PHY

Re: [PATCH v6 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-09-26 Thread Praveen Paneri
On Tue, Sep 25, 2012 at 4:59 PM, Marc Kleine-Budde  wrote:
> On 09/24/2012 11:38 AM, Praveen Paneri wrote:
>> Hi Kishon, Felipe,
>>
>> Any further comments on these patches? Can they be merged now?
>
> One nitpick inline.
>
> Marc
>>
>> Thanks,
>> Praveen
>>
>> On Mon, Sep 17, 2012 at 6:24 PM, Praveen Paneri  wrote:
>>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>>> smdk6410 and smdkv310. More SoCs can be brought under later.
>>>
>>> Signed-off-by: Praveen Paneri 
>>> Acked-by: Heiko Stuebner 
>>> ---
>>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>>  drivers/usb/phy/Kconfig|8 +
>>>  drivers/usb/phy/Makefile   |1 +
>>>  drivers/usb/phy/samsung-usbphy.c   |  360 
>>> 
>>>  include/linux/platform_data/samsung-usbphy.h   |   27 ++
>>>  5 files changed, 405 insertions(+), 0 deletions(-)
>>>  create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>>  create mode 100644 drivers/usb/phy/samsung-usbphy.c
>>>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
>>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>> new file mode 100644
>>> index 000..fefd9c8
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>> @@ -0,0 +1,9 @@
>>> +* Samsung's usb phy transceiver
>>> +
>>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>>> +s3c-hsotg usb device controller.
>>> +
>>> +Required properties:
>>> +- compatible : should be "samsung,exynos4210-usbphy"
>>> +- reg : base physical address of the phy registers and length of memory 
>>> mapped
>>> +   region.
>>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>>> index 63c339b..313685f 100644
>>> --- a/drivers/usb/phy/Kconfig
>>> +++ b/drivers/usb/phy/Kconfig
>>> @@ -32,3 +32,11 @@ config MV_U3D_PHY
>>> help
>>>   Enable this to support Marvell USB 3.0 phy controller for Marvell
>>>   SoC.
>>> +
>>> +config SAMSUNG_USBPHY
>>> +   bool "Samsung USB PHY controller Driver"
>>> +   depends on USB_S3C_HSOTG
>>> +   select USB_OTG_UTILS
>>> +   help
>>> + Enable this to support Samsung USB phy controller for samsung
>>> + SoCs.
>>> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
>>> index b069f29..55dcfc1 100644
>>> --- a/drivers/usb/phy/Makefile
>>> +++ b/drivers/usb/phy/Makefile
>>> @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
>>>  obj-$(CONFIG_USB_ISP1301)      += isp1301.o
>>>  obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
>>>  obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
>>> +obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
>>> diff --git a/drivers/usb/phy/samsung-usbphy.c 
>>> b/drivers/usb/phy/samsung-usbphy.c
>>> new file mode 100644
>>> index 000..95ec4d0
>>> --- /dev/null
>>> +++ b/drivers/usb/phy/samsung-usbphy.c
>>> @@ -0,0 +1,360 @@
>>> +/* linux/drivers/usb/phy/samsung-usbphy.c
>>> + *
>>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>>> + *  http://www.samsung.com
>>> + *
>>> + * Author: Praveen Paneri 
>>> + *
>>> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG 
>>> controller
>>> + *
>>> + * 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.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#incl

Re: [PATCH v6 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-09-26 Thread Praveen Paneri
Hi,

On Tue, Sep 25, 2012 at 6:47 PM, ABRAHAM, KISHON VIJAY  wrote:
> Hi,
>
> On Tue, Sep 25, 2012 at 5:48 PM, Rob Herring  wrote:
>> On 09/25/2012 06:23 AM, Praveen Paneri wrote:
>>> Hi Rob,
>>>
>>> On Mon, Sep 24, 2012 at 6:34 PM, Rob Herring  wrote:
>>>> On 09/17/2012 07:54 AM, Praveen Paneri wrote:
>>>>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>>>>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>>>>> smdk6410 and smdkv310. More SoCs can be brought under later.
>>>>>
>>>>> Signed-off-by: Praveen Paneri 
>>>>> Acked-by: Heiko Stuebner 
>>>>> ---
>>>>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>>>>  drivers/usb/phy/Kconfig|8 +
>>>>>  drivers/usb/phy/Makefile   |1 +
>>>>>  drivers/usb/phy/samsung-usbphy.c   |  360 
>>>>> 
>>>>>  include/linux/platform_data/samsung-usbphy.h   |   27 ++
>>>>>  5 files changed, 405 insertions(+), 0 deletions(-)
>>>>>  create mode 100644 
>>>>> Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>>>>  create mode 100644 drivers/usb/phy/samsung-usbphy.c
>>>>>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
>>>>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>>>> new file mode 100644
>>>>> index 000..fefd9c8
>>>>> --- /dev/null
>>>>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>>>> @@ -0,0 +1,9 @@
>>>>> +* Samsung's usb phy transceiver
>>>>> +
>>>>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>>>>> +s3c-hsotg usb device controller.
>>>>> +
>>>>> +Required properties:
>>>>> +- compatible : should be "samsung,exynos4210-usbphy"
>>>>> +- reg : base physical address of the phy registers and length of memory 
>>>>> mapped
>>>>> + region.
>>>>
>>>> What's missing here is describing the connection of phys to host
>>>> controllers. We've got several people adding usb phy bindings and need
>>>> to define them in a common way.
>>> yes! it just covers the generic binding. I will update it accordingly
>>> as the generic phy framework takes its final shape.
>>
>> That sounds like the wrong way to define a binding... Figuring out how
>> to describe the h/w should not be dependent on changes in the kernel.
>> Bindings are an ABI and should not be evolving.
But since Kishon is getting the generic bindings ready, I can use them
when those are ready. So do we need to hold the merge of this patch
until then?

Thanks,
Praveen
>
> There can be multiple ways to define the binding. For e.g. We
> discussed few ways of binding the phys to the controller
>
> controller {
>   phy0 = <&phandle1_name>;
>   phy1 = <&phandle2_name>;
> }
>
> phy0 and phy1 are any name given to obtain a reference to the phy and
> the controller should send the phandle name like
> get_phy_by_phandle("phy0");. Then we thought of standardizing that
> name.
>
> and then finally we settled on something like this
> controller {
>   phy = <&phandle0_name>, <&phandle1_name>;
> }
> so that controller can obtain a reference to the PHY using
> *of_phy_get(struct device *dev, const char *phandle, u8 index)*
>
> Thanks
> Kishon
> --
> 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
--
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 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-09-25 Thread Praveen Paneri
Hi Rob,

On Mon, Sep 24, 2012 at 6:34 PM, Rob Herring  wrote:
> On 09/17/2012 07:54 AM, Praveen Paneri wrote:
>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>> smdk6410 and smdkv310. More SoCs can be brought under later.
>>
>> Signed-off-by: Praveen Paneri 
>> Acked-by: Heiko Stuebner 
>> ---
>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>  drivers/usb/phy/Kconfig|8 +
>>  drivers/usb/phy/Makefile   |1 +
>>  drivers/usb/phy/samsung-usbphy.c   |  360 
>> 
>>  include/linux/platform_data/samsung-usbphy.h   |   27 ++
>>  5 files changed, 405 insertions(+), 0 deletions(-)
>>  create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>  create mode 100644 drivers/usb/phy/samsung-usbphy.c
>>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>>
>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> new file mode 100644
>> index 000..fefd9c8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> @@ -0,0 +1,9 @@
>> +* Samsung's usb phy transceiver
>> +
>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>> +s3c-hsotg usb device controller.
>> +
>> +Required properties:
>> +- compatible : should be "samsung,exynos4210-usbphy"
>> +- reg : base physical address of the phy registers and length of memory 
>> mapped
>> + region.
>
> What's missing here is describing the connection of phys to host
> controllers. We've got several people adding usb phy bindings and need
> to define them in a common way.
yes! it just covers the generic binding. I will update it accordingly
as the generic phy framework takes its final shape.

Praveen
>
> Rob
>
>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>> index 63c339b..313685f 100644
>> --- a/drivers/usb/phy/Kconfig
>> +++ b/drivers/usb/phy/Kconfig
>> @@ -32,3 +32,11 @@ config MV_U3D_PHY
>>   help
>> Enable this to support Marvell USB 3.0 phy controller for Marvell
>> SoC.
>> +
>> +config SAMSUNG_USBPHY
>> + bool "Samsung USB PHY controller Driver"
>> + depends on USB_S3C_HSOTG
>> + select USB_OTG_UTILS
>> + help
>> +   Enable this to support Samsung USB phy controller for samsung
>> +   SoCs.
>> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
>> index b069f29..55dcfc1 100644
>> --- a/drivers/usb/phy/Makefile
>> +++ b/drivers/usb/phy/Makefile
>> @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2)   += omap-usb2.o
>>  obj-$(CONFIG_USB_ISP1301)+= isp1301.o
>>  obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o
>>  obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
>> +obj-$(CONFIG_SAMSUNG_USBPHY) += samsung-usbphy.o
>> diff --git a/drivers/usb/phy/samsung-usbphy.c 
>> b/drivers/usb/phy/samsung-usbphy.c
>> new file mode 100644
>> index 000..95ec4d0
>> --- /dev/null
>> +++ b/drivers/usb/phy/samsung-usbphy.c
>> @@ -0,0 +1,360 @@
>> +/* linux/drivers/usb/phy/samsung-usbphy.c
>> + *
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *  http://www.samsung.com
>> + *
>> + * Author: Praveen Paneri 
>> + *
>> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
>> + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/* Register definitions */
>> +
>> +#define S3C_PHYPWR   (0x00)
>> +
>> +#define S3C_PHYPWR_NORMAL_MASK   (0x19 << 0)
>> +#define S3C_PHYPWR_OTG_DISABLE

Re: [PATCH v6 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-09-24 Thread Praveen Paneri
Hi Kishon, Felipe,

Any further comments on these patches? Can they be merged now?

Thanks,
Praveen

On Mon, Sep 17, 2012 at 6:24 PM, Praveen Paneri  wrote:
> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
> phy_init and phy_shutdown functions to enable/disable phy. Tested with
> smdk6410 and smdkv310. More SoCs can be brought under later.
>
> Signed-off-by: Praveen Paneri 
> Acked-by: Heiko Stuebner 
> ---
>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>  drivers/usb/phy/Kconfig|8 +
>  drivers/usb/phy/Makefile   |1 +
>  drivers/usb/phy/samsung-usbphy.c   |  360 
> 
>  include/linux/platform_data/samsung-usbphy.h   |   27 ++
>  5 files changed, 405 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>  create mode 100644 drivers/usb/phy/samsung-usbphy.c
>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>
> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
> new file mode 100644
> index 000..fefd9c8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
> @@ -0,0 +1,9 @@
> +* Samsung's usb phy transceiver
> +
> +The Samsung's phy transceiver is used for controlling usb otg phy for
> +s3c-hsotg usb device controller.
> +
> +Required properties:
> +- compatible : should be "samsung,exynos4210-usbphy"
> +- reg : base physical address of the phy registers and length of memory 
> mapped
> +   region.
> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> index 63c339b..313685f 100644
> --- a/drivers/usb/phy/Kconfig
> +++ b/drivers/usb/phy/Kconfig
> @@ -32,3 +32,11 @@ config MV_U3D_PHY
> help
>   Enable this to support Marvell USB 3.0 phy controller for Marvell
>   SoC.
> +
> +config SAMSUNG_USBPHY
> +   bool "Samsung USB PHY controller Driver"
> +   depends on USB_S3C_HSOTG
> +   select USB_OTG_UTILS
> +   help
> + Enable this to support Samsung USB phy controller for samsung
> + SoCs.
> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
> index b069f29..55dcfc1 100644
> --- a/drivers/usb/phy/Makefile
> +++ b/drivers/usb/phy/Makefile
> @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
>  obj-$(CONFIG_USB_ISP1301)  += isp1301.o
>  obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
>  obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
> +obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
> diff --git a/drivers/usb/phy/samsung-usbphy.c 
> b/drivers/usb/phy/samsung-usbphy.c
> new file mode 100644
> index 000..95ec4d0
> --- /dev/null
> +++ b/drivers/usb/phy/samsung-usbphy.c
> @@ -0,0 +1,360 @@
> +/* linux/drivers/usb/phy/samsung-usbphy.c
> + *
> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> + *  http://www.samsung.com
> + *
> + * Author: Praveen Paneri 
> + *
> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
> + *
> + * 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.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* Register definitions */
> +
> +#define S3C_PHYPWR (0x00)
> +
> +#define S3C_PHYPWR_NORMAL_MASK (0x19 << 0)
> +#define S3C_PHYPWR_OTG_DISABLE (1 << 4)
> +#define S3C_PHYPWR_ANALOG_POWERDOWN(1 << 3)
> +#define S3C_PHYPWR_FORCE_SUSPEND   (1 << 1)
> +/* For Exynos4 */
> +#define EXYNOS4_PHYPWR_NORMAL_MASK (0x39 << 0)
> +#define EXYNOS4_PHYPWR_SLEEP   (1 << 5)
> +
> +#define S3C_PHYCLK (0x04)
> +
> +#define S3C_PHYCLK_MODE_SERIAL (1 << 6)
> +#define S3C_PHYCLK_EXT_OSC (1 << 5)
> +#define S3C_PHYCLK_COMMON_ON_N (1 << 4)
> +#define S3C_PHYCLK_ID_PULL (1 << 2)
> +#define S3C_PHYCLK

[PATCH v6 5/5] ARM: Exynos4210: Enabling samsung-usbphy driver

2012-09-17 Thread Praveen Paneri
Adding usbphy node for Exynos4210 along with the platform data.

Signed-off-by: Praveen Paneri 
---
 arch/arm/boot/dts/exynos4210.dtsi   |5 +
 arch/arm/mach-exynos/include/mach/map.h |1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c  |8 
 arch/arm/mach-exynos/setup-usb-phy.c|   13 +
 4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
b/arch/arm/boot/dts/exynos4210.dtsi
index 02891fe..e28cf10 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -62,6 +62,11 @@
interrupts = <0 44 0>, <0 45 0>;
};
 
+   usbphy@125B {
+   compatible = "samsung,exynos4210-usbphy";
+   reg = <0x125B 0x100>;
+   };
+
keypad@100A {
compatible = "samsung,s5pv210-keypad";
reg = <0x100A 0x100>;
diff --git a/arch/arm/mach-exynos/include/mach/map.h 
b/arch/arm/mach-exynos/include/mach/map.h
index c72b675..0625c0a 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -234,6 +234,7 @@
 #define S3C_PA_SPI1EXYNOS4_PA_SPI1
 #define S3C_PA_SPI2EXYNOS4_PA_SPI2
 #define S3C_PA_USB_HSOTG   EXYNOS4_PA_HSOTG
+#define S3C_PA_USB_PHY EXYNOS4_PA_HSPHY
 
 #define S5P_PA_EHCIEXYNOS4_PA_EHCI
 #define S5P_PA_FIMC0   EXYNOS4_PA_FIMC0
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c 
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index b2b5d5f..0739be8 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -20,9 +21,14 @@
 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
+static struct samsung_usbphy_data exynos4_usbphy_pdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
+
 /*
  * The following lookup table is used to override device names when devices
  * are registered from device tree. This is temporarily added to enable
@@ -63,6 +69,8 @@ static const struct of_dev_auxdata 
exynos4210_auxdata_lookup[] __initconst = {
"exynos4210-spi.2", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA0, "dma-pl330.0", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA1, "dma-pl330.1", NULL),
+   OF_DEV_AUXDATA("samsung,exynos4210-usbphy", EXYNOS4_PA_HSPHY,
+   "s3c-usbphy", &exynos4_usbphy_pdata),
{},
 };
 
diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index b81cc56..1c62d20 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -221,3 +221,16 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int 
type)
 
return -EINVAL;
 }
+
+void s5p_usb_phy_pmu_isolation(int on)
+{
+   if (on) {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   & ~S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   } else {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   | S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   }
+}
-- 
1.7.1

--
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/5] ARM: S3C64XX: Enabling samsung-usbphy driver

2012-09-17 Thread Praveen Paneri
Adding platform device for samsung-usbphy driver. Enabling it for
s3c64xx based machines using s3c-hsotg.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/include/mach/map.h |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c|7 ++
 arch/arm/mach-s3c64xx/mach-smartq.c  |8 +++
 arch/arm/mach-s3c64xx/mach-smdk6410.c|7 ++
 arch/arm/mach-s3c64xx/setup-usb-phy.c|   14 +
 arch/arm/plat-samsung/devs.c |   28 ++
 arch/arm/plat-samsung/include/plat/devs.h|1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h |1 +
 8 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/include/mach/map.h 
b/arch/arm/mach-s3c64xx/include/mach/map.h
index 8e2097b..dc482bb 100644
--- a/arch/arm/mach-s3c64xx/include/mach/map.h
+++ b/arch/arm/mach-s3c64xx/include/mach/map.h
@@ -65,6 +65,7 @@
 
 #define S3C64XX_PA_NAND(0x7020)
 #define S3C64XX_PA_FB  (0x7710)
+#define S3C64XX_PA_USB_HSPHY   (0x7C10)
 #define S3C64XX_PA_USB_HSOTG   (0x7C00)
 #define S3C64XX_PA_WATCHDOG(0x7E004000)
 #define S3C64XX_PA_RTC (0x7E005000)
@@ -113,6 +114,7 @@
 #define S3C_PA_FB  S3C64XX_PA_FB
 #define S3C_PA_USBHOST S3C64XX_PA_USBHOST
 #define S3C_PA_USB_HSOTG   S3C64XX_PA_USB_HSOTG
+#define S3C_PA_USB_PHY S3C64XX_PA_USB_HSPHY
 #define S3C_PA_RTC S3C64XX_PA_RTC
 #define S3C_PA_WDT S3C64XX_PA_WATCHDOG
 #define S3C_PA_SPI0S3C64XX_PA_SPI0
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index b0f5baf..adc2e15 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -31,6 +31,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -69,6 +70,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
@@ -336,6 +338,7 @@ static struct platform_device wallvdd_device = {
 };
 
 static struct platform_device *crag6410_devices[] __initdata = {
+   &samsung_device_usbphy,
&s3c_device_hsmmc0,
&s3c_device_hsmmc2,
&s3c_device_i2c0,
@@ -765,6 +768,9 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
+static struct samsung_usbphy_data crag6410_usbphy_pdata __initdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
 
 static void __init crag6410_machine_init(void)
 {
@@ -790,6 +796,7 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
+   samsung_usbphy_set_pdata(&crag6410_usbphy_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index 7400da1..90dc821 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -36,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -234,6 +236,7 @@ static struct i2c_board_info smartq_i2c_devs[] __initdata = 
{
 };
 
 static struct platform_device *smartq_devices[] __initdata = {
+   &samsung_device_usbphy,
&s3c_device_hsmmc1, /* Init iNAND first, ... */
&s3c_device_hsmmc0, /* ... then the external SD card */
&s3c_device_hsmmc2,
@@ -380,9 +383,14 @@ void __init smartq_map_io(void)
smartq_lcd_mode_set();
 }
 
+static struct samsung_usbphy_data smartq_usbphy_pdata __initdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
+
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
+   samsung_usbphy_set_pdata(&smartq_usbphy_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index cbdc91b..4cf1252 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include 
@@ -72,6 +73,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
@@ -263,6 +265,7 @@ static struct samsung_keypad_platdata smdk6410_keypad_data 
__initdata = {
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
+   &samsung_device_usbphy,
 #ifdef CONFIG_SMDK6410_SD_CH0
&s3c_device_hsmmc0,
 #endif
@@ -626,6 +629,9 @@ static struct

[PATCH v6 3/5] ARM: S3C64XX: Removing old phy setup code

2012-09-17 Thread Praveen Paneri
This patch removes old phy code from platform side. 'setup-usb-phy.c'
will be used for providing transceiver platform data in next
patch. Not all of the platform data code is removed as there are others
making use of platform_data defined for hsotg. That can be removed once
all the SoCs start using the new transceiver for usb phy setup.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/mach-crag6410.c |3 -
 arch/arm/mach-s3c64xx/mach-smartq.c   |3 -
 arch/arm/mach-s3c64xx/mach-smdk6410.c |3 -
 arch/arm/mach-s3c64xx/setup-usb-phy.c |   79 -
 4 files changed, 0 insertions(+), 88 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 09cd812..b0f5baf 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -31,7 +31,6 @@
 #include 
 
 #include 
-#include 
 
 #include 
 
@@ -766,7 +765,6 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
-static struct s3c_hsotg_plat crag6410_hsotg_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -792,7 +790,6 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&crag6410_hsotg_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index ceeb1de..7400da1 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -187,7 +186,6 @@ static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata 
= {
},
 };
 
-static struct s3c_hsotg_plat smartq_hsotg_pdata;
 
 static int __init smartq_lcd_setup_gpio(void)
 {
@@ -385,7 +383,6 @@ void __init smartq_map_io(void)
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
-   s3c_hsotg_set_platdata(&smartq_hsotg_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index 0fe4f15..cbdc91b 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include 
@@ -627,7 +626,6 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
-static struct s3c_hsotg_plat smdk6410_hsotg_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -657,7 +655,6 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&smdk6410_hsotg_pdata);
 
samsung_keypad_set_platdata(&smdk6410_keypad_data);
 
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c 
b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index f6757e0..7a09553 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
@@ -9,82 +9,3 @@
  *
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static int s3c_usb_otgphy_init(struct platform_device *pdev)
-{
-   struct clk *xusbxti;
-   u32 phyclk;
-
-   writel(readl(S3C64XX_OTHERS) | S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS);
-
-   /* set clock frequency for PLL */
-   phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK;
-
-   xusbxti = clk_get(&pdev->dev, "xusbxti");
-   if (xusbxti && !IS_ERR(xusbxti)) {
-   switch (clk_get_rate(xusbxti)) {
-   case 12 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_12M;
-   break;
-   case 24 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_24M;
-   break;
-   default:
-   case 48 * MHZ:
-   /* default reference clock */
-   break;
-   }
-   clk_put(xusbxti);
-   }
-
-   /* TODO: select external clock/oscillator */
-   writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK);
-
-   /* set to normal OTG PHY */
-   writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR);
-   mdelay(1);
-
-   /* reset OTG PHY and Link */
-   writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK,
-   S3C_RSTCON);
- 

[PATCH v6 2/5] usb: s3c-hsotg: Adding phy driver support

2012-09-17 Thread Praveen Paneri
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Praveen Paneri 
---
 drivers/usb/gadget/s3c-hsotg.c |   37 +++--
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 6f696ee..29815b9 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transceiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
-   if (hsotg->plat->phy_init)
+
+   if (hsotg->phy)
+   usb_phy_init(hsotg->phy);
+   else if (hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->plat->phy_exit)
+   if (hsotg->phy)
+   usb_phy_shutdown(hsotg->phy);
+   else if (hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = &pdev->dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3501,20 +3511,27 @@ static int __devinit s3c_hsotg_probe(struct 
platform_device *pdev)
int ret;
int i;
 
-   plat = pdev->dev.platform_data;
-   if (!plat) {
-   dev_err(&pdev->dev, "no platform data defined\n");
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
 
+   plat = pdev->dev.platform_data;
+   if (!plat) {
+   /* Fallback for transceiver */
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR_OR_NULL(phy)) {
+   dev_err(&pdev->dev, "no platform data or transceiver 
defined\n");
+   return -EPROBE_DEFER;
+   } else {
+   hsotg->phy = phy;
+   }
+   } else {
+   hsotg->plat = plat;
+   }
+
hsotg->dev = dev;
-   hsotg->plat = plat;
 
hsotg->clk = devm_clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
-- 
1.7.1

--
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/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-09-17 Thread Praveen Paneri
This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable phy. Tested with
smdk6410 and smdkv310. More SoCs can be brought under later.

Signed-off-by: Praveen Paneri 
Acked-by: Heiko Stuebner 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  360 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 5 files changed, 405 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..fefd9c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,9 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 63c339b..313685f 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -32,3 +32,11 @@ config MV_U3D_PHY
help
  Enable this to support Marvell USB 3.0 phy controller for Marvell
  SoC.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..55dcfc1 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
new file mode 100644
index 000..95ec4d0
--- /dev/null
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -0,0 +1,360 @@
+/* linux/drivers/usb/phy/samsung-usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register definitions */
+
+#define S3C_PHYPWR (0x00)
+
+#define S3C_PHYPWR_NORMAL_MASK (0x19 << 0)
+#define S3C_PHYPWR_OTG_DISABLE (1 << 4)
+#define S3C_PHYPWR_ANALOG_POWERDOWN(1 << 3)
+#define S3C_PHYPWR_FORCE_SUSPEND   (1 << 1)
+/* For Exynos4 */
+#define EXYNOS4_PHYPWR_NORMAL_MASK (0x39 << 0)
+#define EXYNOS4_PHYPWR_SLEEP   (1 << 5)
+
+#define S3C_PHYCLK (0x04)
+
+#define S3C_PHYCLK_MODE_SERIAL (1 << 6)
+#define S3C_PHYCLK_EXT_OSC (1 << 5)
+#define S3C_PHYCLK_COMMON_ON_N (1 << 4)
+#define S3C_PHYCLK_ID_PULL (1 << 2)
+#define S3C_PHYCLK_CLKSEL_MASK (0x3 << 0)
+#define S3C_PHYCLK_CLKSEL_SHIFT(0)
+#define S3C_PHYCLK_CLKSEL_48M  (0x0 << 0)
+#define S3C_PHYCLK_CLKSEL_12M  (0x2 << 0)
+#define S3C_PHYCLK_CLKSEL_24M  (0x3 << 0)
+
+#define S3C_RSTCON (0x08)
+
+#define S3C_RSTCON_PHYCLK  (1 << 2)
+#define S3C_RSTCON_HCLK(1 << 1)
+#define S3C_RSTCON_PHY (1 << 0)
+
+#ifndef MHZ
+#define MHZ (1000*1000)
+#endif
+
+enum samsung_cpu_type {
+   TYPE_S3C64XX,
+   TYPE_EXYNOS4210,
+};
+
+/*
+ * struct samsung_usbphy - transceiver driver state
+

[PATCH v6 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-09-17 Thread Praveen Paneri
Changes from v5:
Moved clk_get() to driver's probe function. Now reference clock frequency
selection value is stored in samsung_usbphy structure for later use. Used
IS_ENABLED() instead of #ifdef in samsung_usbphy_get_driver_data().

Changes from v4:
Moved header file contents to driver's source file
Removed unnecessary print message from driver's probe function
Dropped the Free Software Foundation address from the header
Changed the platform data code to use __initdata

Changes from v3:
Replaced susbsys_initcall()/module_exit() by module_platform_driver().
Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
is registered
Removed unnecessary devm_usb_put_phy() call from the hsotg driver remove.

Changes from v2:
Changed the driver filenames to samsung-usbphy
Changed 's3c' to 'samsung' for platform device as well as platform data
Moved platform data structure to a separate file
Rectified coding style related errors

Changes from v1:
Rebased patches to latest usb-next branch
Changed the name 'sec_usbphy' to 'samsung_usbphy'

This patch set introduces a phy driver for samsung SoCs. It uses the existing
transceiver infrastructure to provide phy control functions. Use of this driver
can be extended for usb host phy as well. Over the period of time all the phy
related code for most of the samsung SoCs can be integrated here.
Removing the existing phy code from mach-s3c64xx. Same can be done for other 
SoCs
when they start supporting this phy driver. 
This driver is tested with smdk6410 and Exynos4210(with DT).

Praveen Paneri (5):
  usb: phy: samsung: Introducing usb phy driver for hsotg
  usb: s3c-hsotg: Adding phy driver support
  ARM: S3C64XX: Removing old phy setup code
  ARM: S3C64XX: Enabling samsung-usbphy driver
  ARM: Exynos4210: Enabling samsung-usbphy driver

 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 arch/arm/boot/dts/exynos4210.dtsi  |5 +
 arch/arm/mach-exynos/include/mach/map.h|1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c |8 +
 arch/arm/mach-exynos/setup-usb-phy.c   |   13 +
 arch/arm/mach-s3c64xx/include/mach/map.h   |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c  |   10 +-
 arch/arm/mach-s3c64xx/mach-smartq.c|   11 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c  |   10 +-
 arch/arm/mach-s3c64xx/setup-usb-phy.c  |   79 +
 arch/arm/plat-samsung/devs.c   |   28 ++
 arch/arm/plat-samsung/include/plat/devs.h  |1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h   |1 +
 drivers/usb/gadget/s3c-hsotg.c |   37 ++-
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  360 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 18 files changed, 520 insertions(+), 91 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

--
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 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-09-14 Thread Praveen Paneri
On Wed, Sep 12, 2012 at 9:51 PM, Tomasz Figa  wrote:
> Hi Praveen, Marc,
>
> On Wednesday 12 of September 2012 13:08:26 Marc Kleine-Budde wrote:
>> > +static const struct of_device_id samsung_usbphy_dt_match[];
>> > +
>> > +static inline int samsung_usbphy_get_driver_data(struct
>> > platform_device *pdev) +{
>> > +#ifdef CONFIG_OF
>>
>> if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node)
>
> Is this check needed at all?
>
> In case of CONFIG_OF disabled, of_node should always be NULL and there is a
but I guess it can also be NULL when CONFIG_OF is enabled but the
driver is probed non DT way.
> dummy macro provided for of_match_node, so it should compile and work just
> fine.
>
> --
> Best regards,
> Tomasz Figa
>
> --
> 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
--
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 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-09-13 Thread Praveen Paneri
On Wed, Sep 12, 2012 at 4:38 PM, Marc Kleine-Budde  wrote:
> On 09/12/2012 12:45 PM, Praveen Paneri wrote:
>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>> smdk6410 and smdkv310. More SoCs can be brought under later.
>>
>> Signed-off-by: Praveen Paneri 
>> Acked-by: Heiko Stuebner 
>> ---
>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>  drivers/usb/phy/Kconfig|8 +
>>  drivers/usb/phy/Makefile   |1 +
>>  drivers/usb/phy/samsung-usbphy.c   |  371 
>> 
>>  include/linux/platform_data/samsung-usbphy.h   |   27 ++
>>  5 files changed, 416 insertions(+), 0 deletions(-)
>>  create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>  create mode 100644 drivers/usb/phy/samsung-usbphy.c
>>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>>
>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> new file mode 100644
>> index 000..fefd9c8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> @@ -0,0 +1,9 @@
>> +* Samsung's usb phy transceiver
>> +
>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>> +s3c-hsotg usb device controller.
>> +
>> +Required properties:
>> +- compatible : should be "samsung,exynos4210-usbphy"
>> +- reg : base physical address of the phy registers and length of memory 
>> mapped
>> + region.
>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>> index 63c339b..313685f 100644
>> --- a/drivers/usb/phy/Kconfig
>> +++ b/drivers/usb/phy/Kconfig
>> @@ -32,3 +32,11 @@ config MV_U3D_PHY
>>   help
>> Enable this to support Marvell USB 3.0 phy controller for Marvell
>> SoC.
>> +
>> +config SAMSUNG_USBPHY
>> + bool "Samsung USB PHY controller Driver"
>> + depends on USB_S3C_HSOTG
>> + select USB_OTG_UTILS
>> + help
>> +   Enable this to support Samsung USB phy controller for samsung
>> +   SoCs.
>> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
>> index b069f29..55dcfc1 100644
>> --- a/drivers/usb/phy/Makefile
>> +++ b/drivers/usb/phy/Makefile
>> @@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2)   += omap-usb2.o
>>  obj-$(CONFIG_USB_ISP1301)+= isp1301.o
>>  obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o
>>  obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
>> +obj-$(CONFIG_SAMSUNG_USBPHY) += samsung-usbphy.o
>> diff --git a/drivers/usb/phy/samsung-usbphy.c 
>> b/drivers/usb/phy/samsung-usbphy.c
>> new file mode 100644
>> index 000..b00d01b
>> --- /dev/null
>> +++ b/drivers/usb/phy/samsung-usbphy.c
>> @@ -0,0 +1,371 @@
>> +/* linux/drivers/usb/phy/samsung-usbphy.c
>> + *
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *  http://www.samsung.com
>> + *
>> + * Author: Praveen Paneri 
>> + *
>> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
>> + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/* Register definitions */
>> +
>> +#define S3C_PHYPWR   (0x00)
>> +
>> +#define S3C_PHYPWR_NORMAL_MASK   (0x19 << 0)
>> +#define S3C_PHYPWR_OTG_DISABLE   (1 << 4)
>> +#define S3C_PHYPWR_ANALOG_POWERDOWN  (1 << 3)
>> +#define S3C_PHYPWR_FORCE_SUSPEND (1 << 1)
>> +/* For Exynos4 */
>> +#define EXYNOS4_PHYPWR_NORMAL_MASK   (0x39 << 0)
>> +#define EXYNOS4_PHYPWR_SLEEP (1 << 5)
>> +
&g

[PATCH v5 5/5] ARM: Exynos4210: Enabling samsung-usbphy driver

2012-09-12 Thread Praveen Paneri
Adding usbphy node for Exynos4210 along with the platform data.

Signed-off-by: Praveen Paneri 
---
 arch/arm/boot/dts/exynos4210.dtsi   |5 +
 arch/arm/mach-exynos/include/mach/map.h |1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c  |8 
 arch/arm/mach-exynos/setup-usb-phy.c|   13 +
 4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
b/arch/arm/boot/dts/exynos4210.dtsi
index 02891fe..e28cf10 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -62,6 +62,11 @@
interrupts = <0 44 0>, <0 45 0>;
};
 
+   usbphy@125B {
+   compatible = "samsung,exynos4210-usbphy";
+   reg = <0x125B 0x100>;
+   };
+
keypad@100A {
compatible = "samsung,s5pv210-keypad";
reg = <0x100A 0x100>;
diff --git a/arch/arm/mach-exynos/include/mach/map.h 
b/arch/arm/mach-exynos/include/mach/map.h
index c72b675..0625c0a 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -234,6 +234,7 @@
 #define S3C_PA_SPI1EXYNOS4_PA_SPI1
 #define S3C_PA_SPI2EXYNOS4_PA_SPI2
 #define S3C_PA_USB_HSOTG   EXYNOS4_PA_HSOTG
+#define S3C_PA_USB_PHY EXYNOS4_PA_HSPHY
 
 #define S5P_PA_EHCIEXYNOS4_PA_EHCI
 #define S5P_PA_FIMC0   EXYNOS4_PA_FIMC0
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c 
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index b2b5d5f..0739be8 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -20,9 +21,14 @@
 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
+static struct samsung_usbphy_data exynos4_usbphy_pdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
+
 /*
  * The following lookup table is used to override device names when devices
  * are registered from device tree. This is temporarily added to enable
@@ -63,6 +69,8 @@ static const struct of_dev_auxdata 
exynos4210_auxdata_lookup[] __initconst = {
"exynos4210-spi.2", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA0, "dma-pl330.0", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA1, "dma-pl330.1", NULL),
+   OF_DEV_AUXDATA("samsung,exynos4210-usbphy", EXYNOS4_PA_HSPHY,
+   "s3c-usbphy", &exynos4_usbphy_pdata),
{},
 };
 
diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index b81cc56..1c62d20 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -221,3 +221,16 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int 
type)
 
return -EINVAL;
 }
+
+void s5p_usb_phy_pmu_isolation(int on)
+{
+   if (on) {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   & ~S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   } else {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   | S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   }
+}
-- 
1.7.1

--
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 4/5] ARM: S3C64XX: Enabling samsung-usbphy driver

2012-09-12 Thread Praveen Paneri
Adding platform device for samsung-usbphy driver. Enabling it for
s3c64xx based machines using s3c-hsotg.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/include/mach/map.h |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c|7 ++
 arch/arm/mach-s3c64xx/mach-smartq.c  |8 +++
 arch/arm/mach-s3c64xx/mach-smdk6410.c|7 ++
 arch/arm/mach-s3c64xx/setup-usb-phy.c|   14 +
 arch/arm/plat-samsung/devs.c |   28 ++
 arch/arm/plat-samsung/include/plat/devs.h|1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h |1 +
 8 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/include/mach/map.h 
b/arch/arm/mach-s3c64xx/include/mach/map.h
index 8e2097b..dc482bb 100644
--- a/arch/arm/mach-s3c64xx/include/mach/map.h
+++ b/arch/arm/mach-s3c64xx/include/mach/map.h
@@ -65,6 +65,7 @@
 
 #define S3C64XX_PA_NAND(0x7020)
 #define S3C64XX_PA_FB  (0x7710)
+#define S3C64XX_PA_USB_HSPHY   (0x7C10)
 #define S3C64XX_PA_USB_HSOTG   (0x7C00)
 #define S3C64XX_PA_WATCHDOG(0x7E004000)
 #define S3C64XX_PA_RTC (0x7E005000)
@@ -113,6 +114,7 @@
 #define S3C_PA_FB  S3C64XX_PA_FB
 #define S3C_PA_USBHOST S3C64XX_PA_USBHOST
 #define S3C_PA_USB_HSOTG   S3C64XX_PA_USB_HSOTG
+#define S3C_PA_USB_PHY S3C64XX_PA_USB_HSPHY
 #define S3C_PA_RTC S3C64XX_PA_RTC
 #define S3C_PA_WDT S3C64XX_PA_WATCHDOG
 #define S3C_PA_SPI0S3C64XX_PA_SPI0
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index b0f5baf..adc2e15 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -31,6 +31,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -69,6 +70,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
@@ -336,6 +338,7 @@ static struct platform_device wallvdd_device = {
 };
 
 static struct platform_device *crag6410_devices[] __initdata = {
+   &samsung_device_usbphy,
&s3c_device_hsmmc0,
&s3c_device_hsmmc2,
&s3c_device_i2c0,
@@ -765,6 +768,9 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
+static struct samsung_usbphy_data crag6410_usbphy_pdata __initdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
 
 static void __init crag6410_machine_init(void)
 {
@@ -790,6 +796,7 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
+   samsung_usbphy_set_pdata(&crag6410_usbphy_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index 7400da1..90dc821 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -36,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -234,6 +236,7 @@ static struct i2c_board_info smartq_i2c_devs[] __initdata = 
{
 };
 
 static struct platform_device *smartq_devices[] __initdata = {
+   &samsung_device_usbphy,
&s3c_device_hsmmc1, /* Init iNAND first, ... */
&s3c_device_hsmmc0, /* ... then the external SD card */
&s3c_device_hsmmc2,
@@ -380,9 +383,14 @@ void __init smartq_map_io(void)
smartq_lcd_mode_set();
 }
 
+static struct samsung_usbphy_data smartq_usbphy_pdata __initdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
+
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
+   samsung_usbphy_set_pdata(&smartq_usbphy_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index cbdc91b..4cf1252 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include 
@@ -72,6 +73,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
@@ -263,6 +265,7 @@ static struct samsung_keypad_platdata smdk6410_keypad_data 
__initdata = {
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
+   &samsung_device_usbphy,
 #ifdef CONFIG_SMDK6410_SD_CH0
&s3c_device_hsmmc0,
 #endif
@@ -626,6 +629,9 @@ static struct

[PATCH v5 3/5] ARM: S3C64XX: Removing old phy setup code

2012-09-12 Thread Praveen Paneri
This patch removes old phy code from platform side. 'setup-usb-phy.c'
will be used for providing transceiver platform data in next
patch. Not all of the platform data code is removed as there are others
making use of platform_data defined for hsotg. That can be removed once
all the SoCs start using the new transceiver for usb phy setup.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/mach-crag6410.c |3 -
 arch/arm/mach-s3c64xx/mach-smartq.c   |3 -
 arch/arm/mach-s3c64xx/mach-smdk6410.c |3 -
 arch/arm/mach-s3c64xx/setup-usb-phy.c |   79 -
 4 files changed, 0 insertions(+), 88 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 09cd812..b0f5baf 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -31,7 +31,6 @@
 #include 
 
 #include 
-#include 
 
 #include 
 
@@ -766,7 +765,6 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
-static struct s3c_hsotg_plat crag6410_hsotg_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -792,7 +790,6 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&crag6410_hsotg_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index ceeb1de..7400da1 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -187,7 +186,6 @@ static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata 
= {
},
 };
 
-static struct s3c_hsotg_plat smartq_hsotg_pdata;
 
 static int __init smartq_lcd_setup_gpio(void)
 {
@@ -385,7 +383,6 @@ void __init smartq_map_io(void)
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
-   s3c_hsotg_set_platdata(&smartq_hsotg_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index 0fe4f15..cbdc91b 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include 
@@ -627,7 +626,6 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
-static struct s3c_hsotg_plat smdk6410_hsotg_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -657,7 +655,6 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&smdk6410_hsotg_pdata);
 
samsung_keypad_set_platdata(&smdk6410_keypad_data);
 
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c 
b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index f6757e0..7a09553 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
@@ -9,82 +9,3 @@
  *
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static int s3c_usb_otgphy_init(struct platform_device *pdev)
-{
-   struct clk *xusbxti;
-   u32 phyclk;
-
-   writel(readl(S3C64XX_OTHERS) | S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS);
-
-   /* set clock frequency for PLL */
-   phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK;
-
-   xusbxti = clk_get(&pdev->dev, "xusbxti");
-   if (xusbxti && !IS_ERR(xusbxti)) {
-   switch (clk_get_rate(xusbxti)) {
-   case 12 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_12M;
-   break;
-   case 24 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_24M;
-   break;
-   default:
-   case 48 * MHZ:
-   /* default reference clock */
-   break;
-   }
-   clk_put(xusbxti);
-   }
-
-   /* TODO: select external clock/oscillator */
-   writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK);
-
-   /* set to normal OTG PHY */
-   writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR);
-   mdelay(1);
-
-   /* reset OTG PHY and Link */
-   writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK,
-   S3C_RSTCON);
- 

[PATCH v5 2/5] usb: s3c-hsotg: Adding phy driver support

2012-09-12 Thread Praveen Paneri
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Praveen Paneri 
---
 drivers/usb/gadget/s3c-hsotg.c |   37 +++--
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 6f696ee..29815b9 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transceiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
-   if (hsotg->plat->phy_init)
+
+   if (hsotg->phy)
+   usb_phy_init(hsotg->phy);
+   else if (hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->plat->phy_exit)
+   if (hsotg->phy)
+   usb_phy_shutdown(hsotg->phy);
+   else if (hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = &pdev->dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3501,20 +3511,27 @@ static int __devinit s3c_hsotg_probe(struct 
platform_device *pdev)
int ret;
int i;
 
-   plat = pdev->dev.platform_data;
-   if (!plat) {
-   dev_err(&pdev->dev, "no platform data defined\n");
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
 
+   plat = pdev->dev.platform_data;
+   if (!plat) {
+   /* Fallback for transceiver */
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR_OR_NULL(phy)) {
+   dev_err(&pdev->dev, "no platform data or transceiver 
defined\n");
+   return -EPROBE_DEFER;
+   } else {
+   hsotg->phy = phy;
+   }
+   } else {
+   hsotg->plat = plat;
+   }
+
hsotg->dev = dev;
-   hsotg->plat = plat;
 
hsotg->clk = devm_clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
-- 
1.7.1

--
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 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-09-12 Thread Praveen Paneri
This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable phy. Tested with
smdk6410 and smdkv310. More SoCs can be brought under later.

Signed-off-by: Praveen Paneri 
Acked-by: Heiko Stuebner 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  371 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 5 files changed, 416 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..fefd9c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,9 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 63c339b..313685f 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -32,3 +32,11 @@ config MV_U3D_PHY
help
  Enable this to support Marvell USB 3.0 phy controller for Marvell
  SoC.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..55dcfc1 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
new file mode 100644
index 000..b00d01b
--- /dev/null
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -0,0 +1,371 @@
+/* linux/drivers/usb/phy/samsung-usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Register definitions */
+
+#define S3C_PHYPWR (0x00)
+
+#define S3C_PHYPWR_NORMAL_MASK (0x19 << 0)
+#define S3C_PHYPWR_OTG_DISABLE (1 << 4)
+#define S3C_PHYPWR_ANALOG_POWERDOWN(1 << 3)
+#define S3C_PHYPWR_FORCE_SUSPEND   (1 << 1)
+/* For Exynos4 */
+#define EXYNOS4_PHYPWR_NORMAL_MASK (0x39 << 0)
+#define EXYNOS4_PHYPWR_SLEEP   (1 << 5)
+
+#define S3C_PHYCLK (0x04)
+
+#define S3C_PHYCLK_MODE_SERIAL (1 << 6)
+#define S3C_PHYCLK_EXT_OSC (1 << 5)
+#define S3C_PHYCLK_COMMON_ON_N (1 << 4)
+#define S3C_PHYCLK_ID_PULL (1 << 2)
+#define S3C_PHYCLK_CLKSEL_MASK (0x3 << 0)
+#define S3C_PHYCLK_CLKSEL_SHIFT(0)
+#define S3C_PHYCLK_CLKSEL_48M  (0x0 << 0)
+#define S3C_PHYCLK_CLKSEL_12M  (0x2 << 0)
+#define S3C_PHYCLK_CLKSEL_24M  (0x3 << 0)
+
+#define S3C_RSTCON (0x08)
+
+#define S3C_RSTCON_PHYCLK  (1 << 2)
+#define S3C_RSTCON_HCLK(1 << 1)
+#define S3C_RSTCON_PHY (1 << 0)
+
+#ifndef MHZ
+#define MHZ (1000*1000)
+#endif
+
+enum samsung_cpu_type {
+   TYPE_S3C64XX,
+   TYPE_EXYNOS4210,
+};
+
+/*
+ * struct samsung_usbphy - transceiver driver state
+

[PATCH v5 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-09-12 Thread Praveen Paneri
Changes from v4:
Moved header file contents to driver's source file
Removed unnecessary print message from driver's probe function
Dropped the Free Software Foundation address from the header
Changed the platform data code to use __initdata

Changes from v3:
Replaced susbsys_initcall()/module_exit() by module_platform_driver().
Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
is registered
Removed unnecessary devm_usb_put_phy() call from the hsotg driver remove.

Changes from v2:
Changed the driver filenames to samsung-usbphy
Changed 's3c' to 'samsung' for platform device as well as platform data
Moved platform data structure to a separate file
Rectified coding style related errors

Changes from v1:
Rebased patches to latest usb-next branch
Changed the name 'sec_usbphy' to 'samsung_usbphy'

This patch set introduces a phy driver for samsung SoCs. It uses the existing
transceiver infrastructure to provide phy control functions. Use of this driver
can be extended for usb host phy as well. Over the period of time all the phy
related code for most of the samsung SoCs can be integrated here.
Removing the existing phy code from mach-s3c64xx. Same can be done for other 
SoCs
when they start supporting this phy driver. 
This driver is tested with smdk6410 and Exynos4210(with DT).

Praveen Paneri (5):
  usb: phy: samsung: Introducing usb phy driver for hsotg
  usb: s3c-hsotg: Adding phy driver support
  ARM: S3C64XX: Removing old phy setup code
  ARM: S3C64XX: Enabling samsung-usbphy driver
  ARM: Exynos4210: Enabling samsung-usbphy driver

 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 arch/arm/boot/dts/exynos4210.dtsi  |5 +
 arch/arm/mach-exynos/include/mach/map.h|1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c |8 +
 arch/arm/mach-exynos/setup-usb-phy.c   |   13 +
 arch/arm/mach-s3c64xx/include/mach/map.h   |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c  |   10 +-
 arch/arm/mach-s3c64xx/mach-smartq.c|   11 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c  |   10 +-
 arch/arm/mach-s3c64xx/setup-usb-phy.c  |   79 +
 arch/arm/plat-samsung/devs.c   |   28 ++
 arch/arm/plat-samsung/include/plat/devs.h  |1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h   |1 +
 drivers/usb/gadget/s3c-hsotg.c |   37 ++-
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  371 
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 18 files changed, 531 insertions(+), 91 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

--
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 4/5] ARM: S3C64XX: Enabling samsung-usbphy driver

2012-08-10 Thread Praveen Paneri
On Fri, Aug 10, 2012 at 12:24 PM, Anton Tikhomirov
 wrote:
> Hi Praveen,
>
>> -Original Message-
>> From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb-
>> ow...@vger.kernel.org] On Behalf Of Praveen Paneri
>> Sent: Wednesday, August 08, 2012 4:41 PM
>> To: linux-usb@vger.kernel.org
>> Cc: devicetree-disc...@lists.ozlabs.org; linux-arm-
>> ker...@lists.infradead.org; linux-samsung-...@vger.kernel.org;
>> kgene@samsung.com; ba...@ti.com; gre...@linuxfoundation.org;
>> thomas.abra...@linaro.org; ben-li...@fluff.org;
>> broo...@opensource.wolfsonmicro.com; l.majew...@samsung.com;
>> kyungmin.p...@samsung.com; grant.lik...@secretlab.ca; he...@sntech.de
>> Subject: [PATCH v3 4/5] ARM: S3C64XX: Enabling samsung-usbphy driver
>>
>> Adding platform device for samsung-usbphy driver. Enabling it for
>> s3c64xx based machines using s3c-hsotg.
>>
>> Signed-off-by: Praveen Paneri 
>> ---
>>  arch/arm/mach-s3c64xx/include/mach/map.h |2 +
>>  arch/arm/mach-s3c64xx/mach-crag6410.c|4 +++
>>  arch/arm/mach-s3c64xx/mach-smartq.c  |5 
>>  arch/arm/mach-s3c64xx/mach-smdk6410.c|4 +++
>>  arch/arm/mach-s3c64xx/setup-usb-phy.c|   14 +++
>>  arch/arm/plat-samsung/devs.c |   33
> ++
>>  arch/arm/plat-samsung/include/plat/devs.h|1 +
>>  arch/arm/plat-samsung/include/plat/usb-phy.h |1 +
>>  8 files changed, 64 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/mach-s3c64xx/include/mach/map.h b/arch/arm/mach-
>> s3c64xx/include/mach/map.h
>> index 8e2097b..dc482bb 100644
>> --- a/arch/arm/mach-s3c64xx/include/mach/map.h
>> +++ b/arch/arm/mach-s3c64xx/include/mach/map.h
>> @@ -65,6 +65,7 @@
>>
>>  #define S3C64XX_PA_NAND  (0x7020)
>>  #define S3C64XX_PA_FB(0x7710)
>> +#define S3C64XX_PA_USB_HSPHY (0x7C10)
>>  #define S3C64XX_PA_USB_HSOTG (0x7C00)
>>  #define S3C64XX_PA_WATCHDOG  (0x7E004000)
>>  #define S3C64XX_PA_RTC   (0x7E005000)
>> @@ -113,6 +114,7 @@
>>  #define S3C_PA_FBS3C64XX_PA_FB
>>  #define S3C_PA_USBHOST   S3C64XX_PA_USBHOST
>>  #define S3C_PA_USB_HSOTG S3C64XX_PA_USB_HSOTG
>> +#define S3C_PA_USB_PHY   S3C64XX_PA_USB_HSPHY
>>  #define S3C_PA_RTC   S3C64XX_PA_RTC
>>  #define S3C_PA_WDT   S3C64XX_PA_WATCHDOG
>>  #define S3C_PA_SPI0  S3C64XX_PA_SPI0
>> diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-
>> s3c64xx/mach-crag6410.c
>> index b0f5baf..fa02e2f 100644
>> --- a/arch/arm/mach-s3c64xx/mach-crag6410.c
>> +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
>> @@ -31,6 +31,7 @@
>>  #include 
>>
>>  #include 
>> +#include 
>>
>>  #include 
>>
>> @@ -336,6 +337,7 @@ static struct platform_device wallvdd_device = {
>>  };
>>
>>  static struct platform_device *crag6410_devices[] __initdata = {
>> + &samsung_device_usbphy,
>>   &s3c_device_hsmmc0,
>>   &s3c_device_hsmmc2,
>>   &s3c_device_i2c0,
>> @@ -765,6 +767,7 @@ static const struct gpio_led_platform_data
>> gpio_leds_pdata = {
>>   .num_leds = ARRAY_SIZE(gpio_leds),
>>  };
>>
>> +static struct samsung_usbphy_data crag6410_usbphy_pdata;
>
> Why don't you use __initdata for this structure? It will be duplicated
> in s3c_set_platdata() and we don't need it in memory after booting.
> I think you can even initialize it here (with s5p_usb_phy_pmu_isolation).
Thanks! will change it.

Praveen
>
>>
>>  static void __init crag6410_machine_init(void)
>>  {
>> @@ -790,6 +793,7 @@ static void __init crag6410_machine_init(void)
>>   s3c_i2c0_set_platdata(&i2c0_pdata);
>>   s3c_i2c1_set_platdata(&i2c1_pdata);
>>   s3c_fb_set_platdata(&crag6410_lcd_pdata);
>> + samsung_usbphy_set_pdata(&crag6410_usbphy_pdata);
>>
>>   i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
>>   i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
>> diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c b/arch/arm/mach-
>> s3c64xx/mach-smartq.c
>> index 7400da1..e0c4df8 100644
>> --- a/arch/arm/mach-s3c64xx/mach-smartq.c
>> +++ b/arch/arm/mach-s3c64xx/mach-smartq.c
>> @@ -18,6 +18,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>
>>  #include 
>>  #include 
>> @@ -234,6 +235,7 @@ static struct i2c_board_info smar

Re: [PATCH v4 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-10 Thread Praveen Paneri
On Fri, Aug 10, 2012 at 12:49 PM, ABRAHAM, KISHON VIJAY  wrote:
> Hi,
>
> On Fri, Aug 10, 2012 at 12:40 PM, Praveen Paneri  wrote:
>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>> smdk6410 and smdkv310. More SoCs can be brought under later.
>>
>> Signed-off-by: Praveen Paneri 
>> Acked-by: Heiko Stuebner 
>> ---
>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>  drivers/usb/phy/Kconfig|8 +
>>  drivers/usb/phy/Makefile   |1 +
>>  drivers/usb/phy/samsung-usbphy.c   |  345 
>> 
>>  drivers/usb/phy/samsung-usbphy.h   |   48 +++
>>  include/linux/platform_data/samsung-usbphy.h   |   27 ++
>>  6 files changed, 438 insertions(+), 0 deletions(-)
>>  create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>  create mode 100644 drivers/usb/phy/samsung-usbphy.c
>>  create mode 100644 drivers/usb/phy/samsung-usbphy.h
>>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>>
>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> new file mode 100644
>> index 000..fefd9c8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> @@ -0,0 +1,9 @@
>> +* Samsung's usb phy transceiver
>> +
>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>> +s3c-hsotg usb device controller.
>> +
>> +Required properties:
>> +- compatible : should be "samsung,exynos4210-usbphy"
>> +- reg : base physical address of the phy registers and length of memory 
>> mapped
>> +   region.
>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>> index e7cf84f..d916477 100644
>> --- a/drivers/usb/phy/Kconfig
>> +++ b/drivers/usb/phy/Kconfig
>> @@ -15,3 +15,11 @@ config USB_ISP1301
>>
>>   To compile this driver as a module, choose M here: the
>>   module will be called isp1301.
>> +
>> +config SAMSUNG_USBPHY
>> +   bool "Samsung USB PHY controller Driver"
>> +   depends on USB_S3C_HSOTG
>> +   select USB_OTG_UTILS
>> +   help
>> + Enable this to support Samsung USB phy controller for samsung
>> + SoCs.
>> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
>> index eca095b..dfca70d 100644
>> --- a/drivers/usb/phy/Makefile
>> +++ b/drivers/usb/phy/Makefile
>> @@ -5,3 +5,4 @@
>>  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
>>
>>  obj-$(CONFIG_USB_ISP1301)  += isp1301.o
>> +obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
>> diff --git a/drivers/usb/phy/samsung-usbphy.c 
>> b/drivers/usb/phy/samsung-usbphy.c
>> new file mode 100644
>> index 000..739b6c9
>> --- /dev/null
>> +++ b/drivers/usb/phy/samsung-usbphy.c
>> @@ -0,0 +1,345 @@
>> +/* linux/drivers/usb/phy/samsung-usbphy.c
>> + *
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *  http://www.samsung.com
>> + *
>> + * Author: Praveen Paneri 
>> + *
>> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
>> + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, write to the Free Software
>> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>
> I suggest you drop that last paragraph unless you want to keep track
> of Free Software Foundation office. Right now it is 51 Franklin
> Street, Boston (http://www.fsf.org/about/contact/) :-)
Yeah! it can be dropped :-)

Praveen
>
> -Kishon
> --
> 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
--
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/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-08-10 Thread Praveen Paneri
On Fri, Aug 10, 2012 at 12:36 PM, Felipe Balbi  wrote:
> On Fri, Aug 10, 2012 at 12:40:26PM +0530, Praveen Paneri wrote:
>> Changes from v3:
>> Replaced susbsys_initcall()/module_exit() by module_platform_driver().
>> Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
>> is registered
>> Removed unnecessary devm_usb_put_phy() call from the hsotg driver remove.
>>
>> Changes from v2:
>> Changed the driver filenames to samsung-usbphy
>> Changed 's3c' to 'samsung' for platform device as well as platform data
>> Moved platform data structure to a separate file
>> Rectified coding style related errors
>>
>> Changes from v1:
>> Rebased patches to latest usb-next branch
>> Changed the name 'sec_usbphy' to 'samsung_usbphy'
>>
>> This patch set introduces a phy driver for samsung SoCs. It uses the existing
>> transceiver infrastructure to provide phy control functions. Use of this 
>> driver
>> can be extended for usb host phy as well. Over the period of time all the phy
>> related code for most of the samsung SoCs can be integrated here.
>> Removing the existing phy code from mach-s3c64xx. Same can be done for other 
>> SoCs
>> when they start supporting this phy driver.
>> This driver is tested with smdk6410 and Exynos4210(with DT).
>>
>> Praveen Paneri (5):
>>   usb: phy: samsung: Introducing usb phy driver for hsotg
>>   usb: s3c-hsotg: Adding phy driver support
>>   ARM: S3C64XX: Removing old phy setup code
>>   ARM: S3C64XX: Enabling samsung-usbphy driver
>>   ARM: Exynos4210: Enabling samsung-usbphy driver
>
> just one idea. It looks like after introducing the PHY, you converted
> all users to create the phy device. I wonder if you should have a
Not all
> patch 6/6 which will remove pdata->init support from s3c_hsotg.c and
> stick to using phy driver.
This will make the hsotg driver unusable for others (in mach-s5pv210
and mach-exynos) which are not supported in the phy driver as of now.
My idea was to drop the pdata->init when the last user gets the phy
support. Need some time for that :-)

Praveen
>
> --
> balbi
--
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 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-10 Thread Praveen Paneri
On Fri, Aug 10, 2012 at 12:34 PM, Felipe Balbi  wrote:
> Hi,
>
> On Fri, Aug 10, 2012 at 12:40:27PM +0530, Praveen Paneri wrote:
>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>> smdk6410 and smdkv310. More SoCs can be brought under later.
>>
>> Signed-off-by: Praveen Paneri 
>> Acked-by: Heiko Stuebner 
>
> this looks good. Just 2 comments below.
>
>> ---
>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>  drivers/usb/phy/Kconfig|8 +
>>  drivers/usb/phy/Makefile   |1 +
>>  drivers/usb/phy/samsung-usbphy.c   |  345 
>> 
>>  drivers/usb/phy/samsung-usbphy.h   |   48 +++
>>  include/linux/platform_data/samsung-usbphy.h   |   27 ++
>>  6 files changed, 438 insertions(+), 0 deletions(-)
>>  create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>  create mode 100644 drivers/usb/phy/samsung-usbphy.c
>>  create mode 100644 drivers/usb/phy/samsung-usbphy.h
>>  create mode 100644 include/linux/platform_data/samsung-usbphy.h
>>
>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> new file mode 100644
>> index 000..fefd9c8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> @@ -0,0 +1,9 @@
>> +* Samsung's usb phy transceiver
>> +
>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>> +s3c-hsotg usb device controller.
>> +
>> +Required properties:
>> +- compatible : should be "samsung,exynos4210-usbphy"
>> +- reg : base physical address of the phy registers and length of memory 
>> mapped
>> + region.
>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>> index e7cf84f..d916477 100644
>> --- a/drivers/usb/phy/Kconfig
>> +++ b/drivers/usb/phy/Kconfig
>> @@ -15,3 +15,11 @@ config USB_ISP1301
>>
>> To compile this driver as a module, choose M here: the
>> module will be called isp1301.
>> +
>> +config SAMSUNG_USBPHY
>> +   bool "Samsung USB PHY controller Driver"
>> +   depends on USB_S3C_HSOTG
>> +   select USB_OTG_UTILS
>> +   help
>> + Enable this to support Samsung USB phy controller for samsung
>> + SoCs.
>> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
>> index eca095b..dfca70d 100644
>> --- a/drivers/usb/phy/Makefile
>> +++ b/drivers/usb/phy/Makefile
>> @@ -5,3 +5,4 @@
>>  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
>>
>>  obj-$(CONFIG_USB_ISP1301)+= isp1301.o
>> +obj-$(CONFIG_SAMSUNG_USBPHY)     += samsung-usbphy.o
>> diff --git a/drivers/usb/phy/samsung-usbphy.c 
>> b/drivers/usb/phy/samsung-usbphy.c
>> new file mode 100644
>> index 000..739b6c9
>> --- /dev/null
>> +++ b/drivers/usb/phy/samsung-usbphy.c
>> @@ -0,0 +1,345 @@
>> +/* linux/drivers/usb/phy/samsung-usbphy.c
>> + *
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *  http://www.samsung.com
>> + *
>> + * Author: Praveen Paneri 
>> + *
>> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
>> + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, write to the Free Software
>> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>> +*/
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "samsung-usbphy.h"
>> +
>> +enum samsung_cpu_type {
>> + TYPE_S3C64XX,
>> + TYPE_EXYNOS4210,
>> +};
>> +
>> +/*
>> + * struct samsung_usbphy - transceiver driver state
&

[PATCH v4 5/5] ARM: Exynos4210: Enabling samsung-usbphy driver

2012-08-10 Thread Praveen Paneri
Adding usbphy node for Exynos4210 along with the platform data.

Signed-off-by: Praveen Paneri 
---
 arch/arm/boot/dts/exynos4210.dtsi   |5 +
 arch/arm/mach-exynos/include/mach/map.h |1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c  |8 
 arch/arm/mach-exynos/setup-usb-phy.c|   13 +
 4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
b/arch/arm/boot/dts/exynos4210.dtsi
index 02891fe..e28cf10 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -62,6 +62,11 @@
interrupts = <0 44 0>, <0 45 0>;
};
 
+   usbphy@125B {
+   compatible = "samsung,exynos4210-usbphy";
+   reg = <0x125B 0x100>;
+   };
+
keypad@100A {
compatible = "samsung,s5pv210-keypad";
reg = <0x100A 0x100>;
diff --git a/arch/arm/mach-exynos/include/mach/map.h 
b/arch/arm/mach-exynos/include/mach/map.h
index c72b675..0625c0a 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -234,6 +234,7 @@
 #define S3C_PA_SPI1EXYNOS4_PA_SPI1
 #define S3C_PA_SPI2EXYNOS4_PA_SPI2
 #define S3C_PA_USB_HSOTG   EXYNOS4_PA_HSOTG
+#define S3C_PA_USB_PHY EXYNOS4_PA_HSPHY
 
 #define S5P_PA_EHCIEXYNOS4_PA_EHCI
 #define S5P_PA_FIMC0   EXYNOS4_PA_FIMC0
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c 
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index b2b5d5f..0739be8 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -20,9 +21,14 @@
 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
+static struct samsung_usbphy_data exynos4_usbphy_pdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
+
 /*
  * The following lookup table is used to override device names when devices
  * are registered from device tree. This is temporarily added to enable
@@ -63,6 +69,8 @@ static const struct of_dev_auxdata 
exynos4210_auxdata_lookup[] __initconst = {
"exynos4210-spi.2", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA0, "dma-pl330.0", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA1, "dma-pl330.1", NULL),
+   OF_DEV_AUXDATA("samsung,exynos4210-usbphy", EXYNOS4_PA_HSPHY,
+   "s3c-usbphy", &exynos4_usbphy_pdata),
{},
 };
 
diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index b81cc56..1c62d20 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -221,3 +221,16 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int 
type)
 
return -EINVAL;
 }
+
+void s5p_usb_phy_pmu_isolation(int on)
+{
+   if (on) {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   & ~S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   } else {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   | S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   }
+}
-- 
1.7.1

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


[PATCH v4 4/5] ARM: S3C64XX: Enabling samsung-usbphy driver

2012-08-10 Thread Praveen Paneri
Adding platform device for samsung-usbphy driver. Enabling it for
s3c64xx based machines using s3c-hsotg.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/include/mach/map.h |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c|4 +++
 arch/arm/mach-s3c64xx/mach-smartq.c  |5 
 arch/arm/mach-s3c64xx/mach-smdk6410.c|4 +++
 arch/arm/mach-s3c64xx/setup-usb-phy.c|   14 +++
 arch/arm/plat-samsung/devs.c |   33 ++
 arch/arm/plat-samsung/include/plat/devs.h|1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h |1 +
 8 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/include/mach/map.h 
b/arch/arm/mach-s3c64xx/include/mach/map.h
index 8e2097b..dc482bb 100644
--- a/arch/arm/mach-s3c64xx/include/mach/map.h
+++ b/arch/arm/mach-s3c64xx/include/mach/map.h
@@ -65,6 +65,7 @@
 
 #define S3C64XX_PA_NAND(0x7020)
 #define S3C64XX_PA_FB  (0x7710)
+#define S3C64XX_PA_USB_HSPHY   (0x7C10)
 #define S3C64XX_PA_USB_HSOTG   (0x7C00)
 #define S3C64XX_PA_WATCHDOG(0x7E004000)
 #define S3C64XX_PA_RTC (0x7E005000)
@@ -113,6 +114,7 @@
 #define S3C_PA_FB  S3C64XX_PA_FB
 #define S3C_PA_USBHOST S3C64XX_PA_USBHOST
 #define S3C_PA_USB_HSOTG   S3C64XX_PA_USB_HSOTG
+#define S3C_PA_USB_PHY S3C64XX_PA_USB_HSPHY
 #define S3C_PA_RTC S3C64XX_PA_RTC
 #define S3C_PA_WDT S3C64XX_PA_WATCHDOG
 #define S3C_PA_SPI0S3C64XX_PA_SPI0
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index b0f5baf..a9c3b5e 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -31,6 +31,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -336,6 +337,7 @@ static struct platform_device wallvdd_device = {
 };
 
 static struct platform_device *crag6410_devices[] __initdata = {
+   &samsung_device_usbphy,
&s3c_device_hsmmc0,
&s3c_device_hsmmc2,
&s3c_device_i2c0,
@@ -765,6 +767,7 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
+static struct samsung_usbphy_data crag6410_usbphy_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -790,6 +793,7 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
+   samsung_usbphy_set_pdata(&crag6410_usbphy_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index 7400da1..0e75c36 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -234,6 +235,7 @@ static struct i2c_board_info smartq_i2c_devs[] __initdata = 
{
 };
 
 static struct platform_device *smartq_devices[] __initdata = {
+   &samsung_device_usbphy,
&s3c_device_hsmmc1, /* Init iNAND first, ... */
&s3c_device_hsmmc0, /* ... then the external SD card */
&s3c_device_hsmmc2,
@@ -380,9 +382,12 @@ void __init smartq_map_io(void)
smartq_lcd_mode_set();
 }
 
+static struct samsung_usbphy_data smartq_usbphy_pdata;
+
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
+   samsung_usbphy_set_pdata(&smartq_usbphy_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index cbdc91b..6c2ee6d 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include 
@@ -263,6 +264,7 @@ static struct samsung_keypad_platdata smdk6410_keypad_data 
__initdata = {
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
+   &samsung_device_usbphy,
 #ifdef CONFIG_SMDK6410_SD_CH0
&s3c_device_hsmmc0,
 #endif
@@ -626,6 +628,7 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
+static struct samsung_usbphy_data smdk6410_usbphy_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -655,6 +658,7 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
+   samsung_usbphy_set_pdata(&smd

[PATCH v4 3/5] ARM: S3C64XX: Removing old phy setup code

2012-08-10 Thread Praveen Paneri
This patch removes old phy code from platform side. 'setup-usb-phy.c'
will be used for providing transceiver platform data in next
patch. Not all of the platform data code is removed as there are others
making use of platform_data defined for hsotg. That can be removed once
all the SoCs start using the new transceiver for usb phy setup.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/mach-crag6410.c |3 -
 arch/arm/mach-s3c64xx/mach-smartq.c   |3 -
 arch/arm/mach-s3c64xx/mach-smdk6410.c |3 -
 arch/arm/mach-s3c64xx/setup-usb-phy.c |   79 -
 4 files changed, 0 insertions(+), 88 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 09cd812..b0f5baf 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -31,7 +31,6 @@
 #include 
 
 #include 
-#include 
 
 #include 
 
@@ -766,7 +765,6 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
-static struct s3c_hsotg_plat crag6410_hsotg_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -792,7 +790,6 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&crag6410_hsotg_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index ceeb1de..7400da1 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -187,7 +186,6 @@ static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata 
= {
},
 };
 
-static struct s3c_hsotg_plat smartq_hsotg_pdata;
 
 static int __init smartq_lcd_setup_gpio(void)
 {
@@ -385,7 +383,6 @@ void __init smartq_map_io(void)
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
-   s3c_hsotg_set_platdata(&smartq_hsotg_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index 0fe4f15..cbdc91b 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include 
@@ -627,7 +626,6 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
-static struct s3c_hsotg_plat smdk6410_hsotg_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -657,7 +655,6 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&smdk6410_hsotg_pdata);
 
samsung_keypad_set_platdata(&smdk6410_keypad_data);
 
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c 
b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index f6757e0..7a09553 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
@@ -9,82 +9,3 @@
  *
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static int s3c_usb_otgphy_init(struct platform_device *pdev)
-{
-   struct clk *xusbxti;
-   u32 phyclk;
-
-   writel(readl(S3C64XX_OTHERS) | S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS);
-
-   /* set clock frequency for PLL */
-   phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK;
-
-   xusbxti = clk_get(&pdev->dev, "xusbxti");
-   if (xusbxti && !IS_ERR(xusbxti)) {
-   switch (clk_get_rate(xusbxti)) {
-   case 12 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_12M;
-   break;
-   case 24 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_24M;
-   break;
-   default:
-   case 48 * MHZ:
-   /* default reference clock */
-   break;
-   }
-   clk_put(xusbxti);
-   }
-
-   /* TODO: select external clock/oscillator */
-   writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK);
-
-   /* set to normal OTG PHY */
-   writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR);
-   mdelay(1);
-
-   /* reset OTG PHY and Link */
-   writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK,
-   S3C_RSTCON);
- 

[PATCH v4 2/5] usb: s3c-hsotg: Adding phy driver support

2012-08-10 Thread Praveen Paneri
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Praveen Paneri 
---
 drivers/usb/gadget/s3c-hsotg.c |   37 +++--
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index b13e0bb..60f6160 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transceiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
-   if (hsotg->plat->phy_init)
+
+   if (hsotg->phy)
+   usb_phy_init(hsotg->phy);
+   else if (hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->plat->phy_exit)
+   if (hsotg->phy)
+   usb_phy_shutdown(hsotg->phy);
+   else if (hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = &pdev->dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3501,20 +3511,27 @@ static int __devinit s3c_hsotg_probe(struct 
platform_device *pdev)
int ret;
int i;
 
-   plat = pdev->dev.platform_data;
-   if (!plat) {
-   dev_err(&pdev->dev, "no platform data defined\n");
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
 
+   plat = pdev->dev.platform_data;
+   if (!plat) {
+   /* Fallback for transceiver */
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR_OR_NULL(phy)) {
+   dev_err(&pdev->dev, "no platform data or transceiver 
defined\n");
+   return -EPROBE_DEFER;
+   } else {
+   hsotg->phy = phy;
+   }
+   } else {
+   hsotg->plat = plat;
+   }
+
hsotg->dev = dev;
-   hsotg->plat = plat;
 
hsotg->clk = clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
-- 
1.7.1

--
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 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-10 Thread Praveen Paneri
This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable phy. Tested with
smdk6410 and smdkv310. More SoCs can be brought under later.

Signed-off-by: Praveen Paneri 
Acked-by: Heiko Stuebner 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  345 
 drivers/usb/phy/samsung-usbphy.h   |   48 +++
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 6 files changed, 438 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 drivers/usb/phy/samsung-usbphy.h
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..fefd9c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,9 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index e7cf84f..d916477 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -15,3 +15,11 @@ config USB_ISP1301
 
  To compile this driver as a module, choose M here: the
  module will be called isp1301.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index eca095b..dfca70d 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,3 +5,4 @@
 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
new file mode 100644
index 000..739b6c9
--- /dev/null
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -0,0 +1,345 @@
+/* linux/drivers/usb/phy/samsung-usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "samsung-usbphy.h"
+
+enum samsung_cpu_type {
+   TYPE_S3C64XX,
+   TYPE_EXYNOS4210,
+};
+
+/*
+ * struct samsung_usbphy - transceiver driver state
+ * @phy: transceiver structure
+ * @plat: platform data
+ * @dev: The parent device supplied to the probe function
+ * @clk: usb phy clock
+ * @regs: usb phy register memory base
+ * @cpu_type: machine identifier
+ */
+struct samsung_usbphy {
+   struct usb_phy  phy;
+   struct samsung_usbphy_data *plat;
+   struct device   *dev;
+   struct clk  *clk;
+   void __iomem*regs;
+   int cpu_type;
+};
+
+#define phy_to_sphy(x) container_of((x), struct samsung_usbphy, phy)
+
+/*
+ * Enables or disables the phy clock
+ * returns 0 on success else the error
+ */
+static int samsung_usbphy_clk_control(struct samsung_usbphy *sphy, bool on)
+{
+   if (on) {
+   if (!sphy->clk) {
+   sphy->clk = clk_get(sphy->dev, "otg");
+   if (IS_ERR(sphy->clk)) {
+   dev_err(sphy->dev, "Failed to get otg clock\n");
+   return PTR_ERR(sphy->clk);
+   }
+   }
+   clk_enable(sphy->clk);
+   } else {
+   clk_disable(sphy->clk);
+ 

[PATCH v4 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-08-10 Thread Praveen Paneri
Changes from v3:
Replaced susbsys_initcall()/module_exit() by module_platform_driver().
Accordingly in the hsotg driver returned -EPROBE_DEFER until phy driver
is registered
Removed unnecessary devm_usb_put_phy() call from the hsotg driver remove.

Changes from v2:
Changed the driver filenames to samsung-usbphy
Changed 's3c' to 'samsung' for platform device as well as platform data
Moved platform data structure to a separate file
Rectified coding style related errors

Changes from v1:
Rebased patches to latest usb-next branch
Changed the name 'sec_usbphy' to 'samsung_usbphy'

This patch set introduces a phy driver for samsung SoCs. It uses the existing
transceiver infrastructure to provide phy control functions. Use of this driver
can be extended for usb host phy as well. Over the period of time all the phy
related code for most of the samsung SoCs can be integrated here.
Removing the existing phy code from mach-s3c64xx. Same can be done for other 
SoCs
when they start supporting this phy driver. 
This driver is tested with smdk6410 and Exynos4210(with DT).

Praveen Paneri (5):
  usb: phy: samsung: Introducing usb phy driver for hsotg
  usb: s3c-hsotg: Adding phy driver support
  ARM: S3C64XX: Removing old phy setup code
  ARM: S3C64XX: Enabling samsung-usbphy driver
  ARM: Exynos4210: Enabling samsung-usbphy driver

 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 arch/arm/boot/dts/exynos4210.dtsi  |5 +
 arch/arm/mach-exynos/include/mach/map.h|1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c |8 +
 arch/arm/mach-exynos/setup-usb-phy.c   |   13 +
 arch/arm/mach-s3c64xx/include/mach/map.h   |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c  |7 +-
 arch/arm/mach-s3c64xx/mach-smartq.c|8 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c  |7 +-
 arch/arm/mach-s3c64xx/setup-usb-phy.c  |   79 +
 arch/arm/plat-samsung/devs.c   |   33 ++
 arch/arm/plat-samsung/include/plat/devs.h  |1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h   |1 +
 drivers/usb/gadget/s3c-hsotg.c |   37 ++-
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  345 
 drivers/usb/phy/samsung-usbphy.h   |   48 +++
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 19 files changed, 549 insertions(+), 91 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 drivers/usb/phy/samsung-usbphy.h
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

--
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 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-08-09 Thread Praveen Paneri
On Fri, Aug 10, 2012 at 11:46 AM, Felipe Balbi  wrote:
> HI,
>
> On Fri, Aug 10, 2012 at 11:17:29AM +0530, Praveen Paneri wrote:
>> On Fri, Aug 10, 2012 at 7:03 AM, Joonyoung Shim  
>> wrote:
>> > Hi, Praveen.
>> >
>> >
>> > On 08/08/2012 04:40 PM, Praveen Paneri wrote:
>> >>
>> >> Changes from v2:
>> >> Changed the driver filenames to samsung-usbphy
>> >> Changed 's3c' to 'samsung' for platform device as well as platform data
>> >> Moved platform data structure to a separate file
>> >> Rectified coding style related errors
>> >>
>> >> Changes from v1:
>> >> Rebased patches to latest usb-next branch
>> >> Changed the name 'sec_usbphy' to 'samsung_usbphy'
>> >>
>> >> This patch set introduces a phy driver for samsung SoCs. It uses the
>> >> existing
>> >> transceiver infrastructure to provide phy control functions. Use of this
>> >> driver
>> >> can be extended for usb host phy as well.
>> >
>> >
>> > How can you support usb host phy? I cannot choose to use which phy when
>> > call init or shutdown of phy at current phy framework.
>
> correct. Curretly that's not supported. We are trying to come up with
> proper DeviceTree bindings to allow that. Kishon has been working on
> providing devm_usb_get_phy_by_phandle() would should help achieving what
> you need.
>
>> If you are talking about choosing between PHY0 (for device) and PHY1
>> (for host), I think you can make use of the flags available in usb_phy
>> to pass that information to phy driver and that can be handled there.
>
> I rather you didn't do it that way. Those flags are used to pass
> features to the PHY. See drivers/usb/otg/ulpi.c, for instance.
>
>> This is just one way I have successfully implement two different phy
>> control. There might be a better way to do that.
>
> I guess using DT phandles is the way to go here.
off-course! That is why I haven't included host support as of now.

Praveen
>
> --
> balbi
--
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 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-08-09 Thread Praveen Paneri
On Fri, Aug 10, 2012 at 7:03 AM, Joonyoung Shim  wrote:
> Hi, Praveen.
>
>
> On 08/08/2012 04:40 PM, Praveen Paneri wrote:
>>
>> Changes from v2:
>> Changed the driver filenames to samsung-usbphy
>> Changed 's3c' to 'samsung' for platform device as well as platform data
>> Moved platform data structure to a separate file
>> Rectified coding style related errors
>>
>> Changes from v1:
>> Rebased patches to latest usb-next branch
>> Changed the name 'sec_usbphy' to 'samsung_usbphy'
>>
>> This patch set introduces a phy driver for samsung SoCs. It uses the
>> existing
>> transceiver infrastructure to provide phy control functions. Use of this
>> driver
>> can be extended for usb host phy as well.
>
>
> How can you support usb host phy? I cannot choose to use which phy when
> call init or shutdown of phy at current phy framework.
If you are talking about choosing between PHY0 (for device) and PHY1
(for host), I think you can make use of the flags available in usb_phy
to pass that information to phy driver and that can be handled there.
This is just one way I have successfully implement two different phy
control. There might be a better way to do that.

Thanks
Praveen
>
> Thanks.
>
>> Over the period of time all the phy
>> related code for most of the samsung SoCs can be integrated here.
>> Removing the existing phy code from mach-s3c64xx. Same can be done for
>> other SoCs
>> when they start supporting this phy driver.
>> This driver is tested with smdk6410 and Exynos4210(with DT).
>>
>> Praveen Paneri (5):
>>usb: phy: samsung: Introducing usb phy driver for hsotg
>>usb: s3c-hsotg: Adding phy driver support
>>ARM: S3C64XX: Removing old phy setup code
>>ARM: S3C64XX: Enabling samsung-usbphy driver
>>ARM: Exynos4210: Enabling samsung-usbphy driver
>>
>>   .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>   arch/arm/boot/dts/exynos4210.dtsi  |5 +
>>   arch/arm/mach-exynos/include/mach/map.h|1 +
>>   arch/arm/mach-exynos/mach-exynos4-dt.c |8 +
>>   arch/arm/mach-exynos/setup-usb-phy.c   |   13 +
>>   arch/arm/mach-s3c64xx/include/mach/map.h   |2 +
>>   arch/arm/mach-s3c64xx/mach-crag6410.c  |7 +-
>>   arch/arm/mach-s3c64xx/mach-smartq.c|8 +-
>>   arch/arm/mach-s3c64xx/mach-smdk6410.c  |7 +-
>>   arch/arm/mach-s3c64xx/setup-usb-phy.c  |   79 +
>>   arch/arm/plat-samsung/devs.c   |   33 ++
>>   arch/arm/plat-samsung/include/plat/devs.h  |1 +
>>   arch/arm/plat-samsung/include/plat/usb-phy.h   |1 +
>>   drivers/usb/gadget/s3c-hsotg.c |   40 ++-
>>   drivers/usb/phy/Kconfig|8 +
>>   drivers/usb/phy/Makefile   |1 +
>>   drivers/usb/phy/samsung-usbphy.c   |  355
>> 
>>   drivers/usb/phy/samsung-usbphy.h   |   48 +++
>>   include/linux/platform_data/samsung-usbphy.h   |   27 ++
>>   19 files changed, 562 insertions(+), 91 deletions(-)
>>   create mode 100644
>> Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>   create mode 100644 drivers/usb/phy/samsung-usbphy.c
>>   create mode 100644 drivers/usb/phy/samsung-usbphy.h
>>   create mode 100644 include/linux/platform_data/samsung-usbphy.h
>>
>>
>> ___
>> linux-arm-kernel mailing list
>> linux-arm-ker...@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
>
> --
> 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
--
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 2/5] usb: s3c-hsotg: Adding phy driver support

2012-08-09 Thread Praveen Paneri
On Thu, Aug 9, 2012 at 2:59 PM, Felipe Balbi  wrote:
> On Wed, Aug 08, 2012 at 01:10:58PM +0530, Praveen Paneri wrote:
>> @@ -3689,6 +3706,9 @@ static int __devexit s3c_hsotg_remove(struct 
>> platform_device *pdev)
>>   s3c_hsotg_phy_disable(hsotg);
>>   regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
>>
>> + if (hsotg->phy)
>> + devm_usb_put_phy(&pdev->dev, hsotg->phy);
>
> unnecessary. This will be called for you when the platform_device object
> is detroyed.
Off-course, I will remove this.

Thanks
Praveen
>
> --
> balbi
--
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/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-09 Thread Praveen Paneri
On Thu, Aug 9, 2012 at 2:58 PM, Felipe Balbi  wrote:
> On Wed, Aug 08, 2012 at 01:10:57PM +0530, Praveen Paneri wrote:
>> +static int __init samsung_usbphy_driver_init(void)
>> +{
>> + return platform_driver_register(&samsung_usbphy_driver);
>> +}
>> +subsys_initcall(samsung_usbphy_driver_init);
>
> let's make use of the module_platform_driver() and have dependent
> drivers return -EPROBE_DEFER until this has registered.
Thanks! I will modify accordingly and resend.

Praveen
>
> --
> balbi
--
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 5/5] ARM: Exynos4210: Enabling samsung-usbphy driver

2012-08-08 Thread Praveen Paneri
Adding usbphy node for Exynos4210 along with the platform data.

Signed-off-by: Praveen Paneri 
---
 arch/arm/boot/dts/exynos4210.dtsi   |5 +
 arch/arm/mach-exynos/include/mach/map.h |1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c  |8 
 arch/arm/mach-exynos/setup-usb-phy.c|   13 +
 4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
b/arch/arm/boot/dts/exynos4210.dtsi
index 02891fe..e28cf10 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -62,6 +62,11 @@
interrupts = <0 44 0>, <0 45 0>;
};
 
+   usbphy@125B {
+   compatible = "samsung,exynos4210-usbphy";
+   reg = <0x125B 0x100>;
+   };
+
keypad@100A {
compatible = "samsung,s5pv210-keypad";
reg = <0x100A 0x100>;
diff --git a/arch/arm/mach-exynos/include/mach/map.h 
b/arch/arm/mach-exynos/include/mach/map.h
index c72b675..0625c0a 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -234,6 +234,7 @@
 #define S3C_PA_SPI1EXYNOS4_PA_SPI1
 #define S3C_PA_SPI2EXYNOS4_PA_SPI2
 #define S3C_PA_USB_HSOTG   EXYNOS4_PA_HSOTG
+#define S3C_PA_USB_PHY EXYNOS4_PA_HSPHY
 
 #define S5P_PA_EHCIEXYNOS4_PA_EHCI
 #define S5P_PA_FIMC0   EXYNOS4_PA_FIMC0
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c 
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index b2b5d5f..a652db0 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -20,9 +21,14 @@
 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
+static struct samsung_usbphy_data exynos4_usbphy_pdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
+
 /*
  * The following lookup table is used to override device names when devices
  * are registered from device tree. This is temporarily added to enable
@@ -63,6 +69,8 @@ static const struct of_dev_auxdata 
exynos4210_auxdata_lookup[] __initconst = {
"exynos4210-spi.2", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA0, "dma-pl330.0", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA1, "dma-pl330.1", NULL),
+   OF_DEV_AUXDATA("samsung,exynos4210-usbphy", EXYNOS4_PA_HSPHY,
+   "s3c-usbphy", &exynos4_usbphy_pdata),
{},
 };
 
diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index b81cc56..1c62d20 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -221,3 +221,16 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int 
type)
 
return -EINVAL;
 }
+
+void s5p_usb_phy_pmu_isolation(int on)
+{
+   if (on) {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   & ~S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   } else {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   | S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   }
+}
-- 
1.7.1

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


[PATCH v3 4/5] ARM: S3C64XX: Enabling samsung-usbphy driver

2012-08-08 Thread Praveen Paneri
Adding platform device for samsung-usbphy driver. Enabling it for
s3c64xx based machines using s3c-hsotg.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/include/mach/map.h |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c|4 +++
 arch/arm/mach-s3c64xx/mach-smartq.c  |5 
 arch/arm/mach-s3c64xx/mach-smdk6410.c|4 +++
 arch/arm/mach-s3c64xx/setup-usb-phy.c|   14 +++
 arch/arm/plat-samsung/devs.c |   33 ++
 arch/arm/plat-samsung/include/plat/devs.h|1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h |1 +
 8 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/include/mach/map.h 
b/arch/arm/mach-s3c64xx/include/mach/map.h
index 8e2097b..dc482bb 100644
--- a/arch/arm/mach-s3c64xx/include/mach/map.h
+++ b/arch/arm/mach-s3c64xx/include/mach/map.h
@@ -65,6 +65,7 @@
 
 #define S3C64XX_PA_NAND(0x7020)
 #define S3C64XX_PA_FB  (0x7710)
+#define S3C64XX_PA_USB_HSPHY   (0x7C10)
 #define S3C64XX_PA_USB_HSOTG   (0x7C00)
 #define S3C64XX_PA_WATCHDOG(0x7E004000)
 #define S3C64XX_PA_RTC (0x7E005000)
@@ -113,6 +114,7 @@
 #define S3C_PA_FB  S3C64XX_PA_FB
 #define S3C_PA_USBHOST S3C64XX_PA_USBHOST
 #define S3C_PA_USB_HSOTG   S3C64XX_PA_USB_HSOTG
+#define S3C_PA_USB_PHY S3C64XX_PA_USB_HSPHY
 #define S3C_PA_RTC S3C64XX_PA_RTC
 #define S3C_PA_WDT S3C64XX_PA_WATCHDOG
 #define S3C_PA_SPI0S3C64XX_PA_SPI0
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index b0f5baf..fa02e2f 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -31,6 +31,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -336,6 +337,7 @@ static struct platform_device wallvdd_device = {
 };
 
 static struct platform_device *crag6410_devices[] __initdata = {
+   &samsung_device_usbphy,
&s3c_device_hsmmc0,
&s3c_device_hsmmc2,
&s3c_device_i2c0,
@@ -765,6 +767,7 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
+static struct samsung_usbphy_data crag6410_usbphy_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -790,6 +793,7 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
+   samsung_usbphy_set_pdata(&crag6410_usbphy_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index 7400da1..e0c4df8 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -234,6 +235,7 @@ static struct i2c_board_info smartq_i2c_devs[] __initdata = 
{
 };
 
 static struct platform_device *smartq_devices[] __initdata = {
+   &samsung_device_usbphy,
&s3c_device_hsmmc1, /* Init iNAND first, ... */
&s3c_device_hsmmc0, /* ... then the external SD card */
&s3c_device_hsmmc2,
@@ -380,9 +382,12 @@ void __init smartq_map_io(void)
smartq_lcd_mode_set();
 }
 
+static struct samsung_usbphy_data smartq_usbphy_pdata;
+
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
+   samsung_usbphy_set_pdata(&smartq_usbphy_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index cbdc91b..8d40511 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include 
@@ -263,6 +264,7 @@ static struct samsung_keypad_platdata smdk6410_keypad_data 
__initdata = {
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
+   &samsung_device_usbphy,
 #ifdef CONFIG_SMDK6410_SD_CH0
&s3c_device_hsmmc0,
 #endif
@@ -626,6 +628,7 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
+static struct samsung_usbphy_data smdk6410_usbphy_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -655,6 +658,7 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
+   samsung_usbphy_set_pdata(&smd

[PATCH v3 3/5] ARM: S3C64XX: Removing old phy setup code

2012-08-08 Thread Praveen Paneri
This patch removes old phy code from platform side. 'setup-usb-phy.c'
will be used for providing transceiver platform data in next
patch. Not all of the platform data code is removed as there are others
making use of platform_data defined for hsotg. That can be removed once
all the SoCs start using the new transceiver for usb phy setup.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/mach-crag6410.c |3 -
 arch/arm/mach-s3c64xx/mach-smartq.c   |3 -
 arch/arm/mach-s3c64xx/mach-smdk6410.c |3 -
 arch/arm/mach-s3c64xx/setup-usb-phy.c |   79 -
 4 files changed, 0 insertions(+), 88 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 09cd812..b0f5baf 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -31,7 +31,6 @@
 #include 
 
 #include 
-#include 
 
 #include 
 
@@ -766,7 +765,6 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
-static struct s3c_hsotg_plat crag6410_hsotg_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -792,7 +790,6 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&crag6410_hsotg_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index ceeb1de..7400da1 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -187,7 +186,6 @@ static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata 
= {
},
 };
 
-static struct s3c_hsotg_plat smartq_hsotg_pdata;
 
 static int __init smartq_lcd_setup_gpio(void)
 {
@@ -385,7 +383,6 @@ void __init smartq_map_io(void)
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
-   s3c_hsotg_set_platdata(&smartq_hsotg_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index 0fe4f15..cbdc91b 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -30,7 +30,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include 
@@ -627,7 +626,6 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
-static struct s3c_hsotg_plat smdk6410_hsotg_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -657,7 +655,6 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&smdk6410_hsotg_pdata);
 
samsung_keypad_set_platdata(&smdk6410_keypad_data);
 
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c 
b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index f6757e0..7a09553 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
@@ -9,82 +9,3 @@
  *
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static int s3c_usb_otgphy_init(struct platform_device *pdev)
-{
-   struct clk *xusbxti;
-   u32 phyclk;
-
-   writel(readl(S3C64XX_OTHERS) | S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS);
-
-   /* set clock frequency for PLL */
-   phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK;
-
-   xusbxti = clk_get(&pdev->dev, "xusbxti");
-   if (xusbxti && !IS_ERR(xusbxti)) {
-   switch (clk_get_rate(xusbxti)) {
-   case 12 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_12M;
-   break;
-   case 24 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_24M;
-   break;
-   default:
-   case 48 * MHZ:
-   /* default reference clock */
-   break;
-   }
-   clk_put(xusbxti);
-   }
-
-   /* TODO: select external clock/oscillator */
-   writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK);
-
-   /* set to normal OTG PHY */
-   writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR);
-   mdelay(1);
-
-   /* reset OTG PHY and Link */
-   writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK,
-   S3C_RSTCON);
- 

[PATCH v3 2/5] usb: s3c-hsotg: Adding phy driver support

2012-08-08 Thread Praveen Paneri
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Praveen Paneri 
---
 drivers/usb/gadget/s3c-hsotg.c |   40 ++--
 1 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index b13e0bb..feb202c 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transceiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
-   if (hsotg->plat->phy_init)
+
+   if (hsotg->phy)
+   usb_phy_init(hsotg->phy);
+   else if (hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->plat->phy_exit)
+   if (hsotg->phy)
+   usb_phy_shutdown(hsotg->phy);
+   else if (hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = &pdev->dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3501,20 +3511,27 @@ static int __devinit s3c_hsotg_probe(struct 
platform_device *pdev)
int ret;
int i;
 
-   plat = pdev->dev.platform_data;
-   if (!plat) {
-   dev_err(&pdev->dev, "no platform data defined\n");
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
 
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (!phy) {
+   /* Fallback for platform data */
+   plat = pdev->dev.platform_data;
+   if (!plat) {
+   dev_err(&pdev->dev, "no platform data or transceiver 
defined\n");
+   return -ENODEV;
+   } else {
+   hsotg->plat = plat;
+   }
+   } else {
+   hsotg->phy = phy;
+   }
+
hsotg->dev = dev;
-   hsotg->plat = plat;
 
hsotg->clk = clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
@@ -3689,6 +3706,9 @@ static int __devexit s3c_hsotg_remove(struct 
platform_device *pdev)
s3c_hsotg_phy_disable(hsotg);
regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
 
+   if (hsotg->phy)
+   devm_usb_put_phy(&pdev->dev, hsotg->phy);
+
clk_disable_unprepare(hsotg->clk);
clk_put(hsotg->clk);
 
-- 
1.7.1

--
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/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-08 Thread Praveen Paneri
This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable phy. Tested with
smdk6410 and smdkv310. More SoCs can be brought under later.

Signed-off-by: Praveen Paneri 
Acked-by: Heiko Stuebner 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  355 
 drivers/usb/phy/samsung-usbphy.h   |   48 +++
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 6 files changed, 448 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 drivers/usb/phy/samsung-usbphy.h
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..fefd9c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,9 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index e7cf84f..d916477 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -15,3 +15,11 @@ config USB_ISP1301
 
  To compile this driver as a module, choose M here: the
  module will be called isp1301.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index eca095b..dfca70d 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,3 +5,4 @@
 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung-usbphy.o
diff --git a/drivers/usb/phy/samsung-usbphy.c b/drivers/usb/phy/samsung-usbphy.c
new file mode 100644
index 000..daefec6
--- /dev/null
+++ b/drivers/usb/phy/samsung-usbphy.c
@@ -0,0 +1,355 @@
+/* linux/drivers/usb/phy/samsung-usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "samsung-usbphy.h"
+
+enum samsung_cpu_type {
+   TYPE_S3C64XX,
+   TYPE_EXYNOS4210,
+};
+
+/*
+ * struct samsung_usbphy - transceiver driver state
+ * @phy: transceiver structure
+ * @plat: platform data
+ * @dev: The parent device supplied to the probe function
+ * @clk: usb phy clock
+ * @regs: usb phy register memory base
+ * @cpu_type: machine identifier
+ */
+struct samsung_usbphy {
+   struct usb_phy  phy;
+   struct samsung_usbphy_data *plat;
+   struct device   *dev;
+   struct clk  *clk;
+   void __iomem*regs;
+   int cpu_type;
+};
+
+#define phy_to_sphy(x) container_of((x), struct samsung_usbphy, phy)
+
+/*
+ * Enables or disables the phy clock
+ * returns 0 on success else the error
+ */
+static int samsung_usbphy_clk_control(struct samsung_usbphy *sphy, bool on)
+{
+   if (on) {
+   if (!sphy->clk) {
+   sphy->clk = clk_get(sphy->dev, "otg");
+   if (IS_ERR(sphy->clk)) {
+   dev_err(sphy->dev, "Failed to get otg clock\n");
+   return PTR_ERR(sphy->clk);
+   }
+   }
+   clk_enable(sphy->clk);
+   } else {
+   clk_disable(sphy->clk);
+ 

[PATCH v3 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-08-08 Thread Praveen Paneri
Changes from v2:
Changed the driver filenames to samsung-usbphy
Changed 's3c' to 'samsung' for platform device as well as platform data
Moved platform data structure to a separate file
Rectified coding style related errors

Changes from v1:
Rebased patches to latest usb-next branch
Changed the name 'sec_usbphy' to 'samsung_usbphy'

This patch set introduces a phy driver for samsung SoCs. It uses the existing
transceiver infrastructure to provide phy control functions. Use of this driver
can be extended for usb host phy as well. Over the period of time all the phy
related code for most of the samsung SoCs can be integrated here.
Removing the existing phy code from mach-s3c64xx. Same can be done for other 
SoCs
when they start supporting this phy driver. 
This driver is tested with smdk6410 and Exynos4210(with DT).

Praveen Paneri (5):
  usb: phy: samsung: Introducing usb phy driver for hsotg
  usb: s3c-hsotg: Adding phy driver support
  ARM: S3C64XX: Removing old phy setup code
  ARM: S3C64XX: Enabling samsung-usbphy driver
  ARM: Exynos4210: Enabling samsung-usbphy driver

 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 arch/arm/boot/dts/exynos4210.dtsi  |5 +
 arch/arm/mach-exynos/include/mach/map.h|1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c |8 +
 arch/arm/mach-exynos/setup-usb-phy.c   |   13 +
 arch/arm/mach-s3c64xx/include/mach/map.h   |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c  |7 +-
 arch/arm/mach-s3c64xx/mach-smartq.c|8 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c  |7 +-
 arch/arm/mach-s3c64xx/setup-usb-phy.c  |   79 +
 arch/arm/plat-samsung/devs.c   |   33 ++
 arch/arm/plat-samsung/include/plat/devs.h  |1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h   |1 +
 drivers/usb/gadget/s3c-hsotg.c |   40 ++-
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung-usbphy.c   |  355 
 drivers/usb/phy/samsung-usbphy.h   |   48 +++
 include/linux/platform_data/samsung-usbphy.h   |   27 ++
 19 files changed, 562 insertions(+), 91 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung-usbphy.c
 create mode 100644 drivers/usb/phy/samsung-usbphy.h
 create mode 100644 include/linux/platform_data/samsung-usbphy.h

--
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 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-08-07 Thread Praveen Paneri
On Tue, Aug 7, 2012 at 3:30 PM, Kukjin Kim  wrote:
> Praveen Paneri wrote:
>>
>> Changes from v1:
>> Rebased patches to latest usb-next branch
>> Changed the name 'sec_usbphy' to 'samsung_usbphy'
>>
> Yes, looks better. But I'm not sure Felipe or Greg would prefer to use '_'
> not '-'...you used samsung-usbphy as a name in your patch.
Are you suggesting to change the name to 'samsung-usbphy' instead?
>
>> This patch set introduces a phy driver for samsung SoCs. It uses the
>> existing
>> transceiver infrastructure to provide phy control functions. Use of this
>> driver
>> can be extended for usb host phy as well. Over the period of time all the
>> phy
>> related code for most of the samsung SoCs can be integrated here.
>> Removing the existing phy code from mach-s3c64xx but not from other
>> machine
>
> Why? Is there any reason? After quick looking at your patches, seems this
> can remove all of setup-usb-phy in arch/arm/ for Samsung stuff. In addition,
> the isolation hook function also can be put in this by using platform_data
> or dt parsing.
No particular reason for it. Yes it can remove all of the setup-usbphy
code. I will send separate patches adding the support for other SoCs
and removing the phy related code from arch/arm.
>
>> code.This driver is tested with smdk6410 and Exynos4210(with DT).
>>
> I and my colleague, Yulgon will comment on this series soon.
That would be great. Will wait for that. You may use below patch to
add dt support for s3c-hsotg to test it on V310 board.

diff --git a/arch/arm/boot/dts/exynos4210.dtsi
b/arch/arm/boot/dts/exynos4210.dtsi
index e28cf10..de3cc78 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -67,6 +67,12 @@
reg = <0x125B 0x100>;
};

+   usbotg@1248 {
+   compatible = "samsung,exynos4210-hsotg";
+   reg = <0x1248 0x2>;
+   interrupts = <0 71 0>;
+   };
+
keypad@100A {
compatible = "samsung,s5pv210-keypad";
reg = <0x100A 0x100>;
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index f4ba9a3..79b77ff 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -3719,10 +3720,23 @@ static int __devexit s3c_hsotg_remove(struct
platform_device *pdev)
 #define s3c_hsotg_resume NULL
 #endif

+#ifdef CONFIG_OF
+static const struct of_device_id s3c_hsotg_dt_match[] = {
+   {
+   .compatible = "samsung,exynos4210-hsotg",
+   },
+   {},
+};
+MODULE_DEVICE_TABLE(of, s3c_usbphy_dt_match);
+#else
+#define s3c_hsotg_dt_match NULL
+#endif
+
 static struct platform_driver s3c_hsotg_driver = {
.driver = {
.name   = "s3c-hsotg",
.owner  = THIS_MODULE,
+   .of_match_table = s3c_hsotg_dt_match,
},
.probe      = s3c_hsotg_probe,
.remove = __devexit_p(s3c_hsotg_remove),

Thanks
Praveen
>
> Thanks.
>
> Best regards,
> Kgene.
> --
> Kukjin Kim , Senior Engineer,
> SW Solution Development Team, Samsung Electronics Co., Ltd.
>
>
>> Praveen Paneri (5):
>>   usb: phy: samsung: Introducing usb phy driver for hsotg
>>   usb: s3c-hsotg: Adding phy driver support
>>   ARM: S3C64XX: Removing old phy setup code
>>   ARM: S3C64XX: Enabling samsung_usbphy driver
>>   ARM: Exynos4210: Enabling samsung_usbphy driver
>>
>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>  arch/arm/boot/dts/exynos4210.dtsi  |5 +
>>  arch/arm/mach-exynos/include/mach/map.h|1 +
>>  arch/arm/mach-exynos/mach-exynos4-dt.c |8 +
>>  arch/arm/mach-exynos/setup-usb-phy.c   |   13 +
>>  arch/arm/mach-s3c64xx/include/mach/map.h   |2 +
>>  arch/arm/mach-s3c64xx/mach-crag6410.c  |5 +-
>>  arch/arm/mach-s3c64xx/mach-smartq.c|6 +-
>>  arch/arm/mach-s3c64xx/mach-smdk6410.c  |5 +-
>>  arch/arm/mach-s3c64xx/setup-usb-phy.c  |   79 +
>>  arch/arm/plat-samsung/devs.c   |   32 ++
>>  arch/arm/plat-samsung/include/plat/devs.h  |1 +
>>  arch/arm/plat-samsung/include/plat/usb-phy.h   |1 +
>>  drivers/usb/gadget/s3c-hsotg.c |   38 ++-
>>  drivers/usb/phy/Kconfig|8 +
>>  drivers/usb/phy/Makefile   |1 +
>>  drivers/usb/phy/

Re: [PATCH v2 2/5] usb: s3c-hsotg: Adding phy driver support

2012-08-07 Thread Praveen Paneri
Thanks Sachin! Will incorporate.

On Tue, Aug 7, 2012 at 1:33 PM, Sachin Kamat  wrote:
> Hi Praveen,
>
> Some minor comments:
>
> On 7 August 2012 12:58, Praveen Paneri  wrote:
>> Adding the transceiver to hsotg driver. Keeping the platform data
>> for continuing the smooth operation for boards which still uses it
>>
>> Signed-off-by: Praveen Paneri 
>> ---
>>  drivers/usb/gadget/s3c-hsotg.c |   38 --
>>  1 files changed, 28 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
>> index b13e0bb..f4ba9a3 100644
>> --- a/drivers/usb/gadget/s3c-hsotg.c
>> +++ b/drivers/usb/gadget/s3c-hsotg.c
>> @@ -32,6 +32,7 @@
>>
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>
>>  #include 
>> @@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
>>   * struct s3c_hsotg - driver state.
>>   * @dev: The parent device supplied to the probe function
>>   * @driver: USB gadget driver
>> - * @plat: The platform specific configuration data.
>> + * @phy: The otg phy transeiver structure for phy control.
>
> s/transeiver/transceiver
>
>> + * @plat: The platform specific configuration data. This can be removed once
>> + * all SoCs support usb transceiver.
>>   * @regs: The memory area mapped for accessing registers.
>>   * @irq: The IRQ number we are using
>>   * @supplies: Definition of USB power supplies
>> @@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
>>  struct s3c_hsotg {
>> struct device*dev;
>> struct usb_gadget_driver *driver;
>> +   struct usb_phy  *phy;
>> struct s3c_hsotg_plat*plat;
>>
>> spinlock_t  lock;
>> @@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg 
>> *hsotg)
>> struct platform_device *pdev = to_platform_device(hsotg->dev);
>>
>> dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
>> -   if (hsotg->plat->phy_init)
>> +
>> +   if (hsotg->phy)
>> +   usb_phy_init(hsotg->phy);
>> +   else if (hsotg->plat->phy_init)
>> hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
>>  }
>>
>> @@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg 
>> *hsotg)
>>  {
>> struct platform_device *pdev = to_platform_device(hsotg->dev);
>>
>> -   if (hsotg->plat->phy_exit)
>> +   if (hsotg->phy)
>> +   usb_phy_shutdown(hsotg->phy);
>> +   else if (hsotg->plat->phy_exit)
>> hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
>>  }
>>
>> @@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
>>  static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
>>  {
>> struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
>> +   struct usb_phy *phy;
>> struct device *dev = &pdev->dev;
>> struct s3c_hsotg_ep *eps;
>> struct s3c_hsotg *hsotg;
>> @@ -3501,20 +3511,25 @@ static int __devinit s3c_hsotg_probe(struct 
>> platform_device *pdev)
>> int ret;
>> int i;
>>
>> -   plat = pdev->dev.platform_data;
>> -   if (!plat) {
>> -   dev_err(&pdev->dev, "no platform data defined\n");
>> -   return -EINVAL;
>> -   }
>> -
>> hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), 
>> GFP_KERNEL);
>> if (!hsotg) {
>> dev_err(dev, "cannot get memory\n");
>> return -ENOMEM;
>> }
>>
>> +   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
>> +   if (!phy) {
>> +   /* Fallback for platform data */
>> +   plat = pdev->dev.platform_data;
>> +   if (!plat) {
>> +   dev_err(&pdev->dev, "no platform data or transceiver 
>> defined\n");
>> +   return -ENODEV;
>> +   } else
>> +   hsotg->plat = plat;
>> +   } else
>> +   hsotg->phy = phy;
>
> Braces needed around the above 2 else statements.
> Please refer to: Documentation/CodingStyle
>
>
>> +
>> hsotg->dev = dev;
>> -   hsotg->plat = plat;
>>
>> hsotg->clk = clk_get(&pd

Re: [PATCH v2 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-07 Thread Praveen Paneri
On Tue, Aug 7, 2012 at 1:41 PM, Heiko Stübner  wrote:
> Am Dienstag, 7. August 2012, 09:28:40 schrieb Praveen Paneri:
>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>> smdk6410 and smdkv310. More SoCs can be brought under later.
>>
>> Signed-off-by: Praveen Paneri 
>> ---
>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>  drivers/usb/phy/Kconfig|8 +
>>  drivers/usb/phy/Makefile   |1 +
>>  drivers/usb/phy/samsung_usbphy.c   |  355
>>  drivers/usb/phy/samsung_usbphy.h   |
>>  48 +++
>>  include/linux/platform_data/s3c-hsotg.h|5 +
>>  6 files changed, 426 insertions(+), 0 deletions(-)
>>  create mode 100644
>> Documentation/devicetree/bindings/usb/samsung-usbphy.txt create mode
>> 100644 drivers/usb/phy/samsung_usbphy.c
>>  create mode 100644 drivers/usb/phy/samsung_usbphy.h
>>
>
> [...]
>
>> diff --git a/include/linux/platform_data/s3c-hsotg.h
>> b/include/linux/platform_data/s3c-hsotg.h index 8b79e09..25ed31e 100644
>> --- a/include/linux/platform_data/s3c-hsotg.h
>> +++ b/include/linux/platform_data/s3c-hsotg.h
>> @@ -35,6 +35,11 @@ struct s3c_hsotg_plat {
>>   int (*phy_exit)(struct platform_device *pdev, int type);
>>  };
>>
>> +struct s3c_usbphy_plat {
>> + void (*pmu_isolation)(int on);
>> +};
>> +
>>  extern void s3c_hsotg_set_platdata(struct s3c_hsotg_plat *pd);
>> +extern void s3c_usbphy_set_platdata(struct s3c_usbphy_plat *pd);
>>
>>  #endif /* __LINUX_USB_S3C_HSOTG_H */
>
> hmm, I'm not completely sure about this being in the s3c-hsotg header, as on
> s3c2443/2416/2450 it's the s3c-hsudc that will be (hopefully) using the phy in
> the future.
Okay then I will make a new header file for this. Not only hsudc, we
intent to use it for usb host phy as well so it's a valid point.

Praveen
>
>
> Heiko
> --
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 4/5] ARM: S3C64XX: Enabling samsung_usbphy driver

2012-08-07 Thread Praveen Paneri
Adding platform device for samsung_usbphy driver. Enabling it for
s3c64xx based machines using s3c-hsotg.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/include/mach/map.h |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c|3 ++
 arch/arm/mach-s3c64xx/mach-smartq.c  |4 +++
 arch/arm/mach-s3c64xx/mach-smdk6410.c|3 ++
 arch/arm/mach-s3c64xx/setup-usb-phy.c|   14 +++
 arch/arm/plat-samsung/devs.c |   32 ++
 arch/arm/plat-samsung/include/plat/devs.h|1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h |1 +
 8 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/include/mach/map.h 
b/arch/arm/mach-s3c64xx/include/mach/map.h
index 8e2097b..dc482bb 100644
--- a/arch/arm/mach-s3c64xx/include/mach/map.h
+++ b/arch/arm/mach-s3c64xx/include/mach/map.h
@@ -65,6 +65,7 @@
 
 #define S3C64XX_PA_NAND(0x7020)
 #define S3C64XX_PA_FB  (0x7710)
+#define S3C64XX_PA_USB_HSPHY   (0x7C10)
 #define S3C64XX_PA_USB_HSOTG   (0x7C00)
 #define S3C64XX_PA_WATCHDOG(0x7E004000)
 #define S3C64XX_PA_RTC (0x7E005000)
@@ -113,6 +114,7 @@
 #define S3C_PA_FB  S3C64XX_PA_FB
 #define S3C_PA_USBHOST S3C64XX_PA_USBHOST
 #define S3C_PA_USB_HSOTG   S3C64XX_PA_USB_HSOTG
+#define S3C_PA_USB_PHY S3C64XX_PA_USB_HSPHY
 #define S3C_PA_RTC S3C64XX_PA_RTC
 #define S3C_PA_WDT S3C64XX_PA_WATCHDOG
 #define S3C_PA_SPI0S3C64XX_PA_SPI0
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 3bb0327..05e6e14 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -337,6 +337,7 @@ static struct platform_device wallvdd_device = {
 };
 
 static struct platform_device *crag6410_devices[] __initdata = {
+   &s3c_device_usbphy,
&s3c_device_hsmmc0,
&s3c_device_hsmmc2,
&s3c_device_i2c0,
@@ -766,6 +767,7 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
+static struct s3c_usbphy_plat crag6410_usbphy_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -791,6 +793,7 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
+   s3c_usbphy_set_platdata(&crag6410_usbphy_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index 3647202..97751d5 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -235,6 +235,7 @@ static struct i2c_board_info smartq_i2c_devs[] __initdata = 
{
 };
 
 static struct platform_device *smartq_devices[] __initdata = {
+   &s3c_device_usbphy,
&s3c_device_hsmmc1, /* Init iNAND first, ... */
&s3c_device_hsmmc0, /* ... then the external SD card */
&s3c_device_hsmmc2,
@@ -381,9 +382,12 @@ void __init smartq_map_io(void)
smartq_lcd_mode_set();
 }
 
+static struct s3c_usbphy_plat smartq_usbphy_pdata;
+
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
+   s3c_usbphy_set_platdata(&smartq_usbphy_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index 1a2db14..e5c55ba 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -264,6 +264,7 @@ static struct samsung_keypad_platdata smdk6410_keypad_data 
__initdata = {
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
+   &s3c_device_usbphy,
 #ifdef CONFIG_SMDK6410_SD_CH0
&s3c_device_hsmmc0,
 #endif
@@ -627,6 +628,7 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
+static struct s3c_usbphy_plat smdk6410_usbphy_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -656,6 +658,7 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
+   s3c_usbphy_set_platdata(&smdk6410_usbphy_pdata);
 
samsung_keypad_set_platdata(&smdk6410_keypad_data);
 
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c 
b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index 7a09553..3aee778 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/

[PATCH v2 5/5] ARM: Exynos4210: Enabling samsung_usbphy driver

2012-08-07 Thread Praveen Paneri
Adding usbphy node for Exynos4210 along with the platform data.

Signed-off-by: Praveen Paneri 
---
 arch/arm/boot/dts/exynos4210.dtsi   |5 +
 arch/arm/mach-exynos/include/mach/map.h |1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c  |8 
 arch/arm/mach-exynos/setup-usb-phy.c|   13 +
 4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
b/arch/arm/boot/dts/exynos4210.dtsi
index 02891fe..e28cf10 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -62,6 +62,11 @@
interrupts = <0 44 0>, <0 45 0>;
};
 
+   usbphy@125B {
+   compatible = "samsung,exynos4210-usbphy";
+   reg = <0x125B 0x100>;
+   };
+
keypad@100A {
compatible = "samsung,s5pv210-keypad";
reg = <0x100A 0x100>;
diff --git a/arch/arm/mach-exynos/include/mach/map.h 
b/arch/arm/mach-exynos/include/mach/map.h
index c72b675..0625c0a 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -234,6 +234,7 @@
 #define S3C_PA_SPI1EXYNOS4_PA_SPI1
 #define S3C_PA_SPI2EXYNOS4_PA_SPI2
 #define S3C_PA_USB_HSOTG   EXYNOS4_PA_HSOTG
+#define S3C_PA_USB_PHY EXYNOS4_PA_HSPHY
 
 #define S5P_PA_EHCIEXYNOS4_PA_EHCI
 #define S5P_PA_FIMC0   EXYNOS4_PA_FIMC0
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c 
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index b2b5d5f..0f74438 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -20,9 +21,14 @@
 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
+static struct s3c_usbphy_plat exynos4_usbphy_pdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
+
 /*
  * The following lookup table is used to override device names when devices
  * are registered from device tree. This is temporarily added to enable
@@ -63,6 +69,8 @@ static const struct of_dev_auxdata 
exynos4210_auxdata_lookup[] __initconst = {
"exynos4210-spi.2", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA0, "dma-pl330.0", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA1, "dma-pl330.1", NULL),
+   OF_DEV_AUXDATA("samsung,exynos4210-usbphy", EXYNOS4_PA_HSPHY,
+   "s3c-usbphy", &exynos4_usbphy_pdata),
{},
 };
 
diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index b81cc56..1c62d20 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -221,3 +221,16 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int 
type)
 
return -EINVAL;
 }
+
+void s5p_usb_phy_pmu_isolation(int on)
+{
+   if (on) {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   & ~S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   } else {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   | S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   }
+}
-- 
1.7.1

--
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 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-08-07 Thread Praveen Paneri
Changes from v1:
Rebased patches to latest usb-next branch
Changed the name 'sec_usbphy' to 'samsung_usbphy'

This patch set introduces a phy driver for samsung SoCs. It uses the existing
transceiver infrastructure to provide phy control functions. Use of this driver
can be extended for usb host phy as well. Over the period of time all the phy
related code for most of the samsung SoCs can be integrated here.
Removing the existing phy code from mach-s3c64xx but not from other machine 
code.This driver is tested with smdk6410 and Exynos4210(with DT).

Praveen Paneri (5):
  usb: phy: samsung: Introducing usb phy driver for hsotg
  usb: s3c-hsotg: Adding phy driver support
  ARM: S3C64XX: Removing old phy setup code
  ARM: S3C64XX: Enabling samsung_usbphy driver
  ARM: Exynos4210: Enabling samsung_usbphy driver

 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 arch/arm/boot/dts/exynos4210.dtsi  |5 +
 arch/arm/mach-exynos/include/mach/map.h|1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c |8 +
 arch/arm/mach-exynos/setup-usb-phy.c   |   13 +
 arch/arm/mach-s3c64xx/include/mach/map.h   |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c  |5 +-
 arch/arm/mach-s3c64xx/mach-smartq.c|6 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c  |5 +-
 arch/arm/mach-s3c64xx/setup-usb-phy.c  |   79 +
 arch/arm/plat-samsung/devs.c   |   32 ++
 arch/arm/plat-samsung/include/plat/devs.h  |1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h   |1 +
 drivers/usb/gadget/s3c-hsotg.c |   38 ++-
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung_usbphy.c   |  355 
 drivers/usb/phy/samsung_usbphy.h   |   48 +++
 include/linux/platform_data/s3c-hsotg.h|5 +
 19 files changed, 534 insertions(+), 88 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung_usbphy.c
 create mode 100644 drivers/usb/phy/samsung_usbphy.h

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


[PATCH v2 3/5] ARM: S3C64XX: Removing old phy setup code

2012-08-07 Thread Praveen Paneri
This patch removes old phy code from platform side. 'setup-usb-phy.c'
will be used for providing transceiver platform data in next
patch. Not all of the platform data code is removed as there are others
making use of platform_data defined for hsotg. That can be removed once
all the SoCs start using the new transceiver for usb phy setup.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/mach-crag6410.c |2 -
 arch/arm/mach-s3c64xx/mach-smartq.c   |2 -
 arch/arm/mach-s3c64xx/mach-smdk6410.c |2 -
 arch/arm/mach-s3c64xx/setup-usb-phy.c |   79 -
 4 files changed, 0 insertions(+), 85 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 09cd812..3bb0327 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -766,7 +766,6 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
-static struct s3c_hsotg_plat crag6410_hsotg_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -792,7 +791,6 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&crag6410_hsotg_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index ceeb1de..3647202 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -187,7 +187,6 @@ static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata 
= {
},
 };
 
-static struct s3c_hsotg_plat smartq_hsotg_pdata;
 
 static int __init smartq_lcd_setup_gpio(void)
 {
@@ -385,7 +384,6 @@ void __init smartq_map_io(void)
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
-   s3c_hsotg_set_platdata(&smartq_hsotg_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index 0fe4f15..1a2db14 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -627,7 +627,6 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
-static struct s3c_hsotg_plat smdk6410_hsotg_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -657,7 +656,6 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&smdk6410_hsotg_pdata);
 
samsung_keypad_set_platdata(&smdk6410_keypad_data);
 
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c 
b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index f6757e0..7a09553 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
@@ -9,82 +9,3 @@
  *
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static int s3c_usb_otgphy_init(struct platform_device *pdev)
-{
-   struct clk *xusbxti;
-   u32 phyclk;
-
-   writel(readl(S3C64XX_OTHERS) | S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS);
-
-   /* set clock frequency for PLL */
-   phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK;
-
-   xusbxti = clk_get(&pdev->dev, "xusbxti");
-   if (xusbxti && !IS_ERR(xusbxti)) {
-   switch (clk_get_rate(xusbxti)) {
-   case 12 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_12M;
-   break;
-   case 24 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_24M;
-   break;
-   default:
-   case 48 * MHZ:
-   /* default reference clock */
-   break;
-   }
-   clk_put(xusbxti);
-   }
-
-   /* TODO: select external clock/oscillator */
-   writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK);
-
-   /* set to normal OTG PHY */
-   writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR);
-   mdelay(1);
-
-   /* reset OTG PHY and Link */
-   writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK,
-   S3C_RSTCON);
-   udelay(20); /* at-least 10uS */
-   writel(0, S3C_RSTCON);
-
-   return 0;
-}
-
-static int s3c_usb_otgphy_exit(struct platform_device *pdev)
-{
-   writel((readl(S3C_PHYPWR) | S3C_PHYPWR_ANALOG_POWERDOWN |
-   S3C_PHYPWR_OTG_

[PATCH v2 2/5] usb: s3c-hsotg: Adding phy driver support

2012-08-07 Thread Praveen Paneri
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Praveen Paneri 
---
 drivers/usb/gadget/s3c-hsotg.c |   38 --
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index b13e0bb..f4ba9a3 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transeiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
-   if (hsotg->plat->phy_init)
+
+   if (hsotg->phy)
+   usb_phy_init(hsotg->phy);
+   else if (hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->plat->phy_exit)
+   if (hsotg->phy)
+   usb_phy_shutdown(hsotg->phy);
+   else if (hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = &pdev->dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3501,20 +3511,25 @@ static int __devinit s3c_hsotg_probe(struct 
platform_device *pdev)
int ret;
int i;
 
-   plat = pdev->dev.platform_data;
-   if (!plat) {
-   dev_err(&pdev->dev, "no platform data defined\n");
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
 
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (!phy) {
+   /* Fallback for platform data */
+   plat = pdev->dev.platform_data;
+   if (!plat) {
+   dev_err(&pdev->dev, "no platform data or transceiver 
defined\n");
+   return -ENODEV;
+   } else
+   hsotg->plat = plat;
+   } else
+   hsotg->phy = phy;
+
hsotg->dev = dev;
-   hsotg->plat = plat;
 
hsotg->clk = clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
@@ -3689,6 +3704,9 @@ static int __devexit s3c_hsotg_remove(struct 
platform_device *pdev)
s3c_hsotg_phy_disable(hsotg);
regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
 
+   if (hsotg->phy)
+   devm_usb_put_phy(&pdev->dev, hsotg->phy);
+
clk_disable_unprepare(hsotg->clk);
clk_put(hsotg->clk);
 
-- 
1.7.1

--
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] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-07 Thread Praveen Paneri
This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable phy. Tested with
smdk6410 and smdkv310. More SoCs can be brought under later.

Signed-off-by: Praveen Paneri 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/samsung_usbphy.c   |  355 
 drivers/usb/phy/samsung_usbphy.h   |   48 +++
 include/linux/platform_data/s3c-hsotg.h|5 +
 6 files changed, 426 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/samsung_usbphy.c
 create mode 100644 drivers/usb/phy/samsung_usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..fefd9c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,9 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index e7cf84f..d916477 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -15,3 +15,11 @@ config USB_ISP1301
 
  To compile this driver as a module, choose M here: the
  module will be called isp1301.
+
+config SAMSUNG_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index eca095b..c5a483d 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,3 +5,4 @@
 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
+obj-$(CONFIG_SAMSUNG_USBPHY)   += samsung_usbphy.o
diff --git a/drivers/usb/phy/samsung_usbphy.c b/drivers/usb/phy/samsung_usbphy.c
new file mode 100644
index 000..8e9e772
--- /dev/null
+++ b/drivers/usb/phy/samsung_usbphy.c
@@ -0,0 +1,355 @@
+/* linux/drivers/usb/phy/samsung_usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "samsung_usbphy.h"
+
+enum samsung_cpu_type {
+   TYPE_S3C64XX,
+   TYPE_EXYNOS4210,
+};
+
+/*
+ * struct samsung_usbphy - transceiver driver state
+ * @phy: transceiver structure
+ * @plat: platform data
+ * @dev: The parent device supplied to the probe function
+ * @clk: usb phy clock
+ * @regs: usb phy register memory base
+ * @cpu_type: machine identifier
+ */
+struct samsung_usbphy {
+   struct usb_phy  phy;
+   struct s3c_usbphy_plat *plat;
+   struct device   *dev;
+   struct clk  *clk;
+   void __iomem*regs;
+   int cpu_type;
+};
+
+#define phy_to_sphy(x) container_of((x), struct samsung_usbphy, phy)
+
+/*
+ * Enables or disables the phy clock
+ * returns 0 on success else the error
+ */
+static int samsung_usbphy_clk_control(struct samsung_usbphy *sphy, bool on)
+{
+   if (on) {
+   if (!sphy->clk) {
+   sphy->clk = clk_get(sphy->dev, "otg");
+   if (IS_ERR(sphy->clk)) {
+   dev_err(sphy->dev, "Failed to get otg clock\n");
+   return PTR_ERR(sphy->clk);
+   }
+   }
+   clk_enable(sphy->clk);
+   } else {
+   clk_disable(sphy->clk);
+   clk_put(sphy->clk);
+   }
+
+   return 0;
+}
+
+/*
+ * Returns referenc

Re: [PATCH 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-06 Thread Praveen Paneri
Hi,

On Mon, Aug 6, 2012 at 3:21 PM, Praveen Paneri  wrote:
> Hi,
>
> On Mon, Aug 6, 2012 at 2:53 PM, Heiko Stübner  wrote:
>> Am Montag, 6. August 2012, 10:23:52 schrieb Kyungmin Park:
>>> Hi Praveen,
>>>
>>> On 8/6/12, Praveen Paneri  wrote:
>>> > Hi Heiko,
>>> >
>>> > On Mon, Aug 6, 2012 at 3:24 AM, Heiko Stübner  wrote:
>>> >> Hi Praveen,
>>> >>
>>> >> Am Mittwoch, 1. August 2012, 15:05:47 schrieb Praveen Paneri:
>>> >>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>>> >>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>>> >>> smdk6410 and smdkv310. More SoCs can be brought under later.
>>> >>
>>> >> Looks cool.
>>> >
>>> > Thanks
>>> >
>>> >> From what I've seen the phy controllers on newer Samsung SoCs are still
>>> >> somewhat similar to the one on my s3c2416/2450 machines. So hopefully at
>>> >> some
>>> >> point after the driver has settled, I'll find the time to add support
>>> >> for these to the phy driver.
>>> >
>>> > Yes! that's great.
>>> >
>>> >> Out of curiosity, what does the "sec" in sec_usbphy for?
>>> >
>>> > Its Samsung Electronics Co. :)
>>>
>>> I'm also prefer to use 'samsung' or 'exynos'. Since I didn't see the
>>> 'sec' prefix for samsung drivers.
>>
>> I'd second that. All new generic samsung drivers look like this (i.e. gpio-
>> samsung, pwm-samsung).
On the second thought I am thinking 'sec' is shorter and cooler. I
know that it has not
been used anywhere else but there is always a first time :-P The
shorter string helps in
writing the code; especially when we have 80 character restriction. If
you go through
this driver itself you will realize this. Also there was a suggestion
some time back to
use 'sec' instead of 'samsung'.
This is just my view about it. Please comment.

Praveen

>>
>> Just checked the datasheets again. This general phy type is used in some form
>> down to the S3C2443, so I'd prefer something with samsung in the name :-)
> Yes! That makes sense. I will change the name to samsung_usbphy
>
> Praveen
>>
>>
>> Heiko
>>
>>>
>>> Thank you,
>>> Kyungmin Park
>>>
>>> > Praveen
>>> >
>>> >>> Signed-off-by: Praveen Paneri 
>>> >>
>>> >> Acked-by: Heiko Stuebner 
>>> >>
>>> >>
>>> >> Heiko
>>> >>
>>> >>> ---
>>> >>>
>>> >>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>> >>>  drivers/usb/phy/Kconfig|8 +
>>> >>>  drivers/usb/phy/Makefile   |1 +
>>> >>>  drivers/usb/phy/sec_usbphy.c   |  354
>>> >>>
>>> >>>  drivers/usb/phy/sec_usbphy.h
>>> >>>
>>> >>>  48 +++
>>> >>>  include/linux/platform_data/s3c-hsotg.h|5 +
>>> >>>  6 files changed, 425 insertions(+), 0 deletions(-)
>>> >>>  create mode 100644
>>> >>>
>>> >>> Documentation/devicetree/bindings/usb/samsung-usbphy.txt create mode
>>> >>> 100644 drivers/usb/phy/sec_usbphy.c
>>> >>>
>>> >>>  create mode 100644 drivers/usb/phy/sec_usbphy.h
>>> >>>
>>> >>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>> >>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt new file
>>> >>> mode 100644
>>> >>> index 000..fefd9c8
>>> >>> --- /dev/null
>>> >>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>>> >>> @@ -0,0 +1,9 @@
>>> >>> +* Samsung's usb phy transceiver
>>> >>> +
>>> >>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>>> >>> +s3c-hsotg usb device controller.
>>> >>> +
>>> >>> +Required properties:
>>> >>> +- compatible : should be "samsung,exynos4210-usbphy"
>>> >>> +- reg : base physical address of 

Re: [PATCH 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-06 Thread Praveen Paneri
Hi,

On Mon, Aug 6, 2012 at 2:53 PM, Heiko Stübner  wrote:
> Am Montag, 6. August 2012, 10:23:52 schrieb Kyungmin Park:
>> Hi Praveen,
>>
>> On 8/6/12, Praveen Paneri  wrote:
>> > Hi Heiko,
>> >
>> > On Mon, Aug 6, 2012 at 3:24 AM, Heiko Stübner  wrote:
>> >> Hi Praveen,
>> >>
>> >> Am Mittwoch, 1. August 2012, 15:05:47 schrieb Praveen Paneri:
>> >>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>> >>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>> >>> smdk6410 and smdkv310. More SoCs can be brought under later.
>> >>
>> >> Looks cool.
>> >
>> > Thanks
>> >
>> >> From what I've seen the phy controllers on newer Samsung SoCs are still
>> >> somewhat similar to the one on my s3c2416/2450 machines. So hopefully at
>> >> some
>> >> point after the driver has settled, I'll find the time to add support
>> >> for these to the phy driver.
>> >
>> > Yes! that's great.
>> >
>> >> Out of curiosity, what does the "sec" in sec_usbphy for?
>> >
>> > Its Samsung Electronics Co. :)
>>
>> I'm also prefer to use 'samsung' or 'exynos'. Since I didn't see the
>> 'sec' prefix for samsung drivers.
>
> I'd second that. All new generic samsung drivers look like this (i.e. gpio-
> samsung, pwm-samsung).
>
> Just checked the datasheets again. This general phy type is used in some form
> down to the S3C2443, so I'd prefer something with samsung in the name :-)
Yes! That makes sense. I will change the name to samsung_usbphy

Praveen
>
>
> Heiko
>
>>
>> Thank you,
>> Kyungmin Park
>>
>> > Praveen
>> >
>> >>> Signed-off-by: Praveen Paneri 
>> >>
>> >> Acked-by: Heiko Stuebner 
>> >>
>> >>
>> >> Heiko
>> >>
>> >>> ---
>> >>>
>> >>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>> >>>  drivers/usb/phy/Kconfig|8 +
>> >>>  drivers/usb/phy/Makefile   |1 +
>> >>>  drivers/usb/phy/sec_usbphy.c   |  354
>> >>>
>> >>>  drivers/usb/phy/sec_usbphy.h
>> >>>
>> >>>  48 +++
>> >>>  include/linux/platform_data/s3c-hsotg.h|5 +
>> >>>  6 files changed, 425 insertions(+), 0 deletions(-)
>> >>>  create mode 100644
>> >>>
>> >>> Documentation/devicetree/bindings/usb/samsung-usbphy.txt create mode
>> >>> 100644 drivers/usb/phy/sec_usbphy.c
>> >>>
>> >>>  create mode 100644 drivers/usb/phy/sec_usbphy.h
>> >>>
>> >>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> >>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt new file
>> >>> mode 100644
>> >>> index 000..fefd9c8
>> >>> --- /dev/null
>> >>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> >>> @@ -0,0 +1,9 @@
>> >>> +* Samsung's usb phy transceiver
>> >>> +
>> >>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>> >>> +s3c-hsotg usb device controller.
>> >>> +
>> >>> +Required properties:
>> >>> +- compatible : should be "samsung,exynos4210-usbphy"
>> >>> +- reg : base physical address of the phy registers and length of
>> >>> memory mapped +  region.
>> >>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>> >>> index e7cf84f..abbebe2 100644
>> >>> --- a/drivers/usb/phy/Kconfig
>> >>> +++ b/drivers/usb/phy/Kconfig
>> >>> @@ -15,3 +15,11 @@ config USB_ISP1301
>> >>>
>> >>> To compile this driver as a module, choose M here: the
>> >>> module will be called isp1301.
>> >>>
>> >>> +
>> >>> +config SEC_USBPHY
>> >>> +   bool "Samsung USB PHY controller Driver"
>> >>> +   depends on USB_S3C_HSOTG
>> >>> +   select USB_OTG_UTILS
>> >>> +   help
>> >>> + Enable this to suppo

Re: [PATCH 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-06 Thread Praveen Paneri
Hi Heiko,

On Mon, Aug 6, 2012 at 3:24 AM, Heiko Stübner  wrote:
> Hi Praveen,
>
> Am Mittwoch, 1. August 2012, 15:05:47 schrieb Praveen Paneri:
>> This driver uses usb_phy interface to interact with s3c-hsotg. Supports
>> phy_init and phy_shutdown functions to enable/disable phy. Tested with
>> smdk6410 and smdkv310. More SoCs can be brought under later.
>
> Looks cool.
Thanks
>
> From what I've seen the phy controllers on newer Samsung SoCs are still
> somewhat similar to the one on my s3c2416/2450 machines. So hopefully at some
> point after the driver has settled, I'll find the time to add support for
> these to the phy driver.
Yes! that's great.
>
> Out of curiosity, what does the "sec" in sec_usbphy for?
Its Samsung Electronics Co. :)

Praveen
>
>
>
>> Signed-off-by: Praveen Paneri 
>
> Acked-by: Heiko Stuebner 
>
>
> Heiko
>
>
>> ---
>>  .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
>>  drivers/usb/phy/Kconfig|8 +
>>  drivers/usb/phy/Makefile   |1 +
>>  drivers/usb/phy/sec_usbphy.c   |  354
>>  drivers/usb/phy/sec_usbphy.h   |
>>  48 +++
>>  include/linux/platform_data/s3c-hsotg.h|5 +
>>  6 files changed, 425 insertions(+), 0 deletions(-)
>>  create mode 100644
>> Documentation/devicetree/bindings/usb/samsung-usbphy.txt create mode
>> 100644 drivers/usb/phy/sec_usbphy.c
>>  create mode 100644 drivers/usb/phy/sec_usbphy.h
>>
>> diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt new file mode
>> 100644
>> index 000..fefd9c8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
>> @@ -0,0 +1,9 @@
>> +* Samsung's usb phy transceiver
>> +
>> +The Samsung's phy transceiver is used for controlling usb otg phy for
>> +s3c-hsotg usb device controller.
>> +
>> +Required properties:
>> +- compatible : should be "samsung,exynos4210-usbphy"
>> +- reg : base physical address of the phy registers and length of memory
>> mapped +  region.
>> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
>> index e7cf84f..abbebe2 100644
>> --- a/drivers/usb/phy/Kconfig
>> +++ b/drivers/usb/phy/Kconfig
>> @@ -15,3 +15,11 @@ config USB_ISP1301
>>
>> To compile this driver as a module, choose M here: the
>> module will be called isp1301.
>> +
>> +config SEC_USBPHY
>> +   bool "Samsung USB PHY controller Driver"
>> +   depends on USB_S3C_HSOTG
>> +   select USB_OTG_UTILS
>> +   help
>> + Enable this to support Samsung USB phy controller for samsung
>> + SoCs.
>> diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
>> index eca095b..6bb66f0 100644
>> --- a/drivers/usb/phy/Makefile
>> +++ b/drivers/usb/phy/Makefile
>> @@ -5,3 +5,4 @@
>>  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
>>
>>  obj-$(CONFIG_USB_ISP1301)+= isp1301.o
>> +obj-$(CONFIG_SEC_USBPHY) += sec_usbphy.o
>> diff --git a/drivers/usb/phy/sec_usbphy.c b/drivers/usb/phy/sec_usbphy.c
>> new file mode 100644
>> index 000..33119eb
>> --- /dev/null
>> +++ b/drivers/usb/phy/sec_usbphy.c
>> @@ -0,0 +1,354 @@
>> +/* linux/drivers/usb/phy/sec_usbphy.c
>> + *
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *  http://www.samsung.com
>> + *
>> + * Author: Praveen Paneri 
>> + *
>> + * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG
>> controller + *
>> + * 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.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, write to the Free Software
>> + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>> +*/
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 

Re: [PATCH 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-08-01 Thread Praveen Paneri
Hi Arnd,

On Wed, Aug 1, 2012 at 8:50 PM, Arnd Bergmann  wrote:
> On Wednesday 01 August 2012, Praveen Paneri wrote:
>> This patch set introduces a phy driver for samsung SoCs. It uses the existing
>> transceiver infrastructure to provide phy control functions. Use of this 
>> driver
>> can be extended for usb host phy as well. Over the period of time all the phy
>> related code for most of the samsung SoCs can be integrated here.
>> Removing the existing phy code from mach-s3c64xx but not from other machine
>> code.This driver is tested with smdk6410 and Exynos4210(with DT).
>
> This looks very nice overall, great work!
Thank you!
>
> We will still have to take care of the pmu isolation callback in the
> long run, when we get to the point of removing all auxdata. Do you
> have a plan on how to do that? If yes, it would be good to mention
> that in the changelog.
Yes! I understand this problem and this is the reason these patches
were sitting in my system for couple of weeks. In a  discussion with
Thomas an idea of using the existing regulator framework to
enable/disable numerous PHYs came up. For example the PMU unit
of Exynos4210 has a register set dedicated just to control USBD_PHY,
HDMI_PHY, MIPI_PHY, DAC_PHY and more. If a regulator with
each phy control register as LDO is written, the phy driver becomes a
static consumer and will modify as below.

diff --git a/drivers/usb/phy/sec_usbphy.c b/drivers/usb/phy/sec_usbphy.c
index 33119eb..4f69675 100644
--- a/drivers/usb/phy/sec_usbphy.c
+++ b/drivers/usb/phy/sec_usbphy.c
@@ -28,8 +28,8 @@
 #include 
 #include 
 #include 
+#include 
 #include 
-#include 

 #include "sec_usbphy.h"

@@ -41,7 +41,7 @@ enum sec_cpu_type {
 /*
  * struct sec_usbphy - transceiver driver state
  * @phy: transceiver structure
- * @plat: platform data
+ * @vusbphy: PMU regulator for usb phy
  * @dev: The parent device supplied to the probe function
  * @clk: usb phy clock
  * @regs: usb phy register memory base
@@ -49,7 +49,7 @@ enum sec_cpu_type {
  */
 struct sec_usbphy {
struct usb_phy  phy;
-   struct s3c_usbphy_plat *plat;
+   struct regulator *vusbphy;
struct device   *dev;
struct clk  *clk;
void __iomem*regs;
@@ -187,8 +187,11 @@ static int sec_usbphy_init(struct usb_phy *phy)
}

/* Disable phy isolation */
-   if (sec->plat && sec->plat->pmu_isolation)
-   sec->plat->pmu_isolation(false);
+   ret = regulator_enable(sec->vusbphy);
+   if (ret) {
+   dev_err(sec->dev, "Failed to enable regulator for USBPHY\n");
+   return ret;
+   }

/* Initialize usb phy registers */
sec_usbphy_enable(sec);
@@ -208,8 +211,8 @@ static void sec_usbphy_shutdown(struct usb_phy *phy)
sec_usbphy_disable(sec);

/* Enable phy isolation */
-   if (sec->plat && sec->plat->pmu_isolation)
-   sec->plat->pmu_isolation(true);
+   if (regulator_disable(sec->vusbphy))
+   dev_err(sec->dev, "Failed to disable regulator for USBPHY\n");

/* Disable the phy clock */
sec_usbphy_clk_control(sec, false);
@@ -263,7 +266,6 @@ static int __devinit sec_usbphy_probe(struct
platform_device *pdev)
return -ENOMEM;

sec->dev= &pdev->dev;
-   sec->plat   = pdata;
sec->regs   = phy_base;
sec->phy.dev= sec->dev;
sec->phy.label  = "sec-usbphy";
@@ -271,6 +273,14 @@ static int __devinit sec_usbphy_probe(struct
platform_device *pdev)
sec->phy.shutdown   = sec_usbphy_shutdown;
sec->cpu_type   = sec_usbphy_get_driver_data(pdev);

+   /* acquire regulator */
+   sec->vusbphy = regulator_get(sec->dev, "usbdphy");
+   if (IS_ERR_OR_NULL(sec->vusbphy)) {
+   dev_err(dev, "failed to get regulator 'usbdphy'\n");
+   ret = -ENXIO;
+   goto err;
+   }
+
ret = usb_add_phy(&sec->phy, USB_PHY_TYPE_USB2);
if (ret)
goto err;
@@ -292,6 +302,7 @@ static int __exit sec_usbphy_remove(struct
platform_device *pdev)
clk_put(sec->clk);
sec->clk = NULL;
}
+   regulator_put(sec->vusbphy);

return 0;
 }

This kind of regulator, if generalised can be useful.
Please comment.
>
> My guess is that the PMU code should be moved into a higher-level
> abstraction. I don't know if you would use one of those we already
Could you please point out the location of the code.
> have or whether you'd introduce a new subsystem for those. Apparently.
Havent thought about it. Trying to work it out with the existing infra of the
kernel.
>

[PATCH 5/5] ARM: Exynos4210: Enabling sec_usbphy driver

2012-08-01 Thread Praveen Paneri
Adding usbphy node for Exynos4210 along with the platform data.

Signed-off-by: Praveen Paneri 
---
 arch/arm/boot/dts/exynos4210.dtsi   |5 +
 arch/arm/mach-exynos/include/mach/map.h |1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c  |8 
 arch/arm/mach-exynos/setup-usb-phy.c|   13 +
 4 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
b/arch/arm/boot/dts/exynos4210.dtsi
index a1dd2ee..fc9e00f 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -45,6 +45,11 @@
interrupts = <0 44 0>, <0 45 0>;
};
 
+   usbphy@125B {
+   compatible = "samsung,exynos4210-usbphy";
+   reg = <0x125B 0x100>;
+   };
+
keypad@100A {
compatible = "samsung,s5pv210-keypad";
reg = <0x100A 0x100>;
diff --git a/arch/arm/mach-exynos/include/mach/map.h 
b/arch/arm/mach-exynos/include/mach/map.h
index ca4aa89..a265634 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -231,6 +231,7 @@
 #define S3C_PA_SPI1EXYNOS4_PA_SPI1
 #define S3C_PA_SPI2EXYNOS4_PA_SPI2
 #define S3C_PA_USB_HSOTG   EXYNOS4_PA_HSOTG
+#define S3C_PA_USB_PHY EXYNOS4_PA_HSPHY
 
 #define S5P_PA_EHCIEXYNOS4_PA_EHCI
 #define S5P_PA_FIMC0   EXYNOS4_PA_FIMC0
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c 
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index e7e9743..9126637 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -13,6 +13,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -20,9 +21,14 @@
 
 #include 
 #include 
+#include 
 
 #include "common.h"
 
+static struct s3c_usbphy_plat exynos4_usbphy_pdata = {
+   .pmu_isolation = s5p_usb_phy_pmu_isolation,
+};
+
 /*
  * The following lookup table is used to override device names when devices
  * are registered from device tree. This is temporarily added to enable
@@ -57,6 +63,8 @@ static const struct of_dev_auxdata 
exynos4210_auxdata_lookup[] __initconst = {
"s3c2440-i2c.0", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA0, "dma-pl330.0", NULL),
OF_DEV_AUXDATA("arm,pl330", EXYNOS4_PA_PDMA1, "dma-pl330.1", NULL),
+   OF_DEV_AUXDATA("samsung,exynos4210-usbphy", EXYNOS4_PA_HSPHY,
+   "s3c-usbphy", &exynos4_usbphy_pdata),
{},
 };
 
diff --git a/arch/arm/mach-exynos/setup-usb-phy.c 
b/arch/arm/mach-exynos/setup-usb-phy.c
index 1af0a7f..3fca203 100644
--- a/arch/arm/mach-exynos/setup-usb-phy.c
+++ b/arch/arm/mach-exynos/setup-usb-phy.c
@@ -193,3 +193,16 @@ int s5p_usb_phy_exit(struct platform_device *pdev, int 
type)
 
return -EINVAL;
 }
+
+void s5p_usb_phy_pmu_isolation(int on)
+{
+   if (on) {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   & ~S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   } else {
+   writel(readl(S5P_USBDEVICE_PHY_CONTROL)
+   | S5P_USBDEVICE_PHY_ENABLE,
+   S5P_USBDEVICE_PHY_CONTROL);
+   }
+}
-- 
1.7.1

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


[PATCH 4/5] ARM: S3C64XX: Enabling sec_usbphy driver

2012-08-01 Thread Praveen Paneri
Adding platform device for sec_usbphy driver. Enabling it for s3c64xx
based machines using s3c-hsotg.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/include/mach/map.h |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c|3 ++
 arch/arm/mach-s3c64xx/mach-smartq.c  |4 +++
 arch/arm/mach-s3c64xx/mach-smdk6410.c|3 ++
 arch/arm/mach-s3c64xx/setup-usb-phy.c|   14 +++
 arch/arm/plat-samsung/devs.c |   32 ++
 arch/arm/plat-samsung/include/plat/devs.h|1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h |1 +
 8 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/include/mach/map.h 
b/arch/arm/mach-s3c64xx/include/mach/map.h
index 8e2097b..dc482bb 100644
--- a/arch/arm/mach-s3c64xx/include/mach/map.h
+++ b/arch/arm/mach-s3c64xx/include/mach/map.h
@@ -65,6 +65,7 @@
 
 #define S3C64XX_PA_NAND(0x7020)
 #define S3C64XX_PA_FB  (0x7710)
+#define S3C64XX_PA_USB_HSPHY   (0x7C10)
 #define S3C64XX_PA_USB_HSOTG   (0x7C00)
 #define S3C64XX_PA_WATCHDOG(0x7E004000)
 #define S3C64XX_PA_RTC (0x7E005000)
@@ -113,6 +114,7 @@
 #define S3C_PA_FB  S3C64XX_PA_FB
 #define S3C_PA_USBHOST S3C64XX_PA_USBHOST
 #define S3C_PA_USB_HSOTG   S3C64XX_PA_USB_HSOTG
+#define S3C_PA_USB_PHY S3C64XX_PA_USB_HSPHY
 #define S3C_PA_RTC S3C64XX_PA_RTC
 #define S3C_PA_WDT S3C64XX_PA_WATCHDOG
 #define S3C_PA_SPI0S3C64XX_PA_SPI0
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 984146e..88c4671 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -337,6 +337,7 @@ static struct platform_device wallvdd_device = {
 };
 
 static struct platform_device *crag6410_devices[] __initdata = {
+   &s3c_device_usbphy,
&s3c_device_hsmmc0,
&s3c_device_hsmmc2,
&s3c_device_i2c0,
@@ -767,6 +768,7 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
+static struct s3c_usbphy_plat crag6410_usbphy_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -792,6 +794,7 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
+   s3c_usbphy_set_platdata(&crag6410_usbphy_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index 3647202..97751d5 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -235,6 +235,7 @@ static struct i2c_board_info smartq_i2c_devs[] __initdata = 
{
 };
 
 static struct platform_device *smartq_devices[] __initdata = {
+   &s3c_device_usbphy,
&s3c_device_hsmmc1, /* Init iNAND first, ... */
&s3c_device_hsmmc0, /* ... then the external SD card */
&s3c_device_hsmmc2,
@@ -381,9 +382,12 @@ void __init smartq_map_io(void)
smartq_lcd_mode_set();
 }
 
+static struct s3c_usbphy_plat smartq_usbphy_pdata;
+
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
+   s3c_usbphy_set_platdata(&smartq_usbphy_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index ceec1a9..c5ea838 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -264,6 +264,7 @@ static struct samsung_keypad_platdata smdk6410_keypad_data 
__initdata = {
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
+   &s3c_device_usbphy,
 #ifdef CONFIG_SMDK6410_SD_CH0
&s3c_device_hsmmc0,
 #endif
@@ -628,6 +629,7 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
+static struct s3c_usbphy_plat smdk6410_usbphy_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -657,6 +659,7 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
+   s3c_usbphy_set_platdata(&smdk6410_usbphy_pdata);
 
samsung_keypad_set_platdata(&smdk6410_keypad_data);
 
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c 
b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index 7a09553..3aee778 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/

[PATCH 3/5] ARM: S3C64XX: Removing old phy setup code

2012-08-01 Thread Praveen Paneri
This patch removes old phy code from platform side. 'setup-usb-phy.c'
will be used for providing transceiver platform data in next
patch. Not all of the platform data code is removed as there are others
making use of platform_data defined for hsotg. That can be removed once
all the SoCs start using the new transceiver for usb phy setup.

Signed-off-by: Praveen Paneri 
---
 arch/arm/mach-s3c64xx/mach-crag6410.c |2 -
 arch/arm/mach-s3c64xx/mach-smartq.c   |2 -
 arch/arm/mach-s3c64xx/mach-smdk6410.c |2 -
 arch/arm/mach-s3c64xx/setup-usb-phy.c |   79 -
 4 files changed, 0 insertions(+), 85 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c 
b/arch/arm/mach-s3c64xx/mach-crag6410.c
index d0c352d..984146e 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -767,7 +767,6 @@ static const struct gpio_led_platform_data gpio_leds_pdata 
= {
.num_leds = ARRAY_SIZE(gpio_leds),
 };
 
-static struct s3c_hsotg_plat crag6410_hsotg_pdata;
 
 static void __init crag6410_machine_init(void)
 {
@@ -793,7 +792,6 @@ static void __init crag6410_machine_init(void)
s3c_i2c0_set_platdata(&i2c0_pdata);
s3c_i2c1_set_platdata(&i2c1_pdata);
s3c_fb_set_platdata(&crag6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&crag6410_hsotg_pdata);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c 
b/arch/arm/mach-s3c64xx/mach-smartq.c
index ceeb1de..3647202 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -187,7 +187,6 @@ static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata 
= {
},
 };
 
-static struct s3c_hsotg_plat smartq_hsotg_pdata;
 
 static int __init smartq_lcd_setup_gpio(void)
 {
@@ -385,7 +384,6 @@ void __init smartq_map_io(void)
 void __init smartq_machine_init(void)
 {
s3c_i2c0_set_platdata(NULL);
-   s3c_hsotg_set_platdata(&smartq_hsotg_pdata);
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index df3103d..ceec1a9 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -628,7 +628,6 @@ static struct platform_pwm_backlight_data smdk6410_bl_data 
= {
.pwm_id = 1,
 };
 
-static struct s3c_hsotg_plat smdk6410_hsotg_pdata;
 
 static void __init smdk6410_map_io(void)
 {
@@ -658,7 +657,6 @@ static void __init smdk6410_machine_init(void)
s3c_i2c0_set_platdata(NULL);
s3c_i2c1_set_platdata(NULL);
s3c_fb_set_platdata(&smdk6410_lcd_pdata);
-   s3c_hsotg_set_platdata(&smdk6410_hsotg_pdata);
 
samsung_keypad_set_platdata(&smdk6410_keypad_data);
 
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c 
b/arch/arm/mach-s3c64xx/setup-usb-phy.c
index f6757e0..7a09553 100644
--- a/arch/arm/mach-s3c64xx/setup-usb-phy.c
+++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
@@ -9,82 +9,3 @@
  *
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-static int s3c_usb_otgphy_init(struct platform_device *pdev)
-{
-   struct clk *xusbxti;
-   u32 phyclk;
-
-   writel(readl(S3C64XX_OTHERS) | S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS);
-
-   /* set clock frequency for PLL */
-   phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK;
-
-   xusbxti = clk_get(&pdev->dev, "xusbxti");
-   if (xusbxti && !IS_ERR(xusbxti)) {
-   switch (clk_get_rate(xusbxti)) {
-   case 12 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_12M;
-   break;
-   case 24 * MHZ:
-   phyclk |= S3C_PHYCLK_CLKSEL_24M;
-   break;
-   default:
-   case 48 * MHZ:
-   /* default reference clock */
-   break;
-   }
-   clk_put(xusbxti);
-   }
-
-   /* TODO: select external clock/oscillator */
-   writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK);
-
-   /* set to normal OTG PHY */
-   writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR);
-   mdelay(1);
-
-   /* reset OTG PHY and Link */
-   writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK,
-   S3C_RSTCON);
-   udelay(20); /* at-least 10uS */
-   writel(0, S3C_RSTCON);
-
-   return 0;
-}
-
-static int s3c_usb_otgphy_exit(struct platform_device *pdev)
-{
-   writel((readl(S3C_PHYPWR) | S3C_PHYPWR_ANALOG_POWERDOWN |
-   S3C_PHYPWR_OTG_

[PATCH 2/5] usb: s3c-hsotg: Adding phy driver support

2012-08-01 Thread Praveen Paneri
Adding the transceiver to hsotg driver. Keeping the platform data
for continuing the smooth operation for boards which still uses it

Signed-off-by: Praveen Paneri 
---
 drivers/usb/gadget/s3c-hsotg.c |   38 --
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index b13e0bb..f4ba9a3 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -32,6 +32,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -133,7 +134,9 @@ struct s3c_hsotg_ep {
  * struct s3c_hsotg - driver state.
  * @dev: The parent device supplied to the probe function
  * @driver: USB gadget driver
- * @plat: The platform specific configuration data.
+ * @phy: The otg phy transeiver structure for phy control.
+ * @plat: The platform specific configuration data. This can be removed once
+ * all SoCs support usb transceiver.
  * @regs: The memory area mapped for accessing registers.
  * @irq: The IRQ number we are using
  * @supplies: Definition of USB power supplies
@@ -153,6 +156,7 @@ struct s3c_hsotg_ep {
 struct s3c_hsotg {
struct device*dev;
struct usb_gadget_driver *driver;
+   struct usb_phy  *phy;
struct s3c_hsotg_plat*plat;
 
spinlock_t  lock;
@@ -2854,7 +2858,10 @@ static void s3c_hsotg_phy_enable(struct s3c_hsotg *hsotg)
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
dev_dbg(hsotg->dev, "pdev 0x%p\n", pdev);
-   if (hsotg->plat->phy_init)
+
+   if (hsotg->phy)
+   usb_phy_init(hsotg->phy);
+   else if (hsotg->plat->phy_init)
hsotg->plat->phy_init(pdev, hsotg->plat->phy_type);
 }
 
@@ -2869,7 +2876,9 @@ static void s3c_hsotg_phy_disable(struct s3c_hsotg *hsotg)
 {
struct platform_device *pdev = to_platform_device(hsotg->dev);
 
-   if (hsotg->plat->phy_exit)
+   if (hsotg->phy)
+   usb_phy_shutdown(hsotg->phy);
+   else if (hsotg->plat->phy_exit)
hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type);
 }
 
@@ -3493,6 +3502,7 @@ static void s3c_hsotg_release(struct device *dev)
 static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
 {
struct s3c_hsotg_plat *plat = pdev->dev.platform_data;
+   struct usb_phy *phy;
struct device *dev = &pdev->dev;
struct s3c_hsotg_ep *eps;
struct s3c_hsotg *hsotg;
@@ -3501,20 +3511,25 @@ static int __devinit s3c_hsotg_probe(struct 
platform_device *pdev)
int ret;
int i;
 
-   plat = pdev->dev.platform_data;
-   if (!plat) {
-   dev_err(&pdev->dev, "no platform data defined\n");
-   return -EINVAL;
-   }
-
hsotg = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsotg), GFP_KERNEL);
if (!hsotg) {
dev_err(dev, "cannot get memory\n");
return -ENOMEM;
}
 
+   phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (!phy) {
+   /* Fallback for platform data */
+   plat = pdev->dev.platform_data;
+   if (!plat) {
+   dev_err(&pdev->dev, "no platform data or transceiver 
defined\n");
+   return -ENODEV;
+   } else
+   hsotg->plat = plat;
+   } else
+   hsotg->phy = phy;
+
hsotg->dev = dev;
-   hsotg->plat = plat;
 
hsotg->clk = clk_get(&pdev->dev, "otg");
if (IS_ERR(hsotg->clk)) {
@@ -3689,6 +3704,9 @@ static int __devexit s3c_hsotg_remove(struct 
platform_device *pdev)
s3c_hsotg_phy_disable(hsotg);
regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
 
+   if (hsotg->phy)
+   devm_usb_put_phy(&pdev->dev, hsotg->phy);
+
clk_disable_unprepare(hsotg->clk);
clk_put(hsotg->clk);
 
-- 
1.7.1

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


[PATCH 1/5] usb: phy: samsung: Introducing usb phy driver for hsotg

2012-08-01 Thread Praveen Paneri
This driver uses usb_phy interface to interact with s3c-hsotg. Supports
phy_init and phy_shutdown functions to enable/disable phy. Tested with
smdk6410 and smdkv310. More SoCs can be brought under later.

Signed-off-by: Praveen Paneri 
---
 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/sec_usbphy.c   |  354 
 drivers/usb/phy/sec_usbphy.h   |   48 +++
 include/linux/platform_data/s3c-hsotg.h|5 +
 6 files changed, 425 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/sec_usbphy.c
 create mode 100644 drivers/usb/phy/sec_usbphy.h

diff --git a/Documentation/devicetree/bindings/usb/samsung-usbphy.txt 
b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
new file mode 100644
index 000..fefd9c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/samsung-usbphy.txt
@@ -0,0 +1,9 @@
+* Samsung's usb phy transceiver
+
+The Samsung's phy transceiver is used for controlling usb otg phy for
+s3c-hsotg usb device controller.
+
+Required properties:
+- compatible : should be "samsung,exynos4210-usbphy"
+- reg : base physical address of the phy registers and length of memory mapped
+   region.
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index e7cf84f..abbebe2 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -15,3 +15,11 @@ config USB_ISP1301
 
  To compile this driver as a module, choose M here: the
  module will be called isp1301.
+
+config SEC_USBPHY
+   bool "Samsung USB PHY controller Driver"
+   depends on USB_S3C_HSOTG
+   select USB_OTG_UTILS
+   help
+ Enable this to support Samsung USB phy controller for samsung
+ SoCs.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index eca095b..6bb66f0 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -5,3 +5,4 @@
 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
+obj-$(CONFIG_SEC_USBPHY)   += sec_usbphy.o
diff --git a/drivers/usb/phy/sec_usbphy.c b/drivers/usb/phy/sec_usbphy.c
new file mode 100644
index 000..33119eb
--- /dev/null
+++ b/drivers/usb/phy/sec_usbphy.c
@@ -0,0 +1,354 @@
+/* linux/drivers/usb/phy/sec_usbphy.c
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *  http://www.samsung.com
+ *
+ * Author: Praveen Paneri 
+ *
+ * Samsung USB2.0 High-speed OTG transceiver, talks to S3C HS OTG controller
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sec_usbphy.h"
+
+enum sec_cpu_type {
+   TYPE_S3C64XX,
+   TYPE_EXYNOS4210,
+};
+
+/*
+ * struct sec_usbphy - transceiver driver state
+ * @phy: transceiver structure
+ * @plat: platform data
+ * @dev: The parent device supplied to the probe function
+ * @clk: usb phy clock
+ * @regs: usb phy register memory base
+ * @cpu_type: machine identifier
+ */
+struct sec_usbphy {
+   struct usb_phy  phy;
+   struct s3c_usbphy_plat *plat;
+   struct device   *dev;
+   struct clk  *clk;
+   void __iomem*regs;
+   int cpu_type;
+};
+
+#define phy_to_sec(x)  container_of((x), struct sec_usbphy, phy)
+
+/*
+ * Enables or disables the phy clock
+ * returns 0 on success else the error
+ */
+static int sec_usbphy_clk_control(struct sec_usbphy *sec, bool on)
+{
+   if (on) {
+   if (!sec->clk) {
+   sec->clk = clk_get(sec->dev, "otg");
+   if (IS_ERR(sec->clk)) {
+   dev_err(sec->dev, "Failed to get otg clock\n");
+   return PTR_ERR(sec->clk);
+   }
+   }
+   clk_enable(sec->clk);
+   } else {
+   clk_disable(sec->clk);
+   clk_put(sec->clk);
+   }
+
+   return 0;
+}
+
+/*
+ * Returns reference clock frequency
+ */
+static int sec_usbphy_get_refclk_f

[PATCH 0/5] usb: phy: samsung: Introducing usb phy driver for samsung SoCs

2012-08-01 Thread Praveen Paneri
This patch set introduces a phy driver for samsung SoCs. It uses the existing
transceiver infrastructure to provide phy control functions. Use of this driver
can be extended for usb host phy as well. Over the period of time all the phy
related code for most of the samsung SoCs can be integrated here.
Removing the existing phy code from mach-s3c64xx but not from other machine 
code.This driver is tested with smdk6410 and Exynos4210(with DT).

Praveen Paneri (5):
  usb: phy: samsung: Introducing usb phy driver for hsotg
  usb: s3c-hsotg: Adding phy driver support
  ARM: S3C64XX: Removing old phy setup code
  ARM: S3C64XX: Enabling sec_usbphy driver
  ARM: Exynos4210: Enabling sec_usbphy driver

 .../devicetree/bindings/usb/samsung-usbphy.txt |9 +
 arch/arm/boot/dts/exynos4210.dtsi  |5 +
 arch/arm/mach-exynos/include/mach/map.h|1 +
 arch/arm/mach-exynos/mach-exynos4-dt.c |8 +
 arch/arm/mach-exynos/setup-usb-phy.c   |   13 +
 arch/arm/mach-s3c64xx/include/mach/map.h   |2 +
 arch/arm/mach-s3c64xx/mach-crag6410.c  |5 +-
 arch/arm/mach-s3c64xx/mach-smartq.c|6 +-
 arch/arm/mach-s3c64xx/mach-smdk6410.c  |5 +-
 arch/arm/mach-s3c64xx/setup-usb-phy.c  |   79 +
 arch/arm/plat-samsung/devs.c   |   32 ++
 arch/arm/plat-samsung/include/plat/devs.h  |1 +
 arch/arm/plat-samsung/include/plat/usb-phy.h   |1 +
 drivers/usb/gadget/s3c-hsotg.c |   38 ++-
 drivers/usb/phy/Kconfig|8 +
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/sec_usbphy.c   |  354 
 drivers/usb/phy/sec_usbphy.h   |   48 +++
 include/linux/platform_data/s3c-hsotg.h|5 +
 19 files changed, 533 insertions(+), 88 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/samsung-usbphy.txt
 create mode 100644 drivers/usb/phy/sec_usbphy.c
 create mode 100644 drivers/usb/phy/sec_usbphy.h

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