bcm27xx: import latest patches from the RPi foundation
[openwrt/staging/ynezz.git] / target / linux / bcm27xx / patches-5.4 / 950-0881-Bluetooth-hci_bcm-Support-pcm-params-in-dts.patch
1 From 8b4d7321625cc8403a9ce7f050bd8d1b4ef7446d Mon Sep 17 00:00:00 2001
2 From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
3 Date: Tue, 26 Nov 2019 08:17:32 +0100
4 Subject: [PATCH] Bluetooth: hci_bcm: Support pcm params in dts
5
6 commit eb762b94111b646b4f116ebfdbfcadbad14e12b3 upstream.
7
8 BCM chips may require configuration of PCM to operate correctly and
9 there is a vendor specific HCI command to do this. Add support in the
10 hci_bcm driver to parse this from devicetree and configure the chip.
11
12 Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
13 Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
15 ---
16 drivers/bluetooth/hci_bcm.c | 19 +++++++++++++++++++
17 1 file changed, 19 insertions(+)
18
19 --- a/drivers/bluetooth/hci_bcm.c
20 +++ b/drivers/bluetooth/hci_bcm.c
21 @@ -123,6 +123,7 @@ struct bcm_device {
22 bool is_suspended;
23 #endif
24 bool no_early_set_baudrate;
25 + u8 pcm_int_params[5];
26 };
27
28 /* generic bcm uart resources */
29 @@ -597,6 +598,16 @@ static int bcm_setup(struct hci_uart *hu
30 host_set_baudrate(hu, speed);
31 }
32
33 + /* PCM parameters if provided */
34 + if (bcm->dev && bcm->dev->pcm_int_params[0] != 0xff) {
35 + struct bcm_set_pcm_int_params params;
36 +
37 + btbcm_read_pcm_int_params(hu->hdev, &params);
38 +
39 + memcpy(&params, bcm->dev->pcm_int_params, 5);
40 + btbcm_write_pcm_int_params(hu->hdev, &params);
41 + }
42 +
43 finalize:
44 release_firmware(fw);
45
46 @@ -1134,6 +1145,8 @@ static int bcm_acpi_probe(struct bcm_dev
47 static int bcm_of_probe(struct bcm_device *bdev)
48 {
49 device_property_read_u32(bdev->dev, "max-speed", &bdev->oper_speed);
50 + device_property_read_u8_array(bdev->dev, "brcm,bt-pcm-int-params",
51 + bdev->pcm_int_params, 5);
52 return 0;
53 }
54
55 @@ -1149,6 +1162,9 @@ static int bcm_probe(struct platform_dev
56 dev->dev = &pdev->dev;
57 dev->irq = platform_get_irq(pdev, 0);
58
59 + /* Initialize routing field to an unused value */
60 + dev->pcm_int_params[0] = 0xff;
61 +
62 if (has_acpi_companion(&pdev->dev)) {
63 ret = bcm_acpi_probe(dev);
64 if (ret)
65 @@ -1409,6 +1425,9 @@ static int bcm_serdev_probe(struct serde
66 bcmdev->serdev_hu.serdev = serdev;
67 serdev_device_set_drvdata(serdev, bcmdev);
68
69 + /* Initialize routing field to an unused value */
70 + bcmdev->pcm_int_params[0] = 0xff;
71 +
72 if (has_acpi_companion(&serdev->dev))
73 err = bcm_acpi_probe(bcmdev);
74 else