usb: s3c-otg: Split out PHY control
authorMarek Vasut <marex@denx.de>
Tue, 4 Nov 2014 03:13:57 +0000 (04:13 +0100)
committerMarek Vasut <marex@denx.de>
Fri, 7 Nov 2014 15:32:02 +0000 (16:32 +0100)
Split the Samsung specific PHY control into a separate file
and compile this into the S3C OTG driver only if used on a
Samsung system.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Chin Liang See <clsee@altera.com>
Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
Cc: Vince Bridgers <vbridger@altera.com>
Acked-by: Pavel Machek <pavel@denx.de>
Cc: Stefan Roese <sr@denx.de>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
drivers/usb/gadget/Makefile
drivers/usb/gadget/s3c_udc_otg.c
drivers/usb/gadget/s3c_udc_otg_phy.c [new file with mode: 0644]
include/configs/exynos4-common.h
include/configs/s5p_goni.h
include/configs/s5pc210_universal.h
include/configs/smdkv310.h

index 2efd5a4d5b31969bf23a958f7d5dfb3b5b714bed..70bb550fa470a1799f81b1aeb6c7112e8e931a10 100644 (file)
@@ -12,6 +12,7 @@ obj-$(CONFIG_USB_ETHER) += epautoconf.o config.o usbstring.o
 ifdef CONFIG_USB_GADGET
 obj-$(CONFIG_USB_GADGET_ATMEL_USBA) += atmel_usba_udc.o
 obj-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o
+obj-$(CONFIG_USB_GADGET_S3C_UDC_OTG_PHY) += s3c_udc_otg_phy.o
 obj-$(CONFIG_USB_GADGET_FOTG210) += fotg210.o
 obj-$(CONFIG_CI_UDC)   += ci_udc.o
 obj-$(CONFIG_THOR_FUNCTION) += f_thor.o
index b808ddaf9a8f02be95c76086ac5c91c0e5a7f928..b91005342bee0ad85ce16fb8205c28ca270d3277 100644 (file)
@@ -151,68 +151,8 @@ bool dfu_usb_get_reset(void)
        return !!(readl(&reg->gintsts) & INT_RESET);
 }
 
-void otg_phy_init(struct s3c_udc *dev)
-{
-       unsigned int usb_phy_ctrl = dev->pdata->usb_phy_ctrl;
-       struct s3c_usbotg_phy *phy =
-               (struct s3c_usbotg_phy *)dev->pdata->regs_phy;
-
-       dev->pdata->phy_control(1);
-
-       /*USB PHY0 Enable */
-       printf("USB PHY0 Enable\n");
-
-       /* Enable PHY */
-       writel(readl(usb_phy_ctrl) | USB_PHY_CTRL_EN0, usb_phy_ctrl);
-
-       if (dev->pdata->usb_flags == PHY0_SLEEP) /* C210 Universal */
-               writel((readl(&phy->phypwr)
-                       &~(PHY_0_SLEEP | OTG_DISABLE_0 | ANALOG_PWRDOWN)
-                       &~FORCE_SUSPEND_0), &phy->phypwr);
-       else /* C110 GONI */
-               writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
-                       &~FORCE_SUSPEND_0), &phy->phypwr);
-
-       if (s5p_cpu_id == 0x4412)
-               writel((readl(&phy->phyclk) & ~(EXYNOS4X12_ID_PULLUP0 |
-                       EXYNOS4X12_COMMON_ON_N0)) | EXYNOS4X12_CLK_SEL_24MHZ,
-                      &phy->phyclk); /* PLL 24Mhz */
-       else
-               writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)) |
-                      CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
-
-       writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
-              | PHY_SW_RST0, &phy->rstcon);
-       udelay(10);
-       writel(readl(&phy->rstcon)
-              &~(PHY_SW_RST0 | LINK_SW_RST | PHYLNK_SW_RST), &phy->rstcon);
-       udelay(10);
-}
-
-void otg_phy_off(struct s3c_udc *dev)
-{
-       unsigned int usb_phy_ctrl = dev->pdata->usb_phy_ctrl;
-       struct s3c_usbotg_phy *phy =
-               (struct s3c_usbotg_phy *)dev->pdata->regs_phy;
-
-       /* reset controller just in case */
-       writel(PHY_SW_RST0, &phy->rstcon);
-       udelay(20);
-       writel(readl(&phy->phypwr) &~PHY_SW_RST0, &phy->rstcon);
-       udelay(20);
-
-       writel(readl(&phy->phypwr) | OTG_DISABLE_0 | ANALOG_PWRDOWN
-              | FORCE_SUSPEND_0, &phy->phypwr);
-
-       writel(readl(usb_phy_ctrl) &~USB_PHY_CTRL_EN0, usb_phy_ctrl);
-
-       writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)),
-             &phy->phyclk);
-
-       udelay(10000);
-
-       dev->pdata->phy_control(0);
-}
+__weak void otg_phy_init(struct s3c_udc *dev) {}
+__weak void otg_phy_off(struct s3c_udc *dev) {}
 
 /***********************************************************/
 
