// SPDX-License-Identifier: GPL-2.0-or-later/* * * Bluetooth HCI UART driver for Broadcom devices * * Copyright (C) 2015 Intel Corporation */#include<linux/kernel.h>#include<linux/errno.h>#include<linux/skbuff.h>#include<linux/firmware.h>#include<linux/module.h>#include<linux/acpi.h>#include<linux/of.h>#include<linux/property.h>#include<linux/platform_data/x86/apple.h>#include<linux/platform_device.h>#include<linux/regulator/consumer.h>#include<linux/clk.h>#include<linux/gpio/consumer.h>#include<linux/tty.h>#include<linux/interrupt.h>#include<linux/dmi.h>#include<linux/pm_runtime.h>#include<linux/serdev.h>#include<net/bluetooth/bluetooth.h>#include<net/bluetooth/hci_core.h>#include"btbcm.h"#include"hci_uart.h"#define BCM_NULL_PKT 0x00#define BCM_NULL_SIZE 0#define BCM_LM_DIAG_PKT 0x07#define BCM_LM_DIAG_SIZE 63#define BCM_TYPE49_PKT 0x31#define BCM_TYPE49_SIZE 0#define BCM_TYPE52_PKT 0x34#define BCM_TYPE52_SIZE 0#define BCM_AUTOSUSPEND_DELAY 5000 /* default autosleep delay */#define BCM_NUM_SUPPLIES 2/** * struct bcm_device - device driver resources * @serdev_hu: HCI UART controller struct * @list: bcm_device_list node * @dev: physical UART slave * @name: device name logged by bt_dev_*() functions * @device_wakeup: BT_WAKE pin, * assert = Bluetooth device must wake up or remain awake, * deassert = Bluetooth device may sleep when sleep criteria are met * @shutdown: BT_REG_ON pin, * power up or power down Bluetooth device internal regulators * @set_device_wakeup: callback to toggle BT_WAKE pin * either by accessing @device_wakeup or by calling @btlp * @set_shutdown: callback to toggle BT_REG_ON pin * either by accessing @shutdown or by calling @btpu/@btpd * @btlp: Apple ACPI method to toggle BT_WAKE pin ("Bluetooth Low Power") * @btpu: Apple ACPI method to drive BT_REG_ON pin high ("Bluetooth Power Up") * @btpd: Apple ACPI method to drive BT_REG_ON pin low ("Bluetooth Power Down") * @txco_clk: external reference frequency clock used by Bluetooth device * @lpo_clk: external LPO clock used by Bluetooth device * @supplies: VBAT and VDDIO supplies used by Bluetooth device * @res_enabled: whether clocks and supplies are prepared and enabled * @init_speed: default baudrate of Bluetooth device; * the host UART is initially set to this baudrate so that * it can configure the Bluetooth device for @oper_speed * @oper_speed: preferred baudrate of Bluetooth device; * set to 0 if @init_speed is already the preferred baudrate * @irq: interrupt triggered by HOST_WAKE_BT pin * @irq_active_low: whether @irq is active low * @hu: pointer to HCI UART controller struct, * used to disable flow control during runtime suspend and system sleep * @is_suspended: whether flow control is currently disabled