netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] net: rfkill-gpio device tree support
@ 2023-01-02 17:29 Philipp Zabel
  2023-01-02 17:29 ` [PATCH v2 1/2] dt-bindings: net: Add rfkill-gpio binding Philipp Zabel
  2023-01-02 17:29 ` [PATCH v2 2/2] net: rfkill: gpio: add DT support Philipp Zabel
  0 siblings, 2 replies; 4+ messages in thread
From: Philipp Zabel @ 2023-01-02 17:29 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Johannes Berg
  Cc: netdev, devicetree, linux-kernel, linux-wireless, kernel, Philipp Zabel

The rfkill-gpio driver currently only seems to be used for the Broadcom
4752 GPS UART/GPIO device on ACPI systems, but the driver looks generic
enough. It is already mostly prepared for device tree support, this
series only adds binding documentation and adds support for the
"rfkill-gpio" compatible and the renamed "name" -> "label" and
"type" -> "radio-type" properties.

Changes since v1:
- Rename "name" and "type" properties to "label" and "radio-type",
  respectively, and adapt the driver.
- Drop reset-gpios property from DT binding.
- Fix some style issues, see individual patches for details.

v1: https://lore.kernel.org/all/20221221104803.1693874-1-p.zabel@pengutronix.de/T

To: "David S. Miller" <davem@davemloft.net>
To: Eric Dumazet <edumazet@google.com>
To: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
To: Rob Herring <robh+dt@kernel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: netdev@vger.kernel.org
Cc: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-wireless@vger.kernel.org
Cc: kernel@pengutronix.de
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

---
Philipp Zabel (2):
      dt-bindings: net: Add rfkill-gpio binding
      net: rfkill: gpio: add DT support

 .../devicetree/bindings/net/rfkill-gpio.yaml       | 51 ++++++++++++++++++++++
 net/rfkill/rfkill-gpio.c                           | 20 ++++++++-
 2 files changed, 69 insertions(+), 2 deletions(-)
---
base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
change-id: 20230102-rfkill-gpio-dt-f9a07ef1f036

Best regards,
-- 
Philipp Zabel <p.zabel@pengutronix.de>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] dt-bindings: net: Add rfkill-gpio binding
  2023-01-02 17:29 [PATCH v2 0/2] net: rfkill-gpio device tree support Philipp Zabel
@ 2023-01-02 17:29 ` Philipp Zabel
  2023-01-08 20:48   ` Rob Herring
  2023-01-02 17:29 ` [PATCH v2 2/2] net: rfkill: gpio: add DT support Philipp Zabel
  1 sibling, 1 reply; 4+ messages in thread
From: Philipp Zabel @ 2023-01-02 17:29 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Johannes Berg
  Cc: netdev, devicetree, linux-kernel, linux-wireless, kernel, Philipp Zabel

Add a device tree binding document for GPIO controlled rfkill switches.
The label and radio-type properties correspond to the name and type
properties used for ACPI, respectively. The shutdown-gpios property
is the same as defined for ACPI.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
Changes since v1:
- Drop quotes from $id and $schema (Krzysztof)
- Use generic label property (Rob, Krzysztof)
- Rename type property to radio-type (Rob)
- Reorder list of radio types alphabetically (Krzysztof)
- Drop reset-gpios property (Rob, Krzysztof)
- Use generic node name in example (Rob, Krzysztof)
---
 .../devicetree/bindings/net/rfkill-gpio.yaml       | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/rfkill-gpio.yaml b/Documentation/devicetree/bindings/net/rfkill-gpio.yaml
new file mode 100644
index 000000000000..9630c8466fac
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/rfkill-gpio.yaml
@@ -0,0 +1,51 @@
+# 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 <johannes@sipsolutions.net>
+  - Philipp Zabel <p.zabel@pengutronix.de>
+
+properties:
+  compatible:
+    const: rfkill-gpio
+
+  label:
+    description: rfkill switch name, defaults to node name
+
+  radio-type:
+    description: rfkill radio type
+    enum:
+      - bluetooth
+      - fm
+      - gps
+      - nfc
+      - ultrawideband
+      - wimax
+      - wlan
+      - wwan
+
+  shutdown-gpios:
+    maxItems: 1
+
+required:
+  - compatible
+  - radio-type
+  - shutdown-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    rfkill {
+        compatible = "rfkill-gpio";
+        label = "rfkill-pcie-wlan";
+        radio-type = "wlan";
+        shutdown-gpios = <&gpio2 25 GPIO_ACTIVE_HIGH>;
+    };

-- 
2.30.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] net: rfkill: gpio: add DT support
  2023-01-02 17:29 [PATCH v2 0/2] net: rfkill-gpio device tree support Philipp Zabel
  2023-01-02 17:29 ` [PATCH v2 1/2] dt-bindings: net: Add rfkill-gpio binding Philipp Zabel
