linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rocky Liao <rjliao@codeaurora.org>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
	linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v2] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support
Date: Tue, 15 Sep 2020 17:29:31 +0800	[thread overview]
Message-ID: <c9912094c4627b34f49458ae36c9cd25@codeaurora.org> (raw)
In-Reply-To: <4FCC6630-8350-4E4A-B156-42B2F3581BFD@holtmann.org>

Hi Marcel,

在 2020-09-14 21:28,Marcel Holtmann 写道:
> Hi Rocky,
> 
>> This patch add support for WCN6855 i.e. patch and nvm download
>> support.
>> 
>> Signed-off-by: Rocky Liao <rjliao@codeaurora.org>
>> ---
>> drivers/bluetooth/btusb.c | 50 ++++++++++++++++++++++++++++++++++-----
>> 1 file changed, 44 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
>> index fe80588c7bd3..789e8d5e829e 100644
>> --- a/drivers/bluetooth/btusb.c
>> +++ b/drivers/bluetooth/btusb.c
>> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver;
>> #define BTUSB_MEDIATEK		0x200000
>> #define BTUSB_WIDEBAND_SPEECH	0x400000
>> #define BTUSB_VALID_LE_STATES   0x800000
>> +#define BTUSB_QCA_WCN6855	0x1000000
>> 
>> static const struct usb_device_id btusb_table[] = {
>> 	/* Generic Bluetooth USB device */
>> @@ -273,6 +274,10 @@ static const struct usb_device_id 
>> blacklist_table[] = {
>> 	{ USB_DEVICE(0x13d3, 0x3496), .driver_info = BTUSB_QCA_ROME },
>> 	{ USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME },
>> 
>> +	/* QCA WCN6855 chipset */
>> +	{ USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 |
>> +						     BTUSB_WIDEBAND_SPEECH },
>> +
>> 	/* Broadcom BCM2035 */
>> 	{ USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 },
>> 	{ USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU },
>> @@ -3391,6 +3396,26 @@ static int btusb_set_bdaddr_ath3012(struct 
>> hci_dev *hdev,
>> 	return 0;
>> }
>> 
>> +static int btusb_set_bdaddr_wcn6855(struct hci_dev *hdev,
>> +				const bdaddr_t *bdaddr)
>> +{
>> +	struct sk_buff *skb;
>> +	u8 buf[6];
>> +	long ret;
>> +
>> +	memcpy(buf, bdaddr, sizeof(bdaddr_t));
>> +
>> +	skb = __hci_cmd_sync(hdev, 0xfc14, sizeof(buf), buf, 
>> HCI_INIT_TIMEOUT);
>> +	if (IS_ERR(skb)) {
>> +		ret = PTR_ERR(skb);
>> +		bt_dev_err(hdev, "Change address command failed (%ld)", ret);
>> +		return ret;
>> +	}
>> +	kfree_skb(skb);
>> +
>> +	return 0;
>> +}
>> +
>> #define QCA_DFU_PACKET_LEN	4096
>> 
>> #define QCA_GET_TARGET_VERSION	0x09
>> @@ -3428,6 +3453,8 @@ static const struct qca_device_info 
>> qca_devices_table[] = {
>> 	{ 0x00000201, 28, 4, 18 }, /* Rome 2.1 */
>> 	{ 0x00000300, 28, 4, 18 }, /* Rome 3.0 */
>> 	{ 0x00000302, 28, 4, 18 }, /* Rome 3.2 */
>> +	{ 0x00130100, 40, 4, 18 }, /* WCN6855 1.0 */
>> +	{ 0x00130200, 40, 4, 18 }  /* WCN6855 2.0 */
>> };
>> 
>> static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 
>> request,
>> @@ -3529,8 +3556,8 @@ static int btusb_setup_qca_load_rampatch(struct 
>> hci_dev *hdev,
>> {
>> 	struct qca_rampatch_version *rver;
>> 	const struct firmware *fw;
>> -	u32 ver_rom, ver_patch;
>> -	u16 rver_rom, rver_patch;
>> +	u32 ver_rom, ver_patch, rver_rom;
>> +	u16 rver_rom_low, rver_rom_high, rver_patch;
>> 	char fwname[64];
>> 	int err;
>> 
>> @@ -3549,9 +3576,16 @@ static int btusb_setup_qca_load_rampatch(struct 
>> hci_dev *hdev,
>> 	bt_dev_info(hdev, "using rampatch file: %s", fwname);
>> 
>> 	rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset);
>> -	rver_rom = le16_to_cpu(rver->rom_version);
>> +	rver_rom_low = le16_to_cpu(rver->rom_version);
>> 	rver_patch = le16_to_cpu(rver->patch_version);
>> 
>> +	if (ver_rom & ~0xffffU) {
>> +		rver_rom_high = le16_to_cpu(*(__le16 *)(fw->data + 16));
>> +		rver_rom = le32_to_cpu(rver_rom_high << 16 | rver_rom_low);
>> +	} else {
>> +		rver_rom = (__force u32)rver_rom_low;
>> +	}
>> +
> 
> I don’t get this. Is anything wrong with get_unaligned_le32 etc.?
> 
> My brain just hurts with your casting and pointer magic. Maybe the
> whole rver logic needs a clean up first.
> 
It's not a 4 bytes le data, for example the version stream is 0x13, 
0x00, 0x00, 0x01 and we need to convert it to 0x00130100. So we have to 
convert it to 2 u16 value then combine them to a u32.

> Regards
> 
> Marcel

  reply	other threads:[~2020-09-15  9:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04  6:21 [PATCH v1] Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support Rocky Liao
2020-09-14  9:27 ` [PATCH v2] " Rocky Liao
2020-09-14 13:28   ` Marcel Holtmann
2020-09-15  9:29     ` Rocky Liao [this message]
2020-09-15 13:57       ` Marcel Holtmann
2020-09-16  2:02         ` Rocky Liao
2020-09-25  9:08   ` [PATCH v3] " Rocky Liao
2020-09-25 16:08     ` Marcel Holtmann
2020-09-28  2:11       ` Rocky Liao
2020-09-29  4:23     ` [PATCH v4] " Rocky Liao
2020-09-29  6:17       ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c9912094c4627b34f49458ae36c9cd25@codeaurora.org \
    --to=rjliao@codeaurora.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).