diff --git a/drivers/usb/gadget/s3c_udc_otg_phy.c b/drivers/usb/gadget/s3c_udc_otg_phy.c
new file mode 100644 (file)
index 0000000..f13cb89
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * drivers/usb/gadget/s3c_udc_otg.c
+ * Samsung S3C on-chip full/high speed USB OTG 2.0 device controllers
+ *
+ * Copyright (C) 2008 for Samsung Electronics
+ *
+ * BSP Support for Samsung's UDC driver
+ * available at:
+ * git://git.kernel.org/pub/scm/linux/kernel/git/kki_ap/linux-2.6-samsung.git
+ *
+ * State machine bugfixes:
+ * Marek Szyprowski <m.szyprowski@samsung.com>
+ *
+ * Ported to u-boot:
+ * Marek Szyprowski <m.szyprowski@samsung.com>
+ * Lukasz Majewski <l.majewski@samsumg.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/errno.h>
+#include <linux/list.h>
+#include <malloc.h>
+
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+
+#include <asm/byteorder.h>
+#include <asm/unaligned.h>
+#include <asm/io.h>
+
+#include <asm/mach-types.h>
+
+#include "regs-otg.h"
+#include <usb/lin_gadget_compat.h>
+
+#include <usb/s3c_udc.h>
+
+void otg_phy_init(struct s3c_udc *dev)
+{
+       unsigned int usb_phy_ctrl = dev->pdata->usb_phy_ctrl;
+       struct s3c_usbotg_phy *phy =
+               (struct s3c_usbotg_phy *)dev->pdata->regs_phy;
+
+       dev->pdata->phy_control(1);
+
+       /* USB PHY0 Enable */
+       printf("USB PHY0 Enable\n");
+
+       /* Enable PHY */
+       writel(readl(usb_phy_ctrl) | USB_PHY_CTRL_EN0, usb_phy_ctrl);
+
+       if (dev->pdata->usb_flags == PHY0_SLEEP) /* C210 Universal */
+               writel((readl(&phy->phypwr)
+                       &~(PHY_0_SLEEP | OTG_DISABLE_0 | ANALOG_PWRDOWN)
+                       &~FORCE_SUSPEND_0), &phy->phypwr);
+       else /* C110 GONI */
+               writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
+                       &~FORCE_SUSPEND_0), &phy->phypwr);
+
+       if (s5p_cpu_id == 0x4412)
+               writel((readl(&phy->phyclk) & ~(EXYNOS4X12_ID_PULLUP0 |
+                       EXYNOS4X12_COMMON_ON_N0)) | EXYNOS4X12_CLK_SEL_24MHZ,
+                      &phy->phyclk); /* PLL 24Mhz */
+       else
+               writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)) |
+                      CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
+
+       writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
+              | PHY_SW_RST0, &phy->rstcon);
+       udelay(10);
+       writel(readl(&phy->rstcon)
+              &~(PHY_SW_RST0 | LINK_SW_RST | PHYLNK_SW_RST), &phy->rstcon);
+       udelay(10);
+}
+
+void otg_phy_off(struct s3c_udc *dev)
+{
+       unsigned int usb_phy_ctrl = dev->pdata->usb_phy_ctrl;
+       struct s3c_usbotg_phy *phy =
+               (struct s3c_usbotg_phy *)dev->pdata->regs_phy;
+
+       /* reset controller just in case */
+       writel(PHY_SW_RST0, &phy->rstcon);
+       udelay(20);
+       writel(readl(&phy->phypwr) &~PHY_SW_RST0, &phy->rstcon);
+       udelay(20);
+
+       writel(readl(&phy->phypwr) | OTG_DISABLE_0 | ANALOG_PWRDOWN
+              | FORCE_SUSPEND_0, &phy->phypwr);
+
+       writel(readl(usb_phy_ctrl) &~USB_PHY_CTRL_EN0, usb_phy_ctrl);
+
+       writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)),
+             &phy->phyclk);
+
+       udelay(10000);
+
+       dev->pdata->phy_control(0);
+}
index 89ba14e05dd86f42a6176e99622a413754a00171..41631c72e97f497a080dd8a28cd16fa58bde1c5c 100644 (file)
@@ -59,6 +59,7 @@
 
 #define CONFIG_USB_GADGET
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
+#define CONFIG_USB_GADGET_S3C_UDC_OTG_PHY
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_USB_GADGET_VBUS_DRAW    2
 
index 3633a355bd7f83b04bb65a30b731029376b5bff9..dfa2e079480ed37a032e153fd1e5fd1ffb72a354 100644 (file)
 #define CONFIG_SYS_MAX_I2C_BUS 7
 #define CONFIG_USB_GADGET
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
+#define CONFIG_USB_GADGET_S3C_UDC_OTG_PHY
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_USB_GADGET_VBUS_DRAW 2
 #define CONFIG_CMD_USB_MASS_STORAGE
index 4b30d148c31d4882aee8c544f2d724ca67130245..e7bace4345f919a4b55a016eb68a3f3c09487e6f 100644 (file)
 
 #define CONFIG_USB_GADGET
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
+#define CONFIG_USB_GADGET_S3C_UDC_OTG_PHY
 #define CONFIG_USB_GADGET_DUALSPEED
 
 /*
index a2469eb60c91c4729e5db269416ff67c5afba7f3..655025c9129faafbe3078e076743042197be71ec 100644 (file)
@@ -14,6 +14,7 @@
 #undef CONFIG_BOARD_COMMON
 #undef CONFIG_USB_GADGET
 #undef CONFIG_USB_GADGET_S3C_UDC_OTG
+#undef CONFIG_USB_GADGET_S3C_UDC_OTG_PHY
 #undef CONFIG_CMD_USB_MASS_STORAGE
 #undef CONFIG_REVISION_TAG
 #undef CONFIG_CMD_THOR_DOWNLOAD