⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udc.patch

📁 patches for linux-2.6.
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
+ *+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA+ */+#ifndef AMD5536OTG_H+#define AMD5536OTG_H+++/*****************************************************************************+*  Constants+*****************************************************************************/+++/**********************************+ * OTG sub-state definitions+***********************************/++#define OTG_STATE_MASK                  0x0F++#define OTG_STATE_NO_B_DEVICE_A         (0x60 | OTG_STATE_UNDEFINED)+#define OTG_STATE_NO_B_DEVICE_B         (0x40 | OTG_STATE_UNDEFINED)++#define OTG_STATE_B_HOST_WT             (0x10 | OTG_STATE_B_HOST)+#define OTG_STATE_B_PERIPHERAL_WT       (0x10 | OTG_STATE_B_PERIPHERAL)+#define OTG_STATE_B_PERIPHERAL_DC       (0x20 | OTG_STATE_B_PERIPHERAL)+#define OTG_STATE_B_SRP_WAIT_SE0        (0x10 | OTG_STATE_B_SRP_INIT)+#define OTG_STATE_B_SRP_D_PULSE         (0x20 | OTG_STATE_B_SRP_INIT)+#define OTG_STATE_B_SRP_V_PULSE         (0x30 | OTG_STATE_B_SRP_INIT)+#define OTG_STATE_B_SRP_V_DCHRG         (0x40 | OTG_STATE_B_SRP_INIT)+#define OTG_STATE_B_SRP_WAIT_VBUS       (0x50 | OTG_STATE_B_SRP_INIT)++#define OTG_STATE_A_IDLE_WAIT_DP        (0x10 | OTG_STATE_A_IDLE)+#define OTG_STATE_A_IDLE_WAIT_VP        (0x20 | OTG_STATE_A_IDLE)+#define OTG_STATE_A_IDLE_WAIT_MP        (0x30 | OTG_STATE_A_IDLE)+#define OTG_STATE_A_IDLE_WAIT_DV        (0x40 | OTG_STATE_A_IDLE)+#define OTG_STATE_A_WAIT_BCON_VB        (0x10 | OTG_STATE_A_WAIT_BCON)+#define OTG_STATE_A_WAIT_VFALL_DN       (0x10 | OTG_STATE_A_WAIT_VFALL)+++/**********************************+*  typical timer values+**********************************/++#define OTG_TMR_WAIT_VFALL     10   /* (  ) A waits for VBus                 */+#define OTG_TMR_A_WAIT_VRISE   100  /* (  ) A waits for VBus                 */+#define OTG_TMR_A_WAIT_BCON    200  /* (  ) A waits for B-connect (1.. s)    */+#define OTG_TMR_A_IDLE_BDIS    250  /* (ms) A waits for B-disc (200.. ms)    */+#define OTG_TMR_B_WAIT_ADISCON 600  /* (us) B waits for A to disconnect <1ms */+#define OTG_TMR_B_ACON_BRST    200  /* (us) B waits before starting reset    */+#define OTG_TMR_B_ASE0_BRST    5    /* (ms) B waits for A-conn (3.125.. ms)  */+#define OTG_TMR_B_AIDL_BDIS    50   /* (ms) B waits before dc (5..150ms)     */+#define OTG_TMR_SRP_WAIT_SE0   2    /* (  ) B SRP idle wait                  */+#define OTG_TMR_SRP_WAIT_DP    7    /* (ms) B SRP D_PULSE (5..10ms)          */+#define OTG_TMR_SRP_WAIT_VP    80   /* (ms) B SRP V_PULSE (5..100ms)         */+#define OTG_TMR_SRP_DCHRG_V    30   /* (  ) B SRP VBus discharge             */+#define OTG_TMR_SRP_WAIT_VRS   5800 /* (ms) B SRP waits for VBus (5..6s)     */+#define OTG_TMR_ASRP_WAIT_MP   4    /* (  ) A SRP min. pulse                 */+#define OTG_TMR_ASRP_WAIT_DP   10   /* (ms) A SRP D_PULSE TO                 */+#define OTG_TMR_ASRP_WAIT_VP   200  /* (ms) A SRP V_PULSE TO                 */+#define OTG_TMR_ASRP_WAIT_DV   200  /* (  ) A SRP waits for V_PULSE          */+#define OTG_TMR_A_BCON_VB      50   /* (  ) A waits for VBus after connect   */++#define OTG_TMR_IDSNS_WAIT     10   /* (ms) ID sense wait                    */++/*********************************/++#define TIMER_PERIOD           1000      /* 10 ms, if longer than 10ms       */++/**********************************+ * OTG state parameters+ **********************************/++#define OTG_HOST_READY         (1<<20)   /* indicates a USB host driver is   */+                                         /* running                          */+#define OTG_GADGET_READY       (1<<21)   /* indicates a USB gadget driver is */+                                         /* running                          */+#define OTG_A_BUS_REQ          (1<<22)   /* used by appl-SW to request a     */+                                         /* VBus rise, auto-reset by driver  */+#define OTG_A_BUS_DROP         (1<<23)   /* used by appl-SW to request a     */+                                         /* VBus drop, auto-reset by driver  */+#define OTG_A_CLR_ERR          (1<<24)   /* used by appl-SW to request VBerr */+                                         /* clean-up, auto-reset by driver   */+#define OTG_AB_HNP_REQ         (1<<25)   /* used by appl-SW to initiate      */+                                         /* HNP, auto-reset by driver        */+#define OTG_B_BUS_REQ          (1<<26)   /* used by appl-SW to request       */+                                         /* B-device functionality, ...      */+#define OTG_B_BUS_DIS          (1<<27)   /* used by appl-SW to request       */+                                         /* disable B-device functionality   */+#define OTG_B_aSSN_REQ         (1<<28)   /* used by appl-SW to initiate SRP, */+                                         /* auto-reset by the driver         */+#define OTG_B_SRP_ERROR        (1<<29)   /* indicates invalid HW conditions  */+                                         /* during SRP, reset by writing "1" */+#define OTG_A_VBUS_FAILED      (1<<30)   /* indicates a VBus error, reset by */+                                         /* writing "1", when setting        */+                                         /* CLR_ERR or when leaving A-states */+#define OTG_UDC_RWK_REQ        (1<<31)   /* call UDC function to force a     */+                                         /* remote wake-up                   */++#define SW_REQUEST_MASK        (OTG_A_BUS_REQ | OTG_A_BUS_DROP | \+                                OTG_A_CLR_ERR | OTG_B_aSSN_REQ | \+                                OTG_B_BUS_REQ | OTG_B_BUS_DIS | \+                                OTG_UDC_RWK_REQ)++/*********************************************************************/++/*+ * gadget events for notify function+ */+#define OTG_GADGET_EVT_SVDROP  (1<<0)    /* Session valid drop       */+#define OTG_GADGET_EVT_SVALID  (1<<1)    /* Session valid            */+#define OTG_GADGET_REQ_WAKE    (1<<2)    /* Request remote wake-up   */++/*** HS-A0 WA: gadget phy suspend issue                            ***/+#define OTG_FLAGS_UDC_SUSP     (1<<17)   /* gadget phy suspended     */+++/*****************************************************************************+*  Types+*****************************************************************************/+++/*****************************************************************************+*  Macros+*****************************************************************************/+++/*****************************************************************************+*  Data+*****************************************************************************/+#ifdef __cplusplus+extern "C"+{+#endif++struct usb_otg_gadget_extension {+	int (*request) (u32);	/* function call for state change requests */+	u32 (*query) (int);	/* function call to query state            */+	void (*notify) (u32);   /* filled in by gadget for notification    */+};++#ifdef __cplusplus+} /* extern "C" */+#endif+++/*****************************************************************************+*  Functions+*****************************************************************************/+#ifdef __cplusplus+extern "C"+{+#endif+++#ifdef __cplusplus+} /* extern "C" */+#endif+++/*****************************************************************************+*  Inline Functions+*****************************************************************************/+++#endif /* AMD5536OTG_H */diff -Nru linux26-cvs/drivers/usb/gadget/amd5536udc.c linux.amd/drivers/usb/gadget/amd5536udc.c--- linux26-cvs/drivers/usb/gadget/amd5536udc.c	1970-01-01 01:00:00.000000000 +0100+++ linux.amd/drivers/usb/gadget/amd5536udc.c	2005-11-28 15:03:27.000000000 +0100@@ -0,0 +1,4723 @@+/*+ * AMD 5536 UDC high/full speed USB device controller.+ */++/*+ * Copyright (C) 2005 AMD (http://www.amd.com)+ * Author: Thomas Dahlmann + *+ * This program is free software; you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation; either version 2 of the License, or+ * (at your option) any later version.+ *+ * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA+ */++/*****************************************************************************+ * Defines+ *****************************************************************************/++/* debug control */+#undef UDC_DEBUG+//DISABLEDamd #define UDC_DEBUG     1+#undef UDC_VERBOSE+//DISABLEDamd #define   UDC_VERBOSE         +//DISABLEDamd #define UDC_REGISTER_DUMP++/* device driver registration of kernel 2.6.x usage */+//#define UDC_USE_DRIVER_REGISTER++/* Driver strings */+#define UDC_MOD_DESCRIPTION         "AMD 5536 UDC - USB Device Controller"+#define UDC_DRIVER_VERSION_STRING   "01.00.0201 - $Revision: #26 $"++/* kernel version of new gadget stack generation (for 2.6.x) */+#define UDC_NEW_GADGET_KERNEL KERNEL_VERSION(2,5,59)++/*****************************************************************************+ *  Includes+ *****************************************************************************/++/* system */+#include <linux/config.h>+#include <linux/module.h>+#include <linux/pci.h>+#include <linux/kernel.h>+#include <linux/version.h>+#include <linux/delay.h>+#include <linux/ioport.h>+#include <linux/sched.h>+#include <linux/slab.h>+#include <linux/smp_lock.h>+#include <linux/errno.h>+#include <linux/init.h>+#include <linux/timer.h>+#include <linux/list.h>+#include <linux/interrupt.h>+#include <linux/ioctl.h>+#include <linux/fs.h>+#if     LINUX_VERSION_CODE < UDC_NEW_GADGET_KERNEL+#include <linux/wrapper.h>+#else+#include <linux/dmapool.h>+#include <linux/moduleparam.h>+#include <linux/device.h>+#endif+#include <asm/byteorder.h>+#include <asm/io.h>+#include <asm/irq.h>+#include <asm/system.h>+#include <asm/unaligned.h>++/* MIPS config */+#ifdef CONFIG_SOC_AU1200+#if     LINUX_VERSION_CODE < UDC_NEW_GADGET_KERNEL+#include <asm/au1000.h>+#else+#include <asm/mach-au1x00/au1000.h>+#endif+#ifndef CONFIG_USB_NON_PCI_OTGDEVICE+#define CONFIG_USB_NON_PCI_OTGDEVICE+#endif+#endif++/* gadget stack */+#include <linux/usb_ch9.h>+#include <linux/usb_gadget.h>+#include <linux/usb_otg.h>+#include "amd5536otg.h"++/* udc specific */+#include "amd5536udc.h"++/* use RDE timer for new kernel only */+#if   LINUX_VERSION_CODE >= UDC_NEW_GADGET_KERNEL+#define UDC_USE_TIMER+#endif+/*****************************************************************************+ *  Static Function Declarations+ *****************************************************************************/++void udc_tasklet_disconnect(unsigned long);+#ifdef UDC_USE_TIMER+void udc_timer_function(unsigned long v);+void udc_pollstall_timer_function(unsigned long v);+#endif+static int udc_rxfifo_read_dwords(struct udc* dev, u32* buf, int dwords);+static void empty_req_queue (struct udc_ep *);+static int udc_probe (struct pci_dev *pdev, const struct pci_device_id *id);+static void udc_remove (struct pci_dev *pdev);+static void udc_basic_init (struct udc *dev);+static void udc_setup_endpoints (struct udc *dev);+static void udc_soft_reset(struct udc* dev);+#ifdef UDC_DEBUG+static void dump_buffer(u8* buf, u32 bytes);+static int udc_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);+static int udc_open (struct inode *inode, struct file *file);+static int udc_release (struct inode *inode, struct file *file);+#endif+static struct udc_data_dma* udc_get_last_dma_desc(struct udc_request* req);+static u32 udc_get_ppbdu_rxbytes(struct udc_request* req);+static int udc_free_dma_chain(struct udc* dev, struct udc_request* req);+static int udc_create_dma_chain(struct udc_ep* ep, struct udc_request* req, unsigned long buf_len, int gfp_flags);+static inline int startup_registers(struct udc* dev);+#ifdef CONFIG_SOC_AU1200+void au1200_sync(void);+#endif+static int udc_remote_wakeup(struct udc* dev);+#ifdef UDC_USE_DRIVER_REGISTER+static int udc_suspend(struct udc* dev);+static int udc_resume(struct udc* dev);+#endif++/*****************************************************************************+ *  Data+ *****************************************************************************/++/* description */+static const char mod_desc [] = UDC_MOD_DESCRIPTION;+static const char name [] =     DRIVER_NAME_FOR_PRINT; ++/* structure to hold endpoint function pointers */+static struct usb_ep_ops udc_ep_ops;++/* received setup data */+static union udc_setup_data setup_data;++/* pointer to device object */      +static struct udc       *udc;++/* irq spin lock for soft reset */+spinlock_t udc_irq_spinlock;+/* stall spin lock */+spinlock_t udc_stall_spinlock;++/* TODO this is used for dma chaining, global gfp not good */+static int udc_gfp_flags = 0;+        +/* slave mode: pending bytes in rx fifo after nyet,+used if EPIN irq came but no req was available */+static unsigned int udc_rxfifo_pending = 0;++/* count soft resets after suspend to avoid loop */+static int soft_reset_occured = 0;+#ifdef UDC_IPBUG_3958_WORKAROUND_SOFT_RESET_ON_USBRESET+static int soft_reset_after_usbreset_occured = 0;+#endif++#ifdef UDC_USE_TIMER+/* timer */+static struct timer_list udc_timer;+static int stop_timer = 0;+int set_rde = -1;+DECLARE_COMPLETION(on_exit);+static struct timer_list udc_pollstall_timer;+static int stop_pollstall_timer = 0;+DECLARE_COMPLETION(on_pollstall_exit);+#endif++/* tasklet for usb disconnect */+DECLARE_TASKLET(disconnect_tasklet, udc_tasklet_disconnect, (unsigned long) &udc);++#ifdef CONFIG_USB_NON_PCI_OTGDEVICE+static struct pci_dev pdev_dummy;+static struct pci_dev* pdev = &pdev_dummy;+#endif++#ifdef UDC_IPBUG_3958_WORKAROUND+/* CNAK pending field: bit0 = ep0in, bit16 = ep0out */+static u32 cnak_pending = 0;+#define UDC_QUEUE_CNAK(ep, num) \+        if (readl(&((ep)->regs->ctl)) & AMD_BIT(UDC_EPCTL_NAK)) { \+                DBG("NAK could not be cleared for ep%d\n", num); \+                cnak_pending |= 1 << (num); \+                (ep)->naking = 1; \+        } \+        else \+                cnak_pending = cnak_pending & (~(1<<(num))); +#else+#define UDC_QUEUE_CNAK(ep, num) {} +#endif+#ifdef UDC_IPBUG_3958_WORKAROUND_RXFIFO_FLUSH+/* rxfifo cleari/trash buffer */+static u8 udc_rxfifo_trash[UDC_RXFIFO_SIZE];+#endif++#ifdef UDC_IPBUG_3943_WORKAROUND+/* otg registering count */+static u32 otg_reg_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -