Warning, cross-references for /kernel/include/drivers/usb/uhci.h need to be fixed.
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef _UHCI_H_
0019 #define _UHCI_H_
0020
0021 #include <types.h>
0022 #include <arch/i386.h>
0023 #include <drivers/pci/pci.h>
0024 #include <drivers/usb/usb.h>
0025
0026 #define NUM_FRM_PTRS 1024
0027
0028 #define UHCI_PID_OUT 0xE1
0029 #define UHCI_PID_IN 0x69
0030 #define UHCI_PID_SETUP 0x2D
0031
0032 #define UHCI_MAX_LEN 0x4FF
0033
0034 #define GET_USB_BASE(bus, dev, func) pci_config_rd16(bus, dev, func, 0x20) & 0xFFE0
0035 #define GET_USB_RELNUM(bus, dev, func) pci_config_rd8(bus, dev, func, 0x60)
0036 #define DISABLE_LEGACY(bus, dev, func) pci_config_wr16(bus, dev, func, 0xC0, 0x8f00)
0037 #define SET_LEGACY(bus, dev, func, leg) pci_config_wr16(bus, dev, func, 0xC0, leg);
0038 #define GET_LEGACY(bus, dev, func) pci_config_rd16(bus, dev, func, 0xC0)
0039 #define GET_PCICMD(bus, dev, func) pci_config_rd16(bus, dev, func, 0x04)
0040 #define SET_PCICMD(bus, dev, func, cmd) pci_config_wr16(bus, dev, func, 0x04, cmd)
0041 #define GET_PCISTS(bus, dev, func) pci_config_rd16(bus, dev, func, 0x06)
0042
0043 #define GET_USBCMD(usb_base) inw(usb_base + 0x00)
0044 #define SET_USBCMD(usb_base, cmd) outw(cmd, usb_base + 0x00)
0045 #define GET_USBSTS(usb_base) inw(usb_base + 0x02)
0046 #define SET_USBSTS(usb_base, sts) outw(sts, usb_base + 0x02)
0047 #define SET_FRBASEADD(usb_base, frbase) outl(frbase, usb_base + 0x08)
0048 #define GET_FRBASEADD(usb_base) inl(usb_base + 0x08)
0049 #define SET_SOFMOD(usb_base, sofmod) outb(sofmod, usb_base + 0x0C)
0050 #define SET_FRNUM(usb_base, frnum) outw(frnum, usb_base + 0x06)
0051 #define GET_FRNUM(usb_base) inw(usb_base + 0x06)
0052 #define SET_PORTSC0(usb_base, sc) outw(sc, usb_base + 0x10)
0053 #define SET_PORTSC1(usb_base, sc) outw(sc, usb_base + 0x12)
0054 #define GET_PORTSC0(usb_base) inw(usb_base + 0x10)
0055 #define GET_PORTSC1(usb_base) inw(usb_base + 0x12)
0056 #define SET_USBINTR(usb_base, intr) outw(intr, usb_base + 0x04)
0057 #define GET_USBINTR(usb_base) inw(usb_base + 0x04)
0058
0059 #define TD_POOL_SIZE 200
0060 #define QH_POOL_SIZE 16
0061 #define TYPE_TD 0
0062 #define TYPE_QH 1
0063 #define DIR_IN 0
0064 #define DIR_OUT 1
0065
0066
0067
0068
0069
0070
0071
0072
0073 typedef uint32_t frm_lst_ptr;
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088 typedef struct
0089 {
0090 uint32_t link_ptr;
0091
0092 union {
0093 uint32_t raw2;
0094 struct {
0095 uint32_t act_len:11;
0096 uint32_t reserve0:5;
0097 uint32_t status:8;
0098 uint32_t ioc:1;
0099 uint32_t iso:1;
0100 uint32_t ls:1;
0101 uint32_t c_err:2;
0102 uint32_t spd:1;
0103 uint32_t reserve1:2;
0104 };
0105 };
0106
0107 union {
0108 uint32_t raw3;
0109 struct {
0110 uint32_t pid:8;
0111 uint32_t addr:7;
0112 uint32_t endp:4;
0113 uint32_t toggle:1;
0114 uint32_t reserve2:1;
0115 uint32_t max_len:11;
0116 };
0117 };
0118
0119 uint32_t buf_ptr;
0120
0121
0122 addr_t buf_vptr;
0123
0124 void (*call_back)(addr_t);
0125
0126
0127
0128 uint32_t reserve[2];
0129 } UHCI_TD;
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 typedef struct
0143 {
0144 uint32_t qh_ptr;
0145 uint32_t qe_ptr;
0146 uint32_t padding[2];
0147 } UHCI_QH;
0148
0149 extern bool uhci_init (void);
0150 extern int uhci_reset (void);
0151 extern int port_reset (uint8_t);
0152 extern int uhci_isochronous_transfer (uint8_t, uint8_t, addr_t, int, int *,
0153 uint16_t, uint8_t, void (*) (addr_t));
0154 extern int uhci_control_transfer (uint8_t, addr_t, int, addr_t, int, int);
0155 extern int uhci_bulk_transfer (uint8_t, uint8_t, addr_t, int,
0156 int, uint8_t, uint32_t *);
0157 extern int uhci_get_descriptor (uint8_t, uint16_t, uint16_t, uint16_t,
0158 uint16_t, addr_t, uint8_t);
0159 extern int uhci_set_address (uint8_t, uint8_t, uint8_t);
0160 extern int uhci_get_configuration (uint8_t, uint8_t);
0161 extern int uhci_set_configuration (uint8_t, uint8_t, uint8_t);
0162 extern int uhci_get_interface (uint8_t, uint16_t, uint8_t);
0163 extern int uhci_set_interface (uint8_t, uint16_t, uint16_t, uint8_t);
0164 extern sint uhci_get_string (uint8_t address, uint16_t index, uint16_t lang,
0165 uint16_t length, void *buffer, uint8_t pktsize);
0166 extern sint uhci_interp_string (USB_STR_DESC *string, uint16_t length,
0167 uint16_t lang, uint8 *output, uint16_t out_len);
0168
0169
0170
0171 #endif
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182