From 2c12ff039ca6e36c8c2025befcda3d91fbf47dcd Mon Sep 17 00:00:00 2001
From: Marek Vasut <marex@denx.de>
Date: Fri, 4 Dec 2015 01:36:36 +0100
Subject: [PATCH] usb: s3c-otg: Split private bits from s3c_udc.h

Most of the functions are local to the s3c_udc driver, remove them
from the s3c_udc.h header to stop those bits from propagating all
over the place. Instead, move all the private stuff into new private
s3c_udc_otg_priv.h header.

Signed-off-by: Marek Vasut <marex@denx.de>
---
 drivers/usb/gadget/bcm_udc_otg_phy.c  |   2 +-
 drivers/usb/gadget/s3c_udc_otg.c      |   1 +
 drivers/usb/gadget/s3c_udc_otg_phy.c  |   1 +
 drivers/usb/gadget/s3c_udc_otg_priv.h | 102 ++++++++++++++++++++++++++
 include/usb/s3c_udc.h                 |  94 +-----------------------
 5 files changed, 108 insertions(+), 92 deletions(-)
 create mode 100644 drivers/usb/gadget/s3c_udc_otg_priv.h

diff --git a/drivers/usb/gadget/bcm_udc_otg_phy.c b/drivers/usb/gadget/bcm_udc_otg_phy.c
index 936247e94a..c58388c639 100644
--- a/drivers/usb/gadget/bcm_udc_otg_phy.c
+++ b/drivers/usb/gadget/bcm_udc_otg_phy.c
@@ -9,7 +9,7 @@
 #include <asm/io.h>
 #include <asm/arch/sysmap.h>
 
-#include <usb/s3c_udc.h>
+#include "s3c_udc_otg_priv.h"
 #include "bcm_udc_otg.h"
 
 void otg_phy_init(struct dwc2_udc *dev)
diff --git a/drivers/usb/gadget/s3c_udc_otg.c b/drivers/usb/gadget/s3c_udc_otg.c
index 00d03f32cd..99c6a1b1a7 100644
--- a/drivers/usb/gadget/s3c_udc_otg.c
+++ b/drivers/usb/gadget/s3c_udc_otg.c
@@ -33,6 +33,7 @@
 #include <asm/mach-types.h>
 
 #include "s3c_udc_otg_regs.h"
+#include "s3c_udc_otg_priv.h"
 #include <usb/lin_gadget_compat.h>
 
 /***********************************************************/
diff --git a/drivers/usb/gadget/s3c_udc_otg_phy.c b/drivers/usb/gadget/s3c_udc_otg_phy.c
index ffc930c911..169f8e4dbb 100644
--- a/drivers/usb/gadget/s3c_udc_otg_phy.c
+++ b/drivers/usb/gadget/s3c_udc_otg_phy.c
@@ -33,6 +33,7 @@
 #include <asm/mach-types.h>
 
 #include "s3c_udc_otg_regs.h"
+#include "s3c_udc_otg_priv.h"
 #include <usb/lin_gadget_compat.h>
 
 #include <usb/s3c_udc.h>
diff --git a/drivers/usb/gadget/s3c_udc_otg_priv.h b/drivers/usb/gadget/s3c_udc_otg_priv.h
new file mode 100644
index 0000000000..567fb4e263
--- /dev/null
+++ b/drivers/usb/gadget/s3c_udc_otg_priv.h
@@ -0,0 +1,102 @@
+/*
+ * Samsung S3C on-chip full/high speed USB device controllers
+ * Copyright (C) 2005 for Samsung Electronics
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __S3C_UDC_OTG_PRIV__
+#define __S3C_UDC_OTG_PRIV__
+
+#include <asm/errno.h>
+#include <linux/sizes.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+#include <linux/list.h>
+#include <usb/lin_gadget_compat.h>
+#include <usb/s3c_udc.h>
+
+/*-------------------------------------------------------------------------*/
+/* DMA bounce buffer size, 16K is enough even for mass storage */
+#define DMA_BUFFER_SIZE	(16*SZ_1K)
+
+#define EP0_FIFO_SIZE		64
+#define EP_FIFO_SIZE		512
+#define EP_FIFO_SIZE2		1024
+/* ep0-control, ep1in-bulk, ep2out-bulk, ep3in-int */
+#define S3C_MAX_ENDPOINTS	4
+#define S3C_MAX_HW_ENDPOINTS	16
+
+#define WAIT_FOR_SETUP          0
+#define DATA_STATE_XMIT         1
+#define DATA_STATE_NEED_ZLP     2
+#define WAIT_FOR_OUT_STATUS     3
+#define DATA_STATE_RECV         4
+#define WAIT_FOR_COMPLETE	5
+#define WAIT_FOR_OUT_COMPLETE	6
+#define WAIT_FOR_IN_COMPLETE	7
+#define WAIT_FOR_NULL_COMPLETE	8
+
+#define TEST_J_SEL		0x1
+#define TEST_K_SEL		0x2
+#define TEST_SE0_NAK_SEL	0x3
+#define TEST_PACKET_SEL		0x4
+#define TEST_FORCE_ENABLE_SEL	0x5
+
+/* ************************************************************************* */
+/* IO
+ */
+
+enum ep_type {
+	ep_control, ep_bulk_in, ep_bulk_out, ep_interrupt
+};
+
+struct s3c_ep {
+	struct usb_ep ep;
+	struct dwc2_udc *dev;
+
+	const struct usb_endpoint_descriptor *desc;
+	struct list_head queue;
+	unsigned long pio_irqs;
+	int len;
+	void *dma_buf;
+
+	u8 stopped;
+	u8 bEndpointAddress;
+	u8 bmAttributes;
+
+	enum ep_type ep_type;
+	int fifo_num;
+};
+
+struct s3c_request {
+	struct usb_request req;
+	struct list_head queue;
+};
+
+struct dwc2_udc {
+	struct usb_gadget gadget;
+	struct usb_gadget_driver *driver;
+
+	struct s3c_plat_otg_data *pdata;
+
+	int ep0state;
+	struct s3c_ep ep[S3C_MAX_ENDPOINTS];
+
+	unsigned char usb_address;
+
+	unsigned req_pending:1, req_std:1;
+};
+
+extern struct dwc2_udc *the_controller;
+
+#define ep_is_in(EP) (((EP)->bEndpointAddress&USB_DIR_IN) == USB_DIR_IN)
+#define ep_index(EP) ((EP)->bEndpointAddress&0xF)
+#define ep_maxpacket(EP) ((EP)->ep.maxpacket)
+
+extern void otg_phy_init(struct dwc2_udc *dev);
+extern void otg_phy_off(struct dwc2_udc *dev);
+
+extern void s3c_udc_ep_set_stall(struct s3c_ep *ep);
+
+#endif	/* __S3C_UDC_OTG_PRIV__ */
diff --git a/include/usb/s3c_udc.h b/include/usb/s3c_udc.h
index f6c3a8693c..67c3e9112d 100644
--- a/include/usb/s3c_udc.h
+++ b/include/usb/s3c_udc.h
@@ -9,99 +9,8 @@
 #ifndef __S3C_USB_GADGET
 #define __S3C_USB_GADGET
 
