linux/drivers/bluetooth/btnxpuart.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  NXP Bluetooth driver
 *  Copyright 2023 NXP
 */

#include <linux/module.h>
#include <linux/kernel.h>

#include <linux/serdev.h>
#include <linux/of.h>
#include <linux/skbuff.h>
#include <asm/unaligned.h>
#include <linux/firmware.h>
#include <linux/string.h>
#include <linux/crc8.h>
#include <linux/crc32.h>
#include <linux/string_helpers.h>

#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>

#include "h4_recv.h"

#define MANUFACTURER_NXP

#define BTNXPUART_TX_STATE_ACTIVE
#define BTNXPUART_FW_DOWNLOADING
#define BTNXPUART_CHECK_BOOT_SIGNATURE
#define BTNXPUART_SERDEV_OPEN
#define BTNXPUART_IR_IN_PROGRESS
#define BTNXPUART_FW_DOWNLOAD_ABORT

/* NXP HW err codes */
#define BTNXPUART_IR_HW_ERR

#define FIRMWARE_W8987
#define FIRMWARE_W8987_OLD
#define FIRMWARE_W8997
#define FIRMWARE_W8997_OLD
#define FIRMWARE_W9098
#define FIRMWARE_W9098_OLD
#define FIRMWARE_IW416
#define FIRMWARE_IW612
#define FIRMWARE_IW615
#define FIRMWARE_SECURE_IW615
#define FIRMWARE_IW624
#define FIRMWARE_SECURE_IW624
#define FIRMWARE_AW693
#define FIRMWARE_SECURE_AW693
#define FIRMWARE_AW693_A1
#define FIRMWARE_SECURE_AW693_A1
#define FIRMWARE_HELPER

#define CHIP_ID_W9098
#define CHIP_ID_IW416
#define CHIP_ID_IW612
#define CHIP_ID_IW624a
#define CHIP_ID_IW624c
#define CHIP_ID_AW693a0
#define CHIP_ID_AW693a1
#define CHIP_ID_IW615a0
#define CHIP_ID_IW615a1

#define FW_SECURE_MASK
#define FW_OPEN
#define FW_AUTH_ILLEGAL
#define FW_AUTH_PLAIN
#define FW_AUTH_ENC

#define HCI_NXP_PRI_BAUDRATE
#define HCI_NXP_SEC_BAUDRATE

#define MAX_FW_FILE_NAME_LEN

/* Default ps timeout period in milliseconds */
#define PS_DEFAULT_TIMEOUT_PERIOD_MS

/* wakeup methods */
#define WAKEUP_METHOD_DTR
#define WAKEUP_METHOD_BREAK
#define WAKEUP_METHOD_EXT_BREAK
#define WAKEUP_METHOD_RTS
#define WAKEUP_METHOD_INVALID

/* power save mode status */
#define PS_MODE_DISABLE
#define PS_MODE_ENABLE

/* Power Save Commands to ps_work_func  */
#define PS_CMD_EXIT_PS
#define PS_CMD_ENTER_PS

/* power save state */
#define PS_STATE_AWAKE
#define PS_STATE_SLEEP

/* Bluetooth vendor command : Sleep mode */
#define HCI_NXP_AUTO_SLEEP_MODE
/* Bluetooth vendor command : Wakeup method */
#define HCI_NXP_WAKEUP_METHOD
/* Bluetooth vendor command : Set operational baudrate */
#define HCI_NXP_SET_OPER_SPEED
/* Bluetooth vendor command: Independent Reset */
#define HCI_NXP_IND_RESET

/* Bluetooth Power State : Vendor cmd params */
#define BT_PS_ENABLE
#define BT_PS_DISABLE

/* Bluetooth Host Wakeup Methods */
#define BT_HOST_WAKEUP_METHOD_NONE
#define BT_HOST_WAKEUP_METHOD_DTR
#define BT_HOST_WAKEUP_METHOD_BREAK
#define BT_HOST_WAKEUP_METHOD_GPIO

/* Bluetooth Chip Wakeup Methods */
#define BT_CTRL_WAKEUP_METHOD_DSR
#define BT_CTRL_WAKEUP_METHOD_BREAK
#define BT_CTRL_WAKEUP_METHOD_GPIO
#define BT_CTRL_WAKEUP_METHOD_EXT_BREAK
#define BT_CTRL_WAKEUP_METHOD_RTS

struct ps_data {};

struct wakeup_cmd_payload {} __packed;

struct psmode_cmd_payload {} __packed;

struct btnxpuart_data {};

struct btnxpuart_dev {};

#define NXP_V1_FW_REQ_PKT
#define NXP_V1_CHIP_VER_PKT
#define NXP_V3_FW_REQ_PKT
#define NXP_V3_CHIP_VER_PKT

#define NXP_ACK_V1
#define NXP_NAK_V1
#define NXP_ACK_V3
#define NXP_NAK_V3
#define NXP_CRC_ERROR_V3

/* Bootloader signature error codes */
#define NXP_ACK_RX_TIMEOUT
#define NXP_HDR_RX_TIMEOUT
#define NXP_DATA_RX_TIMEOUT

#define HDR_LEN

#define NXP_RECV_CHIP_VER_V1

#define NXP_RECV_FW_REQ_V1

#define NXP_RECV_CHIP_VER_V3

#define NXP_RECV_FW_REQ_V3

struct v1_data_req {} __packed;

struct v1_start_ind {} __packed;

struct v3_data_req {} __packed;

struct v3_start_ind {} __packed;

