Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	linux-bluetooth@vger.kernel.org, dianders@chromium.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] Bluetooth: hci_bcm: Disallow set_baudrate for BCM4354
Date: Fri, 8 Nov 2019 07:08:53 +0100
Message-ID: <F01BD2DD-B11F-49F8-92D8-CF679C56CD40@holtmann.org> (raw)
In-Reply-To: <20191107232713.48577-2-abhishekpandit@chromium.org>

Hi Abhishek,

> Without updating the patchram, the BCM4354 does not support a higher
> operating speed. The normal bcm_setup follows the correct order
> (init_speed, patchram and then oper_speed) but the serdev driver will
> set the operating speed before calling the hu->setup function. Thus,
> for the BCM4354, disallow setting the operating speed before patchram.
> 
> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> ---
> 
> Changes in v2: None
> 
> drivers/bluetooth/hci_bcm.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
> index 0f851c0dde7f..2114df607cb3 100644
> --- a/drivers/bluetooth/hci_bcm.c
> +++ b/drivers/bluetooth/hci_bcm.c
> @@ -1167,7 +1167,7 @@ static int bcm_remove(struct platform_device *pdev)
> 	return 0;
> }
> 
> -static const struct hci_uart_proto bcm_proto = {
> +static struct hci_uart_proto bcm_proto = {
> 	.id		= HCI_UART_BCM,
> 	.name		= "Broadcom",
> 	.manufacturer	= 15,
> @@ -1371,6 +1371,24 @@ static struct platform_driver bcm_driver = {
> 	},
> };
> 
> +#define BCM_QUIRK_DISALLOW_SET_BAUDRATE (1 << 0)
> +const u32 disallow_set_baudrate = BCM_QUIRK_DISALLOW_SET_BAUDRATE;
> +
> +static int bcm_check_disallow_set_baudrate(struct serdev_device *serdev)
> +{
> +	const u32 *quirks = device_get_match_data(&serdev->dev);
> +
> +	if (quirks) {
> +		/* BCM4354 can't run at full speed before patchram. Disallow
> +		 * externally setting operating speed.
> +		 */
> +		if (*quirks & BCM_QUIRK_DISALLOW_SET_BAUDRATE)
> +			return 1;
> +	}
> +
> +	return 0;
> +}
> +
> static int bcm_serdev_probe(struct serdev_device *serdev)
> {
> 	struct bcm_device *bcmdev;
> @@ -1408,6 +1426,9 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
> 	if (err)
> 		dev_err(&serdev->dev, "Failed to power down\n");
> 
> +	if (bcm_check_disallow_set_baudrate(serdev))
> +		bcm_proto.set_baudrate = NULL;
> +

this change is not allowed since bcm_proto is on purpose const.

> 	return hci_uart_register_device(&bcmdev->serdev_hu, &bcm_proto);
> }
> 
> @@ -1424,7 +1445,7 @@ static const struct of_device_id bcm_bluetooth_of_match[] = {
> 	{ .compatible = "brcm,bcm4345c5" },
> 	{ .compatible = "brcm,bcm4330-bt" },
> 	{ .compatible = "brcm,bcm43438-bt" },
> -	{ .compatible = "brcm,bcm43540-bt" },
> +	{ .compatible = "brcm,bcm43540-bt", .data = &disallow_set_baudrate },
> 	{ },
> };
> MODULE_DEVICE_TABLE(of, bcm_bluetooth_of_match);

So I would prefer if we do this in a more generic from that will make this easy to extend in the future. Similar to what hci_qca.c does actually with defining a separate struct for the module differences.

struct bcm_device_data (
	bool no_early_oper_speed;
};

static const struct bcm_device_data bcm43540_device {
	.no_early_oper_speed = true,
};

static const struct of_device_id bcm_bluetooth_of_match[] = {
	..
	{ .compatible = "brcm,bcm43540-bt", .data = &bcm43540_device },
	( },
};

And then load the struct in serdev probe as pointer and check its existence and add the struct bcm_device_data to struct bcm_device so it can be referenced when you change the baudrate.

Regards

Marcel


  reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07 23:27 [PATCH v2 0/4] Bluetooth: hci_bcm: Additional changes for BCM4354 support Abhishek Pandit-Subedi
2019-11-07 23:27 ` [PATCH v2 1/4] Bluetooth: hci_bcm: Disallow set_baudrate for BCM4354 Abhishek Pandit-Subedi
2019-11-08  6:08   ` Marcel Holtmann [this message]
2019-11-07 23:27 ` [PATCH v2 2/4] Bluetooth: btbcm: Support pcm configuration Abhishek Pandit-Subedi
2019-11-08  6:11   ` Marcel Holtmann
2019-11-07 23:27 ` [PATCH v2 3/4] Bluetooth: hci_bcm: Support pcm params in dts Abhishek Pandit-Subedi
2019-11-07 23:27 ` [PATCH v2 4/4] dt-bindings: net: broadcom-bluetooth: Add pcm config Abhishek Pandit-Subedi
2019-11-08  6:12   ` Marcel Holtmann

Reply instructions:

You may reply publically 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=F01BD2DD-B11F-49F8-92D8-CF679C56CD40@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=abhishekpandit@chromium.org \
    --cc=dianders@chromium.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.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

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git