blob: da3192aee5e159bf0c2261e1f63fe5c35ad6fa0d [file] [log] [blame]
Marcel Holtmann16e38872015-04-04 16:13:02 -07001/*
2 *
3 * Bluetooth HCI UART driver for Intel devices
4 *
5 * Copyright (C) 2015 Intel Corporation
6 *
7 *
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
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <linux/kernel.h>
25#include <linux/errno.h>
26#include <linux/skbuff.h>
Loic Poulainca93cee2015-07-01 12:20:26 +020027#include <linux/firmware.h>
28#include <linux/wait.h>
Marcel Holtmann16e38872015-04-04 16:13:02 -070029
30#include <net/bluetooth/bluetooth.h>
31#include <net/bluetooth/hci_core.h>
32
33#include "hci_uart.h"
Loic Poulainca93cee2015-07-01 12:20:26 +020034#include "btintel.h"
35
36#define STATE_BOOTLOADER 0
37#define STATE_DOWNLOADING 1
38#define STATE_FIRMWARE_LOADED 2
39#define STATE_FIRMWARE_FAILED 3
40#define STATE_BOOTING 4
41
42struct intel_data {
43 struct sk_buff *rx_skb;
44 struct sk_buff_head txq;
45 unsigned long flags;
46};
47
Loic Poulainff289552015-08-25 17:55:44 +020048static u8 intel_convert_speed(unsigned int speed)
49{
50 switch (speed) {
51 case 9600:
52 return 0x00;
53 case 19200:
54 return 0x01;
55 case 38400:
56 return 0x02;
57 case 57600:
58 return 0x03;
59 case 115200:
60 return 0x04;
61 case 230400:
62 return 0x05;
63 case 460800:
64 return 0x06;
65 case 921600:
66 return 0x07;
67 case 1843200:
68 return 0x08;
69 case 3250000:
70 return 0x09;
71 case 2000000:
72 return 0x0a;
73 case 3000000:
74 return 0x0b;
75 default:
76 return 0xff;
77 }
78}
79
Loic Poulainca93cee2015-07-01 12:20:26 +020080static int intel_open(struct hci_uart *hu)
81{
82 struct intel_data *intel;
83
84 BT_DBG("hu %p", hu);
85
86 intel = kzalloc(sizeof(*intel), GFP_KERNEL);
87 if (!intel)
88 return -ENOMEM;
89
90 skb_queue_head_init(&intel->txq);
91
92 hu->priv = intel;
93 return 0;
94}
95
96static int intel_close(struct hci_uart *hu)
97{
98 struct intel_data *intel = hu->priv;
99
100 BT_DBG("hu %p", hu);
101
102 skb_queue_purge(&intel->txq);
103 kfree_skb(intel->rx_skb);
104 kfree(intel);
105
106 hu->priv = NULL;
107 return 0;
108}
109
110static int intel_flush(struct hci_uart *hu)
111{
112 struct intel_data *intel = hu->priv;
113
114 BT_DBG("hu %p", hu);
115
116 skb_queue_purge(&intel->txq);
117
118 return 0;
119}
120
121static int inject_cmd_complete(struct hci_dev *hdev, __u16 opcode)
122{
123 struct sk_buff *skb;
124 struct hci_event_hdr *hdr;
125 struct hci_ev_cmd_complete *evt;
126
127 skb = bt_skb_alloc(sizeof(*hdr) + sizeof(*evt) + 1, GFP_ATOMIC);
128 if (!skb)
129 return -ENOMEM;
130
131 hdr = (struct hci_event_hdr *)skb_put(skb, sizeof(*hdr));
132 hdr->evt = HCI_EV_CMD_COMPLETE;
133 hdr->plen = sizeof(*evt) + 1;
134
135 evt = (struct hci_ev_cmd_complete *)skb_put(skb, sizeof(*evt));
136 evt->ncmd = 0x01;
137 evt->opcode = cpu_to_le16(opcode);
138
139 *skb_put(skb, 1) = 0x00;
140
141 bt_cb(skb)->pkt_type = HCI_EVENT_PKT;
142
143 return hci_recv_frame(hdev, skb);
144}
145
Loic Poulainff289552015-08-25 17:55:44 +0200146static int intel_set_baudrate(struct hci_uart *hu, unsigned int speed)
147{
148 struct intel_data *intel = hu->priv;
149 struct hci_dev *hdev = hu->hdev;
150 u8 speed_cmd[] = { 0x06, 0xfc, 0x01, 0x00 };
151 struct sk_buff *skb;
152
153 BT_INFO("%s: Change controller speed to %d", hdev->name, speed);
154
155 speed_cmd[3] = intel_convert_speed(speed);
156 if (speed_cmd[3] == 0xff) {
157 BT_ERR("%s: Unsupported speed", hdev->name);
158 return -EINVAL;
159 }
160
161 /* Device will not accept speed change if Intel version has not been
162 * previously requested.
163 */
164 skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_INIT_TIMEOUT);
165 if (IS_ERR(skb)) {
166 BT_ERR("%s: Reading Intel version information failed (%ld)",
167 hdev->name, PTR_ERR(skb));
168 return PTR_ERR(skb);
169 }
170 kfree_skb(skb);
171
172 skb = bt_skb_alloc(sizeof(speed_cmd), GFP_KERNEL);
173 if (!skb) {
174 BT_ERR("%s: Failed to allocate memory for baudrate packet",
175 hdev->name);
176 return -ENOMEM;
177 }
178
179 memcpy(skb_put(skb, sizeof(speed_cmd)), speed_cmd, sizeof(speed_cmd));
180 bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
181
182 hci_uart_set_flow_control(hu, true);
183
184 skb_queue_tail(&intel->txq, skb);
185 hci_uart_tx_wakeup(hu);
186
187 /* wait 100ms to change baudrate on controller side */
188 msleep(100);
189
190 hci_uart_set_baudrate(hu, speed);
191 hci_uart_set_flow_control(hu, false);
192
193 return 0;
194}
195
Loic Poulainca93cee2015-07-01 12:20:26 +0200196static int intel_setup(struct hci_uart *hu)
197{
198 static const u8 reset_param[] = { 0x00, 0x01, 0x00, 0x01,
199 0x00, 0x08, 0x04, 0x00 };
200 struct intel_data *intel = hu->priv;
201 struct hci_dev *hdev = hu->hdev;
202 struct sk_buff *skb;
203 struct intel_version *ver;
204 struct intel_boot_params *params;
205 const struct firmware *fw;
206 const u8 *fw_ptr;
207 char fwname[64];
208 u32 frag_len;
209 ktime_t calltime, delta, rettime;
210 unsigned long long duration;
Loic Poulainff289552015-08-25 17:55:44 +0200211 unsigned int init_speed, oper_speed;
212 int speed_change = 0;
Loic Poulainca93cee2015-07-01 12:20:26 +0200213 int err;
214
215 BT_DBG("%s", hdev->name);
216
Marcel Holtmann35ab8152015-07-05 14:37:40 +0200217 hu->hdev->set_bdaddr = btintel_set_bdaddr;
218
Loic Poulainca93cee2015-07-01 12:20:26 +0200219 calltime = ktime_get();
220
Loic Poulainff289552015-08-25 17:55:44 +0200221 if (hu->init_speed)
222 init_speed = hu->init_speed;
223 else
224 init_speed = hu->proto->init_speed;
225
226 if (hu->oper_speed)
227 oper_speed = hu->oper_speed;
228 else
229 oper_speed = hu->proto->oper_speed;
230
231 if (oper_speed && init_speed && oper_speed != init_speed)
232 speed_change = 1;
233
Loic Poulainca93cee2015-07-01 12:20:26 +0200234 set_bit(STATE_BOOTLOADER, &intel->flags);
235
236 /* Read the Intel version information to determine if the device
237 * is in bootloader mode or if it already has operational firmware
238 * loaded.
239 */
240 skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_INIT_TIMEOUT);
241 if (IS_ERR(skb)) {
242 BT_ERR("%s: Reading Intel version information failed (%ld)",
243 hdev->name, PTR_ERR(skb));
244 return PTR_ERR(skb);
245 }
246
247 if (skb->len != sizeof(*ver)) {
248 BT_ERR("%s: Intel version event size mismatch", hdev->name);
249 kfree_skb(skb);
250 return -EILSEQ;
251 }
252
253 ver = (struct intel_version *)skb->data;
254 if (ver->status) {
255 BT_ERR("%s: Intel version command failure (%02x)",
256 hdev->name, ver->status);
257 err = -bt_to_errno(ver->status);
258 kfree_skb(skb);
259 return err;
260 }
261
262 /* The hardware platform number has a fixed value of 0x37 and
263 * for now only accept this single value.
264 */
265 if (ver->hw_platform != 0x37) {
266 BT_ERR("%s: Unsupported Intel hardware platform (%u)",
267 hdev->name, ver->hw_platform);
268 kfree_skb(skb);
269 return -EINVAL;
270 }
271
272 /* At the moment only the hardware variant iBT 3.0 (LnP/SfP) is
273 * supported by this firmware loading method. This check has been
274 * put in place to ensure correct forward compatibility options
275 * when newer hardware variants come along.
276 */
277 if (ver->hw_variant != 0x0b) {
278 BT_ERR("%s: Unsupported Intel hardware variant (%u)",
279 hdev->name, ver->hw_variant);
280 kfree_skb(skb);
281 return -EINVAL;
282 }
283
Marcel Holtmann7feb99e2015-07-05 15:02:07 +0200284 btintel_version_info(hdev, ver);
Loic Poulainca93cee2015-07-01 12:20:26 +0200285
286 /* The firmware variant determines if the device is in bootloader
287 * mode or is running operational firmware. The value 0x06 identifies
288 * the bootloader and the value 0x23 identifies the operational
289 * firmware.
290 *
291 * When the operational firmware is already present, then only
292 * the check for valid Bluetooth device address is needed. This
293 * determines if the device will be added as configured or
294 * unconfigured controller.
295 *
296 * It is not possible to use the Secure Boot Parameters in this
297 * case since that command is only available in bootloader mode.
298 */
299 if (ver->fw_variant == 0x23) {
300 kfree_skb(skb);
301 clear_bit(STATE_BOOTLOADER, &intel->flags);
302 btintel_check_bdaddr(hdev);
303 return 0;
304 }
305
306 /* If the device is not in bootloader mode, then the only possible
307 * choice is to return an error and abort the device initialization.
308 */
309 if (ver->fw_variant != 0x06) {
310 BT_ERR("%s: Unsupported Intel firmware variant (%u)",
311 hdev->name, ver->fw_variant);
312 kfree_skb(skb);
313 return -ENODEV;
314 }
315
316 kfree_skb(skb);
317
318 /* Read the secure boot parameters to identify the operating
319 * details of the bootloader.
320 */
321 skb = __hci_cmd_sync(hdev, 0xfc0d, 0, NULL, HCI_INIT_TIMEOUT);
322 if (IS_ERR(skb)) {
323 BT_ERR("%s: Reading Intel boot parameters failed (%ld)",
324 hdev->name, PTR_ERR(skb));
325 return PTR_ERR(skb);
326 }
327
328 if (skb->len != sizeof(*params)) {
329 BT_ERR("%s: Intel boot parameters size mismatch", hdev->name);
330 kfree_skb(skb);
331 return -EILSEQ;
332 }
333
334 params = (struct intel_boot_params *)skb->data;
335 if (params->status) {
336 BT_ERR("%s: Intel boot parameters command failure (%02x)",
337 hdev->name, params->status);
338 err = -bt_to_errno(params->status);
339 kfree_skb(skb);
340 return err;
341 }
342
343 BT_INFO("%s: Device revision is %u", hdev->name,
344 le16_to_cpu(params->dev_revid));
345
346 BT_INFO("%s: Secure boot is %s", hdev->name,
347 params->secure_boot ? "enabled" : "disabled");
348
349 BT_INFO("%s: Minimum firmware build %u week %u %u", hdev->name,
350 params->min_fw_build_nn, params->min_fw_build_cw,
351 2000 + params->min_fw_build_yy);
352
353 /* It is required that every single firmware fragment is acknowledged
354 * with a command complete event. If the boot parameters indicate
355 * that this bootloader does not send them, then abort the setup.
356 */
357 if (params->limited_cce != 0x00) {
358 BT_ERR("%s: Unsupported Intel firmware loading method (%u)",
359 hdev->name, params->limited_cce);
360 kfree_skb(skb);
361 return -EINVAL;
362 }
363
364 /* If the OTP has no valid Bluetooth device address, then there will
365 * also be no valid address for the operational firmware.
366 */
367 if (!bacmp(&params->otp_bdaddr, BDADDR_ANY)) {
368 BT_INFO("%s: No device address configured", hdev->name);
369 set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
370 }
371
372 /* With this Intel bootloader only the hardware variant and device
373 * revision information are used to select the right firmware.
374 *
375 * Currently this bootloader support is limited to hardware variant
376 * iBT 3.0 (LnP/SfP) which is identified by the value 11 (0x0b).
377 */
378 snprintf(fwname, sizeof(fwname), "intel/ibt-11-%u.sfi",
379 le16_to_cpu(params->dev_revid));
380
381 err = request_firmware(&fw, fwname, &hdev->dev);
382 if (err < 0) {
383 BT_ERR("%s: Failed to load Intel firmware file (%d)",
384 hdev->name, err);
385 kfree_skb(skb);
386 return err;
387 }
388
389 BT_INFO("%s: Found device firmware: %s", hdev->name, fwname);
390
391 kfree_skb(skb);
392
393 if (fw->size < 644) {
394 BT_ERR("%s: Invalid size of firmware file (%zu)",
395 hdev->name, fw->size);
396 err = -EBADF;
397 goto done;
398 }
399
400 set_bit(STATE_DOWNLOADING, &intel->flags);
401
402 /* Start the firmware download transaction with the Init fragment
403 * represented by the 128 bytes of CSS header.
404 */
Marcel Holtmann09df1232015-07-05 14:55:36 +0200405 err = btintel_secure_send(hdev, 0x00, 128, fw->data);
Loic Poulainca93cee2015-07-01 12:20:26 +0200406 if (err < 0) {
407 BT_ERR("%s: Failed to send firmware header (%d)",
408 hdev->name, err);
409 goto done;
410 }
411
412 /* Send the 256 bytes of public key information from the firmware
413 * as the PKey fragment.
414 */
Marcel Holtmann09df1232015-07-05 14:55:36 +0200415 err = btintel_secure_send(hdev, 0x03, 256, fw->data + 128);
Loic Poulainca93cee2015-07-01 12:20:26 +0200416 if (err < 0) {
417 BT_ERR("%s: Failed to send firmware public key (%d)",
418 hdev->name, err);
419 goto done;
420 }
421
422 /* Send the 256 bytes of signature information from the firmware
423 * as the Sign fragment.
424 */
Marcel Holtmann09df1232015-07-05 14:55:36 +0200425 err = btintel_secure_send(hdev, 0x02, 256, fw->data + 388);
Loic Poulainca93cee2015-07-01 12:20:26 +0200426 if (err < 0) {
427 BT_ERR("%s: Failed to send firmware signature (%d)",
428 hdev->name, err);
429 goto done;
430 }
431
432 fw_ptr = fw->data + 644;
433 frag_len = 0;
434
435 while (fw_ptr - fw->data < fw->size) {
436 struct hci_command_hdr *cmd = (void *)(fw_ptr + frag_len);
437
438 frag_len += sizeof(*cmd) + cmd->plen;
439
440 BT_DBG("%s: patching %td/%zu", hdev->name,
441 (fw_ptr - fw->data), fw->size);
442
443 /* The parameter length of the secure send command requires
444 * a 4 byte alignment. It happens so that the firmware file
445 * contains proper Intel_NOP commands to align the fragments
446 * as needed.
447 *
448 * Send set of commands with 4 byte alignment from the
449 * firmware data buffer as a single Data fragement.
450 */
451 if (frag_len % 4)
452 continue;
453
454 /* Send each command from the firmware data buffer as
455 * a single Data fragment.
456 */
Marcel Holtmann09df1232015-07-05 14:55:36 +0200457 err = btintel_secure_send(hdev, 0x01, frag_len, fw_ptr);
Loic Poulainca93cee2015-07-01 12:20:26 +0200458 if (err < 0) {
459 BT_ERR("%s: Failed to send firmware data (%d)",
460 hdev->name, err);
461 goto done;
462 }
463
464 fw_ptr += frag_len;
465 frag_len = 0;
466 }
467
468 set_bit(STATE_FIRMWARE_LOADED, &intel->flags);
469
470 BT_INFO("%s: Waiting for firmware download to complete", hdev->name);
471
472 /* Before switching the device into operational mode and with that
473 * booting the loaded firmware, wait for the bootloader notification
474 * that all fragments have been successfully received.
475 *
476 * When the event processing receives the notification, then the
477 * STATE_DOWNLOADING flag will be cleared.
478 *
479 * The firmware loading should not take longer than 5 seconds
480 * and thus just timeout if that happens and fail the setup
481 * of this device.
482 */
483 err = wait_on_bit_timeout(&intel->flags, STATE_DOWNLOADING,
484 TASK_INTERRUPTIBLE,
485 msecs_to_jiffies(5000));
486 if (err == 1) {
487 BT_ERR("%s: Firmware loading interrupted", hdev->name);
488 err = -EINTR;
489 goto done;
490 }
491
492 if (err) {
493 BT_ERR("%s: Firmware loading timeout", hdev->name);
494 err = -ETIMEDOUT;
495 goto done;
496 }
497
498 if (test_bit(STATE_FIRMWARE_FAILED, &intel->flags)) {
499 BT_ERR("%s: Firmware loading failed", hdev->name);
500 err = -ENOEXEC;
501 goto done;
502 }
503
504 rettime = ktime_get();
505 delta = ktime_sub(rettime, calltime);
506 duration = (unsigned long long) ktime_to_ns(delta) >> 10;
507
508 BT_INFO("%s: Firmware loaded in %llu usecs", hdev->name, duration);
509
510done:
511 release_firmware(fw);
512
513 if (err < 0)
514 return err;
515
Loic Poulainff289552015-08-25 17:55:44 +0200516 /* We need to restore the default speed before Intel reset */
517 if (speed_change) {
518 err = intel_set_baudrate(hu, init_speed);
519 if (err)
520 return err;
521 }
522
Loic Poulainca93cee2015-07-01 12:20:26 +0200523 calltime = ktime_get();
524
525 set_bit(STATE_BOOTING, &intel->flags);
526
527 skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(reset_param), reset_param,
528 HCI_INIT_TIMEOUT);
529 if (IS_ERR(skb))
530 return PTR_ERR(skb);
531
532 kfree_skb(skb);
533
534 /* The bootloader will not indicate when the device is ready. This
535 * is done by the operational firmware sending bootup notification.
536 *
537 * Booting into operational firmware should not take longer than
538 * 1 second. However if that happens, then just fail the setup
539 * since something went wrong.
540 */
541 BT_INFO("%s: Waiting for device to boot", hdev->name);
542
543 err = wait_on_bit_timeout(&intel->flags, STATE_BOOTING,
544 TASK_INTERRUPTIBLE,
545 msecs_to_jiffies(1000));
546
547 if (err == 1) {
548 BT_ERR("%s: Device boot interrupted", hdev->name);
549 return -EINTR;
550 }
551
552 if (err) {
553 BT_ERR("%s: Device boot timeout", hdev->name);
554 return -ETIMEDOUT;
555 }
556
557 rettime = ktime_get();
558 delta = ktime_sub(rettime, calltime);
559 duration = (unsigned long long) ktime_to_ns(delta) >> 10;
560
561 BT_INFO("%s: Device booted in %llu usecs", hdev->name, duration);
562
Loic Poulainff289552015-08-25 17:55:44 +0200563 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_CMD_TIMEOUT);
564 if (IS_ERR(skb))
565 return PTR_ERR(skb);
566 kfree_skb(skb);
567
568 if (speed_change) {
569 err = intel_set_baudrate(hu, oper_speed);
570 if (err)
571 return err;
572 }
573
574 BT_INFO("%s: Setup complete", hdev->name);
575
Loic Poulainca93cee2015-07-01 12:20:26 +0200576 clear_bit(STATE_BOOTLOADER, &intel->flags);
577
578 return 0;
579}
580
581static int intel_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
582{
583 struct hci_uart *hu = hci_get_drvdata(hdev);
584 struct intel_data *intel = hu->priv;
585 struct hci_event_hdr *hdr;
586
587 if (!test_bit(STATE_BOOTLOADER, &intel->flags))
588 goto recv;
589
590 hdr = (void *)skb->data;
591
592 /* When the firmware loading completes the device sends
593 * out a vendor specific event indicating the result of
594 * the firmware loading.
595 */
596 if (skb->len == 7 && hdr->evt == 0xff && hdr->plen == 0x05 &&
597 skb->data[2] == 0x06) {
598 if (skb->data[3] != 0x00)
599 set_bit(STATE_FIRMWARE_FAILED, &intel->flags);
600
601 if (test_and_clear_bit(STATE_DOWNLOADING, &intel->flags) &&
602 test_bit(STATE_FIRMWARE_LOADED, &intel->flags)) {
603 smp_mb__after_atomic();
604 wake_up_bit(&intel->flags, STATE_DOWNLOADING);
605 }
606
607 /* When switching to the operational firmware the device
608 * sends a vendor specific event indicating that the bootup
609 * completed.
610 */
611 } else if (skb->len == 9 && hdr->evt == 0xff && hdr->plen == 0x07 &&
612 skb->data[2] == 0x02) {
613 if (test_and_clear_bit(STATE_BOOTING, &intel->flags)) {
614 smp_mb__after_atomic();
615 wake_up_bit(&intel->flags, STATE_BOOTING);
616 }
617 }
618recv:
619 return hci_recv_frame(hdev, skb);
620}
621
622static const struct h4_recv_pkt intel_recv_pkts[] = {
623 { H4_RECV_ACL, .recv = hci_recv_frame },
624 { H4_RECV_SCO, .recv = hci_recv_frame },
625 { H4_RECV_EVENT, .recv = intel_recv_event },
626};
627
628static int intel_recv(struct hci_uart *hu, const void *data, int count)
629{
630 struct intel_data *intel = hu->priv;
631
632 if (!test_bit(HCI_UART_REGISTERED, &hu->flags))
633 return -EUNATCH;
634
635 intel->rx_skb = h4_recv_buf(hu->hdev, intel->rx_skb, data, count,
636 intel_recv_pkts,
637 ARRAY_SIZE(intel_recv_pkts));
638 if (IS_ERR(intel->rx_skb)) {
639 int err = PTR_ERR(intel->rx_skb);
640 BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err);
641 intel->rx_skb = NULL;
642 return err;
643 }
644
645 return count;
646}
647
648static int intel_enqueue(struct hci_uart *hu, struct sk_buff *skb)
649{
650 struct intel_data *intel = hu->priv;
651
652 BT_DBG("hu %p skb %p", hu, skb);
653
654 skb_queue_tail(&intel->txq, skb);
655
656 return 0;
657}
658
659static struct sk_buff *intel_dequeue(struct hci_uart *hu)
660{
661 struct intel_data *intel = hu->priv;
662 struct sk_buff *skb;
663
664 skb = skb_dequeue(&intel->txq);
665 if (!skb)
666 return skb;
667
668 if (test_bit(STATE_BOOTLOADER, &intel->flags) &&
669 (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT)) {
670 struct hci_command_hdr *cmd = (void *)skb->data;
671 __u16 opcode = le16_to_cpu(cmd->opcode);
672
673 /* When the 0xfc01 command is issued to boot into
674 * the operational firmware, it will actually not
675 * send a command complete event. To keep the flow
676 * control working inject that event here.
677 */
678 if (opcode == 0xfc01)
679 inject_cmd_complete(hu->hdev, opcode);
680 }
681
682 /* Prepend skb with frame type */
683 memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
684
685 return skb;
686}
687
688static const struct hci_uart_proto intel_proto = {
689 .id = HCI_UART_INTEL,
690 .name = "Intel",
691 .init_speed = 115200,
Loic Poulainff289552015-08-25 17:55:44 +0200692 .oper_speed = 3000000,
Loic Poulainca93cee2015-07-01 12:20:26 +0200693 .open = intel_open,
694 .close = intel_close,
695 .flush = intel_flush,
696 .setup = intel_setup,
Loic Poulainff289552015-08-25 17:55:44 +0200697 .set_baudrate = intel_set_baudrate,
Loic Poulainca93cee2015-07-01 12:20:26 +0200698 .recv = intel_recv,
699 .enqueue = intel_enqueue,
700 .dequeue = intel_dequeue,
701};
702
703int __init intel_init(void)
704{
705 return hci_uart_register_proto(&intel_proto);
706}
707
708int __exit intel_deinit(void)
709{
710 return hci_uart_unregister_proto(&intel_proto);
711}