1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Bluetooth support for Realtek devices
5 * Copyright (C) 2015 Endless Mobile, Inc.
8 #define RTL_FRAG_LEN 252
10 #define rtl_dev_err(dev, fmt, ...) bt_dev_err(dev, "RTL: " fmt, ##__VA_ARGS__)
11 #define rtl_dev_warn(dev, fmt, ...) bt_dev_warn(dev, "RTL: " fmt, ##__VA_ARGS__)
12 #define rtl_dev_info(dev, fmt, ...) bt_dev_info(dev, "RTL: " fmt, ##__VA_ARGS__)
13 #define rtl_dev_dbg(dev, fmt, ...) bt_dev_dbg(dev, "RTL: " fmt, ##__VA_ARGS__)
15 struct btrtl_device_info;
17 struct rtl_download_cmd {
19 __u8 data[RTL_FRAG_LEN];
22 struct rtl_download_response {
27 struct rtl_rom_version_evt {
32 struct rtl_epatch_header {
38 struct rtl_vendor_config_entry {
44 struct rtl_vendor_config {
47 struct rtl_vendor_config_entry entry[];
51 REALTEK_ALT6_CONTINUOUS_TX_CHIP,
56 struct btrealtek_data {
57 DECLARE_BITMAP(flags, __REALTEK_NUM_FLAGS);
60 #define btrealtek_set_flag(hdev, nr) \
62 struct btrealtek_data *realtek = hci_get_priv((hdev)); \
63 set_bit((nr), realtek->flags); \
66 #define btrealtek_get_flag(hdev) \
67 (((struct btrealtek_data *)hci_get_priv(hdev))->flags)
69 #define btrealtek_test_flag(hdev, nr) test_bit((nr), btrealtek_get_flag(hdev))
71 #if IS_ENABLED(CONFIG_BT_RTL)
73 struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
75 void btrtl_free(struct btrtl_device_info *btrtl_dev);
76 int btrtl_download_firmware(struct hci_dev *hdev,
77 struct btrtl_device_info *btrtl_dev);
78 void btrtl_set_quirks(struct hci_dev *hdev,
79 struct btrtl_device_info *btrtl_dev);
80 int btrtl_setup_realtek(struct hci_dev *hdev);
81 int btrtl_shutdown_realtek(struct hci_dev *hdev);
82 int btrtl_get_uart_settings(struct hci_dev *hdev,
83 struct btrtl_device_info *btrtl_dev,
84 unsigned int *controller_baudrate,
85 u32 *device_baudrate, bool *flow_control);
89 static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
92 return ERR_PTR(-EOPNOTSUPP);
95 static inline void btrtl_free(struct btrtl_device_info *btrtl_dev)
99 static inline int btrtl_download_firmware(struct hci_dev *hdev,
100 struct btrtl_device_info *btrtl_dev)
105 static inline void btrtl_set_quirks(struct hci_dev *hdev,
106 struct btrtl_device_info *btrtl_dev)
110 static inline int btrtl_setup_realtek(struct hci_dev *hdev)
115 static inline int btrtl_shutdown_realtek(struct hci_dev *hdev)
120 static inline int btrtl_get_uart_settings(struct hci_dev *hdev,
121 struct btrtl_device_info *btrtl_dev,
122 unsigned int *controller_baudrate,
123 u32 *device_baudrate,