/* UART register addresses of BT chip */
#define CLKDIVADDR
#define UARTDIVADDR
#define UARTMCRADDR
#define UARTREINITADDR
#define UARTICRADDR
#define UARTFCRADDR

#define MCR
#define INIT
#define ICR
#define FCR

#define POLYNOMIAL8

struct uart_reg {} __packed;

struct uart_config {} __packed;

struct nxp_bootloader_cmd {} __packed;

struct nxp_v3_rx_timeout_nak {} __packed;

nxp_v3_rx_timeout_nak_u;

static u8 crc8_table[CRC8_TABLE_SIZE];

/* Default configurations */
#define DEFAULT_H2C_WAKEUP_MODE
#define DEFAULT_PS_MODE
#define FW_INIT_BAUDRATE

static struct sk_buff *nxp_drv_send_cmd(struct hci_dev *hdev, u16 opcode,
					u32 plen,
					void *param)
{}

static void btnxpuart_tx_wakeup(struct btnxpuart_dev *nxpdev)
{}

/* NXP Power Save Feature */
static void ps_start_timer(struct btnxpuart_dev *nxpdev)
{}

static void ps_cancel_timer(struct btnxpuart_dev *nxpdev)
{}

static void ps_control(struct hci_dev *hdev, u8 ps_state)
{}

static void ps_work_func(struct work_struct *work)
{}

static void ps_timeout_func(struct timer_list *t)
{}

static void ps_setup(struct hci_dev *hdev)
{}

static bool ps_wakeup(struct btnxpuart_dev *nxpdev)
{}

static int send_ps_cmd(struct hci_dev *hdev, void *data)
{}

static int send_wakeup_method_cmd(struct hci_dev *hdev, void *data)
{}

static void ps_init(struct hci_dev *hdev)
{}

/* NXP Firmware Download Feature */
static int nxp_download_firmware(struct hci_dev *hdev)
{}

static void nxp_send_ack(u8 ack, struct hci_dev *hdev)
{}

static bool nxp_fw_change_baudrate(struct hci_dev *hdev, u16 req_len)
{}

static bool nxp_fw_change_timeout(struct hci_dev *hdev, u16 req_len)
{}

static u32 nxp_get_data_len(const u8 *buf)
{}

static bool is_fw_downloading(struct btnxpuart_dev *nxpdev)
{}

static bool process_boot_signature(struct btnxpuart_dev *nxpdev)
{}

static int nxp_request_firmware(struct hci_dev *hdev, const char *fw_name,
				const char *fw_name_old)
{}

/* for legacy chipsets with V1 bootloader */
static int nxp_recv_chip_ver_v1(struct hci_dev *hdev, struct sk_buff *skb)
{}

static int nxp_recv_fw_req_v1(struct hci_dev *hdev, struct sk_buff *skb)
{}

static char *nxp_get_fw_name_from_chipid(struct hci_dev *hdev, u16 chipid,
					 u8 loader_ver)
{}

static char *nxp_get_old_fw_name_from_chipid(struct hci_dev *hdev, u16 chipid,
					 u8 loader_ver)
{}

static int nxp_recv_chip_ver_v3(struct hci_dev *hdev, struct sk_buff *skb)
{}

static void nxp_handle_fw_download_error(struct hci_dev *hdev, struct v3_data_req *req)
{}

static int nxp_recv_fw_req_v3(struct hci_dev *hdev, struct sk_buff *skb)
{}

static int nxp_set_baudrate_cmd(struct hci_dev *hdev, void *data)
{}

static int nxp_check_boot_sign(struct btnxpuart_dev *nxpdev)
{}

static int nxp_set_ind_reset(struct hci_dev *hdev, void *data)
{}

/* NXP protocol */
static int nxp_setup(struct hci_dev *hdev)
{}

static void nxp_hw_err(struct hci_dev *hdev, u8 code)
{}

static int nxp_shutdown(struct hci_dev *hdev)
{}

static int btnxpuart_queue_skb(struct hci_dev *hdev, struct sk_buff *skb)
{}

static int nxp_enqueue(struct hci_dev *hdev, struct sk_buff *skb)
{}

static struct sk_buff *nxp_dequeue(void *data)
{}

/* btnxpuart based on serdev */
static void btnxpuart_tx_work(struct work_struct *work)
{}

static int btnxpuart_open(struct hci_dev *hdev)
{}

static int btnxpuart_close(struct hci_dev *hdev)
{}

static int btnxpuart_flush(struct hci_dev *hdev)
{}

static const struct h4_recv_pkt nxp_recv_pkts[] =;

static size_t btnxpuart_receive_buf(struct serdev_device *serdev,
				    const u8 *data, size_t count)
{}

static void btnxpuart_write_wakeup(struct serdev_device *serdev)
{}

static const struct serdev_device_ops btnxpuart_client_ops =;

static int nxp_serdev_probe(struct serdev_device *serdev)
{}

static void nxp_serdev_remove(struct serdev_device *serdev)
{}

#ifdef CONFIG_PM_SLEEP
static int nxp_serdev_suspend(struct device *dev)
{}

static int nxp_serdev_resume(struct device *dev)
{}
#endif

static struct btnxpuart_data w8987_data __maybe_unused =;

static struct btnxpuart_data w8997_data __maybe_unused =;

static const struct of_device_id nxpuart_of_match_table[] __maybe_unused =;
MODULE_DEVICE_TABLE(of, nxpuart_of_match_table);

static const struct dev_pm_ops nxp_pm_ops =;

static struct serdev_device_driver nxp_serdev_driver =;

module_serdev_device_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();