@@ -37,6 +37,55 @@ struct bcm_data {
37
37
struct sk_buff_head txq ;
38
38
};
39
39
40
+ static int bcm_set_baudrate (struct hci_uart * hu , unsigned int speed )
41
+ {
42
+ struct hci_dev * hdev = hu -> hdev ;
43
+ struct sk_buff * skb ;
44
+ struct bcm_update_uart_baud_rate param ;
45
+
46
+ if (speed > 3000000 ) {
47
+ struct bcm_write_uart_clock_setting clock ;
48
+
49
+ clock .type = BCM_UART_CLOCK_48MHZ ;
50
+
51
+ BT_DBG ("%s: Set Controller clock (%d)" , hdev -> name , clock .type );
52
+
53
+ /* This Broadcom specific command changes the UART's controller
54
+ * clock for baud rate > 3000000.
55
+ */
56
+ skb = __hci_cmd_sync (hdev , 0xfc45 , 1 , & clock , HCI_INIT_TIMEOUT );
57
+ if (IS_ERR (skb )) {
58
+ int err = PTR_ERR (skb );
59
+ BT_ERR ("%s: BCM: failed to write clock command (%d)" ,
60
+ hdev -> name , err );
61
+ return err ;
62
+ }
63
+
64
+ kfree_skb (skb );
65
+ }
66
+
67
+ BT_DBG ("%s: Set Controller UART speed to %d bit/s" , hdev -> name , speed );
68
+
69
+ param .zero = cpu_to_le16 (0 );
70
+ param .baud_rate = cpu_to_le32 (speed );
71
+
72
+ /* This Broadcom specific command changes the UART's controller baud
73
+ * rate.
74
+ */
75
+ skb = __hci_cmd_sync (hdev , 0xfc18 , sizeof (param ), & param ,
76
+ HCI_INIT_TIMEOUT );
77
+ if (IS_ERR (skb )) {
78
+ int err = PTR_ERR (skb );
79
+ BT_ERR ("%s: BCM: failed to write update baudrate command (%d)" ,
80
+ hdev -> name , err );
81
+ return err ;
82
+ }
83
+
84
+ kfree_skb (skb );
85
+
86
+ return 0 ;
87
+ }
88
+
40
89
static int bcm_open (struct hci_uart * hu )
41
90
{
42
91
struct bcm_data * bcm ;
@@ -107,6 +156,12 @@ static int bcm_setup(struct hci_uart *hu)
107
156
if (hu -> proto -> init_speed )
108
157
hci_uart_set_baudrate (hu , hu -> proto -> init_speed );
109
158
159
+ if (hu -> proto -> oper_speed ) {
160
+ err = bcm_set_baudrate (hu , hu -> proto -> oper_speed );
161
+ if (!err )
162
+ hci_uart_set_baudrate (hu , hu -> proto -> oper_speed );
163
+ }
164
+
110
165
finalize :
111
166
release_firmware (fw );
112
167
@@ -162,10 +217,13 @@ static struct sk_buff *bcm_dequeue(struct hci_uart *hu)
162
217
static const struct hci_uart_proto bcm_proto = {
163
218
.id = HCI_UART_BCM ,
164
219
.name = "BCM" ,
220
+ .init_speed = 115200 ,
221
+ .oper_speed = 4000000 ,
165
222
.open = bcm_open ,
166
223
.close = bcm_close ,
167
224
.flush = bcm_flush ,
168
225
.setup = bcm_setup ,
226
+ .set_baudrate = bcm_set_baudrate ,
169
227
.recv = bcm_recv ,
170
228
.enqueue = bcm_enqueue ,
171
229
.dequeue = bcm_dequeue ,
0 commit comments