-#include <asm/errno.h>
-#include <linux/sizes.h>
-#include <linux/usb/ch9.h>
-#include <linux/usb/gadget.h>
-#include <linux/list.h>
-#include <usb/lin_gadget_compat.h>
-
 #define PHY0_SLEEP              (1 << 5)
 
-/*-------------------------------------------------------------------------*/
-/* DMA bounce buffer size, 16K is enough even for mass storage */
-#define DMA_BUFFER_SIZE	(16*SZ_1K)
-
-#define EP0_FIFO_SIZE		64
-#define EP_FIFO_SIZE		512
-#define EP_FIFO_SIZE2		1024
-/* ep0-control, ep1in-bulk, ep2out-bulk, ep3in-int */
-#define S3C_MAX_ENDPOINTS	4
-#define S3C_MAX_HW_ENDPOINTS	16
-
-#define WAIT_FOR_SETUP          0
-#define DATA_STATE_XMIT         1
-#define DATA_STATE_NEED_ZLP     2
-#define WAIT_FOR_OUT_STATUS     3
-#define DATA_STATE_RECV         4
-#define WAIT_FOR_COMPLETE	5
-#define WAIT_FOR_OUT_COMPLETE	6
-#define WAIT_FOR_IN_COMPLETE	7
-#define WAIT_FOR_NULL_COMPLETE	8
-
-#define TEST_J_SEL		0x1
-#define TEST_K_SEL		0x2
-#define TEST_SE0_NAK_SEL	0x3
-#define TEST_PACKET_SEL		0x4
-#define TEST_FORCE_ENABLE_SEL	0x5
-
-/* ************************************************************************* */
-/* IO
- */
-
-enum ep_type {
-	ep_control, ep_bulk_in, ep_bulk_out, ep_interrupt
-};
-
-struct s3c_ep {
-	struct usb_ep ep;
-	struct dwc2_udc *dev;
-
-	const struct usb_endpoint_descriptor *desc;
-	struct list_head queue;
-	unsigned long pio_irqs;
-	int len;
-	void *dma_buf;
-
-	u8 stopped;
-	u8 bEndpointAddress;
-	u8 bmAttributes;
-
-	enum ep_type ep_type;
-	int fifo_num;
-};
-
-struct s3c_request {
-	struct usb_request req;
-	struct list_head queue;
-};
-
-struct dwc2_udc {
-	struct usb_gadget gadget;
-	struct usb_gadget_driver *driver;
-
-	struct s3c_plat_otg_data *pdata;
-
-	int ep0state;
-	struct s3c_ep ep[S3C_MAX_ENDPOINTS];
-
-	unsigned char usb_address;
-
-	unsigned req_pending:1, req_std:1;
-};
-
-extern struct dwc2_udc *the_controller;
-
-#define ep_is_in(EP) (((EP)->bEndpointAddress&USB_DIR_IN) == USB_DIR_IN)
-#define ep_index(EP) ((EP)->bEndpointAddress&0xF)
-#define ep_maxpacket(EP) ((EP)->ep.maxpacket)
-
-extern void otg_phy_init(struct dwc2_udc *dev);
-extern void otg_phy_off(struct dwc2_udc *dev);
-
-extern void s3c_udc_ep_set_stall(struct s3c_ep *ep);
-extern int s3c_udc_probe(struct s3c_plat_otg_data *pdata);
-
 struct s3c_plat_otg_data {
 	int		(*phy_control)(int on);
 	unsigned int	regs_phy;
@@ -110,4 +19,7 @@ struct s3c_plat_otg_data {
 	unsigned int    usb_flags;
 	unsigned int	usb_gusbcfg;
 };
+
+extern int s3c_udc_probe(struct s3c_plat_otg_data *pdata);
+
 #endif
-- 
2.39.5