|
33 | 33 | #include <linux/acpi.h> |
34 | 34 | #include <linux/interrupt.h> |
35 | 35 | #include <linux/pm_runtime.h> |
36 | | -#include <asm/unaligned.h> |
37 | 36 |
|
38 | 37 | #include <net/bluetooth/bluetooth.h> |
39 | 38 | #include <net/bluetooth/hci_core.h> |
@@ -548,9 +547,7 @@ static int intel_setup(struct hci_uart *hu) |
548 | 547 | struct intel_boot_params params; |
549 | 548 | struct list_head *p; |
550 | 549 | const struct firmware *fw; |
551 | | - const u8 *fw_ptr; |
552 | 550 | char fwname[64]; |
553 | | - u32 frag_len; |
554 | 551 | u32 boot_param; |
555 | 552 | ktime_t calltime, delta, rettime; |
556 | 553 | unsigned long long duration; |
@@ -761,84 +758,10 @@ static int intel_setup(struct hci_uart *hu) |
761 | 758 |
|
762 | 759 | set_bit(STATE_DOWNLOADING, &intel->flags); |
763 | 760 |
|
764 | | - /* Start the firmware download transaction with the Init fragment |
765 | | - * represented by the 128 bytes of CSS header. |
766 | | - */ |
767 | | - err = btintel_secure_send(hdev, 0x00, 128, fw->data); |
768 | | - if (err < 0) { |
769 | | - bt_dev_err(hdev, "Failed to send firmware header (%d)", err); |
770 | | - goto done; |
771 | | - } |
772 | | - |
773 | | - /* Send the 256 bytes of public key information from the firmware |
774 | | - * as the PKey fragment. |
775 | | - */ |
776 | | - err = btintel_secure_send(hdev, 0x03, 256, fw->data + 128); |
777 | | - if (err < 0) { |
778 | | - bt_dev_err(hdev, "Failed to send firmware public key (%d)", |
779 | | - err); |
780 | | - goto done; |
781 | | - } |
782 | | - |
783 | | - /* Send the 256 bytes of signature information from the firmware |
784 | | - * as the Sign fragment. |
785 | | - */ |
786 | | - err = btintel_secure_send(hdev, 0x02, 256, fw->data + 388); |
787 | | - if (err < 0) { |
788 | | - bt_dev_err(hdev, "Failed to send firmware signature (%d)", |
789 | | - err); |
| 761 | + /* Start firmware downloading and get boot parameter */ |
| 762 | + err = btintel_download_firmware(hdev, fw, &boot_param); |
| 763 | + if (err < 0) |
790 | 764 | goto done; |
791 | | - } |
792 | | - |
793 | | - fw_ptr = fw->data + 644; |
794 | | - frag_len = 0; |
795 | | - |
796 | | - while (fw_ptr - fw->data < fw->size) { |
797 | | - struct hci_command_hdr *cmd = (void *)(fw_ptr + frag_len); |
798 | | - |
799 | | - /* Each SKU has a different reset parameter to use in the |
800 | | - * HCI_Intel_Reset command and it is embedded in the firmware |
801 | | - * data. So, instead of using static value per SKU, check |
802 | | - * the firmware data and save it for later use. |
803 | | - */ |
804 | | - if (cmd->opcode == 0xfc0e) { |
805 | | - /* The boot parameter is the first 32-bit value |
806 | | - * and rest of 3 octets are reserved. |
807 | | - */ |
808 | | - boot_param = get_unaligned_le32(fw_ptr + sizeof(*cmd)); |
809 | | - |
810 | | - bt_dev_dbg(hdev, "boot_param=0x%x", boot_param); |
811 | | - } |
812 | | - |
813 | | - frag_len += sizeof(*cmd) + cmd->plen; |
814 | | - |
815 | | - bt_dev_dbg(hdev, "Patching %td/%zu", (fw_ptr - fw->data), |
816 | | - fw->size); |
817 | | - |
818 | | - /* The parameter length of the secure send command requires |
819 | | - * a 4 byte alignment. It happens so that the firmware file |
820 | | - * contains proper Intel_NOP commands to align the fragments |
821 | | - * as needed. |
822 | | - * |
823 | | - * Send set of commands with 4 byte alignment from the |
824 | | - * firmware data buffer as a single Data fragement. |
825 | | - */ |
826 | | - if (frag_len % 4) |
827 | | - continue; |
828 | | - |
829 | | - /* Send each command from the firmware data buffer as |
830 | | - * a single Data fragment. |
831 | | - */ |
832 | | - err = btintel_secure_send(hdev, 0x01, frag_len, fw_ptr); |
833 | | - if (err < 0) { |
834 | | - bt_dev_err(hdev, "Failed to send firmware data (%d)", |
835 | | - err); |
836 | | - goto done; |
837 | | - } |
838 | | - |
839 | | - fw_ptr += frag_len; |
840 | | - frag_len = 0; |
841 | | - } |
842 | 765 |
|
843 | 766 | set_bit(STATE_FIRMWARE_LOADED, &intel->flags); |
844 | 767 |
|
|
0 commit comments