📄 1024.usb.patch
字号:
+ * acts like a qh would, if EHCI had them for ISO.+ */+struct ehci_iso_stream {+ /* first two fields match QH, but info1 == 0 */+ u32 hw_next;+ u32 hw_info1;++ u32 refcount;+ u8 bEndpointAddress;+ struct list_head itd_list; /* queued itds */+ struct list_head free_itd_list; /* list of unused itds */+ struct hcd_dev *dev;++ /* output of (re)scheduling */+ unsigned long start; /* jiffies */+ unsigned long rescheduled;+ int next_uframe;++ /* the rest is derived from the endpoint descriptor,+ * trusting urb->interval == (1 << (epdesc->bInterval - 1)),+ * including the extra info for hw_bufp[0..2]+ */+ u8 interval;+ u8 usecs; + u16 maxp;+ unsigned bandwidth;++ /* This is used to initialize iTD's hw_bufp fields */+ u32 buf0; + u32 buf1; + u32 buf2;++ /* ... sITD won't use buf[012], and needs TT access ... */+};++/*-------------------------------------------------------------------------*/++/*+ * EHCI Specification 0.95 Section 3.3+ * Fig 3-4 "Isochronous Transaction Descriptor (iTD)"+ *+ * Schedule records for high speed iso xfers+ */+struct ehci_itd {+ /* first part defined by EHCI spec */+ u32 hw_next; /* see EHCI 3.3.1 */+ u32 hw_transaction [8]; /* see EHCI 3.3.2 */+#define EHCI_ISOC_ACTIVE (1<<31) /* activate transfer this slot */+#define EHCI_ISOC_BUF_ERR (1<<30) /* Data buffer error */+#define EHCI_ISOC_BABBLE (1<<29) /* babble detected */+#define EHCI_ISOC_XACTERR (1<<28) /* XactErr - transaction error */+#define EHCI_ITD_LENGTH(tok) (((tok)>>16) & 0x0fff)+#define EHCI_ITD_IOC (1 << 15) /* interrupt on complete */++#define ISO_ACTIVE __constant_cpu_to_le32(EHCI_ISOC_ACTIVE)++ u32 hw_bufp [7]; /* see EHCI 3.3.3 */ + u32 hw_bufp_hi [7]; /* Appendix B */++ /* the rest is HCD-private */+ dma_addr_t itd_dma; /* for this itd */+ union ehci_shadow itd_next; /* ptr to periodic q entry */++ struct urb *urb;+ struct ehci_iso_stream *stream; /* endpoint's queue */+ struct list_head itd_list; /* list of stream's itds */++ /* any/all hw_transactions here may be used by that urb */+ unsigned frame; /* where scheduled */+ unsigned pg;+ unsigned index[8]; /* in urb->iso_frame_desc */+ u8 usecs[8];+} __attribute__ ((aligned (32)));++/*-------------------------------------------------------------------------*/++/*+ * EHCI Specification 0.95 Section 3.4 + * siTD, aka split-transaction isochronous Transfer Descriptor+ * ... describe low/full speed iso xfers through TT in hubs+ * see Figure 3-5 "Split-transaction Isochronous Transaction Descriptor (siTD)+ */+struct ehci_sitd {+ /* first part defined by EHCI spec */+ u32 hw_next;+/* uses bit field macros above - see EHCI 0.95 Table 3-8 */+ u32 hw_fullspeed_ep; /* see EHCI table 3-9 */+ u32 hw_uframe; /* see EHCI table 3-10 */+ u32 hw_tx_results1; /* see EHCI table 3-11 */+ u32 hw_tx_results2; /* see EHCI table 3-12 */+ u32 hw_tx_results3; /* see EHCI table 3-12 */+ u32 hw_backpointer; /* see EHCI table 3-13 */+ u32 hw_buf_hi [2]; /* Appendix B */++ /* the rest is HCD-private */+ dma_addr_t sitd_dma;+ union ehci_shadow sitd_next; /* ptr to periodic q entry */+ struct urb *urb;+ dma_addr_t buf_dma; /* buffer address */++ unsigned short usecs; /* start bandwidth */+ unsigned short c_usecs; /* completion bandwidth */+} __attribute__ ((aligned (32)));++/*-------------------------------------------------------------------------*/++/*+ * EHCI Specification 0.96 Section 3.7+ * Periodic Frame Span Traversal Node (FSTN)+ *+ * Manages split interrupt transactions (using TT) that span frame boundaries+ * into uframes 0/1; see 4.12.2.2. In those uframes, a "save place" FSTN+ * makes the HC jump (back) to a QH to scan for fs/ls QH completions until+ * it hits a "restore" FSTN; then it returns to finish other uframe 0/1 work.+ */+struct ehci_fstn {+ u32 hw_next; /* any periodic q entry */+ u32 hw_prev; /* qh or EHCI_LIST_END */++ /* the rest is HCD-private */+ dma_addr_t fstn_dma;+ union ehci_shadow fstn_next; /* ptr to periodic q entry */+} __attribute__ ((aligned (32)));++/*-------------------------------------------------------------------------*/++#include <linux/version.h>+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,32)++#define SUBMIT_URB(urb,mem_flags) usb_submit_urb(urb)+#define STUB_DEBUG_FILES++static inline int hcd_register_root (struct usb_hcd *hcd)+{+ return usb_new_device (hcd_to_bus (hcd)->root_hub);+}++#else /* LINUX_VERSION_CODE */++// hcd_to_bus() eventually moves to hcd.h on 2.5 too+static inline struct usb_bus *hcd_to_bus (struct usb_hcd *hcd)+ { return &hcd->self; }+// ... as does hcd_register_root()+static inline int hcd_register_root (struct usb_hcd *hcd)+{+ return usb_register_root_hub (+ hcd_to_bus (hcd)->root_hub, &hcd->pdev->dev);+}++#define SUBMIT_URB(urb,mem_flags) usb_submit_urb(urb,mem_flags)++#ifndef DEBUG+#define STUB_DEBUG_FILES+#endif /* DEBUG */++#endif /* LINUX_VERSION_CODE */++/*-------------------------------------------------------------------------*/++#endif /* __LINUX_EHCI_HCD_H */diff -Naur --exclude=CVS --exclude='*.o' --exclude='*.a' --exclude='*.so' --exclude='*.elf' --exclude=System.map --exclude=Makefile.d --exclude='*log' --exclude='*log2' --exclude='*~' --exclude='.*~' --exclude='.#*' --exclude='*.bak' --exclude='*.orig' --exclude='*.rej' --exclude='core.[0-9]*' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=.depend --exclude='.*.o.flags' --exclude='*.gz' --exclude=vmlinux --exclude=vmlinux.bin --exclude=yamon-02.06-SIGMADESIGNS-01_el.bin linuxmips-2.4.30.ref/drivers/usb/host/tango2-ehci-hcd.c linuxmips-2.4.30/drivers/usb/host/tango2-ehci-hcd.c--- linuxmips-2.4.30.ref/drivers/usb/host/tango2-ehci-hcd.c 1969-12-31 16:00:00.000000000 -0800+++ linuxmips-2.4.30/drivers/usb/host/tango2-ehci-hcd.c 2007-06-20 14:14:22.000000000 -0700@@ -0,0 +1,1163 @@+/*+ * Copyright (c) 2000-2002 by David Brownell+ * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA.+ */++#include <linux/config.h>+#include <linux/module.h>+#include <linux/pci.h>+#include <linux/kernel.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/reboot.h>+#include <linux/bitops.h> /* for generic_ffs */++#ifdef CONFIG_USB_DEBUG+ #define DEBUG+#else+ #undef DEBUG+#endif++#include <linux/usb.h>++#include <linux/version.h>+#include "../hcd.h"++#include <asm/byteorder.h>+#include <asm/io.h>+#include <asm/irq.h>+#include <asm/system.h>+#include <asm/unaligned.h>++#include "../tango2-usb.h"++/*-------------------------------------------------------------------------*/++/*+ * EHCI hc_driver implementation ... experimental, incomplete.+ * Based on the final 1.0 register interface specification.+ *+ * USB 2.0 shows up in upcoming www.pcmcia.org technology.+ * First was PCMCIA, like ISA; then CardBus, which is PCI.+ * Next comes "CardBay", using USB 2.0 signals.+ *+ * Contains additional contributions by Brad Hards, Rory Bolt, and others.+ * Special thanks to Intel and VIA for providing host controllers to+ * test this driver on, and Cypress (including In-System Design) for+ * providing early devices for those host controllers to talk to!+ *+ * HISTORY:+ *+ * 2003-12-29 Rewritten high speed iso transfer support (by Michal Sojka,+ * <sojkam@centrum.cz>, updates by DB).+ *+ * 2002-11-29 Correct handling for hw async_next register.+ * 2002-08-06 Handling for bulk and interrupt transfers is mostly shared;+ * only scheduling is different, no arbitrary limitations.+ * 2002-07-25 Sanity check PCI reads, mostly for better cardbus support,+ * clean up HC run state handshaking.+ * 2002-05-24 Preliminary FS/LS interrupts, using scheduling shortcuts+ * 2002-05-11 Clear TT errors for FS/LS ctrl/bulk. Fill in some other+ * missing pieces: enabling 64bit dma, handoff from BIOS/SMM.+ * 2002-05-07 Some error path cleanups to report better errors; wmb();+ * use non-CVS version id; better iso bandwidth claim.+ * 2002-04-19 Control/bulk/interrupt submit no longer uses giveback() on+ * errors in submit path. Bugfixes to interrupt scheduling/processing.+ * 2002-03-05 Initial high-speed ISO support; reduce ITD memory; shift+ * more checking to generic hcd framework (db). Make it work with+ * Philips EHCI; reduce PCI traffic; shorten IRQ path (Rory Bolt).+ * 2002-01-14 Minor cleanup; version synch.+ * 2002-01-08 Fix roothub handoff of FS/LS to companion controllers.+ * 2002-01-04 Control/Bulk queuing behaves.+ *+ * 2001-12-12 Initial patch version for Linux 2.5.1 kernel.+ * 2001-June Works with usb-storage and NEC EHCI on 2.4+ */++#define DRIVER_VERSION "2003-Dec-29/2.4"+#define DRIVER_AUTHOR "David Brownell"+#define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver"++#undef EHCI_VERBOSE_DEBUG+#undef EHCI_URB_TRACE++// #define have_split_iso++#ifdef DEBUG+#define EHCI_STATS+#endif++#define INTR_AUTOMAGIC /* urb lifecycle mode, gone in 2.5 */++/* magic numbers that can affect system performance */+#define EHCI_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */+#define EHCI_TUNE_RL_HS 4 /* nak throttle; see 4.9 */+#define EHCI_TUNE_RL_TT 0+#define EHCI_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */+#define EHCI_TUNE_MULT_TT 1+#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */++#define EHCI_IAA_JIFFIES (HZ/100) /* arbitrary; ~10 msec */+#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */+#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */+#define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */++/* Initial IRQ latency: lower than default */+static int log2_irq_thresh = 0; // 0 to 6+MODULE_PARM (log2_irq_thresh, "i");+MODULE_PARM_DESC (log2_irq_thresh, "log2 IRQ latency, 1-64 microframes");++/* initial park setting: slower than hw default */+static unsigned park = 0;+MODULE_PARM (park, "i");+MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets");+++#define INTR_MASK (STS_IAA | STS_FATAL | STS_ERR | STS_INT)++/* stuff need from hcd.c */+#define EHCI_BUS_NAME "tango2-ehci-bus"+#define EHCI_PRODUCT_DESC "Tango2 Integrated USB 2.0"+#define hcd_name "tango2-ehci-hcd"++static LIST_HEAD (hcd_list);+static DECLARE_MUTEX (tango2_hcd_list_lock);+struct usb_hcd *this_hcd;+extern int hcd_alloc_dev (struct usb_device *udev);+extern int hcd_get_frame_number (struct usb_device *udev);+extern int tango2_hcd_submit_urb (struct urb *urb);+extern int hcd_unlink_urb (struct urb *urb);+extern int hcd_free_dev (struct usb_device *udev);+extern void hcd_irq (int irq, void *__hcd, struct pt_regs *r);+static struct usb_operations tango2_hcd_operations = {+ allocate: hcd_alloc_dev,+ get_frame_number: hcd_get_frame_number,+ submit_urb: tango2_hcd_submit_urb,+ unlink_urb: hcd_unlink_urb,+ deallocate: hcd_free_dev,+};++++/*-------------------------------------------------------------------------*/++#include "tango2-ehci.h"+#include "tango2-ehci-dbg.c"++/*-------------------------------------------------------------------------*/++/*+ * handshake - spin reading hc until handshake completes or fails+ * @ptr: address of hc register to be read+ * @mask: bits to look at in result of read+ * @done: value of those bits when handshake succeeds+ * @usec: timeout in microseconds+ *+ * Returns negative errno, or zero on success+ *+ * Success happens when the "mask" bits have the specified value (hardware+ * handshake done). There are two failure modes: "usec" have passed (major+ * hardware flakeout), or the register reads as all-ones (hardware removed).+ *+ * That last failure should_only happen in cases like physical cardbus eject+ * before driver shutdown. But it also seems to be caused by bugs in cardbus+ * bridge shutdown: shutting down the bridge before the devices using it.+ */+static int handshake (u32 *ptr, u32 mask, u32 done, int usec)+{+ u32 result;++ do {+ result = readl (ptr);+ if (result == ~(u32)0) /* card removed */+ return -ENODEV;+ result &= mask;+ if (result == done)+ return 0;+ udelay (1);+ usec--;+ } while (usec > 0);+ return -ETIMEDOUT;+}++/*+ * hc states include: unknown, halted, ready, running+ * transitional states are messy just now+ * trying to avoid "running" unless urbs are active+ * a "ready" hc can be finishing prefetched work+ */++/* force HC to halt state from unknown (EHCI spec section 2.3) */+static int ehci_halt (struct ehci_hcd *ehci)+{+ u32 temp = readl (&ehci->regs->status);++ if ((temp & STS_HALT) != 0)+ return 0;++ temp = readl (&ehci->regs->command);+ temp &= ~CMD_RUN;+ writel (temp, &ehci->regs->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -