Thomas Gleixner | c942fdd | 2019-05-27 08:55:06 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Bluetooth support for Realtek devices |
| 4 | * |
| 5 | * Copyright (C) 2015 Endless Mobile, Inc. |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #define RTL_FRAG_LEN 252 |
| 9 | |
Martin Blumenstingl | 26503ad2 | 2018-08-02 16:57:13 +0200 | [diff] [blame] | 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 | |
| 15 | struct btrtl_device_info; |
| 16 | |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 17 | struct rtl_download_cmd { |
| 18 | __u8 index; |
| 19 | __u8 data[RTL_FRAG_LEN]; |
| 20 | } __packed; |
| 21 | |
| 22 | struct rtl_download_response { |
| 23 | __u8 status; |
| 24 | __u8 index; |
| 25 | } __packed; |
| 26 | |
| 27 | struct rtl_rom_version_evt { |
| 28 | __u8 status; |
| 29 | __u8 version; |
| 30 | } __packed; |
| 31 | |
| 32 | struct rtl_epatch_header { |
| 33 | __u8 signature[8]; |
| 34 | __le32 fw_version; |
| 35 | __le16 num_patches; |
| 36 | } __packed; |
| 37 | |
Martin Blumenstingl | b85b0ee | 2018-08-02 16:57:15 +0200 | [diff] [blame] | 38 | struct rtl_vendor_config_entry { |
| 39 | __le16 offset; |
| 40 | __u8 len; |
Gustavo A. R. Silva | a7e4545 | 2020-02-26 17:02:27 -0600 | [diff] [blame] | 41 | __u8 data[]; |
Martin Blumenstingl | b85b0ee | 2018-08-02 16:57:15 +0200 | [diff] [blame] | 42 | } __packed; |
| 43 | |
| 44 | struct rtl_vendor_config { |
| 45 | __le32 signature; |
| 46 | __le16 total_len; |
Gustavo A. R. Silva | a7e4545 | 2020-02-26 17:02:27 -0600 | [diff] [blame] | 47 | struct rtl_vendor_config_entry entry[]; |
Martin Blumenstingl | b85b0ee | 2018-08-02 16:57:15 +0200 | [diff] [blame] | 48 | } __packed; |
| 49 | |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 50 | #if IS_ENABLED(CONFIG_BT_RTL) |
| 51 | |
Hans de Goede | 1cc194c | 2018-08-02 16:57:17 +0200 | [diff] [blame] | 52 | struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, |
| 53 | const char *postfix); |
Martin Blumenstingl | 26503ad2 | 2018-08-02 16:57:13 +0200 | [diff] [blame] | 54 | void btrtl_free(struct btrtl_device_info *btrtl_dev); |
| 55 | int btrtl_download_firmware(struct hci_dev *hdev, |
| 56 | struct btrtl_device_info *btrtl_dev); |
Archie Pusaka | 3011faa | 2021-05-27 15:19:54 +0800 | [diff] [blame] | 57 | void btrtl_set_quirks(struct hci_dev *hdev, |
| 58 | struct btrtl_device_info *btrtl_dev); |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 59 | int btrtl_setup_realtek(struct hci_dev *hdev); |
Jian-Hong Pan | 7af3f558 | 2019-06-25 16:30:51 +0800 | [diff] [blame] | 60 | int btrtl_shutdown_realtek(struct hci_dev *hdev); |
Martin Blumenstingl | b85b0ee | 2018-08-02 16:57:15 +0200 | [diff] [blame] | 61 | int 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 Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 65 | |
| 66 | #else |
| 67 | |
Hans de Goede | 1cc194c | 2018-08-02 16:57:17 +0200 | [diff] [blame] | 68 | static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, |
| 69 | const char *postfix) |
Martin Blumenstingl | 26503ad2 | 2018-08-02 16:57:13 +0200 | [diff] [blame] | 70 | { |
| 71 | return ERR_PTR(-EOPNOTSUPP); |
| 72 | } |
| 73 | |
| 74 | static inline void btrtl_free(struct btrtl_device_info *btrtl_dev) |
| 75 | { |
| 76 | } |
| 77 | |
| 78 | static inline int btrtl_download_firmware(struct hci_dev *hdev, |
| 79 | struct btrtl_device_info *btrtl_dev) |
| 80 | { |
| 81 | return -EOPNOTSUPP; |
| 82 | } |
| 83 | |
Archie Pusaka | 3011faa | 2021-05-27 15:19:54 +0800 | [diff] [blame] | 84 | static inline void btrtl_set_quirks(struct hci_dev *hdev, |
| 85 | struct btrtl_device_info *btrtl_dev) |
| 86 | { |
| 87 | } |
| 88 | |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 89 | static inline int btrtl_setup_realtek(struct hci_dev *hdev) |
| 90 | { |
| 91 | return -EOPNOTSUPP; |
| 92 | } |
| 93 | |
Jian-Hong Pan | 7af3f558 | 2019-06-25 16:30:51 +0800 | [diff] [blame] | 94 | static inline int btrtl_shutdown_realtek(struct hci_dev *hdev) |
| 95 | { |
| 96 | return -EOPNOTSUPP; |
| 97 | } |
| 98 | |
Martin Blumenstingl | b85b0ee | 2018-08-02 16:57:15 +0200 | [diff] [blame] | 99 | static 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 Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 108 | #endif |