Subject: Re: [RFC PATCH 1/2] dt-bindings: net: h4-bluetooth: add new bindings for hci_h4

From: Dominique Martinet <[email-masked]>
Date: Wed, 9 Nov 2022 08:54:42 +0900

Thanks for all the replies!

All remarks make sense, I'll do my homework and send a v2 once extra
questions have been answered.

Rob Herring wrote on Tue, Nov 08, 2022 at 07:59:33AM -0600:
> On Mon, Nov 7, 2022 at 11:56 PM Dominique Martinet
> <[email-masked]> wrote:
> > Add devicetree binding to support defining a bluetooth device using the h4
> > uart protocol
> 
> The protocol is mostly irrelevant to the binding. The binding is for a
> particular device even if the driver is shared.

This echoes the point below: I wanted to make this a bit more generic
for other adapters, question at the end of my first reply to Krzysztof
below.

> There's now a pending (in linux-next) net/bluetooth/ directory and a
> bluetooth-controller.yaml schema which you should reference.

Will check it out and add that.

Krzysztof Kozlowski wrote on Tue, Nov 08, 2022 at 12:37:39PM +0100:
> > diff --git a/Documentation/devicetree/bindings/net/h4-bluetooth.yaml b/Documentation/devicetree/bindings/net/h4-bluetooth.yaml
> > new file mode 100644
> > index 000000000000..5d11b89ca386
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/h4-bluetooth.yaml
> 
> If the schema is for one specific device, then filename matching the
> compatible, so nxp,aw-xm458-bt.yaml... but I understand you want to
> describe here class of devices using H4 Bluetooth? Won't they need their
> own specific properties?

H4 bluetooth itself has very little configurable elements, from what I
can see about the device I'm using the actual configuration is done by
the wifi driver that uploads a "combo" firmware over the PCI side
(it's based on mwifiex, so for example mrvl/pcieuart8997_combo_v4.bin
upstream works the same way afaik)

This is a pretty terrible design, as the Bluetooth side cannot actually
know when the device is ready as the initialization takes place, but
that means there really aren't any property to give here

(I haven't reproduced during normal boot, but in particular if I run
bluetoothd before loading the wifi driver, I need to unbind/bind the
serial device from the hci_uart_h4 driver to recover bluetooth...
With that in mind it might actually be best to try to coordinate this
from userspace with btattach after all, and I'd be happy with that if I
didn't have to fight our init system so much, but as things stand having
it autoloaded by the kernel is more convenient for us... Which is
admitedly a weak reason for you all, feel free to tell me this isn't
viable)

Anyway, there probably would be other devices benefiting from this, at
the very least other cards in the mwifiex family, but I'm doing this as
a end user so I'm not comfortable adding devices I cannot test.

So with all of this (sorry for the wall of text), should I try to keep
this generic, or just give up and make it specific to nxp,aw-xm458-bt
and let whoever adds the next device rename the file?

> > +examples:
> > +  - |
> > +    #include <dt-bindings/gpio/gpio.h>
> > +    #include <dt-bindings/clock/imx8mp-clock.h>
> > +
> > +    uart {
> > +        fsl,dte-mode = <1>;
> > +        fsl,uart-has-rtscts;
> 
> Are these two related to this hardware?

I'd say it's related to my soc rather than the Bluetooth adapter; I
tried to give a full example but it's unrelated and I'll drop this as
well.

-- 
Dominique Martinet