Skip to contentSkip to conversation

Bluetooth: hci_bcm: Support pcm params in dts

PATCH Superseded Marcel Holtmann 2 participants 3 messages Nov 23, 2019 – Nov 25, 2019 Bluetooth drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 4/4 Bluetooth: hci_bcm: Support pcm params in dts

From: Abhishek Pandit-Subedi <[email protected]>

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.

---
 drivers/bluetooth/hci_bcm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/bluetooth/hci_bcm.c +19 -0
index d48044276895..9cfb202bbeca 100644
@@ -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
Signature · 1 line
2.23.0
#1 lore raw
Quoted 26 lines · Marcel Holtmann

From: Abhishek Pandit-Subedi <[email protected]>

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.

---
 drivers/bluetooth/hci_bcm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/bluetooth/hci_bcm.c +1 -0
index d48044276895..9cfb202bbeca 100644
@@ -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 */

drivers/bluetooth/hci_bcm.c static int bcm_setup(struct hci_uart *hu) · line 602

Quoted 8 lines
drivers/bluetooth/hci_bcm.c +5 -0
@@ -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.

Quoted 18 lines
drivers/bluetooth/hci_bcm.c +7 -0
+
+               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;
 }
 

drivers/bluetooth/hci_bcm.c static int bcm_probe(struct platform_device *pdev) · line 1162

Quoted 4 lines
drivers/bluetooth/hci_bcm.c +1 -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

drivers/bluetooth/hci_bcm.c static int bcm_serdev_probe(struct serdev_device *serdev) · line 1425

Quoted 10 lines
drivers/bluetooth/hci_bcm.c +3 -0
+       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

Quoted 8 lines
drivers/bluetooth/hci_bcm.c +2 -1
+       bcmdev->pcm_int_params[0] = 0xff;
+
        if (has_acpi_companion(&serdev->dev))
                err = bcm_acpi_probe(bcmdev);
        else
--

2.23.0

author maintainer
#2 lore raw

Hi Abhishek,

Quoted 26 lines
Quoted 26 lines

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.

---
drivers/bluetooth/hci_bcm.c | 19 +++++++++++++++++++

1 file changed, 19 insertions(+)
drivers/bluetooth/hci_bcm.c +1 -0
index d48044276895..9cfb202bbeca 100644
@@ -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);
       }
 
Quoted 6 lines

drivers/bluetooth/hci_bcm.c static int bcm_setup(struct hci_uart *hu) · line 602

Quoted 5 lines
drivers/bluetooth/hci_bcm.c +5 -0
+       /* 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.

Quoted 33 lines
Quoted 19 lines
drivers/bluetooth/hci_bcm.c +5 -0
+
+               memcpy(&params, bcm->dev->pcm_int_params, 5);
+               btbcm_write_pcm_int_params(hu->hdev, &params);
+       }
+

finalize:

       release_firmware(fw);
drivers/bluetooth/hci_bcm.c +2 -0
@@ -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;
 }
 

drivers/bluetooth/hci_bcm.c static int bcm_probe(struct platform_device *pdev) · line 1162

Quoted 4 lines
drivers/bluetooth/hci_bcm.c +1 -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

Quoted 9 lines
drivers/bluetooth/hci_bcm.c +2 -0
+       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);
 
Quoted 2 lines

drivers/bluetooth/hci_bcm.c static int bcm_serdev_probe(struct serdev_device *serdev) · line 1425

Quoted 1 line
drivers/bluetooth/hci_bcm.c +1 -0
+       /* Initialize routing field to an unsued value */

unused

Good catch. I will fix this up.

Regards

Marcel