linux/drivers/bluetooth/hci_bcm.c

// 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/of_irq.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/gpio/machine.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
#define BCM_NULL_SIZE

#define BCM_LM_DIAG_PKT
#define BCM_LM_DIAG_SIZE

#define BCM_TYPE49_PKT
#define BCM_TYPE49_SIZE

#define BCM_TYPE52_PKT
#define BCM_TYPE52_SIZE

#define BCM_AUTOSUSPEND_DELAY

#define BCM_NUM_SUPPLIES

/**
 * struct bcm_device_data - device specific data
 * @no_early_set_baudrate: Disallow set baudrate before driver setup()
 * @drive_rts_on_open: drive RTS signal on ->open() when platform requires it
 * @no_uart_clock_set: UART clock set command for >3Mbps mode is unavailable
 * @max_autobaud_speed: max baudrate supported by device in autobaud mode
 * @max_speed: max baudrate supported
 */
struct bcm_device_data {};

/**
 * 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
 * @reset: BT_RST_N pin,
 *	active low resets the Bluetooth logic core
 * @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")
 * @gpio_count: internal counter for GPIO resources associated with ACPI device
 * @gpio_int_idx: index in _CRS for GpioInt() resource
 * @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
 * @irq_acquired: flag to show if IRQ handler has been assigned
 * @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
 * @no_early_set_baudrate: don't set_baudrate before setup()
 * @drive_rts_on_open: drive RTS signal on ->open() when platform requires it
 * @no_uart_clock_set: UART clock set command for >3Mbps mode is unavailable
 * @pcm_int_params: keep the initial PCM configuration
 * @use_autobaud_mode: start Bluetooth device in autobaud mode
 * @max_autobaud_speed: max baudrate supported by device in autobaud mode
 */
struct bcm_device {};

/* generic bcm uart resources */
struct bcm_data {};

/* List of BCM BT UART devices */
static DEFINE_MUTEX(bcm_device_lock);
static LIST_HEAD(bcm_device_list);

static int irq_polarity =;
module_param(irq_polarity, int, 0444);
MODULE_PARM_DESC();

static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)
{}

static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed)
{}

/* bcm_device_exists should be protected by bcm_device_lock */
static bool bcm_device_exists(struct bcm_device *device)
{}

static int bcm_gpio_set_power(struct bcm_device *dev, bool powered)
{}

#ifdef CONFIG_PM
static irqreturn_t bcm_host_wake(int irq, void *data)
{}

static int bcm_request_irq(struct bcm_data *bcm)
{}

static const struct bcm_set_sleep_mode default_sleep_params =;

static int bcm_setup_sleep(struct hci_uart *hu)
{}
#else
static inline int bcm_request_irq(struct bcm_data *bcm) { return 0; }
static inline int bcm_setup_sleep(struct hci_uart *hu) { return 0; }
#endif

static int bcm_set_diag(struct hci_dev *hdev, bool enable)
{}

static int bcm_open(struct hci_uart *hu)
{}

static int bcm_close(struct hci_uart *hu)
{}

static int bcm_flush(struct hci_uart *hu)
{}

static int bcm_setup(struct hci_uart *hu)
{}

#define BCM_RECV_LM_DIAG

#define BCM_RECV_NULL

#define BCM_RECV_TYPE49

#define BCM_RECV_TYPE52

static const struct h4_recv_pkt bcm_recv_pkts[] =;

static int bcm_recv(struct hci_uart *hu, const void *data, int count)
{}

static int bcm_enqueue(struct hci_uart *hu, struct sk_buff *skb)
{}

static struct sk_buff *bcm_dequeue(struct hci_uart *hu)
{}

#ifdef CONFIG_PM
static int bcm_suspend_device(struct device *dev)
{}

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

#ifdef CONFIG_PM_SLEEP
/* suspend callback */
static int bcm_suspend(struct device *dev)
{}

/* resume callback */
static int bcm_resume(struct device *dev)
{}
#endif

/* Some firmware reports an IRQ which does not work (wrong pin in fw table?) */
static struct gpiod_lookup_table irq_on_int33fc02_pin17_gpios =;

static const struct dmi_system_id bcm_broken_irq_dmi_table[] =;

#ifdef CONFIG_ACPI
static const struct acpi_gpio_params first_gpio =;
static const struct acpi_gpio_params second_gpio =;
static const struct acpi_gpio_params third_gpio =;

static const struct acpi_gpio_mapping acpi_bcm_int_last_gpios[] =;

static const struct acpi_gpio_mapping acpi_bcm_int_first_gpios[] =;

static int bcm_resource(struct acpi_resource *ares, void *data)
{}

static int bcm_apple_set_device_wakeup(struct bcm_device *dev, bool awake)
{}

static int bcm_apple_set_shutdown(struct bcm_device *dev, bool powered)
{}

static int bcm_apple_get_resources(struct bcm_device *dev)
{}
#else
static inline int bcm_apple_get_resources(struct bcm_device *dev)
{
	return -EOPNOTSUPP;
}
#endif /* CONFIG_ACPI */

static int bcm_gpio_set_device_wakeup(struct bcm_device *dev, bool awake)
{}

static int bcm_gpio_set_shutdown(struct bcm_device *dev, bool powered)
{}

/* Try a bunch of names for TXCO */
static struct clk *bcm_get_txco(struct device *dev)
{}

static int bcm_get_resources(struct bcm_device *dev)
{}

#ifdef CONFIG_ACPI
static int bcm_acpi_probe(struct bcm_device *dev)
{}
#else
static int bcm_acpi_probe(struct bcm_device *dev)
{
	return -EINVAL;
}
#endif /* CONFIG_ACPI */

static int bcm_of_probe(struct bcm_device *bdev)
{}

static int bcm_probe(struct platform_device *pdev)
{}

static void bcm_remove(struct platform_device *pdev)
{}

static const struct hci_uart_proto bcm_proto =;

#ifdef CONFIG_ACPI

/* bcm43430a0/a1 BT does not support 48MHz UART clock, limit to 2000000 baud */
static struct bcm_device_data bcm43430_device_data =;

static const struct acpi_device_id bcm_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, bcm_acpi_match);
#endif

/* suspend and resume callbacks */
static const struct dev_pm_ops bcm_pm_ops =;

static struct platform_driver bcm_driver =;

static int bcm_serdev_probe(struct serdev_device *serdev)
{}

static void bcm_serdev_remove(struct serdev_device *serdev)
{}

#ifdef CONFIG_OF
static struct bcm_device_data bcm4354_device_data =;

static struct bcm_device_data bcm43438_device_data =;

static struct bcm_device_data cyw4373a0_device_data =;

static struct bcm_device_data cyw55572_device_data =;

static const struct of_device_id bcm_bluetooth_of_match[] =;
MODULE_DEVICE_TABLE(of, bcm_bluetooth_of_match);
#endif

static struct serdev_device_driver bcm_serdev_driver =;

int __init bcm_init(void)
{}

int __exit bcm_deinit(void)
{}