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

📄 usbhost.h

📁 有关于USB的一些主机端驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
/********************************************************************
*Name:usbfunc.h
*Description:This file includes the defination and the data that the omap1510 usb
*                  function driver needed.
*Created:Changming HUANG
*Date:May 09,2003
*********************************************************************/
/*
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <asm/uaccess.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/ioctl.h>
#include <linux/sched.h>
#include <linux/smp_lock.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/usb.h>

#include <asm/io.h>
#include <asm/hardware.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <asm/mach/irq.h>
*/
#define _USB_DEVICE_CNT		1
#define ADRSBASE_OMAPUSB		0xfffb4000
#define USB_OUTREG_BASE_ADDR	0xfffb4080
#define USB_INREG_BASE_ADDR	0xfffb40c0

#define USB_ISO_INTERRUPT		1
#define USB_GENI_INTERRUPT		2
#define USB_NONISO_INTERRUPT	4

#define SIZE_DESCRIPTOR_CONFIG 9
#define SIZE_DESCRIPTOR_INTERFACE 9
#define SIZE_DESCRIPTOR_ENDPOINT 7

/*the run status*/
#define ST_DEFAULT	0x0000
#define ST_SETUP	0x0001
#define ST_CTRLRETDATA	0x0002
#define ST_BULKRETDATA	0x0004
#define ST_BULKGETDATA	0x0008
#define ST_WAITCMD	0x0010
#define ST_RETSTATUS	0x0020

#define INT_2_BASE		0xFFFE0000
#define INT_1_BASE		0xFFFECB00
#define ITR				0x00
#define MIR				0x04
#define INT_CONTROL_REG	0x18
#define SIR_IRQ_CODE	0x10
#define NEW_IRQ_AGR	0x01
#define NEW_FIQ_AGR	0x02
#define ILR0				0x1c
#define IH1_BITMAP		0xb3fa6fc3
#define IH2_BITMAP		0x65b3c061
#define ROUTE_IRQ		0x00
#define ROUTE_FIQ		0x01
#define SENS_LEVEL			0x02
#define SENS_EDGE			0x00


#define SIZE1REG_USB 4

/*---------FUNC_MUX_CTRL_0----------*/
#define CTRL_0		0xFFFE1000
/*---------FUNC_MUX_CTRL_1----------*/
#define CTRL_1		0xFFFE1004
/*---------FUNC_MUX_CTRL_7----------*/
#define CTRL_7		0xFFFE1020
/*---------FUNC_MUX_CTRL_8----------*/
#define CTRL_8		0xFFFE1024
/*---------FUNC_MUX_CTRL_9----------*/
#define CTRL_9		0xFFFE1028
/*---------FUNC_MUX_CTRL_A----------*/
#define CTRL_A		0xFFFE102C
/*---------FUNC_MUX_CTRL_B----------*/
#define CTRL_B		0xFFFE1030
/*---------FUNC_MUX_CTRL_C----------*/
#define CTRL_C		0xFFFE1034
/*---------FUNC_MUX_CTRL_D----------*/
#define CTRL_D		0xFFFE1038
/*---------MOD_CONF_CTRL_0----------*/
#define MOD_CONF_CTRL_0	0xFFFE1080
/*---------CLOCK_CTRL_REG-----------*/
#define CLOCK_CTRL_REG	0xFFFE0830
/*---------ARM_CKCTL-----------------*/
#define ARM_CKCTL	0xFFFECE00
/*---------ARM_IDLECT1----------------*/
#define ARM_IDLECT1 0xfffece04
/*---------ARM_IDLECT2----------------*/
#define ARM_IDLECT2	0xFFFECE08
/*---------ARM_RSTCT1-----------------*/
#define ARM_RSTCT1	0xFFFECE10
/*---------ARM_RSTCT2-----------------*/
#define ARM_RSTCT2	0xFFFECE14
/*---------ARM_SYSST------------------*/
#define ARM_SYSST	0xFFFECE18
/*---------PLL_CTRL--------------------*/
#define PLL_CTRL		0xFFFECF00

/*define the PLL_CTRL register*/
#define IAI_OFF			((unsigned short)0x0000u<<0x000eu)
#define IAI_ON			((unsigned short)0x0001u<<0x000eu)
#define IOB_OFF			((unsigned short)0x0000u<<0x000du)
#define IOB_ON			((unsigned short)0x0001u<<0x000du)
#define TEST_OFF		((unsigned short)0x0000u<<0x000cu)
#define TEST_ON			((unsigned short)0x0001u<<0x000cu)
#define PLL_MULT(n)		((unsigned short)(n&0x001fu)<<0x0007u)
#define PLL_DIV(n)		((unsigned short)(n&0x0003u)<<0x0005u)
#define PLL_ENABLE		((unsigned short)0x0001u<<0x0004u)
#define BYPASS_DIV(n)	((unsigned short)(n&0x0003u)<<0x0002u)
#define BREAKLN			((unsigned short)0x0001u<<0x0001u)
#define PLL_CTL_LOCK	((unsigned short)0x0001u<<0x0000u)
#define BYPASS_DIV_DEFAULT		0x0000u

