Bluetooth: btintel: Create common function for Intel Reset

The Intel_Reset command is used to reset the device after downloading
the firmware and this is Intel generic command used in both USB and
UART.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
Tedd Ho-Jeong An 2018-01-24 09:19:18 -08:00 committed by Marcel Holtmann
parent 965651c16b
commit e5889af62f
4 changed files with 49 additions and 16 deletions

View File

@ -569,6 +569,26 @@ struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
} }
EXPORT_SYMBOL_GPL(btintel_regmap_init); EXPORT_SYMBOL_GPL(btintel_regmap_init);
int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param)
{
struct intel_reset params = { 0x00, 0x01, 0x00, 0x01, 0x00000000 };
struct sk_buff *skb;
params.boot_param = cpu_to_le32(boot_param);
skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(params), &params,
HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
bt_dev_err(hdev, "Failed to send Intel Reset command");
return PTR_ERR(skb);
}
kfree_skb(skb);
return 0;
}
EXPORT_SYMBOL_GPL(btintel_send_intel_reset);
MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION); MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION);
MODULE_VERSION(VERSION); MODULE_VERSION(VERSION);

View File

@ -69,6 +69,14 @@ struct intel_secure_send_result {
__u8 status; __u8 status;
} __packed; } __packed;
struct intel_reset {
__u8 reset_type;
__u8 patch_enable;
__u8 ddc_reload;
__u8 boot_option;
__le32 boot_param;
} __packed;
#if IS_ENABLED(CONFIG_BT_INTEL) #if IS_ENABLED(CONFIG_BT_INTEL)
int btintel_check_bdaddr(struct hci_dev *hdev); int btintel_check_bdaddr(struct hci_dev *hdev);
@ -89,6 +97,7 @@ int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver);
struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read, struct regmap *btintel_regmap_init(struct hci_dev *hdev, u16 opcode_read,
u16 opcode_write); u16 opcode_write);
int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param);
#else #else
@ -165,4 +174,10 @@ static inline struct regmap *btintel_regmap_init(struct hci_dev *hdev,
{ {
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
static inline int btintel_send_intel_reset(struct hci_dev *hdev,
u32 reset_param)
{
return -EOPNOTSUPP;
}
#endif #endif

View File

@ -2009,8 +2009,6 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb)
static int btusb_setup_intel_new(struct hci_dev *hdev) static int btusb_setup_intel_new(struct hci_dev *hdev)
{ {
static const u8 reset_param[] = { 0x00, 0x01, 0x00, 0x01,
0x00, 0x08, 0x04, 0x00 };
struct btusb_data *data = hci_get_drvdata(hdev); struct btusb_data *data = hci_get_drvdata(hdev);
struct sk_buff *skb; struct sk_buff *skb;
struct intel_version ver; struct intel_version ver;
@ -2018,6 +2016,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
const struct firmware *fw; const struct firmware *fw;
const u8 *fw_ptr; const u8 *fw_ptr;
u32 frag_len; u32 frag_len;
u32 boot_param;
char fwname[64]; char fwname[64];
ktime_t calltime, delta, rettime; ktime_t calltime, delta, rettime;
unsigned long long duration; unsigned long long duration;
@ -2025,6 +2024,9 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
/* The default boot parameter */
boot_param = 0x00040800;
calltime = ktime_get(); calltime = ktime_get();
/* Read the Intel version information to determine if the device /* Read the Intel version information to determine if the device
@ -2341,12 +2343,9 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
set_bit(BTUSB_BOOTING, &data->flags); set_bit(BTUSB_BOOTING, &data->flags);
skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(reset_param), reset_param, err = btintel_send_intel_reset(hdev, boot_param);
HCI_INIT_TIMEOUT); if (err)
if (IS_ERR(skb)) return err;
return PTR_ERR(skb);
kfree_skb(skb);
/* The bootloader will not indicate when the device is ready. This /* The bootloader will not indicate when the device is ready. This
* is done by the operational firmware sending bootup notification. * is done by the operational firmware sending bootup notification.

View File

@ -540,8 +540,6 @@ static int intel_set_baudrate(struct hci_uart *hu, unsigned int speed)
static int intel_setup(struct hci_uart *hu) static int intel_setup(struct hci_uart *hu)
{ {
static const u8 reset_param[] = { 0x00, 0x01, 0x00, 0x01,
0x00, 0x08, 0x04, 0x00 };
struct intel_data *intel = hu->priv; struct intel_data *intel = hu->priv;
struct hci_dev *hdev = hu->hdev; struct hci_dev *hdev = hu->hdev;
struct sk_buff *skb; struct sk_buff *skb;
@ -552,6 +550,7 @@ static int intel_setup(struct hci_uart *hu)
const u8 *fw_ptr; const u8 *fw_ptr;
char fwname[64]; char fwname[64];
u32 frag_len; u32 frag_len;
u32 boot_param;
ktime_t calltime, delta, rettime; ktime_t calltime, delta, rettime;
unsigned long long duration; unsigned long long duration;
unsigned int init_speed, oper_speed; unsigned int init_speed, oper_speed;
@ -563,6 +562,9 @@ static int intel_setup(struct hci_uart *hu)
hu->hdev->set_diag = btintel_set_diag; hu->hdev->set_diag = btintel_set_diag;
hu->hdev->set_bdaddr = btintel_set_bdaddr; hu->hdev->set_bdaddr = btintel_set_bdaddr;
/* Default boot parameter */
boot_param = 0x00040800;
calltime = ktime_get(); calltime = ktime_get();
if (hu->init_speed) if (hu->init_speed)
@ -911,12 +913,9 @@ static int intel_setup(struct hci_uart *hu)
set_bit(STATE_BOOTING, &intel->flags); set_bit(STATE_BOOTING, &intel->flags);
skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(reset_param), reset_param, err = btintel_send_intel_reset(hdev, boot_param);
HCI_CMD_TIMEOUT); if (err)
if (IS_ERR(skb)) return err;
return PTR_ERR(skb);
kfree_skb(skb);
/* The bootloader will not indicate when the device is ready. This /* The bootloader will not indicate when the device is ready. This
* is done by the operational firmware sending bootup notification. * is done by the operational firmware sending bootup notification.