Message ID | 20221108055531.2176793-2-dominique.martinet@atmark-techno.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2515410wru; Mon, 7 Nov 2022 22:19:46 -0800 (PST) X-Google-Smtp-Source: AMsMyM6VPNUt+IrNoMomDLrXxAVZpTzHIP0cvR+TKihXjYFcQiSVq0TvzfFWzbXlldAVbcyOiV67 X-Received: by 2002:a17:902:b94c:b0:178:336f:13d6 with SMTP id h12-20020a170902b94c00b00178336f13d6mr55635191pls.64.1667888386554; Mon, 07 Nov 2022 22:19:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667888386; cv=none; d=google.com; s=arc-20160816; b=hc6td09nHpsRx/1WLzUGPPnco4Rtkw1WRPiGzwwOAMxqL8NGas0cztOoWkzeKlU/mR D8kADWvtgl5rObvlNaL8kd0JHsJg+5xtetfOnikrczVtiVPD/lofv11sYNwW462oEVvl f6NXziRm5hVitU95/ufsu1AIVZ9p/dU7N4Up4B8CdZR+OLcWqg9ApSdPjw6R6tszK2Gu BjpyZ8Z6q7cxnBUgPEzK5zu3qEgqZWx2fRjqmrpKXvB2dh00wefTDI7zF/VyEuliAtWz AqeuiouM7+Jufb6rgch5DaEFq0vuQ+n0u5/aYSn9zB75WlhKOiJCNpl3M7WVjyTctuUi LCIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=a8ltF6Z7hveQcIoHTD+Ocqy8FGU/fVCDeqON4Kuh0Nw=; b=BpPJD4xXoSXEE2lLLXv7hbwqOcxemlljAEBDhrmHXoVsgVESLXLRF6ZQRrT+4atx6P 0BqFmRgXq8qs926kOgjVYvdUDQ8YFZMtTuiPc7pEGy/TW+16HXxbCoIkhnoiCX3t+skh iUTXj2rOuUnQg5muggev55h5V3JAqMMhAjC0E+u3tvjaLq0w5cWCwJJMTp4m5ZYplX4M 6YV4d6jOAS4aMfxr37VfnWyXqr2CdiSp4mcYg7lrnIm4dg6ntE21i8gA1Bpk6VoKhFO+ AI21lV3pfgKtjHtH/iXgCxOiY6jzEq+ukml4EUbiWB/ztqlhyV5U83uwP1+3Ixvrje6a Jx1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l13-20020a17090a660d00b001f4fc7af64esi14781492pjj.101.2022.11.07.22.19.34; Mon, 07 Nov 2022 22:19:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233379AbiKHGLM (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Tue, 8 Nov 2022 01:11:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233354AbiKHGLJ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 8 Nov 2022 01:11:09 -0500 Received: from gw.atmark-techno.com (gw.atmark-techno.com [13.115.124.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D98431E73A for <linux-kernel@vger.kernel.org>; Mon, 7 Nov 2022 22:11:08 -0800 (PST) Received: from gw.atmark-techno.com (localhost [127.0.0.1]) by gw.atmark-techno.com (Postfix) with ESMTP id ED03C600F5 for <linux-kernel@vger.kernel.org>; Tue, 8 Nov 2022 14:56:02 +0900 (JST) Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by gw.atmark-techno.com (Postfix) with ESMTPS id B4E4E600F5 for <linux-kernel@vger.kernel.org>; Tue, 8 Nov 2022 14:56:02 +0900 (JST) Received: by mail-pl1-f197.google.com with SMTP id c7-20020a170903234700b0018729febd96so10567668plh.19 for <linux-kernel@vger.kernel.org>; Mon, 07 Nov 2022 21:56:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a8ltF6Z7hveQcIoHTD+Ocqy8FGU/fVCDeqON4Kuh0Nw=; b=LDYVmH0KvHpUQ2rFLx8XGWt4/O4UMHBZQYLiyx188V92CBJdJjUklThJ+tvoGjxqEc DOdQKoOxXyrQX+CDAumGc3PzbSoOVGMU7BnC7v6qxNu663eG53bDQX4ZVKLhGB5mZI0Q wroyj6NG6SML2BuzfChtfkXWVAyv8jsIT1QnQNkiWIX9ekZDaZfr3ekj/BJRFQFuUVG4 uk0X4tii2+xnbwKtGzXqQtvZi7rSz7yyliHeTS00IwOcEIX7abjMZFXXP/fYiQcZ1WnF c8jbmjmOs5/3yCcf/q8dT4kUeZy1tXJiJq01OOnAZKM3DbbAeI59zh7TLrduBVlMwZ8b iA5A== X-Gm-Message-State: ACrzQf22NocUi3OWmop84qjLo/ZQCQ+5/3kF/dbK5Z27Bo3G19y3+FPE aYUW1FZ6JErhZ1keUFonbm7hsxGCX69Z5vZW3Dv8rgRReIniHN1eWUQ4qGZW6Bo97OhOpuJ/r6x y0Li2tPRbfCedR3D7fS+CZObu+to+ X-Received: by 2002:a17:902:c948:b0:187:2d90:9fab with SMTP id i8-20020a170902c94800b001872d909fabmr38509295pla.42.1667886962294; Mon, 07 Nov 2022 21:56:02 -0800 (PST) X-Received: by 2002:a17:902:c948:b0:187:2d90:9fab with SMTP id i8-20020a170902c94800b001872d909fabmr38509273pla.42.1667886962062; Mon, 07 Nov 2022 21:56:02 -0800 (PST) Received: from pc-zest.atmarktech (103.131.189.35.bc.googleusercontent.com. [35.189.131.103]) by smtp.gmail.com with ESMTPSA id q8-20020a170902a3c800b00186ad73e2d5sm5950422plb.208.2022.11.07.21.56.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Nov 2022 21:56:01 -0800 (PST) Received: from martinet by pc-zest.atmarktech with local (Exim 4.96) (envelope-from <martinet@pc-zest>) id 1osHaa-0098Kr-1g; Tue, 08 Nov 2022 14:56:00 +0900 From: Dominique Martinet <dominique.martinet@atmark-techno.com> To: Marcel Holtmann <marcel@holtmann.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Luiz Augusto von Dentz <luiz.dentz@gmail.com>, Johan Hedberg <johan.hedberg@gmail.com> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-bluetooth@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>, Jakub Kicinski <kuba@kernel.org>, Eric Dumazet <edumazet@google.com>, "David S . Miller" <davem@davemloft.net>, mizo@atmark-techno.com, Dominique Martinet <dominique.martinet@atmark-techno.com> Subject: [RFC PATCH 1/2] dt-bindings: net: h4-bluetooth: add new bindings for hci_h4 Date: Tue, 8 Nov 2022 14:55:30 +0900 Message-Id: <20221108055531.2176793-2-dominique.martinet@atmark-techno.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221108055531.2176793-1-dominique.martinet@atmark-techno.com> References: <20221108055531.2176793-1-dominique.martinet@atmark-techno.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748907732625427016?= X-GMAIL-MSGID: =?utf-8?q?1748907732625427016?= |
Series |
Add serdev support for hci h4
|
|
Commit Message
Dominique Martinet
Nov. 8, 2022, 5:55 a.m. UTC
Add devicetree binding to support defining a bluetooth device using the h4
uart protocol
This was tested with a NXP wireless+BT AW-XM458 module, but might
benefit others as the H4 protocol seems often used.
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
---
.../devicetree/bindings/net/h4-bluetooth.yaml | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/h4-bluetooth.yaml
Comments
On 08/11/2022 06:55, Dominique Martinet wrote: > Add devicetree binding to support defining a bluetooth device using the h4 > uart protocol > subject: drop second redundant "bindings" > This was tested with a NXP wireless+BT AW-XM458 module, but might > benefit others as the H4 protocol seems often used. > > Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> > --- > .../devicetree/bindings/net/h4-bluetooth.yaml | 49 +++++++++++++++++++ > 1 file changed, 49 insertions(+) > create mode 100644 Documentation/devicetree/bindings/net/h4-bluetooth.yaml > > 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? > @@ -0,0 +1,49 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/net/h4-bluetooth.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: H4 Bluetooth > + > +maintainers: > + - Dominique Martinet <dominique.martinet@atmark-techno.com> > + > +description: > + H4 is a common bluetooth over uart protocol. Bluetooth UART > + For example, the AW-XM458 is a WiFi + BT module where the WiFi part is > + connected over PCI (M.2), while BT is connected over serial speaking > + the H4 protocol. Its firmware is sent on the PCI side. > + > +properties: > + compatible: > + enum: > + - nxp,aw-xm458-bt > + > + max-speed: true > + > +required: > + - compatible > + > +additionalProperties: false > + > +examples: > + - | > + #include <dt-bindings/gpio/gpio.h> > + #include <dt-bindings/clock/imx8mp-clock.h> > + > + uart1 { uart > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_uart1>; > + assigned-clocks = <&clk IMX8MP_CLK_UART1>; > + assigned-clock-parents = <&clk IMX8MP_SYS_PLL1_80M>; Drop unrelated properties. > + status = "okay"; Drop status. > + fsl,dte-mode = <1>; > + fsl,uart-has-rtscts; Are these two related to this hardware? > + > + > + bluetooth { > + compatible = "nxp,aw-xm458-bt"; > + max-speed = <3000000>; > + }; > + }; Best regards, Krzysztof
On Tue, 08 Nov 2022 14:55:30 +0900, Dominique Martinet wrote: > Add devicetree binding to support defining a bluetooth device using the h4 > uart protocol > > This was tested with a NXP wireless+BT AW-XM458 module, but might > benefit others as the H4 protocol seems often used. > > Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> > --- > .../devicetree/bindings/net/h4-bluetooth.yaml | 49 +++++++++++++++++++ > 1 file changed, 49 insertions(+) > create mode 100644 Documentation/devicetree/bindings/net/h4-bluetooth.yaml > My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13): yamllint warnings/errors: dtschema/dtc warnings/errors: fsl,dte-mode: boolean property with value b'\x00\x00\x00\x01' /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/h4-bluetooth.example.dtb: uart1: fsl,dte-mode: b'\x00\x00\x00\x01' is not of type 'object', 'array', 'boolean', 'null' From schema: /usr/local/lib/python3.10/dist-packages/dtschema/schemas/dt-core.yaml /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/h4-bluetooth.example.dtb: uart1: 'anyOf' conditional failed, one must be fixed: 'clocks' is a required property '#clock-cells' is a required property From schema: /usr/local/lib/python3.10/dist-packages/dtschema/schemas/clock/clock.yaml doc reference errors (make refcheckdocs): See https://patchwork.ozlabs.org/patch/ This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1. If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date: pip3 install dtschema --upgrade Please check and re-submit.
On Mon, Nov 7, 2022 at 11:56 PM Dominique Martinet <dominique.martinet@atmark-techno.com> 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 was tested with a NXP wireless+BT AW-XM458 module, but might > benefit others as the H4 protocol seems often used. > > Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> > --- > .../devicetree/bindings/net/h4-bluetooth.yaml | 49 +++++++++++++++++++ Use the compatible string for the filename. There's now a pending (in linux-next) net/bluetooth/ directory and a bluetooth-controller.yaml schema which you should reference. > 1 file changed, 49 insertions(+) > create mode 100644 Documentation/devicetree/bindings/net/h4-bluetooth.yaml > > 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 > @@ -0,0 +1,49 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/net/h4-bluetooth.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: H4 Bluetooth > + > +maintainers: > + - Dominique Martinet <dominique.martinet@atmark-techno.com> > + > +description: > + H4 is a common bluetooth over uart protocol. > + For example, the AW-XM458 is a WiFi + BT module where the WiFi part is > + connected over PCI (M.2), while BT is connected over serial speaking > + the H4 protocol. Its firmware is sent on the PCI side. > + > +properties: > + compatible: > + enum: > + - nxp,aw-xm458-bt > + > + max-speed: true > + > +required: > + - compatible > + > +additionalProperties: false > + > +examples: > + - | > + #include <dt-bindings/gpio/gpio.h> > + #include <dt-bindings/clock/imx8mp-clock.h> > + > + uart1 { serial { > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_uart1>; > + assigned-clocks = <&clk IMX8MP_CLK_UART1>; > + assigned-clock-parents = <&clk IMX8MP_SYS_PLL1_80M>; > + status = "okay"; > + fsl,dte-mode = <1>; > + fsl,uart-has-rtscts; All these properties are irrelevant to the example. Drop. > + > + > + bluetooth { > + compatible = "nxp,aw-xm458-bt"; > + max-speed = <3000000>; > + }; > + }; > -- > 2.35.1 > >
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 > <dominique.martinet@atmark-techno.com> 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 wrote on Wed, Nov 09, 2022 at 08:54:42AM +0900: > 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) This actually hasn't taken long to bite us: while the driver does work, we get error messages early on before the firmware is loaded. (In hindsight, I probably should have waited a few days before sending this...) My current workaround is to return EPROBE_DEFER until we can find a netdev with a known name in the init namespace, but that isn't really something I'd consider upstreamable for obvious reasons (interfaces can be renamed or moved to different namespaces so this is inherently racy and it's just out of place in BT code) That makes these two patches on their own rather useless as well, so unless one of you have an idea that's less ugly I'd guess just dropping this is the way to go, as much as I dislike the idea of adding more non-upstream code than we already have :( Thank you both for your time, the replies have been very helpful and I'll remember for next time I try to submit something! And if you have a suggestion, I'll be happy to do some legwork to clean this mess, so feel free to ask :) Thanks,
On Wed, Nov 09, 2022 at 04:29:52PM +0900, Dominique Martinet wrote: > Dominique Martinet wrote on Wed, Nov 09, 2022 at 08:54:42AM +0900: > > 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) Punting the issue to userspace is not a great solution... > This actually hasn't taken long to bite us: while the driver does work, > we get error messages early on before the firmware is loaded. > (In hindsight, I probably should have waited a few days before sending > this...) > > > My current workaround is to return EPROBE_DEFER until we can find a > netdev with a known name in the init namespace, but that isn't really > something I'd consider upstreamable for obvious reasons (interfaces can > be renamed or moved to different namespaces so this is inherently racy > and it's just out of place in BT code) Can't you just try to access the BT h/w in some way and defer when that fails? Or perhaps use fw_devlink to create a dependency on the wifi node. I'm not sure offhand how exactly you do that with a custom property. Rob
Rob Herring wrote on Wed, Nov 09, 2022 at 04:00:05PM -0600: > Punting the issue to userspace is not a great solution... I can definitely agree with that :) Userspace has the advantage of being easy to shove ugly things under the rug, whereas I still have faint hope of keeping down the divergences we have with upstream kernel... But that's about it. If we can work out a solution here I'll be very happy. Rob Herring wrote on Wed, Nov 09, 2022 at 04:00:05PM -0600: > > This actually hasn't taken long to bite us: while the driver does work, > > we get error messages early on before the firmware is loaded. > > (In hindsight, I probably should have waited a few days before sending > > this...) > > > > > > My current workaround is to return EPROBE_DEFER until we can find a > > netdev with a known name in the init namespace, but that isn't really > > something I'd consider upstreamable for obvious reasons (interfaces can > > be renamed or moved to different namespaces so this is inherently racy > > and it's just out of place in BT code) > > Can't you just try to access the BT h/w in some way and defer when that > fails? This is just a serial link; I've tried poking at it a bit before the firmware is loaded but mostly never got any reply, or while the driver sometimes got garbage back at some point (baudrate not matching with fresh boot default?) Either way, no reply isn't great -- just waiting a few ms for reply or not is not my idea of good design... > Or perhaps use fw_devlink to create a dependency on the wifi node. I'm > not sure offhand how exactly you do that with a custom property. That sounds great if we can figure how to do that! From what I can see this doesn't look possible to express in pure devicetree, but I see some code initializing a fwnode manually in a constructor function with fwnode_init and a fwnode_operations vector that has .add_links, which in turn could add a link. ... My problem at this point would be that I currently load the wireless driver as a module as it's vendor provided out of tree... (it's loaded through its pci alias, I guess it's udev checking depmod infos? not familiar how that part of autoloading really works...) But that makes me think that rather than defining the bluetooth serdev in dts early, I could try to have the wireless driver create it once it's ready? hmm... Let me sleep on that a bit and have another look at both fwnode (fw_devlink) and dynamic device creation. Cheers,
On Thu, Nov 10, 2022 at 1:38 AM Dominique Martinet <dominique.martinet@atmark-techno.com> wrote: > > Rob Herring wrote on Wed, Nov 09, 2022 at 04:00:05PM -0600: > > Punting the issue to userspace is not a great solution... > > I can definitely agree with that :) > > Userspace has the advantage of being easy to shove ugly things under the > rug, whereas I still have faint hope of keeping down the divergences we > have with upstream kernel... But that's about it. > > If we can work out a solution here I'll be very happy. > > > Rob Herring wrote on Wed, Nov 09, 2022 at 04:00:05PM -0600: > > > This actually hasn't taken long to bite us: while the driver does work, > > > we get error messages early on before the firmware is loaded. > > > (In hindsight, I probably should have waited a few days before sending > > > this...) > > > > > > > > > My current workaround is to return EPROBE_DEFER until we can find a > > > netdev with a known name in the init namespace, but that isn't really > > > something I'd consider upstreamable for obvious reasons (interfaces can > > > be renamed or moved to different namespaces so this is inherently racy > > > and it's just out of place in BT code) > > > > Can't you just try to access the BT h/w in some way and defer when that > > fails? > > This is just a serial link; I've tried poking at it a bit before the > firmware is loaded but mostly never got any reply, or while the driver > sometimes got garbage back at some point (baudrate not matching with > fresh boot default?) > Either way, no reply isn't great -- just waiting a few ms for reply or > not is not my idea of good design... > > > Or perhaps use fw_devlink to create a dependency on the wifi node. I'm > > not sure offhand how exactly you do that with a custom property. > > That sounds great if we can figure how to do that! > From what I can see this doesn't look possible to express in pure > devicetree, but I see some code initializing a fwnode manually in a > constructor function with fwnode_init and a fwnode_operations vector > that has .add_links, which in turn could add a link. If the wifi node was a standard provider (clocks, resets, etc.) to the BT node, it does just work with DT. The issue here is either you'd have some custom property or no property and the BT side driver just knows there is a dependency to create. That case is what .add_links is for IIRC. > ... My problem at this point would be that I currently load the wireless > driver as a module as it's vendor provided out of tree... (it's loaded > through its pci alias, I guess it's udev checking depmod infos? not > familiar how that part of autoloading really works...) Well, that's a fun complication. I guess it has no DT info? You can populate your DT with the necessary PCI nodes to represent the wifi device. Under the PCI host node, you'll need at least a root port node and then probably the wifi device is under that. It's got to match the hierarchy to assign a device_node ptr to the PCI device. Module aliases are the magic that makes the autoloading work. > But that makes me think that rather than defining the bluetooth serdev > in dts early, I could try to have the wireless driver create it once > it's ready? hmm... That is yet another option. The wireless driver could create the BT device when ready. The issue there is serdev devices created asynchronously isn't supported. serdev looks if the serial device has a child node and will register with serdev and create the serdev device. Otherwise, the serial device is bound to the tty layer. Rob
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 @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/h4-bluetooth.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: H4 Bluetooth + +maintainers: + - Dominique Martinet <dominique.martinet@atmark-techno.com> + +description: + H4 is a common bluetooth over uart protocol. + For example, the AW-XM458 is a WiFi + BT module where the WiFi part is + connected over PCI (M.2), while BT is connected over serial speaking + the H4 protocol. Its firmware is sent on the PCI side. + +properties: + compatible: + enum: + - nxp,aw-xm458-bt + + max-speed: true + +required: + - compatible + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/clock/imx8mp-clock.h> + + uart1 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_uart1>; + assigned-clocks = <&clk IMX8MP_CLK_UART1>; + assigned-clock-parents = <&clk IMX8MP_SYS_PLL1_80M>; + status = "okay"; + fsl,dte-mode = <1>; + fsl,uart-has-rtscts; + + + bluetooth { + compatible = "nxp,aw-xm458-bt"; + max-speed = <3000000>; + }; + };