/*symbolic constants for USB descripe types*/
#define USB_DEVICE_DESCRIPTOR_TYPE			0x01
#define USB_CONFIGURATION_DESCRIPTOR_TYPE	0x02
#define USB_STRING_DESCRIPTOR_TYPE			0x03
#define USB_INTERFACE_DESCRIPTOR_TYPE		0x04
#define USB_ENDPOINT_DESCRIPTOR_TYPE			0x05
#define USB_POWER_DESCRIPTOR_TYPE			0x06
#define USB_HID_DESCRIPTOR_TYPE				0x21

/*symbolic constants for USB requests*/
#define USB_REQUEST_GET_STATUS				0x8000
#define USB_REQUEST_CLEAR_FEATURE			0x0001
#define USB_REQUEST_SET_FEATURE				0x0003
#define USB_REQUEST_SET_ADDRESS				0x0005
#define USB_REQUEST_GET_DESCRIPTOR			0x8006
#define USB_REQUEST_SET_DESCRIPTOR			0x0007
#define USB_REQUEST_GET_CONFIGURATION		0x8008
#define USB_REQUEST_SET_CONFIGURATION		0x0009
#define USB_REQUEST_GET_INTERFACE			0x800a
#define USB_REQUEST_SET_INTERFACE				0x000b
#define USB_REQUEST_SYNC_FRAME				0x800c
#define USB_REQUEST_BULK_ONLY_RESET			0x20ff
#define USB_REQUEST_GET_MAX_LUN				0xa1fe
//#define USB_REQUEST_GET_MAX_LUN				0x80fe
/*vendor specific fro SONU code*/
#define USB_REQUEST_START_TRANSFER			0x401f
#define USB_REQUEST_START_ISO					0x4012

/*define USB device classes*/
#define USB_DEVICE_CLASS_RESERVED				0x00
#define USB_DEVICE_CLASS_AUDIO				0x01
#define USB_DEVICE_CLASS_COMMUNICATIONS		0x02
#define USB_DEVICE_CLASS_HUMAN_INTERFACE	0x03
#define USB_DEVICE_CLASS_MONITOR				0x04
#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE	0x05
#define USB_DEVICE_CLASS_POWER				0x06
#define USB_DEVICE_CLASS_PRINTER				0x07
#define USB_DEVICE_CLASS_STORAGE				0x08
#define USB_DEVICE_CLASS_HUB					0x09
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC		0xff

/*USB define feature selectors*/
#define USB_FEATURE_ENDPOINT_STALL			0x0000
#define USB_FEATURE_REMOTE_WAKEUP			0x0001
#define USB_FEATURE_POWER_D0					0x0002
#define USB_FEATURE_POWER_D1					0x0003
#define USB_FEATURE_POWER_D2					0x0004
#define USB_FEATURE_POWER_D3					0x0005

/*device specific descriptor definitions*/
#define SIZE_DESCRIPTOR_CONFIG_ALL			123
#define SIZE_DESCRIPTOR_DEVICE					18


/********************************************************
*Access the address of the omap1510 usb I/O space
*********************************************************/
/*the add is 32 bits int,and the val is 16 bits */
#define readw(add)		((*((unsigned short *)(add))) & 0xffff)
#define writew(val,add)	(*((unsigned short *)(add)) = (unsigned short)(val))
/*the add is 32 bits int ,and the val is 32 bits*/
#define readl(add)		((*((unsigned int *)(add))) & 0xffffffff)
#define writel(val,add)	(*((unsigned int *)(add)) = (unsigned int)(val))
/*the val is 8 bits*/
#define readb(add)			((*((unsigned char *)(add))) & 0xff)
#define writeb(val,add)	(*((unsigned char *)(add))=(unsigned char)(val))


/*descritpor types*/
#define Device			0x01
#define CONFIGURATION	0x02
#define STRING			0x03
#define INTERFACE		0x04
#define ENDPOINT		0x05

#define USB_NULL		0x00
#define SETUP_FIFO_SIZE	0x08
#define TIME_OUT_COUNT	50000

