[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 {
+   TYPE_S3C64XX,
+   TYPE_EXYNOS4210,
+};
+
+/*
+ * struct samsung_usbphy - transceiver driver state
+ * @phy: transceiver struc

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

[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 {
+   TYPE_S3C64XX,
+   TYPE_EXYNOS4210,
+};
+
+/*
+ * struct samsung_usbphy - transceiver driver state
+ * @phy: transceiver struc