mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 01:54:09 +08:00
b85b0ee100
The UART settings are embedded in the config blob. This has to be parsed to successfully initialize the Bluetooth part of the RTL8723BS (which is an SDIO chip, but the Bluetooth part is connected via UART). The Realtek "rtl8723bs_bt" and "rtl8723ds_bt" userspace Bluetooth UART initialization tools (rtk_hciattach) use the following sequence: - send H5 sync pattern (already supported by hci_h5) - get LMP version (already supported by btrtl) - get ROM version (already supported by btrtl) - load the firmware and config for the current chipset (already supported by btrtl) - read UART settings from the config blob (part of this patch) - send UART settings via a vendor command to the device (which changes the baudrate of the device and enables or disables flow control depending on the config) - change the baudrate and flow control settings on the host - send the firmware and config blob to the device (already supported by btrtl) Sending the last firmware and config blob download command (rtl_download_cmd) fails if the UART settings are not updated beforehand. This is presumably because the device applies the config right after the firmware and config blob download - which means that at this point the host is using different UART settings than the device (which will obviously result in non-working communication). Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Jeremy Cline <jeremy@jcline.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
104 lines
2.6 KiB
C
104 lines
2.6 KiB
C
/*
|
|
* Bluetooth support for Realtek devices
|
|
*
|
|
* Copyright (C) 2015 Endless Mobile, Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#define RTL_FRAG_LEN 252
|
|
|
|
#define rtl_dev_err(dev, fmt, ...) bt_dev_err(dev, "RTL: " fmt, ##__VA_ARGS__)
|
|
#define rtl_dev_warn(dev, fmt, ...) bt_dev_warn(dev, "RTL: " fmt, ##__VA_ARGS__)
|
|
#define rtl_dev_info(dev, fmt, ...) bt_dev_info(dev, "RTL: " fmt, ##__VA_ARGS__)
|
|
#define rtl_dev_dbg(dev, fmt, ...) bt_dev_dbg(dev, "RTL: " fmt, ##__VA_ARGS__)
|
|
|
|
struct btrtl_device_info;
|
|
|
|
struct rtl_download_cmd {
|
|
__u8 index;
|
|
__u8 data[RTL_FRAG_LEN];
|
|
} __packed;
|
|
|
|
struct rtl_download_response {
|
|
__u8 status;
|
|
__u8 index;
|
|
} __packed;
|
|
|
|
struct rtl_rom_version_evt {
|
|
__u8 status;
|
|
__u8 version;
|
|
} __packed;
|
|
|
|
struct rtl_epatch_header {
|
|
__u8 signature[8];
|
|
__le32 fw_version;
|
|
__le16 num_patches;
|
|
} __packed;
|
|
|
|
struct rtl_vendor_config_entry {
|
|
__le16 offset;
|
|
__u8 len;
|
|
__u8 data[0];
|
|
} __packed;
|
|
|
|
struct rtl_vendor_config {
|
|
__le32 signature;
|
|
__le16 total_len;
|
|
struct rtl_vendor_config_entry entry[0];
|
|
} __packed;
|
|
|
|
#if IS_ENABLED(CONFIG_BT_RTL)
|
|
|
|
struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev);
|
|
void btrtl_free(struct btrtl_device_info *btrtl_dev);
|
|
int btrtl_download_firmware(struct hci_dev *hdev,
|
|
struct btrtl_device_info *btrtl_dev);
|
|
int btrtl_setup_realtek(struct hci_dev *hdev);
|
|
int btrtl_get_uart_settings(struct hci_dev *hdev,
|
|
struct btrtl_device_info *btrtl_dev,
|
|
unsigned int *controller_baudrate,
|
|
u32 *device_baudrate, bool *flow_control);
|
|
|
|
#else
|
|
|
|
static inline struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev)
|
|
{
|
|
return ERR_PTR(-EOPNOTSUPP);
|
|
}
|
|
|
|
static inline void btrtl_free(struct btrtl_device_info *btrtl_dev)
|
|
{
|
|
}
|
|
|
|
static inline int btrtl_download_firmware(struct hci_dev *hdev,
|
|
struct btrtl_device_info *btrtl_dev)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
static inline int btrtl_setup_realtek(struct hci_dev *hdev)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
static inline int btrtl_get_uart_settings(struct hci_dev *hdev,
|
|
struct btrtl_device_info *btrtl_dev,
|
|
unsigned int *controller_baudrate,
|
|
u32 *device_baudrate,
|
|
bool *flow_control)
|
|
{
|
|
return -ENOENT;
|
|
}
|
|
|
|
#endif
|