/*endpoint size definitions*/
#define SIZETYPE_8		0x0
#define SIZETYPE_16		0x1
#define SIZETYPE_32		0x2
#define SIZETYPE_64		0x3
/*for ISO only*/
#define SIZETYPE_128	0x4
#define SIZETYPE_256	0x5
#define SIZETYPE_512	0x6
#define SIZETYPE_1023	0x7

/*internal flags used by usb data transfer APIs*/
#define USB_IOFLAG_NEW			0x0100
#define USB_IOFLAG_DATAREQ	0x0200
#define USB_IOFLAG_BYTE		0x0400
#define USB_IOFLAG_OBYTREQ		0x0800
#define USB_IOFLAG_ISO			0x1000	/*not in use*/
#define USB_IOFLAG_STALL		0x2000	/*not in use*/
#define USB_IOFLAG_RESET		0x4000	/*not in use*/

#define USB_IOFLAG_NONE		0x0000	/*use default value*/
#define USB_IOFLAG_NOSHORT	0x0001	/*do not expect or insert a 0 byte packet after a full size packet*/
#define USB_IOFLAG_SWAP		0x0002	/*swap high/low bytes before data xmit after data recv*/
#define USB_IOFLAG_LNK			0x0004	/*xmit or recv data buffer passed is a linked list*/
#define USB_IOFLAG_CAT			0x0008	/*concatenate multiple linked list,to fill up the data buffer*/
										/*to max packet size before sending or receiving a data packet*/
#define USB_IOFLAG_EOLL		0x0010	/*ignore argument ByteCnt,transfer ends when the end of the linked*/

/*some more useful macros*/
#define USB_EVENT_NONE			0x0000	/*no interrupt received*/
#define USB_EVENT_RESET		0x0001	/*bus reset*/
#define USB_EVENT_SOF			0x0002	/*start of frame*/
#define USB_EVENT_SUSPEND		0x0004	/*bus suspend*/
#define USB_EVENT_RESUME		0x0008	/*bus resume*/
#define USB_EVENT_SETUP		0x0010	/*setup packet received*/
#define USB_EVENT_EOT			0x0020	/*end of posted transaction*/

#define USB_ENABLE	0x1
#define USB_DISABLE	0x0

/*error code define*/
#define	EPERM		 1	/* Operation not permitted */
#define	ENOENT		 2	/* No such file or directory */
#define	ESRCH		 3	/* No such process */
#define	EINTR		 4	/* Interrupted system call */
#define	EIO		 5	/* I/O error */
#define	ENXIO		 6	/* No such device or address */
#define	E2BIG		 7	/* Arg list too long */
#define	ENOEXEC		 8	/* Exec format error */
#define	EBADF		 9	/* Bad file number */
#define	ECHILD		10	/* No child processes */
#define	EAGAIN		11	/* Try again */
#define	ENOMEM		12	/* Out of memory */
#define	EACCES		13	/* Permission denied */
#define	EFAULT		14	/* Bad address */
#define	ENOTBLK		15	/* Block device required */
#define	EBUSY		16	/* Device or resource busy */
#define	EEXIST		17	/* File exists */
#define	EXDEV		18	/* Cross-device link */
#define	ENODEV		19	/* No such device */
#define	ENOTDIR		20	/* Not a directory */
#define	EISDIR		21	/* Is a directory */
#define	EINVAL		22	/* Invalid argument */
#define	ENFILE		23	/* File table overflow */
#define	EMFILE		24	/* Too many open files */
#define	ENOTTY		25	/* Not a typewriter */
#define	ETXTBSY		26	/* Text file busy */
#define	EFBIG		27	/* File too large */
#define	ENOSPC		28	/* No space left on device */
#define	ESPIPE		29	/* Illegal seek */
#define	EROFS		30	/* Read-only file system */
#define	EMLINK		31	/* Too many links */
#define	EPIPE		32	/* Broken pipe */
#define	EDOM		33	/* Math argument out of domain of func */
#define	ERANGE		34	/* Math result not representable */
#define	EDEADLK		35	/* Resource deadlock would occur */
#define	ENAMETOOLONG	36	/* File name too long */
#define	ENOLCK		37	/* No record locks available */
#define	ENOSYS		38	/* Function not implemented */
#define	ENOTEMPTY	39	/* Directory not empty */
#define	ELOOP		40	/* Too many symbolic links encountered */
#define	EWOULDBLOCK	EAGAIN	/* Operation would block */
#define	ENOMSG		42	/* No message of desired type */
#define	EIDRM		43	/* Identifier removed */
#define	ECHRNG		44	/* Channel number out of range */
#define	EL2NSYNC	45	/* Level 2 not synchronized */
#define	EL3HLT		46	/* Level 3 halted */
#define	EL3RST		47	/* Level 3 reset */

⌨️ 快捷键说明

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