2019-05-27 08:55:06 +02:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
2015-05-14 10:49:09 +02:00
/*
* Bluetooth support for Realtek devices
*
* Copyright ( C ) 2015 Endless Mobile , Inc .
*/
# define RTL_FRAG_LEN 252
2018-08-02 16:57:13 +02:00
# 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 ;
2023-03-07 23:17:31 +01:00
struct rtl_chip_type_evt {
__u8 status ;
__u8 type ;
} __packed ;
2015-05-14 10:49:09 +02:00
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 ;
2018-08-02 16:57:15 +02:00
struct rtl_vendor_config_entry {
__le16 offset ;
__u8 len ;
2020-02-26 17:02:27 -06:00
__u8 data [ ] ;
2018-08-02 16:57:15 +02:00
} __packed ;
struct rtl_vendor_config {
__le32 signature ;
__le16 total_len ;
2023-04-17 10:33:58 +08:00
__u8 entry [ ] ;
} __packed ;
struct rtl_epatch_header_v2 {
__u8 signature [ 8 ] ;
__u8 fw_version [ 8 ] ;
__le32 num_sections ;
} __packed ;
struct rtl_section {
__le32 opcode ;
__le32 len ;
u8 data [ ] ;
} __packed ;
struct rtl_section_hdr {
__le16 num ;
__le16 reserved ;
} __packed ;
struct rtl_common_subsec {
__u8 eco ;
__u8 prio ;
__u8 cb [ 2 ] ;
__le32 len ;
__u8 data [ ] ;
} ;
struct rtl_sec_hdr {
__u8 eco ;
__u8 prio ;
__u8 key_id ;
__u8 reserved ;
__le32 len ;
__u8 data [ ] ;
} __packed ;
struct rtl_subsection {
struct list_head list ;
u32 opcode ;
u32 len ;
u8 prio ;
u8 * data ;
} ;
struct rtl_iovec {
u8 * data ;
u32 len ;
} ;
struct rtl_vendor_cmd {
__u8 param [ 5 ] ;
2018-08-02 16:57:15 +02:00
} __packed ;
2022-10-05 16:43:30 +08:00
enum {
REALTEK_ALT6_CONTINUOUS_TX_CHIP ,
__REALTEK_NUM_FLAGS ,
} ;
2023-04-27 11:27:55 +08:00
struct rtl_dump_info {
const char * driver_name ;
char * controller ;
u32 fw_version ;
} ;
2022-10-05 16:43:30 +08:00
struct btrealtek_data {
DECLARE_BITMAP ( flags , __REALTEK_NUM_FLAGS ) ;
2023-04-27 11:27:55 +08:00
struct rtl_dump_info rtl_dump ;
2022-10-05 16:43:30 +08:00
} ;
# define btrealtek_set_flag(hdev, nr) \
do { \
struct btrealtek_data * realtek = hci_get_priv ( ( hdev ) ) ; \
set_bit ( ( nr ) , realtek - > flags ) ; \
} while ( 0 )
# define btrealtek_get_flag(hdev) \
( ( ( struct btrealtek_data * ) hci_get_priv ( hdev ) ) - > flags )
# define btrealtek_test_flag(hdev, nr) test_bit((nr), btrealtek_get_flag(hdev))
2015-05-14 10:49:09 +02:00
# if IS_ENABLED(CONFIG_BT_RTL)
2018-08-02 16:57:17 +02:00
struct btrtl_device_info * btrtl_initialize ( struct hci_dev * hdev ,
const char * postfix ) ;
2018-08-02 16:57:13 +02:00
void btrtl_free ( struct btrtl_device_info * btrtl_dev ) ;
int btrtl_download_firmware ( struct hci_dev * hdev ,
struct btrtl_device_info * btrtl_dev ) ;
2021-05-27 15:19:54 +08:00
void btrtl_set_quirks ( struct hci_dev * hdev ,
struct btrtl_device_info * btrtl_dev ) ;
2015-05-14 10:49:09 +02:00
int btrtl_setup_realtek ( struct hci_dev * hdev ) ;
2019-06-25 16:30:51 +08:00
int btrtl_shutdown_realtek ( struct hci_dev * hdev ) ;
2018-08-02 16:57:15 +02:00
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 ) ;
2023-04-27 11:27:55 +08:00
void btrtl_set_driver_name ( struct hci_dev * hdev , const char * driver_name ) ;
2015-05-14 10:49:09 +02:00
# else
2018-08-02 16:57:17 +02:00
static inline struct btrtl_device_info * btrtl_initialize ( struct hci_dev * hdev ,
const char * postfix )
2018-08-02 16:57:13 +02:00
{
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 ;
}
2021-05-27 15:19:54 +08:00
static inline void btrtl_set_quirks ( struct hci_dev * hdev ,
struct btrtl_device_info * btrtl_dev )
{
}
2015-05-14 10:49:09 +02:00
static inline int btrtl_setup_realtek ( struct hci_dev * hdev )
{
return - EOPNOTSUPP ;
}
2019-06-25 16:30:51 +08:00
static inline int btrtl_shutdown_realtek ( struct hci_dev * hdev )
{
return - EOPNOTSUPP ;
}
2018-08-02 16:57:15 +02:00
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 ;
}
2023-04-27 11:27:55 +08:00
static inline void btrtl_set_driver_name ( struct hci_dev * hdev , const char * driver_name )
{
}
2015-05-14 10:49:09 +02:00
# endif