OLD | NEW |
1 /* | 1 /* |
2 * | 2 * |
3 * Generic Bluetooth USB driver | 3 * Generic Bluetooth USB driver |
4 * | 4 * |
5 * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org> | 5 * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org> |
6 * | 6 * |
7 * | 7 * |
8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License as published by | 9 * it under the terms of the GNU General Public License as published by |
10 * the Free Software Foundation; either version 2 of the License, or | 10 * the Free Software Foundation; either version 2 of the License, or |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include <linux/slab.h> | 27 #include <linux/slab.h> |
28 #include <linux/types.h> | 28 #include <linux/types.h> |
29 #include <linux/sched.h> | 29 #include <linux/sched.h> |
30 #include <linux/errno.h> | 30 #include <linux/errno.h> |
31 #include <linux/skbuff.h> | 31 #include <linux/skbuff.h> |
32 | 32 |
33 #include <linux/usb.h> | 33 #include <linux/usb.h> |
34 | 34 |
35 #include <net/bluetooth/bluetooth.h> | 35 #include <net/bluetooth/bluetooth.h> |
36 #include <net/bluetooth/hci_core.h> | 36 #include <net/bluetooth/hci_core.h> |
| 37 #include "fwload.h" |
37 | 38 |
38 #define VERSION "0.6" | 39 #define VERSION "0.6" |
39 | 40 |
40 static int ignore_dga; | 41 static int ignore_dga; |
41 static int ignore_csr; | 42 static int ignore_csr; |
42 static int ignore_sniffer; | 43 static int ignore_sniffer; |
43 static int disable_scofix; | 44 static int disable_scofix; |
44 static int force_scofix; | 45 static int force_scofix; |
45 | 46 |
46 static int reset = 1; | 47 static int reset = 1; |
47 | 48 |
48 static struct usb_driver btusb_driver; | 49 static struct usb_driver btusb_driver; |
49 | 50 |
50 #define BTUSB_IGNORE 0x01 | 51 #define BTUSB_IGNORE 0x01 |
51 #define BTUSB_DIGIANSWER 0x02 | 52 #define BTUSB_DIGIANSWER 0x02 |
52 #define BTUSB_CSR 0x04 | 53 #define BTUSB_CSR 0x04 |
53 #define BTUSB_SNIFFER 0x08 | 54 #define BTUSB_SNIFFER 0x08 |
54 #define BTUSB_BCM92035 0x10 | 55 #define BTUSB_BCM92035 0x10 |
55 #define BTUSB_BROKEN_ISOC 0x20 | 56 #define BTUSB_BROKEN_ISOC 0x20 |
56 #define BTUSB_WRONG_SCO_MTU 0x40 | 57 #define BTUSB_WRONG_SCO_MTU 0x40 |
57 | 58 |
| 59 static struct usb_device_id ath_table[] = { |
| 60 /* Atheros AR3011 */ |
| 61 { USB_DEVICE(0x0CF3, 0x3002) }, |
| 62 { USB_DEVICE(0x13D3, 0x3304) }, |
| 63 { } /* Terminating entry */ |
| 64 }; |
| 65 |
| 66 /* Add firmware file, load and unload function |
| 67 * to download the firmware to target RAM |
| 68 */ |
| 69 static struct fw_cb_config btusb_fwcbs[] = { |
| 70 { |
| 71 .fwfile = "ath3k-1.fw", |
| 72 .usb_id_table = ath_table, |
| 73 .fwload = ath_fw_load, |
| 74 .fwunload = ath_fw_unload |
| 75 }, |
| 76 {} |
| 77 }; |
| 78 |
58 static struct usb_device_id btusb_table[] = { | 79 static struct usb_device_id btusb_table[] = { |
59 /* Generic Bluetooth USB device */ | 80 /* Generic Bluetooth USB device */ |
60 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) }, | 81 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) }, |
61 | 82 |
62 /* Apple iMac11,1 */ | 83 /* Apple iMac11,1 */ |
63 { USB_DEVICE(0x05ac, 0x8215) }, | 84 { USB_DEVICE(0x05ac, 0x8215) }, |
64 | 85 |
65 /* AVM BlueFRITZ! USB v2.0 */ | 86 /* AVM BlueFRITZ! USB v2.0 */ |
66 { USB_DEVICE(0x057c, 0x3800) }, | 87 { USB_DEVICE(0x057c, 0x3800) }, |
67 | 88 |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 usb_autopm_put_interface(data->intf); | 877 usb_autopm_put_interface(data->intf); |
857 } | 878 } |
858 | 879 |
859 static int btusb_probe(struct usb_interface *intf, | 880 static int btusb_probe(struct usb_interface *intf, |
860 const struct usb_device_id *id) | 881 const struct usb_device_id *id) |
861 { | 882 { |
862 struct usb_endpoint_descriptor *ep_desc; | 883 struct usb_endpoint_descriptor *ep_desc; |
863 struct btusb_data *data; | 884 struct btusb_data *data; |
864 struct hci_dev *hdev; | 885 struct hci_dev *hdev; |
865 int i, err; | 886 int i, err; |
| 887 const struct usb_device_id *match; |
866 | 888 |
867 BT_DBG("intf %p id %p", intf, id); | 889 BT_DBG("intf %p id %p", intf, id); |
868 | 890 |
869 /* interface numbers are hardcoded in the spec */ | 891 /* interface numbers are hardcoded in the spec */ |
870 if (intf->cur_altsetting->desc.bInterfaceNumber != 0) | 892 if (intf->cur_altsetting->desc.bInterfaceNumber != 0) |
871 return -ENODEV; | 893 return -ENODEV; |
872 | 894 |
873 if (!id->driver_info) { | 895 if (!id->driver_info) { |
874 const struct usb_device_id *match; | 896 const struct usb_device_id *match; |
875 match = usb_match_id(intf, blacklist_table); | 897 match = usb_match_id(intf, blacklist_table); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) { | 937 if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) { |
916 kfree(data); | 938 kfree(data); |
917 return -ENODEV; | 939 return -ENODEV; |
918 } | 940 } |
919 | 941 |
920 data->cmdreq_type = USB_TYPE_CLASS; | 942 data->cmdreq_type = USB_TYPE_CLASS; |
921 | 943 |
922 data->udev = interface_to_usbdev(intf); | 944 data->udev = interface_to_usbdev(intf); |
923 data->intf = intf; | 945 data->intf = intf; |
924 | 946 |
| 947 for (i = 0; btusb_fwcbs[i].fwfile; i++) { |
| 948 match = usb_match_id(intf, btusb_fwcbs[i].usb_id_table); |
| 949 if (match) { |
| 950 if (btusb_fwcbs[i].fwload) { |
| 951 btusb_fwcbs[i].data = |
| 952 btusb_fwcbs[i].fwload(intf, |
| 953 btusb_fwcbs[i].fwfile, |
| 954 &btusb_fwcbs[i].bsuspend); |
| 955 } |
| 956 break; |
| 957 } |
| 958 } |
| 959 |
925 spin_lock_init(&data->lock); | 960 spin_lock_init(&data->lock); |
926 | 961 |
927 INIT_WORK(&data->work, btusb_work); | 962 INIT_WORK(&data->work, btusb_work); |
928 INIT_WORK(&data->waker, btusb_waker); | 963 INIT_WORK(&data->waker, btusb_waker); |
929 spin_lock_init(&data->txlock); | 964 spin_lock_init(&data->txlock); |
930 | 965 |
931 init_usb_anchor(&data->tx_anchor); | 966 init_usb_anchor(&data->tx_anchor); |
932 init_usb_anchor(&data->intr_anchor); | 967 init_usb_anchor(&data->intr_anchor); |
933 init_usb_anchor(&data->bulk_anchor); | 968 init_usb_anchor(&data->bulk_anchor); |
934 init_usb_anchor(&data->isoc_anchor); | 969 init_usb_anchor(&data->isoc_anchor); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 | 1058 |
1024 usb_set_intfdata(intf, data); | 1059 usb_set_intfdata(intf, data); |
1025 | 1060 |
1026 return 0; | 1061 return 0; |
1027 } | 1062 } |
1028 | 1063 |
1029 static void btusb_disconnect(struct usb_interface *intf) | 1064 static void btusb_disconnect(struct usb_interface *intf) |
1030 { | 1065 { |
1031 struct btusb_data *data = usb_get_intfdata(intf); | 1066 struct btusb_data *data = usb_get_intfdata(intf); |
1032 struct hci_dev *hdev; | 1067 struct hci_dev *hdev; |
| 1068 const struct usb_device_id *match; |
| 1069 int i; |
1033 | 1070 |
1034 BT_DBG("intf %p", intf); | 1071 BT_DBG("intf %p", intf); |
1035 | 1072 |
1036 if (!data) | 1073 if (!data) |
1037 return; | 1074 return; |
1038 | 1075 |
| 1076 for (i = 0; btusb_fwcbs[i].fwfile; i++) { |
| 1077 match = usb_match_id(intf, btusb_fwcbs[i].usb_id_table); |
| 1078 if (match) { |
| 1079 if (btusb_fwcbs[i].fwunload) { |
| 1080 btusb_fwcbs[i].fwunload(btusb_fwcbs[i].data, |
| 1081 btusb_fwcbs[i].bsuspend); |
| 1082 btusb_fwcbs[i].data = NULL; |
| 1083 } |
| 1084 break; |
| 1085 } |
| 1086 } |
| 1087 |
1039 hdev = data->hdev; | 1088 hdev = data->hdev; |
1040 | 1089 |
1041 __hci_dev_hold(hdev); | 1090 __hci_dev_hold(hdev); |
1042 | 1091 |
1043 usb_set_intfdata(data->intf, NULL); | 1092 usb_set_intfdata(data->intf, NULL); |
1044 | 1093 |
1045 if (data->isoc) | 1094 if (data->isoc) |
1046 usb_set_intfdata(data->isoc, NULL); | 1095 usb_set_intfdata(data->isoc, NULL); |
1047 | 1096 |
1048 hci_unregister_dev(hdev); | 1097 hci_unregister_dev(hdev); |
1049 | 1098 |
1050 if (intf == data->isoc) | 1099 if (intf == data->isoc) |
1051 usb_driver_release_interface(&btusb_driver, data->intf); | 1100 usb_driver_release_interface(&btusb_driver, data->intf); |
1052 else if (data->isoc) | 1101 else if (data->isoc) |
1053 usb_driver_release_interface(&btusb_driver, data->isoc); | 1102 usb_driver_release_interface(&btusb_driver, data->isoc); |
1054 | 1103 |
1055 __hci_dev_put(hdev); | 1104 __hci_dev_put(hdev); |
1056 | 1105 |
1057 hci_free_dev(hdev); | 1106 hci_free_dev(hdev); |
1058 } | 1107 } |
1059 | 1108 |
1060 #ifdef CONFIG_PM | 1109 #ifdef CONFIG_PM |
1061 static int btusb_suspend(struct usb_interface *intf, pm_message_t message) | 1110 static int btusb_suspend(struct usb_interface *intf, pm_message_t message) |
1062 { | 1111 { |
1063 struct btusb_data *data = usb_get_intfdata(intf); | 1112 struct btusb_data *data = usb_get_intfdata(intf); |
| 1113 const struct usb_device_id *match; |
| 1114 int i; |
1064 | 1115 |
1065 BT_DBG("intf %p", intf); | 1116 BT_DBG("intf %p", intf); |
1066 | 1117 |
1067 if (data->suspend_count++) | 1118 if (data->suspend_count++) |
1068 return 0; | 1119 return 0; |
1069 | 1120 |
| 1121 for (i = 0; btusb_fwcbs[i].fwfile; i++) { |
| 1122 match = usb_match_id(intf, btusb_fwcbs[i].usb_id_table); |
| 1123 if (match) { |
| 1124 btusb_fwcbs[i].bsuspend = 1; |
| 1125 break; |
| 1126 } |
| 1127 } |
| 1128 |
1070 spin_lock_irq(&data->txlock); | 1129 spin_lock_irq(&data->txlock); |
1071 if (!((message.event & PM_EVENT_AUTO) && data->tx_in_flight)) { | 1130 if (!((message.event & PM_EVENT_AUTO) && data->tx_in_flight)) { |
1072 set_bit(BTUSB_SUSPENDING, &data->flags); | 1131 set_bit(BTUSB_SUSPENDING, &data->flags); |
1073 spin_unlock_irq(&data->txlock); | 1132 spin_unlock_irq(&data->txlock); |
1074 } else { | 1133 } else { |
1075 spin_unlock_irq(&data->txlock); | 1134 spin_unlock_irq(&data->txlock); |
1076 data->suspend_count--; | 1135 data->suspend_count--; |
1077 return -EBUSY; | 1136 return -EBUSY; |
1078 } | 1137 } |
1079 | 1138 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 | 1231 |
1173 static int __init btusb_init(void) | 1232 static int __init btusb_init(void) |
1174 { | 1233 { |
1175 BT_INFO("Generic Bluetooth USB driver ver %s", VERSION); | 1234 BT_INFO("Generic Bluetooth USB driver ver %s", VERSION); |
1176 | 1235 |
1177 return usb_register(&btusb_driver); | 1236 return usb_register(&btusb_driver); |
1178 } | 1237 } |
1179 | 1238 |
1180 static void __exit btusb_exit(void) | 1239 static void __exit btusb_exit(void) |
1181 { | 1240 { |
| 1241 int i; |
| 1242 for (i = 0; btusb_fwcbs[i].fwfile; i++) { |
| 1243 if (btusb_fwcbs[i].fwunload && btusb_fwcbs[i].data) { |
| 1244 btusb_fwcbs[i].fwunload(btusb_fwcbs[i].data, |
| 1245 btusb_fwcbs[i].bsuspend); |
| 1246 btusb_fwcbs[i].data = NULL; |
| 1247 } |
| 1248 } |
1182 usb_deregister(&btusb_driver); | 1249 usb_deregister(&btusb_driver); |
1183 } | 1250 } |
1184 | 1251 |
1185 module_init(btusb_init); | 1252 module_init(btusb_init); |
1186 module_exit(btusb_exit); | 1253 module_exit(btusb_exit); |
1187 | 1254 |
1188 module_param(ignore_dga, bool, 0644); | 1255 module_param(ignore_dga, bool, 0644); |
1189 MODULE_PARM_DESC(ignore_dga, "Ignore devices with id 08fd:0001"); | 1256 MODULE_PARM_DESC(ignore_dga, "Ignore devices with id 08fd:0001"); |
1190 | 1257 |
1191 module_param(ignore_csr, bool, 0644); | 1258 module_param(ignore_csr, bool, 0644); |
1192 MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001"); | 1259 MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001"); |
1193 | 1260 |
1194 module_param(ignore_sniffer, bool, 0644); | 1261 module_param(ignore_sniffer, bool, 0644); |
1195 MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002"); | 1262 MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002"); |
1196 | 1263 |
1197 module_param(disable_scofix, bool, 0644); | 1264 module_param(disable_scofix, bool, 0644); |
1198 MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size"); | 1265 MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size"); |
1199 | 1266 |
1200 module_param(force_scofix, bool, 0644); | 1267 module_param(force_scofix, bool, 0644); |
1201 MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size"); | 1268 MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size"); |
1202 | 1269 |
1203 module_param(reset, bool, 0644); | 1270 module_param(reset, bool, 0644); |
1204 MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); | 1271 MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); |
1205 | 1272 |
1206 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); | 1273 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
1207 MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION); | 1274 MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION); |
1208 MODULE_VERSION(VERSION); | 1275 MODULE_VERSION(VERSION); |
1209 MODULE_LICENSE("GPL"); | 1276 MODULE_LICENSE("GPL"); |
OLD | NEW |