HCI UART:Line Discipline 与 Serdev

HCI UART:Line Discipline 与 Serdev

1. 两种绑定

TTY line discipline

用户态打开 /dev/ttySx,设置波特率并附加 N_HCI,再通过ioctl选择protocol。传统 hciattach使用此路径。

Serdev

Bluetooth作为UART controller的DT/ACPI child,kernel serdev driver直接probe,管理电源、GPIO、clock和baud,不需要用户态attach。

2. Common object

struct hci_uart包含:

  • tty或serdev;
  • hci_dev;
  • protocol ops/private data;
  • tx queue/state bits;
  • init work;
  • current/oper speed;
  • flow control。

3. Protocol registry

hci_uart_register_proto()把 H4/H5/BCSP/BCM/QCA等挂入固定ID数组。选择后protocol提供:

  • open/close;
  • flush;
  • setup;
  • recv;
  • enqueue/dequeue;
  • wakeup;
  • suspend/resume。

4. TX

1
2
3
4
5
hci_uart_send_frame
-> proto enqueue
-> hci_uart_tx_wakeup
-> tty write 或 serdev_device_write_buf
-> write_wakeup循环dequeue

HCI_UART_SENDINGTX_WAKEUP位避免并发发送者丢唤醒。

5. RX

TTY receive_buf或serdev receive_buf把字节交给protocol parser。Parser可跨调用保存partial frame。

6. Speed

常见流程:

1.初始低速;
2.发送厂商baud命令;
3.等待controller确认;
4.切host UART speed;
5.启用flow control。

次序或时延错误会在下载固件后失联。

7. Serdev DT

标准写法是UART child:

1
2
3
4
5
bluetooth {
compatible = "brcm,bcm43438-bt";
shutdown-gpios = <...>;
max-speed = <3000000>;
};

但本树多数RK3588板型使用独立 bluetooth-platdata节点和Rockchip rfkill,不能混为同一驱动模型。

8. RK3588

模块常连接UART7或其它高速UART,需RTS/CTS、DMA/PIO和pinmux一致。平台rfkill可在suspend把RTS切为GPIO。

文章互动

阅读 --

留言

0 条留言

正在加载留言…