blob: 2a582682136d6167fcc7d1b1666fb7023bd62020 [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);
Carlo Caionedb33c772015-05-14 10:49:09 +020057int btrtl_setup_realtek(struct hci_dev *hdev);
Jian-Hong Pan7af3f5582019-06-25 16:30:51 +080058int btrtl_shutdown_realtek(struct hci_dev *hdev);
Martin Blumenstinglb85b0ee2018-08-02 16:57:15 +020059int btrtl_get_uart_settings(struct hci_dev *hdev,
60 struct btrtl_device_info *btrtl_dev,
61 unsigned int *controller_baudrate,
62 u32 *device_baudrate, bool *flow_control);
Carlo Caionedb33c772015-05-14 10:49:09 +020063
64#else
65
Hans de Goede1cc194c2018-08-02 16:57:17 +020066static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
67 const char *postfix)
Martin Blumenstingl26503ad22018-08-02 16:57:13 +020068{
69 return ERR_PTR(-EOPNOTSUPP);
70}
71
72static inline void btrtl_free(struct btrtl_device_info *btrtl_dev)
73{
74}
75
76static inline int btrtl_download_firmware(struct hci_dev *hdev,
77 struct btrtl_device_info *btrtl_dev)
78{
79 return -EOPNOTSUPP;
80}
81
Carlo Caionedb33c772015-05-14 10:49:09 +020082static inline int btrtl_setup_realtek(struct hci_dev *hdev)
83{
84 return -EOPNOTSUPP;
85}
86
Jian-Hong Pan7af3f5582019-06-25 16:30:51 +080087static inline int btrtl_shutdown_realtek(struct hci_dev *hdev)
88{
89 return -EOPNOTSUPP;
90}
91
Martin Blumenstinglb85b0ee2018-08-02 16:57:15 +020092static inline int btrtl_get_uart_settings(struct hci_dev *hdev,
93 struct btrtl_device_info *btrtl_dev,
94 unsigned int *controller_baudrate,
95 u32 *device_baudrate,
96 bool *flow_control)
97{
98 return -ENOENT;
99}
100
Carlo Caionedb33c772015-05-14 10:49:09 +0200101#endif