Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 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 | |
Martin Blumenstingl | 26503ad2 | 2018-08-02 16:57:13 +0200 | [diff] [blame] | 20 | #define rtl_dev_err(dev, fmt, ...) bt_dev_err(dev, "RTL: " fmt, ##__VA_ARGS__) |
| 21 | #define rtl_dev_warn(dev, fmt, ...) bt_dev_warn(dev, "RTL: " fmt, ##__VA_ARGS__) |
| 22 | #define rtl_dev_info(dev, fmt, ...) bt_dev_info(dev, "RTL: " fmt, ##__VA_ARGS__) |
| 23 | #define rtl_dev_dbg(dev, fmt, ...) bt_dev_dbg(dev, "RTL: " fmt, ##__VA_ARGS__) |
| 24 | |
| 25 | struct btrtl_device_info; |
| 26 | |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 27 | struct rtl_download_cmd { |
| 28 | __u8 index; |
| 29 | __u8 data[RTL_FRAG_LEN]; |
| 30 | } __packed; |
| 31 | |
| 32 | struct rtl_download_response { |
| 33 | __u8 status; |
| 34 | __u8 index; |
| 35 | } __packed; |
| 36 | |
| 37 | struct rtl_rom_version_evt { |
| 38 | __u8 status; |
| 39 | __u8 version; |
| 40 | } __packed; |
| 41 | |
| 42 | struct rtl_epatch_header { |
| 43 | __u8 signature[8]; |
| 44 | __le32 fw_version; |
| 45 | __le16 num_patches; |
| 46 | } __packed; |
| 47 | |
Martin Blumenstingl | b85b0ee | 2018-08-02 16:57:15 +0200 | [diff] [blame] | 48 | struct rtl_vendor_config_entry { |
| 49 | __le16 offset; |
| 50 | __u8 len; |
| 51 | __u8 data[0]; |
| 52 | } __packed; |
| 53 | |
| 54 | struct rtl_vendor_config { |
| 55 | __le32 signature; |
| 56 | __le16 total_len; |
| 57 | struct rtl_vendor_config_entry entry[0]; |
| 58 | } __packed; |
| 59 | |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 60 | #if IS_ENABLED(CONFIG_BT_RTL) |
| 61 | |
Hans de Goede | 1cc194c | 2018-08-02 16:57:17 +0200 | [diff] [blame] | 62 | struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, |
| 63 | const char *postfix); |
Martin Blumenstingl | 26503ad2 | 2018-08-02 16:57:13 +0200 | [diff] [blame] | 64 | void btrtl_free(struct btrtl_device_info *btrtl_dev); |
| 65 | int btrtl_download_firmware(struct hci_dev *hdev, |
| 66 | struct btrtl_device_info *btrtl_dev); |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 67 | int btrtl_setup_realtek(struct hci_dev *hdev); |
Martin Blumenstingl | b85b0ee | 2018-08-02 16:57:15 +0200 | [diff] [blame] | 68 | int btrtl_get_uart_settings(struct hci_dev *hdev, |
| 69 | struct btrtl_device_info *btrtl_dev, |
| 70 | unsigned int *controller_baudrate, |
| 71 | u32 *device_baudrate, bool *flow_control); |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 72 | |
| 73 | #else |
| 74 | |
Hans de Goede | 1cc194c | 2018-08-02 16:57:17 +0200 | [diff] [blame] | 75 | static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, |
| 76 | const char *postfix) |
Martin Blumenstingl | 26503ad2 | 2018-08-02 16:57:13 +0200 | [diff] [blame] | 77 | { |
| 78 | return ERR_PTR(-EOPNOTSUPP); |
| 79 | } |
| 80 | |
| 81 | static inline void btrtl_free(struct btrtl_device_info *btrtl_dev) |
| 82 | { |
| 83 | } |
| 84 | |
| 85 | static inline int btrtl_download_firmware(struct hci_dev *hdev, |
| 86 | struct btrtl_device_info *btrtl_dev) |
| 87 | { |
| 88 | return -EOPNOTSUPP; |
| 89 | } |
| 90 | |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 91 | static inline int btrtl_setup_realtek(struct hci_dev *hdev) |
| 92 | { |
| 93 | return -EOPNOTSUPP; |
| 94 | } |
| 95 | |
Martin Blumenstingl | b85b0ee | 2018-08-02 16:57:15 +0200 | [diff] [blame] | 96 | static inline int btrtl_get_uart_settings(struct hci_dev *hdev, |
| 97 | struct btrtl_device_info *btrtl_dev, |
| 98 | unsigned int *controller_baudrate, |
| 99 | u32 *device_baudrate, |
| 100 | bool *flow_control) |
| 101 | { |
| 102 | return -ENOENT; |
| 103 | } |
| 104 | |
Carlo Caione | db33c77 | 2015-05-14 10:49:09 +0200 | [diff] [blame] | 105 | #endif |