507f21ab66416c66ba0e4b5ab5898af18cc9ed54
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0882-Bluetooth-hci_bcm-Drive-RTS-only-for-BCM43438.patch
1 From b2e19dbff471eb6b9b39ff8f21c8d38e4fac8fe6 Mon Sep 17 00:00:00 2001
2 From: Stefan Wahren <wahrenst@gmx.net>
3 Date: Wed, 1 Jan 2020 15:01:34 +0100
4 Subject: [PATCH] Bluetooth: hci_bcm: Drive RTS only for BCM43438
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 commit e601daed271e9eb1b923972a0a1af65f8c7bb77b upstream.
10
11 The commit 3347a80965b3 ("Bluetooth: hci_bcm: Fix RTS handling during
12 startup") is causing at least a regression for AP6256 on Orange Pi 3.
13 So do the RTS line handing during startup only on the necessary platform.
14
15 Fixes: 3347a80965b3 ("Bluetooth: hci_bcm: Fix RTS handling during startup")
16 Reported-by: Ondřej Jirman <megous@megous.com>
17 Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
18 Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
19 ---
20 drivers/bluetooth/hci_bcm.c | 21 +++++++++++++++++----
21 1 file changed, 17 insertions(+), 4 deletions(-)
22
23 --- a/drivers/bluetooth/hci_bcm.c
24 +++ b/drivers/bluetooth/hci_bcm.c
25 @@ -53,6 +53,7 @@
26 */
27 struct bcm_device_data {
28 bool no_early_set_baudrate;
29 + bool drive_rts_on_open;
30 };
31
32 /**
33 @@ -123,6 +124,7 @@ struct bcm_device {
34 bool is_suspended;
35 #endif
36 bool no_early_set_baudrate;
37 + bool drive_rts_on_open;
38 u8 pcm_int_params[5];
39 };
40
41 @@ -459,7 +461,9 @@ static int bcm_open(struct hci_uart *hu)
42
43 out:
44 if (bcm->dev) {
45 - hci_uart_set_flow_control(hu, true);
46 + if (bcm->dev->drive_rts_on_open)
47 + hci_uart_set_flow_control(hu, true);
48 +
49 hu->init_speed = bcm->dev->init_speed;
50
51 /* If oper_speed is set, ldisc/serdev will set the baudrate
52 @@ -469,7 +473,10 @@ out:
53 hu->oper_speed = bcm->dev->oper_speed;
54
55 err = bcm_gpio_set_power(bcm->dev, true);
56 - hci_uart_set_flow_control(hu, false);
57 +
58 + if (bcm->dev->drive_rts_on_open)
59 + hci_uart_set_flow_control(hu, false);
60 +
61 if (err)
62 goto err_unset_hu;
63 }
64 @@ -1450,8 +1457,10 @@ static int bcm_serdev_probe(struct serde
65 dev_err(&serdev->dev, "Failed to power down\n");
66
67 data = device_get_match_data(bcmdev->dev);
68 - if (data)
69 + if (data) {
70 bcmdev->no_early_set_baudrate = data->no_early_set_baudrate;
71 + bcmdev->drive_rts_on_open = data->drive_rts_on_open;
72 + }
73
74 return hci_uart_register_device(&bcmdev->serdev_hu, &bcm_proto);
75 }
76 @@ -1468,11 +1477,15 @@ static struct bcm_device_data bcm4354_de
77 .no_early_set_baudrate = true,
78 };
79
80 +static struct bcm_device_data bcm43438_device_data = {
81 + .drive_rts_on_open = true,
82 +};
83 +
84 static const struct of_device_id bcm_bluetooth_of_match[] = {
85 { .compatible = "brcm,bcm20702a1" },
86 { .compatible = "brcm,bcm4345c5" },
87 { .compatible = "brcm,bcm4330-bt" },
88 - { .compatible = "brcm,bcm43438-bt" },
89 + { .compatible = "brcm,bcm43438-bt", .data = &bcm43438_device_data },
90 { .compatible = "brcm,bcm43540-bt", .data = &bcm4354_device_data },
91 { .compatible = "brcm,bcm4335a0" },
92 { },