1 /* SPDX-License-Identifier: ISC */
2 /* Copyright (C) 2021 MediaTek Inc. */
4 #define FIRMWARE_MT7622 "mediatek/mt7622pr2h.bin"
5 #define FIRMWARE_MT7663 "mediatek/mt7663pr2h.bin"
6 #define FIRMWARE_MT7668 "mediatek/mt7668pr2h.bin"
7 #define FIRMWARE_MT7961 "mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin"
9 #define HCI_EV_WMT 0xe4
10 #define HCI_WMT_MAX_EVENT_SIZE 64
12 #define BTMTK_WMT_REG_WRITE 0x1
13 #define BTMTK_WMT_REG_READ 0x2
15 #define MT7921_BTSYS_RST 0x70002610
16 #define MT7921_BTSYS_RST_WITH_GPIO BIT(7)
18 #define MT7921_PINMUX_0 0x70005050
19 #define MT7921_PINMUX_1 0x70005054
21 #define MT7921_DLSTATUS 0x7c053c10
22 #define BT_DL_STATE BIT(1)
25 BTMTK_WMT_PATCH_DWNLD = 0x1,
27 BTMTK_WMT_WAKEUP = 0x3,
29 BTMTK_WMT_FUNC_CTRL = 0x6,
31 BTMTK_WMT_REGISTER = 0x8,
32 BTMTK_WMT_SEMAPHORE = 0x17,
37 BTMTK_WMT_PATCH_UNDONE,
38 BTMTK_WMT_PATCH_PROGRESS,
42 BTMTK_WMT_ON_PROGRESS,
45 struct btmtk_wmt_hdr {
52 struct btmtk_hci_wmt_cmd {
53 struct btmtk_wmt_hdr hdr;
57 struct btmtk_hci_wmt_evt {
58 struct hci_event_hdr hhdr;
59 struct btmtk_wmt_hdr whdr;
62 struct btmtk_hci_wmt_evt_funcc {
63 struct btmtk_hci_wmt_evt hwhdr;
67 struct btmtk_hci_wmt_evt_reg {
68 struct btmtk_hci_wmt_evt hwhdr;
75 struct btmtk_tci_sleep {
93 u8 transmit_format_config;
94 u8 channel_format_config;
95 u8 channel_select_config;
105 struct reg_write_cmd {
114 struct btmtk_hci_wmt_params {
122 typedef int (*wmt_cmd_sync_func_t)(struct hci_dev *,
123 struct btmtk_hci_wmt_params *);
125 #if IS_ENABLED(CONFIG_BT_MTK)
127 int btmtk_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
129 int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,
130 wmt_cmd_sync_func_t wmt_cmd_sync);
132 int btmtk_setup_firmware(struct hci_dev *hdev, const char *fwname,
133 wmt_cmd_sync_func_t wmt_cmd_sync);
136 static inline int btmtk_set_bdaddr(struct hci_dev *hdev,
137 const bdaddr_t *bdaddr)
142 static int btmtk_setup_firmware_79xx(struct hci_dev *hdev, const char *fwname,
143 wmt_cmd_sync_func_t wmt_cmd_sync)
148 static int btmtk_setup_firmware(struct hci_dev *hdev, const char *fwname,
149 wmt_cmd_sync_func_t wmt_cmd_sync)