drivers/bluetooth/btmtksdio.c
Source file repositories/reference/linux-study-clean/drivers/bluetooth/btmtksdio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bluetooth/btmtksdio.c- Extension
.c- Size
- 38075 bytes
- Lines
- 1579
- Domain
- Driver Families
- Bucket
- drivers/bluetooth
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/unaligned.hlinux/atomic.hlinux/gpio/consumer.hlinux/init.hlinux/iopoll.hlinux/kernel.hlinux/module.hlinux/of.hlinux/pm_runtime.hlinux/skbuff.hlinux/usb.hlinux/mmc/host.hlinux/mmc/sdio_ids.hlinux/mmc/sdio_func.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hhci_uart.hbtmtk.h
Detected Declarations
struct btmtksdio_datastruct mtkbtsdio_hdrstruct btmtksdio_devfunction mtk_hci_wmt_syncfunction btmtksdio_tx_packetfunction btmtksdio_drv_own_queryfunction btmtksdio_drv_own_query_79xxfunction btmtksdio_chcr_queryfunction btmtksdio_fw_pmctrlfunction btmtksdio_drv_pmctrlfunction btmtksdio_recv_eventfunction btmtksdio_recv_aclfunction btmtksdio_rx_packetfunction btmtksdio_txrx_workfunction btmtksdio_interruptfunction btmtksdio_openfunction btmtksdio_closefunction btmtksdio_flushfunction btmtksdio_func_queryfunction mt76xx_setupfunction mt79xx_setupfunction btmtksdio_mtk_reg_readfunction btmtksdio_mtk_reg_writefunction btmtksdio_get_data_path_idfunction btmtksdio_get_codec_config_datafunction btmtksdio_sco_settingfunction btmtksdio_reset_settingfunction btmtksdio_setupfunction btmtksdio_shutdownfunction btmtksdio_send_framefunction btmtksdio_resetfunction btmtksdio_sdio_inband_wakeupfunction btmtksdio_sdio_wakeupfunction btmtksdio_probefunction btmtksdio_removefunction btmtksdio_runtime_suspendfunction btmtksdio_system_suspendfunction btmtksdio_runtime_resumefunction btmtksdio_system_resume
Annotated Snippet
struct btmtksdio_data {
const char *fwname;
u16 chipid;
bool lp_mbox_supported;
bool pm_runtime_supported;
};
static const struct btmtksdio_data mt7663_data = {
.fwname = FIRMWARE_MT7663,
.chipid = 0x7663,
.lp_mbox_supported = false,
.pm_runtime_supported = true,
};
static const struct btmtksdio_data mt7668_data = {
.fwname = FIRMWARE_MT7668,
.chipid = 0x7668,
.lp_mbox_supported = false,
.pm_runtime_supported = true,
};
static const struct btmtksdio_data mt7921_data = {
.fwname = FIRMWARE_MT7961,
.chipid = 0x7921,
.lp_mbox_supported = true,
.pm_runtime_supported = true,
};
static const struct btmtksdio_data mt7902_data = {
.fwname = FIRMWARE_MT7902,
.chipid = 0x7902,
.lp_mbox_supported = false,
.pm_runtime_supported = false,
};
static const struct sdio_device_id btmtksdio_table[] = {
{SDIO_DEVICE(SDIO_VENDOR_ID_MEDIATEK, SDIO_DEVICE_ID_MEDIATEK_MT7663),
.driver_data = (kernel_ulong_t)&mt7663_data },
{SDIO_DEVICE(SDIO_VENDOR_ID_MEDIATEK, SDIO_DEVICE_ID_MEDIATEK_MT7668),
.driver_data = (kernel_ulong_t)&mt7668_data },
{SDIO_DEVICE(SDIO_VENDOR_ID_MEDIATEK, SDIO_DEVICE_ID_MEDIATEK_MT7961),
.driver_data = (kernel_ulong_t)&mt7921_data },
{SDIO_DEVICE(SDIO_VENDOR_ID_MEDIATEK, SDIO_DEVICE_ID_MEDIATEK_MT7902),
.driver_data = (kernel_ulong_t)&mt7902_data },
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(sdio, btmtksdio_table);
#define MTK_REG_CHLPCR 0x4 /* W1S */
#define C_INT_EN_SET BIT(0)
#define C_INT_EN_CLR BIT(1)
#define C_FW_OWN_REQ_SET BIT(8) /* For write */
#define C_COM_DRV_OWN BIT(8) /* For read */
#define C_FW_OWN_REQ_CLR BIT(9)
#define MTK_REG_CSDIOCSR 0x8
#define SDIO_RE_INIT_EN BIT(0)
#define SDIO_INT_CTL BIT(2)
#define MTK_REG_CHCR 0xc
#define C_INT_CLR_CTRL BIT(1)
#define BT_RST_DONE BIT(8)
/* CHISR have the same bits field definition with CHIER */
#define MTK_REG_CHISR 0x10
#define MTK_REG_CHIER 0x14
#define FW_OWN_BACK_INT BIT(0)
#define RX_DONE_INT BIT(1)
#define TX_EMPTY BIT(2)
#define TX_FIFO_OVERFLOW BIT(8)
#define FW_MAILBOX_INT BIT(15)
#define INT_MASK GENMASK(15, 0)
#define RX_PKT_LEN GENMASK(31, 16)
#define MTK_REG_CSICR 0xc0
#define CSICR_CLR_MBOX_ACK BIT(0)
#define MTK_REG_PH2DSM0R 0xc4
#define PH2DSM0R_DRIVER_OWN BIT(0)
#define MTK_REG_PD2HRM0R 0xdc
#define PD2HRM0R_DRV_OWN BIT(0)
#define MTK_REG_CTDR 0x18
#define MTK_REG_CRDR 0x1c
#define MTK_REG_CRPLR 0x24
#define MTK_SDIO_BLOCK_SIZE 256
#define BTMTKSDIO_TX_WAIT_VND_EVT 1
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/atomic.h`, `linux/gpio/consumer.h`, `linux/init.h`, `linux/iopoll.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct btmtksdio_data`, `struct mtkbtsdio_hdr`, `struct btmtksdio_dev`, `function mtk_hci_wmt_sync`, `function btmtksdio_tx_packet`, `function btmtksdio_drv_own_query`, `function btmtksdio_drv_own_query_79xx`, `function btmtksdio_chcr_query`, `function btmtksdio_fw_pmctrl`, `function btmtksdio_drv_pmctrl`.
- Atlas domain: Driver Families / drivers/bluetooth.
- Implementation status: source implementation candidate.
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.