1 /* SPDX-License-Identifier: ISC */ 2 /* Copyright (C) 2021 MediaTek Inc. */ 3 4 #define FIRMWARE_MT7663 "mediatek/mt7663pr2h.bin" 5 #define FIRMWARE_MT7668 "mediatek/mt7668pr2h.bin" 6 #define FIRMWARE_MT7961 "mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin" 7 8 #define HCI_WMT_MAX_EVENT_SIZE 64 9 10 #define BTMTK_WMT_REG_READ 0x2 11 12 enum { 13 BTMTK_WMT_PATCH_DWNLD = 0x1, 14 BTMTK_WMT_TEST = 0x2, 15 BTMTK_WMT_WAKEUP = 0x3, 16 BTMTK_WMT_HIF = 0x4, 17 BTMTK_WMT_FUNC_CTRL = 0x6, 18 BTMTK_WMT_RST = 0x7, 19 BTMTK_WMT_REGISTER = 0x8, 20 BTMTK_WMT_SEMAPHORE = 0x17, 21 }; 22 23 enum { 24 BTMTK_WMT_INVALID, 25 BTMTK_WMT_PATCH_UNDONE, 26 BTMTK_WMT_PATCH_PROGRESS, 27 BTMTK_WMT_PATCH_DONE, 28 BTMTK_WMT_ON_UNDONE, 29 BTMTK_WMT_ON_DONE, 30 BTMTK_WMT_ON_PROGRESS, 31 }; 32 33 struct btmtk_wmt_hdr { 34 u8 dir; 35 u8 op; 36 __le16 dlen; 37 u8 flag; 38 } __packed; 39 40 struct btmtk_hci_wmt_cmd { 41 struct btmtk_wmt_hdr hdr; 42 u8 data[]; 43 } __packed; 44 45 struct btmtk_hci_wmt_evt { 46 struct hci_event_hdr hhdr; 47 struct btmtk_wmt_hdr whdr; 48 } __packed; 49 50 struct btmtk_hci_wmt_evt_funcc { 51 struct btmtk_hci_wmt_evt hwhdr; 52 __be16 status; 53 } __packed; 54 55 struct btmtk_hci_wmt_evt_reg { 56 struct btmtk_hci_wmt_evt hwhdr; 57 u8 rsv[2]; 58 u8 num; 59 __le32 addr; 60 __le32 val; 61 } __packed; 62 63 struct btmtk_tci_sleep { 64 u8 mode; 65 __le16 duration; 66 __le16 host_duration; 67 u8 host_wakeup_pin; 68 u8 time_compensation; 69 } __packed; 70 71 struct btmtk_hci_wmt_params { 72 u8 op; 73 u8 flag; 74 u16 dlen; 75 const void *data; 76 u32 *status; 77 }; 78 79 typedef int (*wmt_cmd_sync_func_t)(struct hci_dev *, 80 struct btmtk_hci_wmt_params *); 81 82 #if IS_ENABLED(CONFIG_BT_MTK) 83 84 int btmtk_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); 85 86 int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, 87 wmt_cmd_sync_func_t wmt_cmd_sync); 88 89 int btmtk_setup_firmware(struct hci_dev *hdev, const char *fwname, 90 wmt_cmd_sync_func_t wmt_cmd_sync); 91 #else 92 93 static inline int btmtk_set_bdaddr(struct hci_dev *hdev, 94 const bdaddr_t *bdaddr) 95 { 96 return -EOPNOTSUPP; 97 } 98 99 static int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname, 100 wmt_cmd_sync_func_t wmt_cmd_sync) 101 { 102 return -EOPNOTSUPP; 103 } 104 105 static int btmtk_setup_firmware(struct hci_dev *hdev, const char *fwname, 106 wmt_cmd_sync_func_t wmt_cmd_sync) 107 { 108 return -EOPNOTSUPP; 109 } 110 111 #endif 112