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

📄 patch-2.4.4-sl811hs

📁 This is cypress sl811 driver. I think it is very useful. Thankyou.
💻 4-SL811HS
📖 第 1 页 / 共 5 页
字号:
+#define RH_PORT_CONNECTION         0x00
+#define RH_PORT_ENABLE             0x01
+#define RH_PORT_SUSPEND            0x02
+#define RH_PORT_OVER_CURRENT       0x03
+#define RH_PORT_RESET              0x04
+#define RH_PORT_POWER              0x08
+#define RH_PORT_LOW_SPEED          0x09
+
+#define RH_C_PORT_CONNECTION       0x10
+#define RH_C_PORT_ENABLE           0x11
+#define RH_C_PORT_SUSPEND          0x12
+#define RH_C_PORT_OVER_CURRENT     0x13
+#define RH_C_PORT_RESET            0x14  
+
+/* Hub features */
+#define RH_C_HUB_LOCAL_POWER       0x00
+#define RH_C_HUB_OVER_CURRENT      0x01
+
+#define RH_DEVICE_REMOTE_WAKEUP    0x00
+#define RH_ENDPOINT_STALL          0x01
+
+#endif
+
+
+/*-------------------------------------------------------------------------*/
+/* struct for each HC 
+ * */
+
+#define MAX_TRANS 32
+
+typedef struct td {
+		urb_t * urb; 
+		__u16 len;
+		__u16 iso_index;
+} td_t;
+
+typedef struct td_array {
+	int len;
+	td_t td [MAX_TRANS];
+} td_array_t;
+
+typedef struct hci {
+	struct virt_root_hub rh;		/* roothub */
+	wait_queue_head_t waitq;		/* deletion of URBs and devices needs a waitqueue */
+	int active;						/* HC is operating */
+	
+	struct list_head ctrl_list;		/* set of ctrl endpoints */
+	struct list_head bulk_list;		/* set of bulk endpoints */
+	struct list_head iso_list;		/* set of isoc endpoints */
+	struct list_head intr_list;		/* ordered (tree) set of int endpoints */
+	struct list_head del_list;		/* set of entpoints to be deleted */
+
+	td_array_t * td_array; 
+	td_array_t a_td_array;
+	td_array_t i_td_array [2];
+
+ 	struct list_head hci_hcd_list;	/* list of all hci_hcd */
+  	struct usb_bus * bus;    		/* our bus */
+
+//	int trans;						/* number of transactions pending */
+	int active_urbs;
+        int active_trans;
+	int frame_number;					/* frame number */
+	hcipriv_t hp;			/* individual part of hc type */
+	int nakCnt;
+	int last_packet_nak;
+
+} hci_t;
+
+
+/*-------------------------------------------------------------------------*/
+/* condition (error) CC codes and mapping OHCI like
+ * */
+ 
+#define TD_CC_NOERROR      0x00
+#define TD_CC_CRC          0x01
+#define TD_CC_BITSTUFFING  0x02
+#define TD_CC_DATATOGGLEM  0x03
+#define TD_CC_STALL        0x04
+#define TD_DEVNOTRESP      0x05
+#define TD_PIDCHECKFAIL    0x06
+#define TD_UNEXPECTEDPID   0x07
+#define TD_DATAOVERRUN     0x08
+#define TD_DATAUNDERRUN    0x09
+#define TD_BUFFEROVERRUN   0x0C
+#define TD_BUFFERUNDERRUN  0x0D
+#define TD_NOTACCESSED     0x0F
+
+// static int cc_to_error[16] = { 
+
+/* mapping of the OHCI CC status to error codes */ 
+//	/* No  Error  */               USB_ST_NOERROR,
+//	/* CRC Error  */               USB_ST_CRC,
+//	/* Bit Stuff  */               USB_ST_BITSTUFF,
+//	/* Data Togg  */               USB_ST_CRC,
+//	/* Stall      */               USB_ST_STALL,
+//	/* DevNotResp */               USB_ST_NORESPONSE,
+//	/* PIDCheck   */               USB_ST_BITSTUFF,
+//	/* UnExpPID   */               USB_ST_BITSTUFF,
+//	/* DataOver   */               USB_ST_DATAOVERRUN,
+//	/* DataUnder  */               USB_ST_DATAUNDERRUN,
+//	/* reservd    */               USB_ST_NORESPONSE,
+//	/* reservd    */               USB_ST_NORESPONSE,
+//	/* BufferOver */               USB_ST_BUFFEROVERRUN,
+//	/* BuffUnder  */               USB_ST_BUFFERUNDERRUN,
+//	/* Not Access */               USB_ST_NORESPONSE,
+//	/* Not Access */               USB_ST_NORESPONSE 
+//};
+
+
+/*-------------------------------------------------------------------------*/
+/* PID - packet ID 
+ * */
+#if 0 
+#define PID_SETUP	0
+#define PID_OUT		1
+#define PID_IN		2
+#endif
+/*-------------------------------------------------------------------------*/
+/* misc 
+ * */
+
+#define min(a,b) (((a)<(b))?(a):(b))  
+// #define GET_FRAME_NUMBER(hci) (hci)->frame_number
+
+/*-------------------------------------------------------------------------*/
+/* functions
+ * */
+ 
+/* urb interface functions */
+static int hci_get_current_frame_number (struct usb_device *usb_dev);
+static int hci_unlink_urb (urb_t * urb);
+
+static int qu_queue_urb (hci_t * hci, urb_t * urb);
+
+
+/* root hub */
+static int rh_init_int_timer (urb_t * urb);
+static int rh_submit_urb (urb_t *urb);
+static int rh_unlink_urb (urb_t *urb);
+
+/* schedule functions */
+static int sh_add_packet (hci_t * hci, urb_t * urb);
+
+/* hc specific functions */
+static inline void hc_flush_data_cache (hci_t * hci, void * data, int len);
+static inline int hc_parse_trans (hci_t * hci, int * actbytes, __u8 * data, 
+			int * cc, int * toggle, int length, int pid, int urb_state);
+static inline int hc_add_trans (hci_t * hci, int len, void * data,
+		int toggle, int maxps, int slow, int endpoint, int address, 
+		int pid, int format, int urb_state);
+
+static void hc_start_int (hci_t * hci);
+static void hc_stop_int (hci_t * hci);
+static void SL811Write (hci_t * hci, char offset, char data);
+
+/* debug| print the main components of an URB     
+ * small: 0) header + data packets 1) just header */
+
+static void urb_print (urb_t * urb, char * str, int small)
+{
+	unsigned int pipe= urb->pipe;
+	int i, len;
+	
+	if (!urb->dev || !urb->dev->bus) {
+		dbg("%s URB: no dev", str);
+		return;
+	}
+	
+	printk("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,flags:%4x,len:%d/%d,stat:%d(%x)\n", 
+			str,
+		 	hci_get_current_frame_number (urb->dev), 
+		 	usb_pipedevice (pipe),
+		 	usb_pipeendpoint (pipe), 
+		 	usb_pipeout (pipe)? 'O': 'I',
+		 	usb_pipetype (pipe) < 2? (usb_pipeint (pipe)? "INTR": "ISOC"):
+		 		(usb_pipecontrol (pipe)? "CTRL": "BULK"),
+		 	urb->transfer_flags, 
+		 	urb->actual_length, 
+		 	urb->transfer_buffer_length,
+		 	urb->status, urb->status);
+	if (!small) {
+		if (usb_pipecontrol (pipe)) {
+			printk ( __FILE__ ": cmd(8):");
+			for (i = 0; i < 8 ; i++) 
+				printk (" %02x", ((__u8 *) urb->setup_packet) [i]);
+			printk ("\n");
+		}
+		if (urb->transfer_buffer_length > 0 && urb->transfer_buffer) {
+			printk ( __FILE__ ": data(%d/%d):", 
+				urb->actual_length, 
+				urb->transfer_buffer_length);
+			len = usb_pipeout (pipe)? 
+						urb->transfer_buffer_length: urb->actual_length;
+			for (i = 0; i < 2096 && i < len; i++) 
+				printk (" %02x", ((__u8 *) urb->transfer_buffer) [i]);
+			printk ("%s stat:%d\n", i < len? "...": "", urb->status);
+		}
+	} 
+}
+
diff -urN -X dontdiff linux-vanilla/drivers/usb/hc_sl811.c linux/drivers/usb/hc_sl811.c
--- linux-vanilla/drivers/usb/hc_sl811.c	Wed Dec 31 17:00:00 1969
+++ linux/drivers/usb/hc_sl811.c	Fri Feb  8 16:56:39 2002
@@ -0,0 +1,1474 @@
+/*-------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*
+ * SL811HS USB HCD for Linux Version 0.1 (10/28/2001)
+ * 
+ * requires (includes) hc_simple.[hc] simple generic HCD frontend
+ *  
+ * COPYRIGHT(C) 2001 by CYPRESS SEMICONDUCTOR INC.
+ *
+ *-------------------------------------------------------------------------*
+ * 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
+ *
+ *-------------------------------------------------------------------------*/
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
+#include <linux/malloc.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/smp_lock.h>
+#include <linux/list.h>
+#include <linux/ioport.h>
+#include <asm/io.h>
+#include <asm/arch/irq.h>
+
+#include <linux/usb.h>
+
+#undef HC_URB_TIMEOUT
+#undef HC_SWITCH_INT
+#undef HC_ENABLE_ISOC
+
+#define SL811_DEBUG_ERR
+
+#ifdef SL811_DEBUG_ERR
+#define DBGERR(fmt, args...) printk(fmt,## args)
+#else
+#define DBGERR(fmt, args...)
+#endif
+
+#ifdef SL811_DEBUG
+#define DBG(fmt, args...) printk(fmt,## args)
+#else
+#define DBG(fmt, args...)
+#endif
+
+#ifdef SL811_DEBUG_FUNC
+#define DBGFUNC(fmt, args...) printk(fmt,## args)
+#else
+#define DBGFUNC(fmt, args...)
+#endif
+
+#ifdef SL811_DEBUG_DATA
+#define DBGDATAR(fmt, args...) printk(fmt,## args)
+#define DBGDATAW(fmt, args...) printk(fmt,## args)
+#else
+#define DBGDATAR(fmt, args...)
+#define DBGDATAW(fmt, args...)
+#endif
+
+#ifdef SL811_DEBUG_VERBOSE
+#define DBGVERBOSE(fmt, args...) printk(fmt,## args)
+#else
+#define DBGVERBOSE(fmt, args...)
+#endif
+
+#define TRUE 1
+#define FALSE 0
+
+#define HC_SWITCH_INT
+#include "hc_sl811.h"
+#include "hc_simple.h"
+
+static int urb_debug = 0;
+ 
+#include "hc_simple.c"
+#include "hc_sl811_rh.c"
+
+
+/* The base_addr, data_reg_addr, and irq number are board specific.
+ * The current values are design to run on the Accelent SA1110 IDP
+ * NOTE: values need to modify for different development boards 
+ */
+
+static int base_addr = 0xd3800000;
+static int data_reg_addr = 0xd3810000;
+static int irq = 34;
+
+
+/* forware declaration */
+
+int SL11StartXaction(hci_t *hci, __u8 addr, __u8 epaddr, int pid, int len, 
+                     int toggle, int slow, int urb_state);
+
+static int sofWaitCnt =0;
+
+MODULE_PARM(urb_debug,"i");
+MODULE_PARM_DESC(urb_debug,"debug urb messages, default is 0 (no)");
+
+MODULE_PARM(base_addr,"i");
+MODULE_PARM_DESC(base_addr,"sl811 base address 0xd3800000");
+MODULE_PARM(data_reg_addr,"i");
+MODULE_PARM_DESC(data_reg_addr,"sl811 data register address 0xd3810000");
+MODULE_PARM(irq,"i");
+MODULE_PARM_DESC(irq,"IRQ 34 (default)");
+
+static int hc_reset (hci_t * hci);
+
+/***************************************************************************
+ * Function Name : SL811Read
+ *
+ * Read a byte of data from the SL811H/SL11H
+ *
+ * Input:  hci = data structure for the host controller
+ *         offset = address of SL811/SL11H register or memory
+ *
+ * Return: data 
+ **************************************************************************/
+
+char SL811Read(hci_t *hci, char offset)
+{  
+   hcipriv_t *hp = &hci->hp; 
+   char data;
+   writeb(offset, hp->hcport);
+   wmb();
+   data = readb (hp->hcport2);
+   rmb();
+   return (data);
+}
+
+/***************************************************************************
+ * Function Name : SL811Write
+ *
+ * Write a byte of data to the SL811H/SL11H
+ *
+ * Input:  hci = data structure for the host controller
+ *         offset = address of SL811/SL11H register or memory
+ *         data  = the data going to write to SL811H
+ *
+ * Return: none 
+ **************************************************************************/
+
+void SL811Write(hci_t *hci, char offset, char data)
+{ 
+   hcipriv_t *hp = &hci->hp; 
+   writeb(offset, hp->hcport);
+   writeb(data, hp->hcport2);
+   wmb();
+}
+
+
+/***************************************************************************
+ * Function Name : SL811BufRead
+ *
+ * Read consecutive bytes of data from the SL811H/SL11H buffer
+ *
+ * Input:  hci = data structure for the host controller
+ *         offset = SL811/SL11H register offset
+ *         buf = the buffer where the data will store
+ *         size = number of bytes to read
+ *
+ * Return: none 
+ **************************************************************************/
+
+void SL811BufRead(hci_t *hci, short offset, char *buf, short size)
+{	
+   hcipriv_t *hp = &hci->hp; 
+   if( size <= 0) 
+       return;
+   writeb((char) offset, hp->hcport);
+   wmb();
+   DBGDATAR ("SL811BufRead: offset = 0x%x, data = ", offset);
+   while (size--)
+   {
+       *buf++ = (char)readb(hp->hcport2);
+       DBGDATAR ("0x%x ", *(buf-1));
+       rmb(); 
+   }
+   DBGDATAR ("\n");
+}
+
+/***************************************************************************
+ * Function Name : SL811BufWrite
+ *
+ * Write consecutive bytes of data to the SL811H/SL11H buffer
+ *
+ * Input:  hci = data structure for the host controller
+ *         offset = SL811/SL11H register offset
+ *         buf = the data buffer 
+ *         size = number of bytes to write
+ *
+ * Return: none 
+ **************************************************************************/
+
+void SL811BufWrite(hci_t *hci, short offset, char *buf, short size)
+{	
+   hcipriv_t *hp = &hci->hp; 
+   if(size<=0) 
+       return;
+   writeb((char) offset, hp->hcport);
+   wmb();
+   DBGDATAW ("SL811BufWrite: offset = 0x%x, data = ", offset);
+   while (size--) 
+   {
+       DBGDATAW ("0x%x ", *buf);
+       writeb(*buf, hp->hcport2);
+       wmb();   
+       buf++;
+   }
+   DBGDATAW ("\n");
+}

⌨️ 快捷键说明

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