Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[IRDA]: Support for Sigmatel STIR421x chip

This patch enables support for the Sigmatel's STIR421x IrDA chip.
Once patched with Sigmatel's firmware, this chip "almost" follows the
USB-IrDA spec. Thus this patch is against irda-usb.[ch].

The code has been tested by Nick Fedchik on an STIR4210 chipset based
dongle.

Signed-off-by: Samuel Ortiz <samuel.ortiz@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Samuel Ortiz and committed by
David S. Miller
137dc023 c1e14a6e

+372 -34
+343 -20
drivers/net/irda/irda-usb.c
··· 1 1 /***************************************************************************** 2 2 * 3 3 * Filename: irda-usb.c 4 - * Version: 0.9b 4 + * Version: 0.10 5 5 * Description: IrDA-USB Driver 6 6 * Status: Experimental 7 7 * Author: Dag Brattli <dag@brattli.net> ··· 9 9 * Copyright (C) 2000, Roman Weissgaerber <weissg@vienna.at> 10 10 * Copyright (C) 2001, Dag Brattli <dag@brattli.net> 11 11 * Copyright (C) 2001, Jean Tourrilhes <jt@hpl.hp.com> 12 + * Copyright (C) 2004, SigmaTel, Inc. <irquality@sigmatel.com> 13 + * Copyright (C) 2005, Milan Beno <beno@pobox.sk> 14 + * Copyright (C) 2006, Nick Fedchik <nick@fedchik.org.ua> 12 15 * 13 16 * This program is free software; you can redistribute it and/or modify 14 17 * it under the terms of the GNU General Public License as published by ··· 64 61 #include <linux/slab.h> 65 62 #include <linux/rtnetlink.h> 66 63 #include <linux/usb.h> 64 + #include <linux/firmware.h> 67 65 68 66 #include "irda-usb.h" 69 67 ··· 82 78 { USB_DEVICE(0x50f, 0x180), .driver_info = IUC_SPEED_BUG | IUC_NO_WINDOW }, 83 79 /* Extended Systems, Inc., XTNDAccess IrDA USB (ESI-9685) */ 84 80 { USB_DEVICE(0x8e9, 0x100), .driver_info = IUC_SPEED_BUG | IUC_NO_WINDOW }, 81 + /* SigmaTel STIR4210/4220/4116 USB IrDA (VFIR) Bridge */ 82 + { USB_DEVICE(0x66f, 0x4210), .driver_info = IUC_STIR_4210 | IUC_SPEED_BUG }, 83 + { USB_DEVICE(0x66f, 0x4220), .driver_info = IUC_STIR_4210 | IUC_SPEED_BUG }, 84 + { USB_DEVICE(0x66f, 0x4116), .driver_info = IUC_STIR_4210 | IUC_SPEED_BUG }, 85 85 { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | 86 - USB_DEVICE_ID_MATCH_INT_SUBCLASS, 86 + USB_DEVICE_ID_MATCH_INT_SUBCLASS, 87 87 .bInterfaceClass = USB_CLASS_APP_SPEC, 88 88 .bInterfaceSubClass = USB_CLASS_IRDA, 89 89 .driver_info = IUC_DEFAULT, }, ··· 107 99 108 100 /*------------------------------------------------------------------*/ 109 101 102 + static void irda_usb_init_qos(struct irda_usb_cb *self) ; 110 103 static struct irda_class_desc *irda_usb_find_class_desc(struct usb_interface *intf); 111 104 static void irda_usb_disconnect(struct usb_interface *intf); 112 105 static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self); ··· 150 141 __u8 *header, 151 142 int force) 152 143 { 153 - /* Set the negotiated link speed */ 144 + /* Here we check if we have an STIR421x chip, 145 + * and if either speed or xbofs (or both) needs 146 + * to be changed. 147 + */ 148 + if (self->capability & IUC_STIR_4210 && 149 + ((self->new_speed != -1) || (self->new_xbofs != -1))) { 150 + 151 + /* With STIR421x, speed and xBOFs must be set at the same 152 + * time, even if only one of them changes. 153 + */ 154 + if (self->new_speed == -1) 155 + self->new_speed = self->speed ; 156 + 157 + if (self->new_xbofs == -1) 158 + self->new_xbofs = self->xbofs ; 159 + } 160 + 161 + /* Set the link speed */ 154 162 if (self->new_speed != -1) { 155 163 /* Hum... Ugly hack :-( 156 164 * Some device are not compliant with the spec and change ··· 217 191 *header = SPEED_4000000; 218 192 self->new_xbofs = 0; 219 193 break; 220 - } 194 + case 16000000: 195 + *header = SPEED_16000000; 196 + self->new_xbofs = 0; 197 + break; 198 + } 221 199 } else 222 200 /* No change */ 223 201 *header = 0; ··· 265 235 } 266 236 } 267 237 238 + /* 239 + * calculate turnaround time for SigmaTel header 240 + */ 241 + static __u8 get_turnaround_time(struct sk_buff *skb) 242 + { 243 + int turnaround_time = irda_get_mtt(skb); 244 + 245 + if ( turnaround_time == 0 ) 246 + return 0; 247 + else if ( turnaround_time <= 10 ) 248 + return 1; 249 + else if ( turnaround_time <= 50 ) 250 + return 2; 251 + else if ( turnaround_time <= 100 ) 252 + return 3; 253 + else if ( turnaround_time <= 500 ) 254 + return 4; 255 + else if ( turnaround_time <= 1000 ) 256 + return 5; 257 + else if ( turnaround_time <= 5000 ) 258 + return 6; 259 + else 260 + return 7; 261 + } 262 + 263 + 268 264 /*------------------------------------------------------------------*/ 269 265 /* 270 266 * Send a command to change the speed of the dongle ··· 318 262 /* Set the new speed and xbofs in this fake frame */ 319 263 irda_usb_build_header(self, frame, 1); 320 264 265 + if ( self->capability & IUC_STIR_4210 ) { 266 + if (frame[0] == 0) return ; // do nothing if no change 267 + frame[1] = 0; // other parameters don't change here 268 + frame[2] = 0; 269 + } 270 + 321 271 /* Submit the 0 length IrDA frame to trigger new speed settings */ 322 272 usb_fill_bulk_urb(urb, self->usbdev, 323 273 usb_sndbulkpipe(self->usbdev, self->bulk_out_ep), 324 274 frame, IRDA_USB_SPEED_MTU, 325 275 speed_bulk_callback, self); 326 - urb->transfer_buffer_length = USB_IRDA_HEADER; 276 + urb->transfer_buffer_length = self->header_length; 327 277 urb->transfer_flags = 0; 328 278 329 279 /* Irq disabled -> GFP_ATOMIC */ ··· 445 383 * allocation will be done lower in skb_push(). 446 384 * Also, we don't use directly skb_cow(), because it require 447 385 * headroom >= 16, which force unnecessary copies - Jean II */ 448 - if (skb_headroom(skb) < USB_IRDA_HEADER) { 386 + if (skb_headroom(skb) < self->header_length) { 449 387 IRDA_DEBUG(0, "%s(), Insuficient skb headroom.\n", __FUNCTION__); 450 - if (skb_cow(skb, USB_IRDA_HEADER)) { 388 + if (skb_cow(skb, self->header_length)) { 451 389 IRDA_WARNING("%s(), failed skb_cow() !!!\n", __FUNCTION__); 452 390 goto drop; 453 391 } 454 392 } 455 393 456 394 /* Change setting for next frame */ 457 - irda_usb_build_header(self, skb_push(skb, USB_IRDA_HEADER), 0); 395 + 396 + if ( self->capability & IUC_STIR_4210 ) { 397 + __u8 turnaround_time; 398 + __u8* frame; 399 + turnaround_time = get_turnaround_time( skb ); 400 + frame= skb_push(skb, self->header_length); 401 + irda_usb_build_header(self, frame, 0); 402 + frame[2] = turnaround_time; 403 + if ((skb->len != 0) && 404 + ((skb->len % 128) == 0) && 405 + ((skb->len % 512) != 0)) { 406 + /* add extra byte for special SigmaTel feature */ 407 + frame[1] = 1; 408 + skb_put(skb, 1); 409 + } else { 410 + frame[1] = 0; 411 + } 412 + } else { 413 + irda_usb_build_header(self, skb_push(skb, self->header_length), 0); 414 + } 458 415 459 416 /* FIXME: Make macro out of this one */ 460 417 ((struct irda_skb_cb *)skb->cb)->context = self; ··· 876 795 } 877 796 878 797 /* Check for empty frames */ 879 - if (urb->actual_length <= USB_IRDA_HEADER) { 798 + if (urb->actual_length <= self->header_length) { 880 799 IRDA_WARNING("%s(), empty frame!\n", __FUNCTION__); 881 800 goto done; 882 801 } ··· 897 816 docopy = (urb->actual_length < IRDA_RX_COPY_THRESHOLD); 898 817 899 818 /* Allocate a new skb */ 900 - newskb = dev_alloc_skb(docopy ? urb->actual_length : IRDA_SKB_MAX_MTU); 819 + if ( self->capability & IUC_STIR_4210 ) 820 + newskb = dev_alloc_skb(docopy ? urb->actual_length : IRDA_SKB_MAX_MTU + USB_IRDA_SIGMATEL_HEADER); 821 + else 822 + newskb = dev_alloc_skb(docopy ? urb->actual_length : IRDA_SKB_MAX_MTU); 823 + 901 824 if (!newskb) { 902 825 self->stats.rx_dropped++; 903 826 /* We could deliver the current skb, but this would stall ··· 930 845 931 846 /* Set proper length on skb & remove USB-IrDA header */ 932 847 skb_put(dataskb, urb->actual_length); 933 - skb_pull(dataskb, USB_IRDA_HEADER); 848 + skb_pull(dataskb, self->header_length); 934 849 935 850 /* Ask the networking layer to queue the packet for the IrDA stack */ 936 851 dataskb->dev = self->netdev; ··· 1022 937 return 0; /* For now */ 1023 938 } 1024 939 940 + 941 + #define STIR421X_PATCH_PRODUCT_VERSION_STR "Product Version: " 942 + #define STIR421X_PATCH_COMPONENT_VERSION_STR "Component Version: " 943 + #define STIR421X_PATCH_DATA_TAG_STR "STMP" 944 + #define STIR421X_PATCH_FILE_VERSION_MAX_OFFSET 512 /* version info is before here */ 945 + #define STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET 512 /* patch image starts before here */ 946 + #define STIR421X_PATCH_FILE_END_OF_HEADER_TAG 0x1A /* marks end of patch file header (PC DOS text file EOF character) */ 947 + 948 + /* 949 + * Known firmware patches for STIR421x dongles 950 + */ 951 + static char * stir421x_patches[] = { 952 + "42101001.sb", 953 + "42101002.sb", 954 + }; 955 + 956 + static int stir421x_get_patch_version(unsigned char * patch, const unsigned long patch_len) 957 + { 958 + unsigned int version_offset; 959 + unsigned long version_major, version_minor, version_build; 960 + unsigned char * version_start; 961 + int version_found = 0; 962 + 963 + for (version_offset = 0; 964 + version_offset < STIR421X_PATCH_FILE_END_OF_HEADER_TAG; 965 + version_offset++) { 966 + if (!memcmp(patch + version_offset, 967 + STIR421X_PATCH_PRODUCT_VERSION_STR, 968 + sizeof(STIR421X_PATCH_PRODUCT_VERSION_STR) - 1)) { 969 + version_found = 1; 970 + version_start = patch + 971 + version_offset + 972 + sizeof(STIR421X_PATCH_PRODUCT_VERSION_STR) - 1; 973 + break; 974 + } 975 + } 976 + 977 + /* We couldn't find a product version on this patch */ 978 + if (!version_found) 979 + return -EINVAL; 980 + 981 + /* Let's check if the product version is dotted */ 982 + if (version_start[3] != '.' || 983 + version_start[7] != '.') 984 + return -EINVAL; 985 + 986 + version_major = simple_strtoul(version_start, NULL, 10); 987 + version_minor = simple_strtoul(version_start + 4, NULL, 10); 988 + version_build = simple_strtoul(version_start + 8, NULL, 10); 989 + 990 + IRDA_DEBUG(2, "%s(), Major: %ld Minor: %ld Build: %ld\n", 991 + __FUNCTION__, 992 + version_major, version_minor, version_build); 993 + 994 + return (((version_major) << 12) + 995 + ((version_minor) << 8) + 996 + ((version_build / 10) << 4) + 997 + (version_build % 10)); 998 + 999 + } 1000 + 1001 + 1002 + static int stir421x_upload_patch (struct irda_usb_cb *self, 1003 + unsigned char * patch, 1004 + const unsigned int patch_len) 1005 + { 1006 + int retval = 0; 1007 + int actual_len; 1008 + unsigned int i = 0, download_amount = 0; 1009 + unsigned char * patch_chunk; 1010 + 1011 + IRDA_DEBUG (2, "%s(), Uploading STIR421x Patch\n", __FUNCTION__); 1012 + 1013 + patch_chunk = kzalloc(STIR421X_MAX_PATCH_DOWNLOAD_SIZE, GFP_KERNEL); 1014 + if (patch_chunk == NULL) 1015 + return -ENOMEM; 1016 + 1017 + /* break up patch into 1023-byte sections */ 1018 + for (i = 0; retval >= 0 && i < patch_len; i += download_amount) { 1019 + download_amount = patch_len - i; 1020 + if (download_amount > STIR421X_MAX_PATCH_DOWNLOAD_SIZE) 1021 + download_amount = STIR421X_MAX_PATCH_DOWNLOAD_SIZE; 1022 + 1023 + /* download the patch section */ 1024 + memcpy(patch_chunk, patch + i, download_amount); 1025 + 1026 + retval = usb_bulk_msg (self->usbdev, 1027 + usb_sndbulkpipe (self->usbdev, 1028 + self->bulk_out_ep), 1029 + patch_chunk, download_amount, 1030 + &actual_len, msecs_to_jiffies (500)); 1031 + IRDA_DEBUG (2, "%s(), Sent %u bytes\n", __FUNCTION__, 1032 + actual_len); 1033 + if (retval == 0) 1034 + mdelay(10); 1035 + } 1036 + 1037 + kfree(patch_chunk); 1038 + 1039 + if (i != patch_len) { 1040 + IRDA_ERROR ("%s(), Pushed %d bytes (!= patch_len (%d))\n", 1041 + __FUNCTION__, i, patch_len); 1042 + retval = -EIO; 1043 + } 1044 + 1045 + if (retval < 0) 1046 + /* todo - mark device as not ready */ 1047 + IRDA_ERROR ("%s(), STIR421x patch upload failed (%d)\n", 1048 + __FUNCTION__, retval); 1049 + 1050 + return retval; 1051 + } 1052 + 1053 + 1054 + static int stir421x_patch_device(struct irda_usb_cb *self) 1055 + { 1056 + unsigned int i, patch_found = 0, data_found = 0, data_offset; 1057 + int patch_version, ret = 0; 1058 + const struct firmware *fw_entry; 1059 + 1060 + for (i = 0; i < ARRAY_SIZE(stir421x_patches); i++) { 1061 + if(request_firmware(&fw_entry, stir421x_patches[i], &self->usbdev->dev) != 0) { 1062 + IRDA_ERROR( "%s(), Patch %s is not available\n", __FUNCTION__, stir421x_patches[i]); 1063 + continue; 1064 + } 1065 + 1066 + /* We found a patch from userspace */ 1067 + patch_version = stir421x_get_patch_version (fw_entry->data, fw_entry->size); 1068 + 1069 + if (patch_version < 0) { 1070 + /* Couldn't fetch a version, let's move on to the next file */ 1071 + IRDA_ERROR("%s(), version parsing failed\n", __FUNCTION__); 1072 + ret = patch_version; 1073 + release_firmware(fw_entry); 1074 + continue; 1075 + } 1076 + 1077 + if (patch_version != self->usbdev->descriptor.bcdDevice) { 1078 + /* Patch version and device don't match */ 1079 + IRDA_ERROR ("%s(), wrong patch version (%d <-> %d)\n", 1080 + __FUNCTION__, 1081 + patch_version, self->usbdev->descriptor.bcdDevice); 1082 + ret = -EINVAL; 1083 + release_firmware(fw_entry); 1084 + continue; 1085 + } 1086 + 1087 + /* If we're here, we've found a correct patch */ 1088 + patch_found = 1; 1089 + break; 1090 + 1091 + } 1092 + 1093 + /* We couldn't find a valid firmware, let's leave */ 1094 + if (!patch_found) 1095 + return ret; 1096 + 1097 + /* The actual image starts after the "STMP" keyword */ 1098 + for (data_offset = 0; data_offset < STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET; data_offset++) { 1099 + if (!memcmp(fw_entry->data + data_offset, 1100 + STIR421X_PATCH_DATA_TAG_STR, 1101 + sizeof(STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET))) { 1102 + IRDA_DEBUG(2, "%s(), found patch data for STIR421x at offset %d\n", 1103 + __FUNCTION__, data_offset); 1104 + data_found = 1; 1105 + break; 1106 + } 1107 + } 1108 + 1109 + /* We couldn't find "STMP" from the header */ 1110 + if (!data_found) 1111 + return -EINVAL; 1112 + 1113 + /* Let's upload the patch to the target */ 1114 + ret = stir421x_upload_patch(self, 1115 + &fw_entry->data[data_offset + sizeof(STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET)], 1116 + fw_entry->size - (data_offset + sizeof(STIR421X_PATCH_FILE_IMAGE_MAX_OFFSET))); 1117 + 1118 + release_firmware(fw_entry); 1119 + 1120 + return ret; 1121 + 1122 + } 1123 + 1124 + 1025 1125 /********************** IRDA DEVICE CALLBACKS **********************/ 1026 1126 /* 1027 1127 * Main calls from the IrDA/Network subsystem. ··· 1240 970 if(!self->present) { 1241 971 IRDA_WARNING("%s(), device not present!\n", __FUNCTION__); 1242 972 return -1; 973 + } 974 + 975 + if(self->needspatch) { 976 + IRDA_WARNING("%s(), device needs patch\n", __FUNCTION__) ; 977 + return -EIO ; 1243 978 } 1244 979 1245 980 /* Initialise default speed and xbofs value ··· 1325 1050 del_timer(&self->rx_defer_timer); 1326 1051 1327 1052 /* Deallocate all the Rx path buffers (URBs and skb) */ 1328 - for (i = 0; i < IU_MAX_RX_URBS; i++) { 1053 + for (i = 0; i < self->max_rx_urb; i++) { 1329 1054 struct urb *urb = self->rx_urb[i]; 1330 1055 struct sk_buff *skb = (struct sk_buff *) urb->context; 1331 1056 /* Cancel the receive command */ ··· 1701 1426 spin_lock_init(&self->lock); 1702 1427 init_timer(&self->rx_defer_timer); 1703 1428 1429 + self->capability = id->driver_info; 1430 + self->needspatch = ((self->capability & IUC_STIR_4210) != 0) ; 1431 + 1704 1432 /* Create all of the needed urbs */ 1705 - for (i = 0; i < IU_MAX_RX_URBS; i++) { 1433 + if (self->capability & IUC_STIR_4210) { 1434 + self->max_rx_urb = IU_SIGMATEL_MAX_RX_URBS; 1435 + self->header_length = USB_IRDA_SIGMATEL_HEADER; 1436 + } else { 1437 + self->max_rx_urb = IU_MAX_RX_URBS; 1438 + self->header_length = USB_IRDA_HEADER; 1439 + } 1440 + 1441 + self->rx_urb = kzalloc(self->max_rx_urb * sizeof(struct urb *), 1442 + GFP_KERNEL); 1443 + 1444 + for (i = 0; i < self->max_rx_urb; i++) { 1706 1445 self->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); 1707 1446 if (!self->rx_urb[i]) { 1708 1447 goto err_out_1; ··· 1768 1479 goto err_out_3; 1769 1480 } 1770 1481 1482 + self->usbdev = dev; 1483 + 1771 1484 /* Find IrDA class descriptor */ 1772 1485 irda_desc = irda_usb_find_class_desc(intf); 1773 1486 ret = -ENODEV; 1774 1487 if (irda_desc == NULL) 1775 1488 goto err_out_3; 1776 1489 1490 + if (self->needspatch) { 1491 + ret = usb_control_msg (self->usbdev, usb_sndctrlpipe (self->usbdev, 0), 1492 + 0x02, 0x40, 0, 0, 0, 0, msecs_to_jiffies(500)); 1493 + if (ret < 0) { 1494 + IRDA_DEBUG (0, "usb_control_msg failed %d\n", ret); 1495 + goto err_out_3; 1496 + } else { 1497 + mdelay(10); 1498 + } 1499 + } 1500 + 1777 1501 self->irda_desc = irda_desc; 1778 1502 self->present = 1; 1779 1503 self->netopen = 0; 1780 - self->capability = id->driver_info; 1781 - self->usbdev = dev; 1782 1504 self->usbintf = intf; 1783 1505 1784 1506 /* Allocate the buffer for speed changes */ ··· 1808 1508 1809 1509 IRDA_MESSAGE("IrDA: Registered device %s\n", net->name); 1810 1510 usb_set_intfdata(intf, self); 1511 + 1512 + if (self->needspatch) { 1513 + /* Now we fetch and upload the firmware patch */ 1514 + ret = stir421x_patch_device(self); 1515 + self->needspatch = (ret < 0); 1516 + if (ret < 0) { 1517 + printk("patch_device failed\n"); 1518 + goto err_out_4; 1519 + } 1520 + 1521 + /* replace IrDA class descriptor with what patched device is now reporting */ 1522 + irda_desc = irda_usb_find_class_desc (self->usbintf); 1523 + if (irda_desc == NULL) { 1524 + ret = -ENODEV; 1525 + goto err_out_4; 1526 + } 1527 + if (self->irda_desc) 1528 + kfree (self->irda_desc); 1529 + self->irda_desc = irda_desc; 1530 + irda_usb_init_qos(self); 1531 + } 1532 + 1811 1533 return 0; 1812 1534 1813 1535 err_out_4: ··· 1840 1518 err_out_2: 1841 1519 usb_free_urb(self->tx_urb); 1842 1520 err_out_1: 1843 - for (i = 0; i < IU_MAX_RX_URBS; i++) { 1521 + for (i = 0; i < self->max_rx_urb; i++) { 1844 1522 if (self->rx_urb[i]) 1845 1523 usb_free_urb(self->rx_urb[i]); 1846 1524 } ··· 1893 1571 /*netif_device_detach(self->netdev);*/ 1894 1572 netif_stop_queue(self->netdev); 1895 1573 /* Stop all the receive URBs. Must be synchronous. */ 1896 - for (i = 0; i < IU_MAX_RX_URBS; i++) 1574 + for (i = 0; i < self->max_rx_urb; i++) 1897 1575 usb_kill_urb(self->rx_urb[i]); 1898 1576 /* Cancel Tx and speed URB. 1899 1577 * Make sure it's synchronous to avoid races. */ ··· 1908 1586 self->usbintf = NULL; 1909 1587 1910 1588 /* Clean up our urbs */ 1911 - for (i = 0; i < IU_MAX_RX_URBS; i++) 1589 + for (i = 0; i < self->max_rx_urb; i++) 1912 1590 usb_free_urb(self->rx_urb[i]); 1591 + kfree(self->rx_urb); 1913 1592 /* Clean up Tx and speed URB */ 1914 1593 usb_free_urb(self->tx_urb); 1915 1594 usb_free_urb(self->speed_urb); ··· 1971 1648 */ 1972 1649 module_param(qos_mtt_bits, int, 0); 1973 1650 MODULE_PARM_DESC(qos_mtt_bits, "Minimum Turn Time"); 1974 - MODULE_AUTHOR("Roman Weissgaerber <weissg@vienna.at>, Dag Brattli <dag@brattli.net> and Jean Tourrilhes <jt@hpl.hp.com>"); 1975 - MODULE_DESCRIPTION("IrDA-USB Dongle Driver"); 1651 + MODULE_AUTHOR("Roman Weissgaerber <weissg@vienna.at>, Dag Brattli <dag@brattli.net>, Jean Tourrilhes <jt@hpl.hp.com> and Nick Fedchik <nick@fedchik.org.ua>"); 1652 + MODULE_DESCRIPTION("IrDA-USB Dongle Driver"); 1976 1653 MODULE_LICENSE("GPL");
+29 -14
drivers/net/irda/irda-usb.h
··· 1 1 /***************************************************************************** 2 2 * 3 3 * Filename: irda-usb.h 4 - * Version: 0.9b 4 + * Version: 0.10 5 5 * Description: IrDA-USB Driver 6 6 * Status: Experimental 7 7 * Author: Dag Brattli <dag@brattli.net> ··· 9 9 * Copyright (C) 2001, Roman Weissgaerber <weissg@vienna.at> 10 10 * Copyright (C) 2000, Dag Brattli <dag@brattli.net> 11 11 * Copyright (C) 2001, Jean Tourrilhes <jt@hpl.hp.com> 12 + * Copyright (C) 2004, SigmaTel, Inc. <irquality@sigmatel.com> 13 + * Copyright (C) 2005, Milan Beno <beno@pobox.sk> 14 + * Copyright (C) 2006, Nick FEdchik <nick@fedchik.org.ua> 12 15 * 13 16 * This program is free software; you can redistribute it and/or modify 14 17 * it under the terms of the GNU General Public License as published by ··· 33 30 34 31 #include <net/irda/irda.h> 35 32 #include <net/irda/irda_device.h> /* struct irlap_cb */ 33 + 34 + #define PATCH_FILE_SIZE_MAX 65536 35 + #define PATCH_FILE_SIZE_MIN 80 36 36 37 37 #define RX_COPY_THRESHOLD 200 38 38 #define IRDA_USB_MAX_MTU 2051 ··· 85 79 /* Inbound header */ 86 80 #define MEDIA_BUSY 0x80 87 81 88 - #define SPEED_2400 0x01 89 - #define SPEED_9600 0x02 90 - #define SPEED_19200 0x03 91 - #define SPEED_38400 0x04 92 - #define SPEED_57600 0x05 93 - #define SPEED_115200 0x06 94 - #define SPEED_576000 0x07 95 - #define SPEED_1152000 0x08 96 - #define SPEED_4000000 0x09 82 + #define SPEED_2400 0x01 83 + #define SPEED_9600 0x02 84 + #define SPEED_19200 0x03 85 + #define SPEED_38400 0x04 86 + #define SPEED_57600 0x05 87 + #define SPEED_115200 0x06 88 + #define SPEED_576000 0x07 89 + #define SPEED_1152000 0x08 90 + #define SPEED_4000000 0x09 91 + #define SPEED_16000000 0x0a 97 92 98 93 /* Basic capabilities */ 99 94 #define IUC_DEFAULT 0x00 /* Basic device compliant with 1.0 spec */ ··· 107 100 #define IUC_SMALL_PKT 0x10 /* Device doesn't behave with big Rx packets */ 108 101 #define IUC_MAX_WINDOW 0x20 /* Device underestimate the Rx window */ 109 102 #define IUC_MAX_XBOFS 0x40 /* Device need more xbofs than advertised */ 103 + #define IUC_STIR_4210 0x80 /* SigmaTel 4210/4220/4116 VFIR */ 110 104 111 105 /* USB class definitions */ 112 - #define USB_IRDA_HEADER 0x01 113 - #define USB_CLASS_IRDA 0x02 /* USB_CLASS_APP_SPEC subclass */ 114 - #define USB_DT_IRDA 0x21 106 + #define USB_IRDA_HEADER 0x01 107 + #define USB_CLASS_IRDA 0x02 /* USB_CLASS_APP_SPEC subclass */ 108 + #define USB_DT_IRDA 0x21 109 + #define USB_IRDA_SIGMATEL_HEADER 0x03 110 + #define IU_SIGMATEL_MAX_RX_URBS (IU_MAX_ACTIVE_RX_URBS + USB_IRDA_SIGMATEL_HEADER) 115 111 116 112 struct irda_class_desc { 117 113 __u8 bLength; ··· 133 123 * (6.2.5, USB-IrDA class spec 1.0) */ 134 124 135 125 #define IU_REQ_GET_CLASS_DESC 0x06 126 + #define STIR421X_MAX_PATCH_DOWNLOAD_SIZE 1023 136 127 137 128 struct irda_usb_cb { 138 129 struct irda_class_desc *irda_desc; ··· 147 136 __u16 bulk_out_mtu; /* Max Tx packet size in bytes */ 148 137 __u8 bulk_int_ep; /* Interrupt Endpoint assignments */ 149 138 150 - struct urb *rx_urb[IU_MAX_RX_URBS]; /* URBs used to receive data frames */ 139 + __u8 max_rx_urb; 140 + struct urb **rx_urb; /* URBs used to receive data frames */ 151 141 struct urb *idle_rx_urb; /* Pointer to idle URB in Rx path */ 152 142 struct urb *tx_urb; /* URB used to send data frames */ 153 143 struct urb *speed_urb; /* URB used to send speed commands */ ··· 168 156 __s16 new_xbofs; /* xbofs we need to set */ 169 157 __u32 speed; /* Current speed */ 170 158 __s32 new_speed; /* speed we need to set */ 159 + 160 + __u8 header_length; /* USB-IrDA frame header size */ 161 + int needspatch; /* device needs firmware patch */ 171 162 172 163 struct timer_list rx_defer_timer; /* Wait for Rx error to clear */ 173 164 };