123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425 |
- #ifndef RT2X00USB_H
- #define RT2X00USB_H
- #include <linux/usb.h>
- #define to_usb_device_intf(d) \
- ({ \
- struct usb_interface *intf = to_usb_interface(d); \
- interface_to_usbdev(intf); \
- })
- #define REGISTER_TIMEOUT 100
- #define REGISTER_TIMEOUT_FIRMWARE 1000
- #define EEPROM_TIMEOUT 2000
- #define CSR_CACHE_SIZE 64
- #define USB_VENDOR_REQUEST ( USB_TYPE_VENDOR | USB_RECIP_DEVICE )
- #define USB_VENDOR_REQUEST_IN ( USB_DIR_IN | USB_VENDOR_REQUEST )
- #define USB_VENDOR_REQUEST_OUT ( USB_DIR_OUT | USB_VENDOR_REQUEST )
- enum rt2x00usb_vendor_request {
- USB_DEVICE_MODE = 1,
- USB_SINGLE_WRITE = 2,
- USB_SINGLE_READ = 3,
- USB_MULTI_WRITE = 6,
- USB_MULTI_READ = 7,
- USB_EEPROM_WRITE = 8,
- USB_EEPROM_READ = 9,
- USB_LED_CONTROL = 10,
- USB_RX_CONTROL = 12,
- };
- enum rt2x00usb_mode_offset {
- USB_MODE_RESET = 1,
- USB_MODE_UNPLUG = 2,
- USB_MODE_FUNCTION = 3,
- USB_MODE_TEST = 4,
- USB_MODE_SLEEP = 7,
- USB_MODE_FIRMWARE = 8,
- USB_MODE_WAKEUP = 9,
- USB_MODE_AUTORUN = 17,
- };
- int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev,
- const u8 request, const u8 requesttype,
- const u16 offset, const u16 value,
- void *buffer, const u16 buffer_length,
- const int timeout);
- int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev,
- const u8 request, const u8 requesttype,
- const u16 offset, void *buffer,
- const u16 buffer_length);
- int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev,
- const u8 request, const u8 requesttype,
- const u16 offset, void *buffer,
- const u16 buffer_length, const int timeout);
- static inline int rt2x00usb_vendor_request_sw(struct rt2x00_dev *rt2x00dev,
- const u8 request,
- const u16 offset,
- const u16 value,
- const int timeout)
- {
- return rt2x00usb_vendor_request(rt2x00dev, request,
- USB_VENDOR_REQUEST_OUT, offset,
- value, NULL, 0, timeout);
- }
- static inline int rt2x00usb_eeprom_read(struct rt2x00_dev *rt2x00dev,
- __le16 *eeprom, const u16 length)
- {
- return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ,
- USB_VENDOR_REQUEST_IN, 0, 0,
- eeprom, length, EEPROM_TIMEOUT);
- }
- static inline void rt2x00usb_register_read(struct rt2x00_dev *rt2x00dev,
- const unsigned int offset,
- u32 *value)
- {
- __le32 reg = 0;
- rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
- USB_VENDOR_REQUEST_IN, offset,
- ®, sizeof(reg));
- *value = le32_to_cpu(reg);
- }
- static inline void rt2x00usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
- const unsigned int offset,
- u32 *value)
- {
- __le32 reg = 0;
- rt2x00usb_vendor_req_buff_lock(rt2x00dev, USB_MULTI_READ,
- USB_VENDOR_REQUEST_IN, offset,
- ®, sizeof(reg), REGISTER_TIMEOUT);
- *value = le32_to_cpu(reg);
- }
- static inline void rt2x00usb_register_multiread(struct rt2x00_dev *rt2x00dev,
- const unsigned int offset,
- void *value, const u32 length)
- {
- rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
- USB_VENDOR_REQUEST_IN, offset,
- value, length);
- }
- static inline void rt2x00usb_register_write(struct rt2x00_dev *rt2x00dev,
- const unsigned int offset,
- u32 value)
- {
- __le32 reg = cpu_to_le32(value);
- rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
- USB_VENDOR_REQUEST_OUT, offset,
- ®, sizeof(reg));
- }
- static inline void rt2x00usb_register_write_lock(struct rt2x00_dev *rt2x00dev,
- const unsigned int offset,
- u32 value)
- {
- __le32 reg = cpu_to_le32(value);
- rt2x00usb_vendor_req_buff_lock(rt2x00dev, USB_MULTI_WRITE,
- USB_VENDOR_REQUEST_OUT, offset,
- ®, sizeof(reg), REGISTER_TIMEOUT);
- }
- static inline void rt2x00usb_register_multiwrite(struct rt2x00_dev *rt2x00dev,
- const unsigned int offset,
- const void *value,
- const u32 length)
- {
- rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
- USB_VENDOR_REQUEST_OUT, offset,
- (void *)value, length);
- }
- int rt2x00usb_regbusy_read(struct rt2x00_dev *rt2x00dev,
- const unsigned int offset,
- const struct rt2x00_field32 field,
- u32 *reg);
- void rt2x00usb_register_read_async(struct rt2x00_dev *rt2x00dev,
- const unsigned int offset,
- bool (*callback)(struct rt2x00_dev*, int, u32));
- void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev);
- struct queue_entry_priv_usb {
- struct urb *urb;
- };
- struct queue_entry_priv_usb_bcn {
- struct urb *urb;
- unsigned int guardian_data;
- struct urb *guardian_urb;
- };
- void rt2x00usb_kick_queue(struct data_queue *queue);
- void rt2x00usb_flush_queue(struct data_queue *queue, bool drop);
- void rt2x00usb_watchdog(struct rt2x00_dev *rt2x00dev);
- void rt2x00usb_clear_entry(struct queue_entry *entry);
- int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev);
- void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev);
- int rt2x00usb_probe(struct usb_interface *usb_intf,
- const struct rt2x00_ops *ops);
- void rt2x00usb_disconnect(struct usb_interface *usb_intf);
- #ifdef CONFIG_PM
- int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state);
- int rt2x00usb_resume(struct usb_interface *usb_intf);
- #else
- #define rt2x00usb_suspend NULL
- #define rt2x00usb_resume NULL
- #endif /* CONFIG_PM */
- #endif /* RT2X00USB_H */
|