blob: 2c441bda390a03fc1042c8e50abdd84fed52688c [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Carlo Caionedb33c772015-05-14 10:49:09 +02002/*
3 * Bluetooth support for Realtek devices
4 *
5 * Copyright (C) 2015 Endless Mobile, Inc.
Carlo Caionedb33c772015-05-14 10:49:09 +02006 */
7
8#define RTL_FRAG_LEN 252
9
Martin Blumenstingl26503ad22018-08-02 16:57:13 +020010#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
Carlo Caionedb33c772015-05-14 10:49:09 +020017struct 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
Martin Blumenstinglb85b0ee2018-08-02 16:57:15 +020038struct rtl_vendor_config_entry {
39 __le16 offset;
40 __u8 len;
Gustavo A. R. Silvaa7e45452020-02-26 17:02:27 -060041 __u8 data[];
Martin Blumenstinglb85b0ee2018-08-02 16:57:15 +020042} __packed;
43
44struct rtl_vendor_config {
45 __le32 signature;
46 __le16 total_len;
Gustavo A. R. Silvaa7e45452020-02-26 17:02:27 -060047 struct rtl_vendor_config_entry entry[];
Martin Blumenstinglb85b0ee2018-08-02 16:57:15 +020048} __packed;
49
Carlo Caionedb33c772015-05-14 10:49:09 +020050#if IS_ENABLED(CONFIG_BT_RTL)
51
Hans de Goede1cc194c2018-08-02 16:57:17 +020052struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
53 const char *postfix);
Martin Blumenstingl26503ad22018-08-02 16:57:13 +020054void btrtl_free(struct btrtl_device_info *btrtl_dev);
55int btrtl_download_firmware(struct hci_dev *hdev,
56 struct btrtl_device_info *btrtl_dev);
Archie Pusaka3011faa2021-05-27 15:19:54 +080057void btrtl_set_quirks(struct hci_dev *hdev,
58 struct btrtl_device_info *btrtl_dev);
Carlo Caionedb33c772015-05-14 10:49:09 +020059int btrtl_setup_realtek(struct hci_dev *hdev);
Jian-Hong Pan7af3f5582019-06-25 16:30:51 +080060int btrtl_shutdown_realtek(struct hci_dev *hdev);
Martin Blumenstinglb85b0ee2018-08-02 16:57:15 +020061int btrtl_get_uart_settings(struct hci_dev *hdev,
62 struct btrtl_device_info *btrtl_dev,
63 unsigned int *controller_baudrate,
64 u32 *device_baudrate, bool *flow_control);
Carlo Caionedb33c772015-05-14 10:49:09 +020065
66#else
67
Hans de Goede1cc194c2018-08-02 16:57:17 +020068static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
69 const char *postfix)
Martin Blumenstingl26503ad22018-08-02 16:57:13 +020070{
71 return ERR_PTR(-EOPNOTSUPP);
72}
73
74static inline void btrtl_free(struct btrtl_device_info *btrtl_dev)
75{
76}
77
78static inline int btrtl_download_firmware(struct hci_dev *hdev,
79 struct btrtl_device_info *btrtl_dev)
80{
81 return -EOPNOTSUPP;
82}
83
Archie Pusaka3011faa2021-05-27 15:19:54 +080084static inline void btrtl_set_quirks(struct hci_dev *hdev,
85 struct btrtl_device_info *btrtl_dev)
86{
87}
88
Carlo Caionedb33c772015-05-14 10:49:09 +020089static inline int btrtl_setup_realtek(struct hci_dev *hdev)
90{
91 return -EOPNOTSUPP;
92}
93
Jian-Hong Pan7af3f5582019-06-25 16:30:51 +080094static inline int btrtl_shutdown_realtek(struct hci_dev *hdev)
95{
96 return -EOPNOTSUPP;
97}
98
Martin Blumenstinglb85b0ee2018-08-02 16:57:15 +020099static inline int btrtl_get_uart_settings(struct hci_dev *hdev,
100 struct btrtl_device_info *btrtl_dev,
101 unsigned int *controller_baudrate,
102 u32 *device_baudrate,
103 bool *flow_control)
104{
105 return -ENOENT;
106}
107
Carlo Caionedb33c772015-05-14 10:49:09 +0200108#endif