Skip to content
Permalink
Browse files
Bluetooth: hci_h5: btrtl: Add quirk for keep power during suspend/res…
…ume for specific devices

RTL8822C devices support BT wakeup Host. Add a quirk for these specific
devices did not power off during suspend and resume.
By this change, if the Host support that received BT device signal then
it can be wakeup.

Signed-off-by: hildawu <hildawu@realtek.com>
  • Loading branch information
hildawur authored and intel-lab-lkp committed Mar 15, 2021
1 parent c1a7416 commit c97383d88c50364f4451a74ac4d3ad7b3605c20b
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 47 deletions.
@@ -38,42 +38,6 @@
.hci_ver = (hciv), \
.hci_bus = (bus)

enum btrtl_chip_id {
CHIP_ID_8723A,
CHIP_ID_8723B,
CHIP_ID_8821A,
CHIP_ID_8761A,
CHIP_ID_8822B = 8,
CHIP_ID_8723D,
CHIP_ID_8821C,
CHIP_ID_8822C = 13,
CHIP_ID_8761B,
CHIP_ID_8852A = 18,
};

struct id_table {
__u16 match_flags;
__u16 lmp_subver;
__u16 hci_rev;
__u8 hci_ver;
__u8 hci_bus;
bool config_needed;
bool has_rom_version;
char *fw_name;
char *cfg_name;
};

struct btrtl_device_info {
const struct id_table *ic_info;
u8 rom_version;
u8 *fw_data;
int fw_len;
u8 *cfg_data;
int cfg_len;
bool drop_fw;
int project_id;
};

static const struct id_table ic_id_table[] = {
/* 8723A */
{ IC_INFO(RTL_ROM_LMP_8723A, 0xb, 0x6, HCI_USB),
@@ -12,6 +12,41 @@
#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__)

enum btrtl_chip_id {
CHIP_ID_8723A,
CHIP_ID_8723B,
CHIP_ID_8821A,
CHIP_ID_8761A,
CHIP_ID_8822B = 8,
CHIP_ID_8723D,
CHIP_ID_8821C,
CHIP_ID_8822C = 13,
CHIP_ID_8761B,
CHIP_ID_8852A = 18,
};

struct id_table {
__u16 match_flags;
__u16 lmp_subver;
__u16 hci_rev;
__u8 hci_ver;
__u8 hci_bus;
bool config_needed;
bool has_rom_version;
char *fw_name;
char *cfg_name;
};

struct btrtl_device_info {
const struct id_table *ic_info;
u8 rom_version;
u8 *fw_data;
int fw_len;
u8 *cfg_data;
int cfg_len;
int project_id;
};

struct btrtl_device_info;

struct rtl_download_cmd {
@@ -909,7 +909,15 @@ static int h5_btrtl_setup(struct h5 *h5)
/* Enable controller to do both LE scan and BR/EDR inquiry
* simultaneously.
*/
set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks);
switch (btrtl_dev->project_id) {
case CHIP_ID_8822C:
case CHIP_ID_8852A:
set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks);
set_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks);
break;
default:
break;
}

out_free:
btrtl_free(btrtl_dev);
@@ -945,8 +953,11 @@ static void h5_btrtl_close(struct h5 *h5)
static int h5_btrtl_suspend(struct h5 *h5)
{
serdev_device_set_flow_control(h5->hu->serdev, false);
gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
gpiod_set_value_cansleep(h5->enable_gpio, 0);

if (!test_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks)) {
gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
gpiod_set_value_cansleep(h5->enable_gpio, 0);
}
return 0;
}

@@ -972,17 +983,19 @@ static void h5_btrtl_reprobe_worker(struct work_struct *work)

static int h5_btrtl_resume(struct h5 *h5)
{
struct h5_btrtl_reprobe *reprobe;
if (!test_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks)) {
struct h5_btrtl_reprobe *reprobe;

reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
if (!reprobe)
return -ENOMEM;
reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
if (!reprobe)
return -ENOMEM;

__module_get(THIS_MODULE);
__module_get(THIS_MODULE);

INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker);
reprobe->dev = get_device(&h5->hu->serdev->dev);
queue_work(system_long_wq, &reprobe->work);
INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker);
reprobe->dev = get_device(&h5->hu->serdev->dev);
queue_work(system_long_wq, &reprobe->work);
}
return 0;
}

@@ -246,6 +246,15 @@ enum {
* HCI after resume.
*/
HCI_QUIRK_NO_SUSPEND_NOTIFIER,

/* When this quirk is set, the controller does not power off
* during suspend and resume. This mechanism lets BT devices wake
* the Host up if the Host and chips support.
*
* This quirk can be set before hci_register_dev is called or
* during the hdev->setup vendor callback.
*/
HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED,
};

/* HCI device flags */

0 comments on commit c97383d

Please sign in to comment.