📄 s3c2440_usb.h
字号:
/* in usb_recev.c */int elfin_usb_recv(char *buf, int len, usb_callback_t callback);void elfin_usb_recv_reset(void);//////////////////////////////////////////////////////////////////////////////// Descriptor Management//////////////////////////////////////////////////////////////////////////////#define DescriptorHeader \ __u8 bLength; \ __u8 bDescriptorType// --- Device Descriptor -------------------typedef struct { DescriptorHeader; __u16 bcdUSB; /* USB specification revision number in BCD */ __u8 bDeviceClass; /* USB class for entire device */ __u8 bDeviceSubClass; /* USB subclass information for entire device */ __u8 bDeviceProtocol; /* USB protocol information for entire device */ __u8 bMaxPacketSize0; /* Max packet size for endpoint zero */ __u16 idVendor; /* USB vendor ID */ __u16 idProduct; /* USB product ID */ __u16 bcdDevice; /* vendor assigned device release number */ __u8 iManufacturer; /* index of manufacturer string */ __u8 iProduct; /* index of string that describes product */ __u8 iSerialNumber; /* index of string containing device serial number */ __u8 bNumConfigurations; /* number fo configurations */} __attribute__ ((packed)) device_desc_t;// --- Configuration Descriptor ------------typedef struct { DescriptorHeader; __u16 wTotalLength; /* total # of bytes returned in the cfg buf 4 this cfg */ __u8 bNumInterfaces; /* number of interfaces in this cfg */ __u8 bConfigurationValue; /* used to uniquely ID this cfg */ __u8 iConfiguration; /* index of string describing configuration */ __u8 bmAttributes; /* bitmap of attributes for ths cfg */ __u8 MaxPower; /* power draw in 2ma units */} __attribute__ ((packed)) config_desc_t;// bmAttributes:enum { USB_CONFIG_REMOTEWAKE=0x20, USB_CONFIG_SELFPOWERED=0x40, USB_CONFIG_BUSPOWERED=0x80 };// MaxPower:#define USB_POWER( x) ((x)>>1) /* convert mA to descriptor units of A for MaxPower */// --- Interface Descriptor ---------------typedef struct { DescriptorHeader; __u8 bInterfaceNumber; /* Index uniquely identfying this interface */ __u8 bAlternateSetting; /* ids an alternate setting for this interface */ __u8 bNumEndpoints; /* number of endpoints in this interface */ __u8 bInterfaceClass; /* USB class info applying to this interface */ __u8 bInterfaceSubClass; /* USB subclass info applying to this interface */ __u8 bInterfaceProtocol; /* USB protocol info applying to this interface */ __u8 iInterface; /* index of string describing interface */} __attribute__ ((packed)) intf_desc_t;// --- Endpoint Descriptor ---------------typedef struct { DescriptorHeader; __u8 bEndpointAddress; /* 0..3 ep num, bit 7: 0 = 0ut 1= in */ __u8 bmAttributes; /* 0..1 = 0: ctrl, 1: isoc, 2: bulk 3: intr */ __u16 wMaxPacketSize; /* data payload size for this ep in this cfg */ __u8 bInterval; /* polling interval for this ep in this cfg */} __attribute__ ((packed)) ep_desc_t;#if defined(CONFIG_S3C2440_USB_CDC_ENCM) || defined(CONFIG_S3C2440_USB_CDC_ENCM_MODULE)// --- Header Functional Descriptor -------typedef struct { DescriptorHeader; __u8 bDescriptorSubtype; /* 0x00 */ __u16 bcdCDC;} __attribute__((packed)) hdr_func_desc_t;// --- Ethernet Functional Descriptor -----typedef struct { DescriptorHeader; __u8 bDescriptorSubtype; /* 0x0f */ __u8 iMACAddress; __u32 bmEthernetStatistics; __u16 wMaxSegmentSize; __u16 wNumberMCFilters; __u8 bNumberPowerFilters;} __attribute__((packed)) eth_func_desc_t;// --- Union Functional Descriptor --------typedef struct { DescriptorHeader; __u8 bDescriptorSubtype; /* 0x06 */ __u8 bMasterInterface; __u8 bSlaveInterface;} __attribute__((packed)) union_func_desc_t;// --- All Functional Descriptors ---------typedef struct { hdr_func_desc_t hdr; eth_func_desc_t eth; union_func_desc_t uni;} __attribute__((packed)) func_desc_t;#endif /* CONFIG_S3C2440_USB_CDC_ENCM || CONFIG_S3C2440_USB_CDC_ENCM_MODULE */// bEndpointAddress:enum { USB_OUT =0, USB_IN =1 };#define USB_EP_ADDRESS(a,d) (((a)&0xf) | ((d) << 7))// bmAttributes:enum { USB_EP_CNTRL =0, USB_EP_BULK =2, USB_EP_INT =3, USB_EP_ISO =4 };// --- String Descriptor -------------------typedef struct { DescriptorHeader; __u16 bString[1]; /* unicode string .. actaully 'n' __u16s */} __attribute__ ((packed)) string_desc_t;/*======================================================= * Handy helpers when working with above * */// these are x86-style 16 bit "words" ...#define make_word_c( w ) __constant_cpu_to_le16(w)#define make_word( w ) __cpu_to_le16(w)// descriptor typesenum { USB_DESC_DEVICE = 1, USB_DESC_CONFIG = 2, USB_DESC_STRING = 3, USB_DESC_INTERFACE = 4, USB_DESC_ENDPOINT = 5};/*======================================================= * Default descriptor layout for S3C2440 UDC */enum { UNUSED = 0, BULK_IN1 = 1, BULK_OUT1 = 2, ISO_IN1 = 3, ISO_OUT1 = 4, INT_IN1 = 5, BULK_IN2 = 6, BULK_OUT2 = 7, ISO_IN2 = 8, ISO_OUT2 = 9, INT_IN2 = 10, BULK_IN3 = 11, BULK_OUT3 = 12, ISO_IN3 = 13, ISO_OUT3 = 14, INT_IN3 = 15} /*endpoint_type*/;/* "config descriptor buffer" - that is, one config, ..one interface and 2 endpoints */struct cdb { config_desc_t cfg; intf_desc_t intf; ep_desc_t ep1; ep_desc_t ep2;} __attribute__ ((packed));#if defined(CONFIG_S3C2440_USB_CDC_ENCM) || defined(CONFIG_S3C2440_USB_CDC_ENCM_MODULE)struct cdc_cdb { config_desc_t cfg; intf_desc_t comm_intf; func_desc_t func;#ifdef CDC_ALTERNATE_INTERFACE intf_desc_t data_intf0;#endif /* CDC_ALTERNATE_INTERFACE */ intf_desc_t data_intf1; ep_desc_t ep1; ep_desc_t ep2;} __attribute__ ((packed));#endif /* CONFIG_S3C2440_USB_CDC_ENCM || CONFIG_S3C2440_USB_CDC_ENCM_MODULE *//* all S3C2440 device descriptors */typedef struct { device_desc_t dev; /* device descriptor */ struct cdb b; /* bundle of descriptors for this cfg */#if defined(CONFIG_S3C2440_USB_CDC_ENCM) || defined(CONFIG_S3C2440_USB_CDC_ENCM_MODULE) struct cdc_cdb cdc_b; /* bundle of descriptors for CDC ENCM */#endif /* CONFIG_S3C2440_USB_CDC_ENCM || CONFIG_S3C2440_USB_CDC_ENCM_MODULE */} __attribute__ ((packed)) desc_t;/*======================================================= * Descriptor API *//* Get the address of the statically allocated desc_t structure in the usb core driver. Clients can modify this between the time they call elfin_usb_open() and elfin_usb_start()*/desc_t *elfin_usb_get_descriptor_ptr( void );/* Set a pointer to the string descriptor at "index". The driver ..has room for 8 string indicies internally. Index zero holds ..a LANGID code and is set to US English by default. Inidices ..1-7 are available for use in the config descriptors as client's ..see fit. This pointer is assumed to be good as long as the ..S3C2440 usb core is open (so statically allocate them). Returnes -EINVAL ..if index out of range */int elfin_usb_set_string_descriptor( int index, string_desc_t * p );/* reverse of above */string_desc_t *elfin_usb_get_string_descriptor( int index );/* kmalloc() a string descriptor and convert "p" to unicode in it */string_desc_t *elfin_usb_kmalloc_string_descriptor( const char * p );#endif /* _S3C2440_USB_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -