Re: [PATCH V7 07/10] USB/ppc4xx: Add Synopsys DWC OTG PCD function

2011-01-19 Thread Alan Stern
On Tue, 18 Jan 2011 tma...@apm.com wrote:

 From: Tirumala Marri tma...@apm.com
 
 The PCD is responsible for translating requests from the gadget driver
 to appropriate actions on the DWC OTG controller.
 
 Signed-off-by: Tirumala R Marri tma...@apm.com
 Signed-off-by: Fushen Chen fc...@apm.com
 Signed-off-by: Mark Miesfeld mmiesf...@apm.com
 ---
  drivers/usb/dwc_otg/dwc_otg_pcd.c | 1752 
 +
  drivers/usb/dwc_otg/dwc_otg_pcd.h |  139 +++
  2 files changed, 1891 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd.c 
 b/drivers/usb/dwc_otg/dwc_otg_pcd.c
 new file mode 100644
 index 000..857dcee
 --- /dev/null
 +++ b/drivers/usb/dwc_otg/dwc_otg_pcd.c

...

 +static struct usb_ep_ops dwc_otg_pcd_ep_ops = {
 + .enable = dwc_otg_pcd_ep_enable,
 + .disable = dwc_otg_pcd_ep_disable,
 + .alloc_request = dwc_otg_pcd_alloc_request,
 + .free_request = dwc_otg_pcd_free_request,
 + .queue = dwc_otg_pcd_ep_queue,
 + .dequeue = dwc_otg_pcd_ep_dequeue,
 + .set_halt = dwc_otg_pcd_ep_set_halt,
 + .fifo_status = NULL,
 + .fifo_flush = NULL,
 +};

This is missing a .set_wedge method.

Alan Stern

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH V7 07/10] USB/ppc4xx: Add Synopsys DWC OTG PCD function

2011-01-18 Thread tmarri
From: Tirumala Marri tma...@apm.com

The PCD is responsible for translating requests from the gadget driver
to appropriate actions on the DWC OTG controller.

Signed-off-by: Tirumala R Marri tma...@apm.com
Signed-off-by: Fushen Chen fc...@apm.com
Signed-off-by: Mark Miesfeld mmiesf...@apm.com
---
 drivers/usb/dwc_otg/dwc_otg_pcd.c | 1752 +
 drivers/usb/dwc_otg/dwc_otg_pcd.h |  139 +++
 2 files changed, 1891 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd.c 
b/drivers/usb/dwc_otg/dwc_otg_pcd.c
new file mode 100644
index 000..857dcee
--- /dev/null
+++ b/drivers/usb/dwc_otg/dwc_otg_pcd.c
@@ -0,0 +1,1752 @@
+/*
+ * DesignWare HS OTG controller driver
+ * Copyright (C) 2006 Synopsys, Inc.
+ * Portions Copyright (C) 2010 Applied Micro Circuits Corporation.
+ *
+ * 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 version 2 for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see http://www.gnu.org/licenses
+ * or write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Suite 500, Boston, MA 02110-1335 USA.
+ *
+ * Based on Synopsys driver version 2.60a
+ * Modified by Mark Miesfeld mmiesf...@apm.com
+ * Modified by Stefan Roese s...@denx.de, DENX Software Engineering
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL SYNOPSYS, INC. BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/*
+ * This file implements the Peripheral Controller Driver.
+ *
+ * The Peripheral Controller Driver (PCD) is responsible for
+ * translating requests from the Function Driver into the appropriate
+ * actions on the DWC_otg controller. It isolates the Function Driver
+ * from the specifics of the controller by providing an API to the
+ * Function Driver.
+ *
+ * The Peripheral Controller Driver for Linux will implement the
+ * Gadget API, so that the existing Gadget drivers can be used.
+ * (Gadget Driver is the Linux terminology for a Function Driver.)
+ *
+ * The Linux Gadget API is defined in the header file linux/usb/gadget.h. The
+ * USB EP operations API is defined in the structure usb_ep_ops and the USB
+ * Controller API is defined in the structure usb_gadget_ops
+ *
+ * An important function of the PCD is managing interrupts generated
+ * by the DWC_otg controller. The implementation of the DWC_otg device
+ * mode interrupt service routines is in dwc_otg_pcd_intr.c.
+ */
+
+#include linux/dma-mapping.h
+#include linux/delay.h
+
+#include dwc_otg_pcd.h
+
+/*
+ * Static PCD pointer for use in usb_gadget_register_driver and
+ * usb_gadget_unregister_driver.  Initialized in dwc_otg_pcd_init.
+ */
+static struct dwc_pcd *s_pcd;
+
+static inline int need_stop_srp_timer(struct core_if *core_if)
+{
+   if (core_if-core_params-phy_type != DWC_PHY_TYPE_PARAM_FS ||
+   !core_if-core_params-i2c_enable)
+   return core_if-srp_timer_started ? 1 : 0;
+   return 0;
+}
+
+/**
+ * Tests if the module is set to FS or if the PHY_TYPE is FS. If so, then the
+ * gadget should not report as dual-speed capable.
+ */
+static inline int check_is_dual_speed(struct core_if *core_if)
+{
+   if (core_if-core_params-speed == DWC_SPEED_PARAM_FULL ||
+   (DWC_HWCFG2_HS_PHY_TYPE_RD(core_if-hwcfg2) == 2 
+DWC_HWCFG2_P_2_P_RD(core_if-hwcfg2) == 1 
+core_if-core_params-ulpi_fs_ls))
+   return 0;
+   return 1;
+}
+
+/**
+ * Tests if driver is OTG capable.
+ */
+static inline int check_is_otg(struct core_if *core_if)
+{
+   if (DWC_HWCFG2_OP_MODE_RD(core_if-hwcfg2) ==
+   DWC_HWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE ||
+   DWC_HWCFG2_OP_MODE_RD(core_if-hwcfg2) ==
+   DWC_HWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST ||
+   DWC_HWCFG2_OP_MODE_RD(core_if-hwcfg2) ==
+   DWC_HWCFG2_OP_MODE_SRP_CAPABLE_DEVICE ||
+   DWC_HWCFG2_OP_MODE_RD(core_if-hwcfg2) ==
+