linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/4] Bluetooth: hci_bcm: Support pcm params in dts
@ 2019-11-23 10:01 Marcel Holtmann
  2019-11-25 18:19 ` Abhishek Pandit-Subedi
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2019-11-23 10:01 UTC (permalink / raw)
  To: linux-bluetooth

From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>

BCM chips may require configuration of PCM to operate correctly and
there is a vendor specific HCI command to do this. Add support in the
hci_bcm driver to parse this from devicetree and configure the chip.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
 drivers/bluetooth/hci_bcm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index d48044276895..9cfb202bbeca 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -122,6 +122,7 @@ struct bcm_device {
 	bool			is_suspended;
 #endif
 	bool			no_early_set_baudrate;
+	u8			pcm_int_params[5];
 };
 
 /* generic bcm uart resources */
@@ -594,6 +595,16 @@ static int bcm_setup(struct hci_uart *hu)
 			host_set_baudrate(hu, speed);
 	}
 
+	/* PCM parameters if provided */
+	if (bcm->dev && bcm->dev->pcm_int_params[0] != 0xff) {
+		struct bcm_set_pcm_int_params params;
+
+		btbcm_read_pcm_int_params(hu->hdev, &params);
+
+		memcpy(&params, bcm->dev->pcm_int_params, 5);
+		btbcm_write_pcm_int_params(hu->hdev, &params);
+	}
+
 finalize:
 	release_firmware(fw);
 
@@ -1131,6 +1142,8 @@ static int bcm_acpi_probe(struct bcm_device *dev)
 static int bcm_of_probe(struct bcm_device *bdev)
 {
 	device_property_read_u32(bdev->dev, "max-speed", &bdev->oper_speed);
+	device_property_read_u8_array(bdev->dev, "brcm,bt-pcm-int-params",
+				      bdev->pcm_int_params, 5);
 	return 0;
 }
 
@@ -1146,6 +1159,9 @@ static int bcm_probe(struct platform_device *pdev)
 	dev->dev = &pdev->dev;
 	dev->irq = platform_get_irq(pdev, 0);
 
+	/* Initialize routing field to an unsued value */
+	dev->pcm_int_params[0] = 0xff;
+
 	if (has_acpi_companion(&pdev->dev)) {
 		ret = bcm_acpi_probe(dev);
 		if (ret)
@@ -1406,6 +1422,9 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
 	bcmdev->serdev_hu.serdev = serdev;
 	serdev_device_set_drvdata(serdev, bcmdev);
 
+	/* Initialize routing field to an unsued value */
+	bcmdev->pcm_int_params[0] = 0xff;
+
 	if (has_acpi_companion(&serdev->dev))
 		err = bcm_acpi_probe(bcmdev);
 	else
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/4] Bluetooth: hci_bcm: Support pcm params in dts
  2019-11-23 10:01 [PATCH 4/4] Bluetooth: hci_bcm: Support pcm params in dts Marcel Holtmann
@ 2019-11-25 18:19 ` Abhishek Pandit-Subedi
  2019-11-25 18:39   ` Marcel Holtmann
  0 siblings, 1 reply; 3+ messages in thread
From: Abhishek Pandit-Subedi @ 2019-11-25 18:19 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

On Sat, Nov 23, 2019 at 2:01 AM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
>
> BCM chips may require configuration of PCM to operate correctly and
> there is a vendor specific HCI command to do this. Add support in the
> hci_bcm driver to parse this from devicetree and configure the chip.
>
> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
>  drivers/bluetooth/hci_bcm.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
> index d48044276895..9cfb202bbeca 100644
> --- a/drivers/bluetooth/hci_bcm.c
> +++ b/drivers/bluetooth/hci_bcm.c
> @@ -122,6 +122,7 @@ struct bcm_device {
>         bool                    is_suspended;
>  #endif
>         bool                    no_early_set_baudrate;
> +       u8                      pcm_int_params[5];
>  };
>
>  /* generic bcm uart resources */
> @@ -594,6 +595,16 @@ static int bcm_setup(struct hci_uart *hu)
>                         host_set_baudrate(hu, speed);
>         }
>
> +       /* PCM parameters if provided */
> +       if (bcm->dev && bcm->dev->pcm_int_params[0] != 0xff) {
> +               struct bcm_set_pcm_int_params params;
> +
> +               btbcm_read_pcm_int_params(hu->hdev, &params);
This seems redundant since we just overwrite it anyway.

> +
> +               memcpy(&params, bcm->dev->pcm_int_params, 5);
> +               btbcm_write_pcm_int_params(hu->hdev, &params);
> +       }
> +
>  finalize:
>         release_firmware(fw);
>
> @@ -1131,6 +1142,8 @@ static int bcm_acpi_probe(struct bcm_device *dev)
>  static int bcm_of_probe(struct bcm_device *bdev)
>  {
>         device_property_read_u32(bdev->dev, "max-speed", &bdev->oper_speed);
> +       device_property_read_u8_array(bdev->dev, "brcm,bt-pcm-int-params",
> +                                     bdev->pcm_int_params, 5);
>         return 0;
>  }
>
> @@ -1146,6 +1159,9 @@ static int bcm_probe(struct platform_device *pdev)
>         dev->dev = &pdev->dev;
>         dev->irq = platform_get_irq(pdev, 0);
>
> +       /* Initialize routing field to an unsued value */
unused
> +       dev->pcm_int_params[0] = 0xff;
> +
>         if (has_acpi_companion(&pdev->dev)) {
>                 ret = bcm_acpi_probe(dev);
>                 if (ret)
> @@ -1406,6 +1422,9 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
>         bcmdev->serdev_hu.serdev = serdev;
>         serdev_device_set_drvdata(serdev, bcmdev);
>
> +       /* Initialize routing field to an unsued value */
unused
> +       bcmdev->pcm_int_params[0] = 0xff;
> +
>         if (has_acpi_companion(&serdev->dev))
>                 err = bcm_acpi_probe(bcmdev);
>         else
> --
> 2.23.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/4] Bluetooth: hci_bcm: Support pcm params in dts
  2019-11-25 18:19 ` Abhishek Pandit-Subedi
