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_chip_type_evt
{
22 struct rtl_download_cmd
{
24 __u8 data
[RTL_FRAG_LEN
];
27 struct rtl_download_response
{
32 struct rtl_rom_version_evt
{
37 struct rtl_epatch_header
{
43 struct rtl_vendor_config_entry
{
49 struct rtl_vendor_config
{
55 struct rtl_epatch_header_v2
{
67 struct rtl_section_hdr
{
72 struct rtl_common_subsec
{
89 struct rtl_subsection
{
90 struct list_head list
;
102 struct rtl_vendor_cmd
{
107 REALTEK_ALT6_CONTINUOUS_TX_CHIP
,
112 struct rtl_dump_info
{
113 const char *driver_name
;
118 struct btrealtek_data
{
119 DECLARE_BITMAP(flags
, __REALTEK_NUM_FLAGS
);
121 struct rtl_dump_info rtl_dump
;
124 #define btrealtek_set_flag(hdev, nr) \
126 struct btrealtek_data *realtek = hci_get_priv((hdev)); \
127 set_bit((nr), realtek->flags); \
130 #define btrealtek_get_flag(hdev) \
131 (((struct btrealtek_data *)hci_get_priv(hdev))->flags)
133 #define btrealtek_test_flag(hdev, nr) test_bit((nr), btrealtek_get_flag(hdev))
135 #if IS_ENABLED(CONFIG_BT_RTL)
137 struct btrtl_device_info
*btrtl_initialize(struct hci_dev
*hdev
,
138 const char *postfix
);
139 void btrtl_free(struct btrtl_device_info
*btrtl_dev
);
140 int btrtl_download_firmware(struct hci_dev
*hdev
,
141 struct btrtl_device_info
*btrtl_dev
);
142 void btrtl_set_quirks(struct hci_dev
*hdev
,
143 struct btrtl_device_info
*btrtl_dev
);
144 int btrtl_setup_realtek(struct hci_dev
*hdev
);
145 int btrtl_shutdown_realtek(struct hci_dev
*hdev
);
146 int btrtl_get_uart_settings(struct hci_dev
*hdev
,
147 struct btrtl_device_info
*btrtl_dev
,
148 unsigned int *controller_baudrate
,
149 u32
*device_baudrate
, bool *flow_control
);
150 void btrtl_set_driver_name(struct hci_dev
*hdev
, const char *driver_name
);
154 static inline struct btrtl_device_info
*btrtl_initialize(struct hci_dev
*hdev
,
157 return ERR_PTR(-EOPNOTSUPP
);
160 static inline void btrtl_free(struct btrtl_device_info
*btrtl_dev
)
164 static inline int btrtl_download_firmware(struct hci_dev
*hdev
,
165 struct btrtl_device_info
*btrtl_dev
)
170 static inline void btrtl_set_quirks(struct hci_dev
*hdev
,
171 struct btrtl_device_info
*btrtl_dev
)
175 static inline int btrtl_setup_realtek(struct hci_dev
*hdev
)
180 static inline int btrtl_shutdown_realtek(struct hci_dev
*hdev
)
185 static inline int btrtl_get_uart_settings(struct hci_dev
*hdev
,
186 struct btrtl_device_info
*btrtl_dev
,
187 unsigned int *controller_baudrate
,
188 u32
*device_baudrate
,
194 static inline void btrtl_set_driver_name(struct hci_dev
*hdev
, const char *driver_name
)