aboutsummaryrefslogtreecommitdiffstats
path: root/package/rt2x00/src/rt2x00usb.h
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2008-03-09 10:55:19 +0000
committerFlorian Fainelli <florian@openwrt.org>2008-03-09 10:55:19 +0000
commitfef15a956c143d470e76258f410ef5d1349dd6a9 (patch)
tree47097d050dd1c91feb0af8f1bf4dd8e77eecd803 /package/rt2x00/src/rt2x00usb.h
parent3d66117ef06d4a85967d0d1a9c26af38320b4e4c (diff)
downloadupstream-fef15a956c143d470e76258f410ef5d1349dd6a9.tar.gz
upstream-fef15a956c143d470e76258f410ef5d1349dd6a9.tar.bz2
upstream-fef15a956c143d470e76258f410ef5d1349dd6a9.zip
Fix rt2x00 compilation and upgrade to the current mainline version (2.6.24)
SVN-Revision: 10573
Diffstat (limited to 'package/rt2x00/src/rt2x00usb.h')
-rw-r--r--package/rt2x00/src/rt2x00usb.h94
1 files changed, 71 insertions, 23 deletions
diff --git a/package/rt2x00/src/rt2x00usb.h b/package/rt2x00/src/rt2x00usb.h
index 91627f2dd2..2681abe4d4 100644
--- a/package/rt2x00/src/rt2x00usb.h
+++ b/package/rt2x00/src/rt2x00usb.h
@@ -21,7 +21,6 @@
/*
Module: rt2x00usb
Abstract: Data structures for the rt2x00usb module.
- Supported chipsets: rt2570, rt2571W & rt2671.
*/
#ifndef RT2X00USB_H
@@ -35,20 +34,26 @@
/*
* Register defines.
- * When register access attempts should be repeated
- * only REGISTER_BUSY_COUNT attempts with a delay
- * of REGISTER_BUSY_DELAY us should be taken.
+ * Some registers require multiple attempts before success,
+ * in those cases REGISTER_BUSY_COUNT attempts should be
+ * taken with a REGISTER_BUSY_DELAY interval.
* For USB vendor requests we need to pass a timeout
* time in ms, for this we use the REGISTER_TIMEOUT,
* however when loading firmware a higher value is
- * required. For that we use the REGISTER_TIMEOUT_FIRMWARE.
+ * required. In that case we use the REGISTER_TIMEOUT_FIRMWARE.
*/
#define REGISTER_BUSY_COUNT 5
#define REGISTER_BUSY_DELAY 100
-#define REGISTER_TIMEOUT 20
+#define REGISTER_TIMEOUT 500
#define REGISTER_TIMEOUT_FIRMWARE 1000
/*
+ * Cache size
+ */
+#define CSR_CACHE_SIZE 8
+#define CSR_CACHE_SIZE_FIRMWARE 64
+
+/*
* USB request types.
*/
#define USB_VENDOR_REQUEST ( USB_TYPE_VENDOR | USB_RECIP_DEVICE )
@@ -80,37 +85,77 @@
#define USB_MODE_WAKEUP 0x09 /* RT73USB */
/*
- * USB devices need an additional Beacon (guardian beacon) to be generated.
+ * Used to read/write from/to the device.
+ * This is the main function to communicate with the device,
+ * the buffer argument _must_ either be NULL or point to
+ * a buffer allocated by kmalloc. Failure to do so can lead
+ * to unexpected behavior depending on the architecture.
*/
-#undef BEACON_ENTRIES
-#define BEACON_ENTRIES 2
+int rt2x00usb_vendor_request(const 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);
/*
- * Interfacing with the HW.
+ * Used to read/write from/to the device.
+ * This function will use a previously with kmalloc allocated cache
+ * to communicate with the device. The contents of the buffer pointer
+ * will be copied to this cache when writing, or read from the cache
+ * when reading.
+ * Buffers send to rt2x00usb_vendor_request _must_ be allocated with
+ * kmalloc. Hence the reason for using a previously allocated cache
+ * which has been allocated properly.
*/
-int rt2x00usb_vendor_request(const struct rt2x00_dev *rt2x00dev,
- const u8 request, const u8 type, const u16 offset,
- u32 value, void *buffer, const u16 buffer_length, const u16 timeout);
+int rt2x00usb_vendor_request_buff(const struct rt2x00_dev *rt2x00dev,
+ const u8 request, const u8 requesttype,
+ const u16 offset, void *buffer,
+ const u16 buffer_length, const int timeout);
/*
- * Radio handlers
+ * Simple wrapper around rt2x00usb_vendor_request to write a single
+ * command to the device. Since we don't use the buffer argument we
+ * don't have to worry about kmalloc here.
*/
-void rt2x00usb_enable_radio(struct rt2x00_dev *rt2x00dev);
-void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev);
+static inline int rt2x00usb_vendor_request_sw(const 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);
+}
/*
- * Beacon handlers.
+ * Simple wrapper around rt2x00usb_vendor_request to read the eeprom
+ * from the device. Note that the eeprom argument _must_ be allocated using
+ * kmalloc for correct handling inside the kernel USB layer.
*/
-int rt2x00usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
- struct ieee80211_tx_control *control);
-void rt2x00usb_beacondone(struct urb *urb);
+static inline int rt2x00usb_eeprom_read(const struct rt2x00_dev *rt2x00dev,
+ __le16 *eeprom, const u16 lenght)
+{
+ int timeout = REGISTER_TIMEOUT * (lenght / sizeof(u16));
+
+ return rt2x00usb_vendor_request(rt2x00dev, USB_EEPROM_READ,
+ USB_VENDOR_REQUEST_IN, 0x0000,
+ 0x0000, eeprom, lenght, timeout);
+}
+
+/*
+ * Radio handlers
+ */
+void rt2x00usb_enable_radio(struct rt2x00_dev *rt2x00dev);
+void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev);
/*
* TX data handlers.
*/
int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
- struct data_ring *ring, struct sk_buff *skb,
- struct ieee80211_tx_control *control);
+ struct data_ring *ring, struct sk_buff *skb,
+ struct ieee80211_tx_control *control);
/*
* Device initialization handlers.
@@ -122,11 +167,14 @@ void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev);
* USB driver handlers.
*/
int rt2x00usb_probe(struct usb_interface *usb_intf,
- const struct usb_device_id *id);
+ const struct usb_device_id *id);
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 */