drivers/bluetooth/btmtk.c
Source file repositories/reference/linux-study-clean/drivers/bluetooth/btmtk.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bluetooth/btmtk.c- Extension
.c- Size
- 40175 bytes
- Lines
- 1599
- Domain
- Driver Families
- Bucket
- drivers/bluetooth
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/firmware.hlinux/usb.hlinux/iopoll.hlinux/unaligned.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hbtmtk.h
Detected Declarations
struct btmtk_patch_headerstruct btmtk_global_descstruct btmtk_section_mapfunction btmtk_coredumpfunction btmtk_coredump_hdrfunction btmtk_coredump_notifyfunction btmtk_fw_get_filenamefunction btmtk_setup_firmware_79xxfunction btmtk_setup_firmwarefunction btmtk_set_bdaddrfunction btmtk_reset_syncfunction btmtk_register_coredumpfunction btmtk_process_coredumpfunction btmtk_usb_wmt_recvfunction btmtk_usb_submit_wmt_recv_urbfunction btmtk_usb_hci_wmt_syncfunction btmtk_usb_func_queryfunction btmtk_usb_uhw_reg_writefunction btmtk_usb_uhw_reg_readfunction btmtk_usb_reg_readfunction btmtk_usb_id_getfunction btmtk_usb_reset_donefunction btmtk_usb_subsys_resetfunction btmtk_usb_recv_aclfunction btmtk_isopkt_padfunction __set_mtk_intr_interfacefunction btmtk_recv_isopktfunction btmtk_intr_completefunction btmtk_submit_intr_urbfunction btmtk_usb_isointf_initfunction btmtk_usb_resumefunction btmtk_usb_suspendfunction btmtk_usb_setupfunction btmtk_usb_shutdownfunction btmtk_recv_eventexport btmtk_fw_get_filenameexport btmtk_setup_firmware_79xxexport btmtk_setup_firmwareexport btmtk_set_bdaddrexport btmtk_reset_syncexport btmtk_register_coredumpexport btmtk_process_coredumpexport btmtk_usb_subsys_resetexport btmtk_usb_recv_aclexport alloc_mtk_intr_urbexport btmtk_usb_resumeexport btmtk_usb_suspendexport btmtk_usb_setup
Annotated Snippet
struct btmtk_patch_header {
u8 datetime[16];
u8 platform[4];
__le16 hwver;
__le16 swver;
__le32 magicnum;
} __packed;
struct btmtk_global_desc {
__le32 patch_ver;
__le32 sub_sys;
__le32 feature_opt;
__le32 section_num;
} __packed;
struct btmtk_section_map {
__le32 sectype;
__le32 secoffset;
__le32 secsize;
union {
__le32 u4SecSpec[13];
struct {
__le32 dlAddr;
__le32 dlsize;
__le32 seckeyidx;
__le32 alignlen;
__le32 sectype;
__le32 dlmodecrctype;
__le32 crc;
__le32 reserved[6];
} bin_info_spec;
};
} __packed;
static void btmtk_coredump(struct hci_dev *hdev)
{
int err;
err = __hci_cmd_send(hdev, 0xfd5b, 0, NULL);
if (err < 0)
bt_dev_err(hdev, "Coredump failed (%d)", err);
}
static void btmtk_coredump_hdr(struct hci_dev *hdev, struct sk_buff *skb)
{
struct btmtk_data *data = hci_get_priv(hdev);
char buf[80];
snprintf(buf, sizeof(buf), "Controller Name: 0x%X\n",
data->dev_id);
skb_put_data(skb, buf, strlen(buf));
snprintf(buf, sizeof(buf), "Firmware Version: 0x%X\n",
data->cd_info.fw_version);
skb_put_data(skb, buf, strlen(buf));
snprintf(buf, sizeof(buf), "Driver: %s\n",
data->cd_info.driver_name);
skb_put_data(skb, buf, strlen(buf));
snprintf(buf, sizeof(buf), "Vendor: MediaTek\n");
skb_put_data(skb, buf, strlen(buf));
}
static void btmtk_coredump_notify(struct hci_dev *hdev, int state)
{
struct btmtk_data *data = hci_get_priv(hdev);
switch (state) {
case HCI_DEVCOREDUMP_IDLE:
data->cd_info.state = HCI_DEVCOREDUMP_IDLE;
break;
case HCI_DEVCOREDUMP_ACTIVE:
data->cd_info.state = HCI_DEVCOREDUMP_ACTIVE;
break;
case HCI_DEVCOREDUMP_TIMEOUT:
case HCI_DEVCOREDUMP_ABORT:
case HCI_DEVCOREDUMP_DONE:
data->cd_info.state = HCI_DEVCOREDUMP_IDLE;
btmtk_reset_sync(hdev);
break;
}
}
void btmtk_fw_get_filename(char *buf, size_t size, u32 dev_id, u32 fw_ver,
u32 fw_flavor)
{
if (dev_id == 0x6639)
snprintf(buf, size,
"mediatek/mt7927/BT_RAM_CODE_MT%04x_2_%x_hdr.bin",
Annotation
- Immediate include surface: `linux/module.h`, `linux/firmware.h`, `linux/usb.h`, `linux/iopoll.h`, `linux/unaligned.h`, `net/bluetooth/bluetooth.h`, `net/bluetooth/hci_core.h`, `btmtk.h`.
- Detected declarations: `struct btmtk_patch_header`, `struct btmtk_global_desc`, `struct btmtk_section_map`, `function btmtk_coredump`, `function btmtk_coredump_hdr`, `function btmtk_coredump_notify`, `function btmtk_fw_get_filename`, `function btmtk_setup_firmware_79xx`, `function btmtk_setup_firmware`, `function btmtk_set_bdaddr`.
- Atlas domain: Driver Families / drivers/bluetooth.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.