17 #include <linux/pci.h>
18 #include <linux/slab.h>
23 #include <linux/module.h>
47 {USB_DEVICE(0x0411, 0x0050)},
48 {USB_DEVICE(0x045e, 0x00c2)},
49 {USB_DEVICE(0x0506, 0x0a11)},
50 {USB_DEVICE(0x06b9, 0x0120)},
51 {USB_DEVICE(0x0707, 0xee06)},
52 {USB_DEVICE(0x07aa, 0x001c)},
53 {USB_DEVICE(0x083a, 0x4501)},
54 {USB_DEVICE(0x083a, 0x4502)},
55 {USB_DEVICE(0x083a, 0x5501)},
56 {USB_DEVICE(0x0846, 0x4200)},
57 {USB_DEVICE(0x0846, 0x4210)},
58 {USB_DEVICE(0x0846, 0x4220)},
59 {USB_DEVICE(0x09aa, 0x1000)},
60 {USB_DEVICE(0x0bf8, 0x1007)},
61 {USB_DEVICE(0x0cde, 0x0006)},
62 {USB_DEVICE(0x0db0, 0x6826)},
63 {USB_DEVICE(0x107b, 0x55f2)},
64 {USB_DEVICE(0x124a, 0x4023)},
65 {USB_DEVICE(0x1435, 0x0210)},
66 {USB_DEVICE(0x15a9, 0x0002)},
67 {USB_DEVICE(0x1630, 0x0005)},
68 {USB_DEVICE(0x182d, 0x096b)},
69 {USB_DEVICE(0x1915, 0x2234)},
70 {USB_DEVICE(0x1915, 0x2235)},
71 {USB_DEVICE(0x2001, 0x3701)},
72 {USB_DEVICE(0x2001, 0x3703)},
73 {USB_DEVICE(0x2001, 0x3762)},
74 {USB_DEVICE(0x5041, 0x2234)},
75 {USB_DEVICE(0x5041, 0x2235)},
78 {USB_DEVICE(0x0471, 0x1230)},
79 {USB_DEVICE(0x050d, 0x7050)},
80 {USB_DEVICE(0x0572, 0x2000)},
81 {USB_DEVICE(0x0572, 0x2002)},
82 {USB_DEVICE(0x06a9, 0x000e)},
83 {USB_DEVICE(0x06b9, 0x0121)},
84 {USB_DEVICE(0x0707, 0xee13)},
85 {USB_DEVICE(0x083a, 0x4521)},
86 {USB_DEVICE(0x083a, 0xc501)},
87 {USB_DEVICE(0x083a, 0xf503)},
88 {USB_DEVICE(0x0846, 0x4240)},
89 {USB_DEVICE(0x0915, 0x2000)},
90 {USB_DEVICE(0x0915, 0x2002)},
91 {USB_DEVICE(0x0baf, 0x0118)},
92 {USB_DEVICE(0x0bf8, 0x1009)},
95 {USB_DEVICE(0x0cde, 0x0008)},
96 {USB_DEVICE(0x0cde, 0x0015)},
97 {USB_DEVICE(0x0d8e, 0x3762)},
98 {USB_DEVICE(0x124a, 0x4025)},
99 {USB_DEVICE(0x1260, 0xee22)},
100 {USB_DEVICE(0x13b1, 0x000a)},
101 {USB_DEVICE(0x13B1, 0x000C)},
102 {USB_DEVICE(0x1413, 0x5400)},
103 {USB_DEVICE(0x1435, 0x0427)},
104 {USB_DEVICE(0x1668, 0x1050)},
105 {USB_DEVICE(0x1740, 0x1000)},
106 {USB_DEVICE(0x2001, 0x3704)},
107 {USB_DEVICE(0x2001, 0x3705)},
108 {USB_DEVICE(0x413c, 0x5513)},
109 {USB_DEVICE(0x413c, 0x8102)},
110 {USB_DEVICE(0x413c, 0x8104)},
116 static const struct {
126 .hw =
"ISL3886 + net2280",
136 static void p54u_rx_cb(
struct urb *
urb)
150 skb_put(skb, urb->actual_length);
160 skb = dev_alloc_skb(priv->
common.rx_mtu + 32);
169 urb->transfer_buffer = skb_tail_pointer(skb);
178 skb_reset_tail_pointer(skb);
180 urb->transfer_buffer = skb_tail_pointer(skb);
191 static void p54u_tx_cb(
struct urb *urb)
193 struct sk_buff *skb = urb->context;
200 static void p54u_tx_dummy_cb(
struct urb *urb) { }
226 while (skb_queue_len(&priv->
rx_queue) < 32) {
238 usb_fill_bulk_urb(entry, priv->
udev,
240 skb_tail_pointer(skb),
241 priv->
common.rx_mtu + 32, p54u_rx_cb, skb);
274 return p54u_init_urbs(dev);
284 chk = (chk >> 5) ^ (chk << 3);
293 struct urb *data_urb;
305 usb_fill_bulk_urb(data_urb, priv->
udev,
308 p54u_tx_cb : p54u_tx_dummy_cb, skb);
309 data_urb->transfer_flags |= URB_ZERO_PACKET;
322 struct urb *int_urb =
NULL, *data_urb =
NULL;
343 memset(hdr, 0,
sizeof(*hdr));
347 usb_fill_bulk_urb(int_urb, priv->
udev,
349 p54u_tx_dummy_cb, dev);
356 int_urb->transfer_flags |= URB_FREE_BUFFER | URB_ZERO_PACKET;
359 usb_fill_bulk_urb(data_urb, priv->
udev,
362 p54u_tx_cb : p54u_tx_dummy_cb, skb);
363 data_urb->transfer_flags |= URB_ZERO_PACKET;
388 static int p54u_write(
struct p54u_priv *priv,
408 static int p54u_read(
struct p54u_priv *priv,
void *buf,
426 read,
sizeof(*read), &alen, 1000);
431 reg,
sizeof(*reg), &alen, 1000);
439 static int p54u_bulk_msg(
struct p54u_priv *priv,
unsigned int ep,
440 void *data,
size_t len)
444 data, len, &alen, 2000);
450 int ret,
lock = (priv->
intf->condition != USB_INTERFACE_BINDING);
455 dev_err(&priv->
udev->dev,
"(p54usb) unable to lock "
456 "device for reset (%d)!\n", ret);
463 usb_unlock_device(priv->
udev);
466 dev_err(&priv->
udev->dev,
"(p54usb) unable to reset "
467 "device (%d)!\n", ret);
472 static const char p54u_romboot_3887[] =
"~~~~";
473 static int p54u_firmware_reset_3887(
struct ieee80211_hw *dev)
486 dev_err(&priv->
udev->dev,
"(p54usb) unable to jump to "
487 "boot ROM (%d)!\n", ret);
492 static const char p54u_firmware_upload_3887[] =
"<\r";
493 static int p54u_upload_firmware_3887(
struct ieee80211_hw *dev)
504 err = p54u_firmware_reset_3887(dev);
510 dev_err(&priv->
udev->dev,
"(p54usb) cannot allocate firmware"
516 strcpy(buf, p54u_firmware_upload_3887);
517 left -=
strlen(p54u_firmware_upload_3887);
518 tmp +=
strlen(p54u_firmware_upload_3887);
520 data = priv->
fw->data;
521 remains = priv->
fw->size;
529 left -=
sizeof(*hdr);
561 goto err_upload_failed;
572 dev_err(&priv->
udev->dev,
"(p54usb) firmware upload failed!\n");
573 goto err_upload_failed;
578 if (alen > 2 && !
memcmp(buf,
"OK", 2))
581 if (alen > 5 && !
memcmp(buf,
"ERROR", 5)) {
587 dev_err(&priv->
udev->dev,
"(p54usb) firmware boot "
594 dev_err(&priv->
udev->dev,
"(p54usb) firmware upload failed!\n");
595 goto err_upload_failed;
602 dev_err(&priv->
udev->dev,
"(p54usb) firmware boot failed!\n");
603 goto err_upload_failed;
609 if (alen > 0 && buf[0] ==
'g')
618 goto err_upload_failed;
625 static int p54u_upload_firmware_net2280(
struct ieee80211_hw *dev)
632 unsigned int remains,
offset;
637 dev_err(&priv->
udev->dev,
"(p54usb) firmware buffer "
642 #define P54U_WRITE(type, addr, data) \
644 err = p54u_write(priv, buf, type,\
645 cpu_to_le32((u32)(unsigned long)addr), data);\
650 #define P54U_READ(type, addr) \
652 err = p54u_read(priv, buf, type,\
653 cpu_to_le32((u32)(unsigned long)addr), ®);\
741 remains = priv->
fw->size;
742 data = priv->
fw->data;
746 unsigned int block_len =
min(remains, (
unsigned int)512);
747 memcpy(buf, data, block_len);
751 dev_err(&priv->
udev->dev,
"(p54usb) firmware block "
786 "transfer failed\n");
793 remains -= block_len;
834 buf,
sizeof(
__le32), &alen, 1000);
835 if (err || alen !=
sizeof(
__le32))
856 static int p54_find_type(
struct p54u_priv *priv)
861 if (p54u_fwlist[i].type == priv->
hw_type)
863 if (i == __NUM_P54U_HWTYPES)
869 static int p54u_start_ops(
struct p54u_priv *priv)
878 ret = p54_find_type(priv);
882 if (priv->
common.fw_interface != p54u_fwlist[ret].intf) {
883 dev_err(&priv->
udev->dev,
"wrong firmware, please get "
884 "a firmware for \"%s\" and try again.\n",
885 p54u_fwlist[ret].hw);
894 ret = p54u_open(dev);
925 struct usb_device *
udev = priv->
udev;
931 err = p54u_start_ops(priv);
934 dev_err(&udev->dev,
"Firmware not found.\n");
940 dev_err(&udev->dev,
"failed to initialize device (%d)\n", err);
953 device_unlock(parent);
962 struct usb_device *udev = interface_to_usbdev(intf);
970 i = p54_find_type(priv);
974 dev_info(&priv->
udev->dev,
"Loading firmware file %s\n",
980 p54u_load_firmware_cb);
982 dev_err(&priv->
udev->dev,
"(p54usb) cannot load firmware %s "
983 "(%d)!\n", p54u_fwlist[i].fw, err);
992 struct usb_device *udev = interface_to_usbdev(intf);
996 unsigned int i, recognized_pipes;
1001 dev_err(&udev->dev,
"(p54usb) ieee80211 alloc failed\n");
1008 SET_IEEE80211_DEV(dev, &intf->dev);
1009 usb_set_intfdata(intf, dev);
1012 skb_queue_head_init(&priv->
rx_queue);
1019 i = intf->altsetting->desc.bNumEndpoints;
1020 recognized_pipes = 0;
1022 switch (intf->altsetting->endpoint[i].desc.bEndpointAddress) {
1035 priv->
common.open = p54u_open;
1036 priv->
common.stop = p54u_stop;
1040 udev->reset_resume = 1;
1042 err = p54u_device_reset(dev);
1047 priv->
common.tx = p54u_tx_lm87;
1048 priv->
upload_fw = p54u_upload_firmware_3887;
1053 priv->
common.tx = p54u_tx_net2280;
1054 priv->
upload_fw = p54u_upload_firmware_net2280;
1056 err = p54u_load_firmware(dev, intf);
1109 err = p54u_resume(intf);
1125 return p54u_pre_reset(intf);
1130 static struct usb_driver p54u_driver = {
1132 .id_table = p54u_table,
1133 .probe = p54u_probe,
1135 .pre_reset = p54u_pre_reset,
1136 .post_reset = p54u_post_reset,
1138 .suspend = p54u_suspend,
1139 .resume = p54u_resume,
1140 .reset_resume = p54u_resume,
1143 .disable_hub_initiated_lpm = 1,