Loading...
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Bluetooth support for Realtek devices
4 *
5 * Copyright (C) 2015 Endless Mobile, Inc.
6 */
7
8#define RTL_FRAG_LEN 252
9
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__)
14
15struct btrtl_device_info;
16
17struct rtl_chip_type_evt {
18 __u8 status;
19 __u8 type;
20} __packed;
21
22struct rtl_download_cmd {
23 __u8 index;
24 __u8 data[RTL_FRAG_LEN];
25} __packed;
26
27struct rtl_download_response {
28 __u8 status;
29 __u8 index;
30} __packed;
31
32struct rtl_rom_version_evt {
33 __u8 status;
34 __u8 version;
35} __packed;
36
37struct rtl_epatch_header {
38 __u8 signature[8];
39 __le32 fw_version;
40 __le16 num_patches;
41} __packed;
42
43struct rtl_vendor_config_entry {
44 __le16 offset;
45 __u8 len;
46 __u8 data[];
47} __packed;
48
49struct rtl_vendor_config {
50 __le32 signature;
51 __le16 total_len;
52 __u8 entry[];
53} __packed;
54
55struct rtl_epatch_header_v2 {
56 __u8 signature[8];
57 __u8 fw_version[8];
58 __le32 num_sections;
59} __packed;
60
61struct rtl_section {
62 __le32 opcode;
63 __le32 len;
64 u8 data[];
65} __packed;
66
67struct rtl_section_hdr {
68 __le16 num;
69 __le16 reserved;
70} __packed;
71
72struct rtl_common_subsec {
73 __u8 eco;
74 __u8 prio;
75 __u8 cb[2];
76 __le32 len;
77 __u8 data[];
78};
79
80struct rtl_sec_hdr {
81 __u8 eco;
82 __u8 prio;
83 __u8 key_id;
84 __u8 reserved;
85 __le32 len;
86 __u8 data[];
87} __packed;
88
89struct rtl_subsection {
90 struct list_head list;
91 u32 opcode;
92 u32 len;
93 u8 prio;
94 u8 *data;
95};
96
97struct rtl_iovec {
98 u8 *data;
99 u32 len;
100};
101
102struct rtl_vendor_cmd {
103 __u8 param[5];
104} __packed;
105
106enum {
107 REALTEK_ALT6_CONTINUOUS_TX_CHIP,
108
109 __REALTEK_NUM_FLAGS,
110};
111
112struct rtl_dump_info {
113 const char *driver_name;
114 char *controller;
115 u32 fw_version;
116};
117
118struct btrealtek_data {
119 DECLARE_BITMAP(flags, __REALTEK_NUM_FLAGS);
120
121 struct rtl_dump_info rtl_dump;
122};
123
124#define btrealtek_set_flag(hdev, nr) \
125 do { \
126 struct btrealtek_data *realtek = hci_get_priv((hdev)); \
127 set_bit((nr), realtek->flags); \
128 } while (0)
129
130#define btrealtek_get_flag(hdev) \
131 (((struct btrealtek_data *)hci_get_priv(hdev))->flags)
132
133#define btrealtek_test_flag(hdev, nr) test_bit((nr), btrealtek_get_flag(hdev))
134
135#if IS_ENABLED(CONFIG_BT_RTL)
136
137struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
138 const char *postfix);
139void btrtl_free(struct btrtl_device_info *btrtl_dev);
140int btrtl_download_firmware(struct hci_dev *hdev,
141 struct btrtl_device_info *btrtl_dev);
142void btrtl_set_quirks(struct hci_dev *hdev,
143 struct btrtl_device_info *btrtl_dev);
144int btrtl_setup_realtek(struct hci_dev *hdev);
145int btrtl_shutdown_realtek(struct hci_dev *hdev);
146int 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);
150void btrtl_set_driver_name(struct hci_dev *hdev, const char *driver_name);
151
152#else
153
154static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
155 const char *postfix)
156{
157 return ERR_PTR(-EOPNOTSUPP);
158}
159
160static inline void btrtl_free(struct btrtl_device_info *btrtl_dev)
161{
162}
163
164static inline int btrtl_download_firmware(struct hci_dev *hdev,
165 struct btrtl_device_info *btrtl_dev)
166{
167 return -EOPNOTSUPP;
168}
169
170static inline void btrtl_set_quirks(struct hci_dev *hdev,
171 struct btrtl_device_info *btrtl_dev)
172{
173}
174
175static inline int btrtl_setup_realtek(struct hci_dev *hdev)
176{
177 return -EOPNOTSUPP;
178}
179
180static inline int btrtl_shutdown_realtek(struct hci_dev *hdev)
181{
182 return -EOPNOTSUPP;
183}
184
185static 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,
189 bool *flow_control)
190{
191 return -ENOENT;
192}
193
194static inline void btrtl_set_driver_name(struct hci_dev *hdev, const char *driver_name)
195{
196}
197
198#endif
1/*
2 * Bluetooth support for Realtek devices
3 *
4 * Copyright (C) 2015 Endless Mobile, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
18#define RTL_FRAG_LEN 252
19
20struct rtl_download_cmd {
21 __u8 index;
22 __u8 data[RTL_FRAG_LEN];
23} __packed;
24
25struct rtl_download_response {
26 __u8 status;
27 __u8 index;
28} __packed;
29
30struct rtl_rom_version_evt {
31 __u8 status;
32 __u8 version;
33} __packed;
34
35struct rtl_epatch_header {
36 __u8 signature[8];
37 __le32 fw_version;
38 __le16 num_patches;
39} __packed;
40
41#if IS_ENABLED(CONFIG_BT_RTL)
42
43int btrtl_setup_realtek(struct hci_dev *hdev);
44
45#else
46
47static inline int btrtl_setup_realtek(struct hci_dev *hdev)
48{
49 return -EOPNOTSUPP;
50}
51
52#endif