@ 2019-11-25 18:39   ` Marcel Holtmann
  0 siblings, 0 replies; 3+ messages in thread
From: Marcel Holtmann @ 2019-11-25 18:39 UTC (permalink / raw)
  To: Abhishek Pandit-Subedi; +Cc: linux-bluetooth

Hi Abhishek,

>> BCM chips may require configuration of PCM to operate correctly and
>> there is a vendor specific HCI command to do this. Add support in the
>> hci_bcm driver to parse this from devicetree and configure the chip.
>> 
>> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
>> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
>> ---
>> drivers/bluetooth/hci_bcm.c | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>> 
>> diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
>> index d48044276895..9cfb202bbeca 100644
>> --- a/drivers/bluetooth/hci_bcm.c
>> +++ b/drivers/bluetooth/hci_bcm.c
>> @@ -122,6 +122,7 @@ struct bcm_device {
>>        bool                    is_suspended;
>> #endif
>>        bool                    no_early_set_baudrate;
>> +       u8                      pcm_int_params[5];
>> };
>> 
>> /* generic bcm uart resources */
>> @@ -594,6 +595,16 @@ static int bcm_setup(struct hci_uart *hu)
>>                        host_set_baudrate(hu, speed);
>>        }
>> 
>> +       /* PCM parameters if provided */
>> +       if (bcm->dev && bcm->dev->pcm_int_params[0] != 0xff) {
>> +               struct bcm_set_pcm_int_params params;
>> +
>> +               btbcm_read_pcm_int_params(hu->hdev, &params);
> This seems redundant since we just overwrite it anyway.

this is here to have it show up in btmon.

> 
>> +
>> +               memcpy(&params, bcm->dev->pcm_int_params, 5);
>> +               btbcm_write_pcm_int_params(hu->hdev, &params);
>> +       }
>> +
>> finalize:
>>        release_firmware(fw);
>> 
>> @@ -1131,6 +1142,8 @@ static int bcm_acpi_probe(struct bcm_device *dev)
>> static int bcm_of_probe(struct bcm_device *bdev)
>> {
>>        device_property_read_u32(bdev->dev, "max-speed", &bdev->oper_speed);
>> +       device_property_read_u8_array(bdev->dev, "brcm,bt-pcm-int-params",
>> +                                     bdev->pcm_int_params, 5);
>>        return 0;
>> }
>> 
>> @@ -1146,6 +1159,9 @@ static int bcm_probe(struct platform_device *pdev)
>>        dev->dev = &pdev->dev;
>>        dev->irq = platform_get_irq(pdev, 0);
>> 
>> +       /* Initialize routing field to an unsued value */
> unused
>> +       dev->pcm_int_params[0] = 0xff;
>> +
>>        if (has_acpi_companion(&pdev->dev)) {
>>                ret = bcm_acpi_probe(dev);
>>                if (ret)
>> @@ -1406,6 +1422,9 @@ static int bcm_serdev_probe(struct serdev_device *serdev)
>>        bcmdev->serdev_hu.serdev = serdev;
>>        serdev_device_set_drvdata(serdev, bcmdev);
>> 
>> +       /* Initialize routing field to an unsued value */
> unused

Good catch. I will fix this up.

Regards

Marcel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-25 18:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-23 10:01 [PATCH 4/4] Bluetooth: hci_bcm: Support pcm params in dts Marcel Holtmann
2019-11-25 18:19 ` Abhishek Pandit-Subedi
2019-11-25 18:39   ` Marcel Holtmann

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).