Add a device tree binding document for GPIO controlled rfkill switches.
The name, type, shutdown-gpios and reset-gpios properties are the same
as defined for ACPI.
Signed-off-by: Philipp Zabel <[email protected]>
---
.../devicetree/bindings/net/rfkill-gpio.yaml | 60 +++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/rfkill-gpio.yaml
diff --git a/Documentation/devicetree/bindings/net/rfkill-gpio.yaml b/Documentation/devicetree/bindings/net/rfkill-gpio.yaml
new file mode 100644
index 000000000000..6e62e6c96456
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/rfkill-gpio.yaml
@@ -0,0 +1,60 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/net/rfkill-gpio.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: GPIO controlled rfkill switch
+
+maintainers:
+ - Johannes Berg <[email protected]>
+ - Philipp Zabel <[email protected]>
+
+properties:
+ compatible:
+ const: rfkill-gpio
+
+ name:
+ $ref: /schemas/types.yaml#/definitions/string
+ description: rfkill switch name, defaults to node name
+
+ type:
+ description: rfkill radio type
+ enum:
+ - wlan
+ - bluetooth
+ - ultrawideband
+ - wimax
+ - wwan
+ - gps
+ - fm
+ - nfc
+
+ shutdown-gpios:
+ maxItems: 1
+
+ reset-gpios:
+ maxItems: 1
+
+required:
+ - compatible
+ - type
+
+oneOf:
+ - required:
+ - shutdown-gpios
+ - required:
+ - reset-gpios
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+
+ rfkill-pcie-wlan {
+ compatible = "rfkill-gpio";
+ name = "rfkill-pcie-wlan";
+ type = "wlan";
+ shutdown-gpios = <&gpio2 25 GPIO_ACTIVE_HIGH>;
+ };
--
2.30.2
Allow probing rfkill-gpio via device tree. This just hooks up the
already existing support that was started in commit 262c91ee5e52 ("net:
rfkill: gpio: prepare for DT and ACPI support") via the "rfkill-gpio"
compatible.
Signed-off-by: Philipp Zabel <[email protected]>
---
net/rfkill/rfkill-gpio.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index f5afc9bcdee6..9f763654cd27 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -157,12 +157,21 @@ static const struct acpi_device_id rfkill_acpi_match[] = {
MODULE_DEVICE_TABLE(acpi, rfkill_acpi_match);
#endif
+#ifdef CONFIG_OF
+static const struct of_device_id rfkill_of_match[] = {
+ { .compatible = "rfkill-gpio", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, rfkill_of_match);
+#endif
+
static struct platform_driver rfkill_gpio_driver = {
.probe = rfkill_gpio_probe,
.remove = rfkill_gpio_remove,
.driver = {
.name = "rfkill_gpio",
.acpi_match_table = ACPI_PTR(rfkill_acpi_match),
+ .of_match_table = of_match_ptr(rfkill_of_match),
},
};
--
2.30.2
On Wed, Dec 21, 2022 at 11:48:02AM +0100, Philipp Zabel wrote:
> Add a device tree binding document for GPIO controlled rfkill switches.
> The name, type, shutdown-gpios and reset-gpios properties are the same
> as defined for ACPI.
>
> Signed-off-by: Philipp Zabel <[email protected]>
> ---
> .../devicetree/bindings/net/rfkill-gpio.yaml | 60 +++++++++++++++++++
> 1 file changed, 60 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/net/rfkill-gpio.yaml
>
> diff --git a/Documentation/devicetree/bindings/net/rfkill-gpio.yaml b/Documentation/devicetree/bindings/net/rfkill-gpio.yaml
> new file mode 100644
> index 000000000000..6e62e6c96456
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/rfkill-gpio.yaml
> @@ -0,0 +1,60 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/net/rfkill-gpio.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: GPIO controlled rfkill switch
> +
> +maintainers:
> + - Johannes Berg <[email protected]>
> + - Philipp Zabel <[email protected]>
> +
> +properties:
> + compatible:
> + const: rfkill-gpio
> +
> + name:
Did you test this? Something should complain, but maybe not. The problem
is 'name' is already a property in the unflattened DT (and old FDT
formats).
'label' would be appropriate perhaps, but why do we care what the name
is?
> + $ref: /schemas/types.yaml#/definitions/string
> + description: rfkill switch name, defaults to node name
> +
> + type:
Too generic. Property names should ideally have 1 type globally. I think
'type' is already in use. 'radio-type' instead?
> + description: rfkill radio type
> + enum:
> + - wlan
> + - bluetooth
> + - ultrawideband
> + - wimax
> + - wwan
> + - gps
> + - fm
> + - nfc
> +
> + shutdown-gpios:
> + maxItems: 1
> +
> + reset-gpios:
> + maxItems: 1
I'm lost as to why there are 2 GPIOs.
> +
> +required:
> + - compatible
> + - type
> +
> +oneOf:
> + - required:
> + - shutdown-gpios
> + - required:
> + - reset-gpios
But only 1 can be present? So just define 1 GPIO name.
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/gpio/gpio.h>
> +
> + rfkill-pcie-wlan {
Node names should be generic.
> + compatible = "rfkill-gpio";
> + name = "rfkill-pcie-wlan";
> + type = "wlan";
> + shutdown-gpios = <&gpio2 25 GPIO_ACTIVE_HIGH>;
> + };
> --
> 2.30.2
>
>
On Mi, 2022-12-21 at 08:45 -0600, Rob Herring wrote:
> On Wed, Dec 21, 2022 at 11:48:02AM +0100, Philipp Zabel wrote:
> > Add a device tree binding document for GPIO controlled rfkill switches.
> > The name, type, shutdown-gpios and reset-gpios properties are the same
> > as defined for ACPI.
> >
> > Signed-off-by: Philipp Zabel <[email protected]>
> > ---
> > .../devicetree/bindings/net/rfkill-gpio.yaml | 60 +++++++++++++++++++
> > 1 file changed, 60 insertions(+)
> > create mode 100644 Documentation/devicetree/bindings/net/rfkill-gpio.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/net/rfkill-gpio.yaml b/Documentation/devicetree/bindings/net/rfkill-gpio.yaml
> > new file mode 100644
> > index 000000000000..6e62e6c96456
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/rfkill-gpio.yaml
> > @@ -0,0 +1,60 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: "http://devicetree.org/schemas/net/rfkill-gpio.yaml#"
> > +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> > +
> > +title: GPIO controlled rfkill switch
> > +
> > +maintainers:
> > + - Johannes Berg <[email protected]>
> > + - Philipp Zabel <[email protected]>
> > +
> > +properties:
> > + compatible:
> > + const: rfkill-gpio
> > +
> > + name:
>
> Did you test this? Something should complain, but maybe not. The problem
> is 'name' is already a property in the unflattened DT (and old FDT
> formats).
Thank you. Maybe this was hidden by the fact that I set the name
property to the same string as the node's name.
> 'label' would be appropriate perhaps, but why do we care what the name
> is?
This is meant to be the identifier of the rfkill API object. It is the
content of /sys/class/rfkill/rfkill0/name, and the 'ID' in the rfkill
command line tool, that can be used to select a switch, in case a
device has multiple radios of the same type.
> > + $ref: /schemas/types.yaml#/definitions/string
> > + description: rfkill switch name, defaults to node name
> > +
> > + type:
>
> Too generic. Property names should ideally have 1 type globally. I think
> 'type' is already in use. 'radio-type' instead?
These values correspond to the 'enum rfkill_type' in Linux UAPI, but I
think in this context 'radio-type' would be better than 'rfkill-type'.
> > + description: rfkill radio type
> > + enum:
> > + - wlan
> > + - bluetooth
> > + - ultrawideband
> > + - wimax
> > + - wwan
> > + - gps
> > + - fm
> > + - nfc
> > +
> > + shutdown-gpios:
> > + maxItems: 1
> > +
> > + reset-gpios:
> > + maxItems: 1
>
> I'm lost as to why there are 2 GPIOs.
I don't know either. My assumption is that this is for devices that
are radio silenced by just asserting their reset pin (for example GPS
chips). The driver handles them the same.
I could remove reset-gpios and make shutdown-gpios required.
> > +
> > +required:
> > + - compatible
> > + - type
> > +
> > +oneOf:
> > + - required:
> > + - shutdown-gpios
> > + - required:
> > + - reset-gpios
>
> But only 1 can be present? So just define 1 GPIO name.
The intent was that only one of them would be required.
> > +additionalProperties: false
> > +
> > +examples:
> > + - |
> > + #include <dt-bindings/gpio/gpio.h>
> > +
> > + rfkill-pcie-wlan {
>
> Node names should be generic.
What could be a generic name for this - is "rfkill" acceptable even
though it is a Linux subsystem name? Or would "rf-kill-switch" be
better?
How should they be called if there are multiple of them?
> > + compatible = "rfkill-gpio";
> > + name = "rfkill-pcie-wlan";
> > + type = "wlan";
> > + shutdown-gpios = <&gpio2 25 GPIO_ACTIVE_HIGH>;
> > + };
> > --
> > 2.30.2
regards
Philipp
On 21/12/2022 11:48, Philipp Zabel wrote:
> Add a device tree binding document for GPIO controlled rfkill switches.
> The name, type, shutdown-gpios and reset-gpios properties are the same
> as defined for ACPI.
>
> Signed-off-by: Philipp Zabel <[email protected]>
Please use scripts/get_maintainers.pl to get a list of necessary people
and lists to CC. It might happen, that command when run on an older
kernel, gives you outdated entries. Therefore please be sure you base
your patches on recent Linux kernel.
You missed several maintainers. Resend.
> ---
> .../devicetree/bindings/net/rfkill-gpio.yaml | 60 +++++++++++++++++++
> 1 file changed, 60 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/net/rfkill-gpio.yaml
>
> diff --git a/Documentation/devicetree/bindings/net/rfkill-gpio.yaml b/Documentation/devicetree/bindings/net/rfkill-gpio.yaml
> new file mode 100644
> index 000000000000..6e62e6c96456
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/rfkill-gpio.yaml
> @@ -0,0 +1,60 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/net/rfkill-gpio.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
Drop quotes.
> +
> +title: GPIO controlled rfkill switch
> +
> +maintainers:
> + - Johannes Berg <[email protected]>
> + - Philipp Zabel <[email protected]>
> +
> +properties:
> + compatible:
> + const: rfkill-gpio
> +
> + name:
> + $ref: /schemas/types.yaml#/definitions/string
> + description: rfkill switch name, defaults to node name
There is a generic label property.
> +
> + type:
> + description: rfkill radio type
> + enum:
> + - wlan
> + - bluetooth
> + - ultrawideband
> + - wimax
> + - wwan
> + - gps
> + - fm
> + - nfc
Order the list.
> +
> + shutdown-gpios:
> + maxItems: 1
> +
> + reset-gpios:
> + maxItems: 1
Reset of rfkill? It seems entire binding is a workaround of missing
reset in your device. I don't think this is suitable for binding.
> +
> +required:
> + - compatible
> + - type
> +
> +oneOf:
> + - required:
> + - shutdown-gpios
> + - required:
> + - reset-gpios
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/gpio/gpio.h>
> +
> + rfkill-pcie-wlan {
Generic node names, so: rfkill
> + compatible = "rfkill-gpio";
> + name = "rfkill-pcie-wlan";
> + type = "wlan";
> + shutdown-gpios = <&gpio2 25 GPIO_ACTIVE_HIGH>;
> + };
Best regards,
Krzysztof
On 21/12/2022 16:36, Philipp Zabel wrote:
>>> + $ref: /schemas/types.yaml#/definitions/string
>>> + description: rfkill switch name, defaults to node name
>>> +
>>> + type:
>>
>> Too generic. Property names should ideally have 1 type globally. I think
>> 'type' is already in use. 'radio-type' instead?
>
> These values correspond to the 'enum rfkill_type' in Linux UAPI, but I
> think in this context 'radio-type' would be better than 'rfkill-type'.
Do not map Linux driver to DT, but rather describe the actual hardware.
>
>>> + description: rfkill radio type
>>> + enum:
>>> + - wlan
>>> + - bluetooth
>>> + - ultrawideband
>>> + - wimax
>>> + - wwan
>>> + - gps
>>> + - fm
>>> + - nfc
>>> +
>>> + shutdown-gpios:
>>> + maxItems: 1
>>> +
>>> + reset-gpios:
>>> + maxItems: 1
>>
>> I'm lost as to why there are 2 GPIOs.
>
> I don't know either. My assumption is that this is for devices that
> are radio silenced by just asserting their reset pin (for example GPS
> chips). The driver handles them the same.
>
> I could remove reset-gpios and make shutdown-gpios required.
>
>>> +
>>> +required:
>>> + - compatible
>>> + - type
>>> +
>>> +oneOf:
>>> + - required:
>>> + - shutdown-gpios
>>> + - required:
>>> + - reset-gpios
>>
>> But only 1 can be present? So just define 1 GPIO name.
>
> The intent was that only one of them would be required.
>
>>> +additionalProperties: false
>>> +
>>> +examples:
>>> + - |
>>> + #include <dt-bindings/gpio/gpio.h>
>>> +
>>> + rfkill-pcie-wlan {
>>
>> Node names should be generic.
>
> What could be a generic name for this - is "rfkill" acceptable even
> though it is a Linux subsystem name? Or would "rf-kill-switch" be
> better?
rfkill
>
> How should they be called if there are multiple of them?
The same as in all other cases (leds, gpios, regulators), so rfkill-1,
rfkill-2...
Best regards,
Krzysztof
On 21/12/2022 11:48, Philipp Zabel wrote:
> Allow probing rfkill-gpio via device tree. This just hooks up the
> already existing support that was started in commit 262c91ee5e52 ("net:
> rfkill: gpio: prepare for DT and ACPI support") via the "rfkill-gpio"
> compatible.
>
> Signed-off-by: Philipp Zabel <[email protected]>
> ---
> net/rfkill/rfkill-gpio.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
> index f5afc9bcdee6..9f763654cd27 100644
> --- a/net/rfkill/rfkill-gpio.c
> +++ b/net/rfkill/rfkill-gpio.c
> @@ -157,12 +157,21 @@ static const struct acpi_device_id rfkill_acpi_match[] = {
> MODULE_DEVICE_TABLE(acpi, rfkill_acpi_match);
> #endif
>
> +#ifdef CONFIG_OF
__maybe_unused instead
> +static const struct of_device_id rfkill_of_match[] = {
> + { .compatible = "rfkill-gpio", },
> + { },
> +};
> +MODULE_DEVICE_TABLE(of, rfkill_of_match);
Best regards,
Krzysztof