@ 2023-01-02 17:29 ` Philipp Zabel
  1 sibling, 0 replies; 4+ messages in thread
From: Philipp Zabel @ 2023-01-02 17:29 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Rob Herring, Krzysztof Kozlowski, Johannes Berg
  Cc: netdev, devicetree, linux-kernel, linux-wireless, kernel, Philipp Zabel

Allow probing rfkill-gpio via device tree. This 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, with the "name" and "type" properties renamed to "label"
and "radio-type", respectively, in the device tree case.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
Changes since v1:
- Use __maybe_unused instead of #ifdef CONFIG_OF (Krzysztof)
- Support renamed "label" and "radio-type" property names
---
 net/rfkill/rfkill-gpio.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index f5afc9bcdee6..786dbfdad772 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -75,6 +75,8 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
 {
 	struct rfkill_gpio_data *rfkill;
 	struct gpio_desc *gpio;
+	const char *name_property;
+	const char *type_property;
 	const char *type_name;
 	int ret;
 
@@ -82,8 +84,15 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
 	if (!rfkill)
 		return -ENOMEM;
 
-	device_property_read_string(&pdev->dev, "name", &rfkill->name);
-	device_property_read_string(&pdev->dev, "type", &type_name);
+	if (dev_of_node(&pdev->dev)) {
+		name_property = "label";
+		type_property = "radio-type";
+	} else {
+		name_property = "name";
+		type_property = "type";
+	}
+	device_property_read_string(&pdev->dev, name_property, &rfkill->name);
+	device_property_read_string(&pdev->dev, type_property, &type_name);
 
 	if (!rfkill->name)
 		rfkill->name = dev_name(&pdev->dev);
@@ -157,12 +166,19 @@ static const struct acpi_device_id rfkill_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, rfkill_acpi_match);
 #endif
 
+static const struct of_device_id rfkill_of_match[] __maybe_unused = {
+	{ .compatible = "rfkill-gpio", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, rfkill_of_match);
+
 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: net: Add rfkill-gpio binding
  2023-01-02 17:29 ` [PATCH v2 1/2] dt-bindings: net: Add rfkill-gpio binding Philipp Zabel
@ 2023-01-08 20:48   ` Rob Herring
  0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2023-01-08 20:48 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Paolo Abeni, linux-wireless, Johannes Berg, devicetree, netdev,
	Krzysztof Kozlowski, Eric Dumazet, David S. Miller, kernel,
	Jakub Kicinski, Rob Herring, linux-kernel


On Mon, 02 Jan 2023 18:29:33 +0100, Philipp Zabel wrote:
> Add a device tree binding document for GPIO controlled rfkill switches.
> The label and radio-type properties correspond to the name and type
> properties used for ACPI, respectively. The shutdown-gpios property
> is the same as defined for ACPI.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
> Changes since v1:
> - Drop quotes from $id and $schema (Krzysztof)
> - Use generic label property (Rob, Krzysztof)
> - Rename type property to radio-type (Rob)
> - Reorder list of radio types alphabetically (Krzysztof)
> - Drop reset-gpios property (Rob, Krzysztof)
> - Use generic node name in example (Rob, Krzysztof)
> ---
>  .../devicetree/bindings/net/rfkill-gpio.yaml       | 51 ++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-08 20:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-02 17:29 [PATCH v2 0/2] net: rfkill-gpio device tree support Philipp Zabel
2023-01-02 17:29 ` [PATCH v2 1/2] dt-bindings: net: Add rfkill-gpio binding Philipp Zabel
2023-01-08 20:48   ` Rob Herring
2023-01-02 17:29 ` [PATCH v2 2/2] net: rfkill: gpio: add DT support Philipp Zabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).