drivers/bluetooth/btnxpuart.c
Source file repositories/reference/linux-study-clean/drivers/bluetooth/btnxpuart.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bluetooth/btnxpuart.c- Extension
.c- Size
- 56451 bytes
- Lines
- 2030
- 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.
- 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/kernel.hlinux/serdev.hlinux/of.hlinux/skbuff.hlinux/unaligned.hlinux/firmware.hlinux/string.hlinux/crc8.hlinux/crc32.hlinux/string_helpers.hlinux/gpio/consumer.hlinux/of_irq.hlinux/regulator/consumer.hlinux/reset.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hhci_uart.h
Detected Declarations
struct ps_datastruct wakeup_cmd_payloadstruct psmode_cmd_payloadstruct btnxpuart_datastruct btnxpuart_devstruct v1_data_reqstruct v1_start_indstruct v3_data_reqstruct v3_start_indstruct uart_regstruct uart_configstruct nxp_bootloader_cmdstruct nxp_v3_rx_timeout_nakstruct nxp_v3_crc_nakstruct nxp_fw_dump_hdrenum bootloader_param_changefunction btnxpuart_tx_wakeupfunction ps_start_timerfunction ps_cancel_timerfunction ps_controlfunction ps_work_funcfunction ps_timeout_funcfunction ps_host_wakeup_irq_handlerfunction ps_setupfunction ps_wakeupfunction ps_cleanupfunction send_ps_cmdfunction send_wakeup_method_cmdfunction ps_initfunction nxp_download_firmwarefunction nxp_send_ackfunction nxp_fw_change_baudratefunction nxp_fw_change_timeoutfunction nxp_get_data_lenfunction is_fw_downloadingfunction ind_reset_in_progressfunction fw_dump_in_progressfunction process_boot_signaturefunction nxp_request_firmwarefunction nxp_recv_chip_ver_v1function nxp_recv_fw_req_v1function nxp_recv_chip_ver_v3function nxp_handle_fw_download_errorfunction nxp_recv_fw_req_v3function nxp_set_baudrate_cmdfunction nxp_check_boot_signfunction nxp_set_ind_resetfunction nxp_coredump
Annotated Snippet
struct ps_data {
u8 target_ps_mode; /* ps mode to be set */
u8 cur_psmode; /* current ps_mode */
u8 ps_state; /* controller's power save state */
u8 ps_cmd;
u8 h2c_wakeupmode;
u8 cur_h2c_wakeupmode;
u8 c2h_wakeupmode;
u8 c2h_wakeup_gpio;
u8 h2c_wakeup_gpio;
bool driver_sent_cmd;
u16 h2c_ps_interval;
u16 c2h_ps_interval;
bool wakeup_source;
struct gpio_desc *h2c_ps_gpio;
s32 irq_handler;
struct hci_dev *hdev;
struct work_struct work;
struct timer_list ps_timer;
struct mutex ps_lock;
};
struct wakeup_cmd_payload {
u8 c2h_wakeupmode;
u8 c2h_wakeup_gpio;
u8 h2c_wakeupmode;
u8 h2c_wakeup_gpio;
} __packed;
struct psmode_cmd_payload {
u8 ps_cmd;
__le16 c2h_ps_interval;
} __packed;
struct btnxpuart_data {
const char *helper_fw_name;
const char *fw_name;
const char *fw_name_old;
};
enum bootloader_param_change {
not_changed,
cmd_sent,
changed
};
struct btnxpuart_dev {
struct hci_dev *hdev;
struct serdev_device *serdev;
struct work_struct tx_work;
unsigned long tx_state;
struct sk_buff_head txq;
struct sk_buff *rx_skb;
const struct firmware *fw;
u8 fw_name[MAX_FW_FILE_NAME_LEN];
u32 fw_dnld_v1_offset;
u32 fw_v1_sent_bytes;
u32 fw_dnld_v3_offset;
u32 fw_v3_offset_correction;
u32 fw_v3_prev_sent;
u32 fw_v1_expected_len;
u32 boot_reg_offset;
wait_queue_head_t fw_dnld_done_wait_q;
wait_queue_head_t check_boot_sign_wait_q;
u32 new_baudrate;
u32 current_baudrate;
u32 fw_init_baudrate;
u32 secondary_baudrate;
enum bootloader_param_change timeout_changed;
enum bootloader_param_change baudrate_changed;
bool helper_downloaded;
struct ps_data psdata;
struct btnxpuart_data *nxp_data;
struct reset_control *pdn;
struct hci_uart hu;
};
#define NXP_V1_FW_REQ_PKT 0xa5
#define NXP_V1_CHIP_VER_PKT 0xaa
#define NXP_V3_FW_REQ_PKT 0xa7
#define NXP_V3_CHIP_VER_PKT 0xab
#define NXP_ACK_V1 0x5a
#define NXP_NAK_V1 0xbf
#define NXP_ACK_V3 0x7a
#define NXP_NAK_V3 0x7b
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/serdev.h`, `linux/of.h`, `linux/skbuff.h`, `linux/unaligned.h`, `linux/firmware.h`, `linux/string.h`.
- Detected declarations: `struct ps_data`, `struct wakeup_cmd_payload`, `struct psmode_cmd_payload`, `struct btnxpuart_data`, `struct btnxpuart_dev`, `struct v1_data_req`, `struct v1_start_ind`, `struct v3_data_req`, `struct v3_start_ind`, `struct uart_reg`.
- Atlas domain: Driver Families / drivers/bluetooth.
- Implementation status: source 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.