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_download_cmd {
18 __u8 index;
19 __u8 data[RTL_FRAG_LEN];
20} __packed;
21
22struct rtl_download_response {
23 __u8 status;
24 __u8 index;
25} __packed;
26
27struct rtl_rom_version_evt {
28 __u8 status;
29 __u8 version;
30} __packed;
31
32struct rtl_epatch_header {
33 __u8 signature[8];
34 __le32 fw_version;
35 __le16 num_patches;
36} __packed;
37
38struct rtl_vendor_config_entry {
39 __le16 offset;
40 __u8 len;
41 __u8 data[];
42} __packed;
43
44struct rtl_vendor_config {
45 __le32 signature;
46 __le16 total_len;
47 struct rtl_vendor_config_entry entry[];
48} __packed;
49
50enum {
51 REALTEK_ALT6_CONTINUOUS_TX_CHIP,
52
53 __REALTEK_NUM_FLAGS,
54};
55
56struct btrealtek_data {
57 DECLARE_BITMAP(flags, __REALTEK_NUM_FLAGS);
58};
59
60#define btrealtek_set_flag(hdev, nr) \
61 do { \
62 struct btrealtek_data *realtek = hci_get_priv((hdev)); \
63 set_bit((nr), realtek->flags); \
64 } while (0)
65
66#define btrealtek_get_flag(hdev) \
67 (((struct btrealtek_data *)hci_get_priv(hdev))->flags)
68
69#define btrealtek_test_flag(hdev, nr) test_bit((nr), btrealtek_get_flag(hdev))
70
71#if IS_ENABLED(CONFIG_BT_RTL)
72
73struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
74 const char *postfix);
75void btrtl_free(struct btrtl_device_info *btrtl_dev);
76int btrtl_download_firmware(struct hci_dev *hdev,
77 struct btrtl_device_info *btrtl_dev);
78void btrtl_set_quirks(struct hci_dev *hdev,
79 struct btrtl_device_info *btrtl_dev);
80int btrtl_setup_realtek(struct hci_dev *hdev);
81int btrtl_shutdown_realtek(struct hci_dev *hdev);
82int 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);
86
87#else
88
89static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
90 const char *postfix)
91{
92 return ERR_PTR(-EOPNOTSUPP);
93}
94
95static inline void btrtl_free(struct btrtl_device_info *btrtl_dev)
96{
97}
98
99static inline int btrtl_download_firmware(struct hci_dev *hdev,
100 struct btrtl_device_info *btrtl_dev)
101{
102 return -EOPNOTSUPP;
103}
104
105static inline void btrtl_set_quirks(struct hci_dev *hdev,
106 struct btrtl_device_info *btrtl_dev)
107{
108}
109
110static inline int btrtl_setup_realtek(struct hci_dev *hdev)
111{
112 return -EOPNOTSUPP;
113}
114
115static inline int btrtl_shutdown_realtek(struct hci_dev *hdev)
116{
117 return -EOPNOTSUPP;
118}
119
120static 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,
124 bool *flow_control)
125{
126 return -ENOENT;
127}
128
129#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