linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] auxdisplay: 7 segment LED display
@ 2024-02-27 21:22 Chris Packham
  2024-02-27 21:22 ` [PATCH v2 1/4] auxdisplay: Add 7 segment LED display driver Chris Packham
                   ` (4 more replies)
  0 siblings, 5 replies; 24+ messages in thread
From: Chris Packham @ 2024-02-27 21:22 UTC (permalink / raw)
  To: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel
  Cc: devicetree, linux-leds, linux-kernel, linux-arm-kernel, Chris Packham

This series adds a driver for a 7 segment LED display.

At this point I've decided not to pursue supporting >1 character. I had
a look at what would be required to add a devm_fwnode_gpiod_get_array()
and got bogged down in OF and ACPI code for counting GPIOs.
--
[1] - https://lore.kernel.org/lkml/2a8d19ee-b18b-4b7c-869f-7d601cea30b6@alliedtelesis.co.nz/

Chris Packham (4):
  auxdisplay: Add 7 segment LED display driver
  dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  ARM: dts: marvell: Add 7 segment LED display on x530
  ARM: dts: marvell: Indicate USB activity on x530

 .../auxdisplay/generic-gpio-7seg.yaml         |  40 ++++++
 .../boot/dts/marvell/armada-385-atl-x530.dts  |  22 +++-
 drivers/auxdisplay/Kconfig                    |  10 ++
 drivers/auxdisplay/Makefile                   |   1 +
 drivers/auxdisplay/seg-led.c                  | 119 ++++++++++++++++++
 5 files changed, 191 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml
 create mode 100644 drivers/auxdisplay/seg-led.c

-- 
2.43.2


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

* [PATCH v2 1/4] auxdisplay: Add 7 segment LED display driver
  2024-02-27 21:22 [PATCH v2 0/4] auxdisplay: 7 segment LED display Chris Packham
@ 2024-02-27 21:22 ` Chris Packham
  2024-02-27 22:13   ` Randy Dunlap
  2024-02-27 23:56   ` Andy Shevchenko
  2024-02-27 21:22 ` [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED Chris Packham
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 24+ messages in thread
From: Chris Packham @ 2024-02-27 21:22 UTC (permalink / raw)
  To: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel
  Cc: devicetree, linux-leds, linux-kernel, linux-arm-kernel, Chris Packham

Add a driver for a 7 segment LED display. At the moment only one
character is supported but it should be possible to expand this to
support more characters and/or 14 segment displays in the future.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---

Notes:
    Changes in v2:
    - Rebased on top of auxdisplay/for-next dropping unnecessary code for 7
      segment maps.
    - Update for new linedisp_register() API
    - Include headers based on actual usage
    - Allow building as module
    - Use compatible = "generic-gpio-7seg" to keep checkpatch.pl happy

 drivers/auxdisplay/Kconfig   |  10 +++
 drivers/auxdisplay/Makefile  |   1 +
 drivers/auxdisplay/seg-led.c | 119 +++++++++++++++++++++++++++++++++++
 3 files changed, 130 insertions(+)
 create mode 100644 drivers/auxdisplay/seg-led.c

diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
index d4be0a3695ce..52a245ca0c8d 100644
--- a/drivers/auxdisplay/Kconfig
+++ b/drivers/auxdisplay/Kconfig
@@ -211,6 +211,16 @@ config ARM_CHARLCD
 	  line and the Linux version on the second line, but that's
 	  still useful.
 
+config SEG_LED
+	tristate "Generic 7 segment LED display"
+	select LINEDISP
+	help
+	  This driver supports a generic 7 segment LED display made up
+	  of GPIO pins connected to the individual segments.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called seg-led.
+
 menuconfig PARPORT_PANEL
 	tristate "Parallel port LCD/Keypad Panel support"
 	depends on PARPORT
diff --git a/drivers/auxdisplay/Makefile b/drivers/auxdisplay/Makefile
index a725010ca651..744e354318ae 100644
--- a/drivers/auxdisplay/Makefile
+++ b/drivers/auxdisplay/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_PARPORT_PANEL)	+= panel.o
 obj-$(CONFIG_LCD2S)		+= lcd2s.o
 obj-$(CONFIG_LINEDISP)		+= line-display.o
 obj-$(CONFIG_MAX6959)		+= max6959.o
+obj-$(CONFIG_SEG_LED)		+= seg-led.o
diff --git a/drivers/auxdisplay/seg-led.c b/drivers/auxdisplay/seg-led.c
new file mode 100644
index 000000000000..7bb304fcaa6e
--- /dev/null
+++ b/drivers/auxdisplay/seg-led.c
@@ -0,0 +1,119 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Driver for a 7 segment LED display
+ *
+ * The GPIOs are wired to the 7 segments in a clockwise fashion starting from
+ * the top.
+ *
+ *      -a-
+ *     |   |
+ *     f   b
+ *     |   |
+ *      -g-
+ *     |   |
+ *     e   c
+ *     |   |
+ *      -d-
+ *
+ * The decimal point LED present on some devices is currently not
+ * supported.
+ *
+ * Copyright (C) Allied Telesis Labs
+ */
+
+#include <linux/container_of.h>
+#include <linux/errno.h>
+#include <linux/gpio/consumer.h>
+#include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+#include <linux/workqueue.h>
+
+#include "line-display.h"
+
+struct seg_led_priv {
+	struct gpio_descs *segment_gpios;
+	struct delayed_work work;
+	struct linedisp linedisp;
+};
+
+static void seg_led_update(struct work_struct *work)
+{
+	struct seg_led_priv *priv = container_of(work, struct seg_led_priv, work.work);
+	struct linedisp_map *map = priv->linedisp.map;
+	DECLARE_BITMAP(values, 8);
+
+	values[0] = map_to_seg7(&map->map.seg7, priv->linedisp.buf[0]);
+
+	gpiod_set_array_value_cansleep(priv->segment_gpios->ndescs, priv->segment_gpios->desc,
+				       priv->segment_gpios->info, values);
+}
+
+static int seg_led_linedisp_get_map_type(struct linedisp *linedisp)
+{
+	return LINEDISP_MAP_SEG7;
+}
+
+static void seg_led_linedisp_update(struct linedisp *linedisp)
+{
+	struct seg_led_priv *priv = container_of(linedisp, struct seg_led_priv, linedisp);
+
+	schedule_delayed_work(&priv->work, 0);
+}
+
+static const struct linedisp_ops seg_led_linedisp_ops = {
+	.get_map_type = seg_led_linedisp_get_map_type,
+	.update = seg_led_linedisp_update,
+};
+
+static const struct of_device_id seg_led_of_match[] = {
+	{ .compatible = "generic-gpio-7seg"},
+	{}
+};
+MODULE_DEVICE_TABLE(of, seg_led_of_match);
+
+static int seg_led_probe(struct platform_device *pdev)
+{
+	struct seg_led_priv *priv;
+	struct device *dev = &pdev->dev;
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, priv);
+
+	priv->segment_gpios = devm_gpiod_get_array(dev, "segment", GPIOD_OUT_LOW);
+	if (IS_ERR(priv->segment_gpios))
+		return PTR_ERR(priv->segment_gpios);
+
+	INIT_DELAYED_WORK(&priv->work, seg_led_update);
+
+	return linedisp_register(&priv->linedisp, dev, 1, &seg_led_linedisp_ops);
+}
+
+static int seg_led_remove(struct platform_device *pdev)
+{
+	struct seg_led_priv *priv = platform_get_drvdata(pdev);
+
+	cancel_delayed_work_sync(&priv->work);
+	linedisp_unregister(&priv->linedisp);
+
+	return 0;
+}
+
+static struct platform_driver seg_led_driver = {
+	.probe = seg_led_probe,
+	.remove = seg_led_remove,
+	.driver = {
+		.name = "seg-led",
+		.of_match_table = seg_led_of_match,
+	},
+};
+module_platform_driver(seg_led_driver);
+
+MODULE_AUTHOR("Chris Packham <chris.packham@alliedtelesis.co.nz>");
+MODULE_DESCRIPTION("7 segment LED driver");
+MODULE_LICENSE("GPL");
-- 
2.43.2


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

* [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-27 21:22 [PATCH v2 0/4] auxdisplay: 7 segment LED display Chris Packham
  2024-02-27 21:22 ` [PATCH v2 1/4] auxdisplay: Add 7 segment LED display driver Chris Packham
@ 2024-02-27 21:22 ` Chris Packham
  2024-02-27 22:19   ` Rob Herring
                     ` (2 more replies)
  2024-02-27 21:22 ` [PATCH v2 3/4] ARM: dts: marvell: Add 7 segment LED display on x530 Chris Packham
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 24+ messages in thread
From: Chris Packham @ 2024-02-27 21:22 UTC (permalink / raw)
  To: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel
  Cc: devicetree, linux-leds, linux-kernel, linux-arm-kernel, Chris Packham

Add bindings for a generic 7 segment LED display using GPIOs.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---

Notes:
    Changes in v2:
    - Use compatible = "generic-gpio-7seg" to keep checkpatch.pl happy

 .../auxdisplay/generic-gpio-7seg.yaml         | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml

diff --git a/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml b/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml
new file mode 100644
index 000000000000..46d53ebdf413
--- /dev/null
+++ b/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/auxdisplay/generic,gpio-7seg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: GPIO based LED segment display
+
+maintainers:
+  - Chris Packham <chris.packham@alliedtelesis.co.nz>
+
+properties:
+  compatible:
+    const: generic-gpio-7seg
+
+  segment-gpios:
+    description:
+      An array of GPIOs one per segment.
+    minItems: 7
+
+required:
+  - segment-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+
+    #include <dt-bindings/gpio/gpio.h>
+
+    led-7seg {
+        compatible = "generic-gpio-7seg";
+        segment-gpios = <&gpio 0 GPIO_ACTIVE_LOW
+                         &gpio 1 GPIO_ACTIVE_LOW
+                         &gpio 2 GPIO_ACTIVE_LOW
+                         &gpio 3 GPIO_ACTIVE_LOW
+                         &gpio 4 GPIO_ACTIVE_LOW
+                         &gpio 5 GPIO_ACTIVE_LOW
+                         &gpio 6 GPIO_ACTIVE_LOW>;
+    };
-- 
2.43.2


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

* [PATCH v2 3/4] ARM: dts: marvell: Add 7 segment LED display on x530
  2024-02-27 21:22 [PATCH v2 0/4] auxdisplay: 7 segment LED display Chris Packham
  2024-02-27 21:22 ` [PATCH v2 1/4] auxdisplay: Add 7 segment LED display driver Chris Packham
  2024-02-27 21:22 ` [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED Chris Packham
@ 2024-02-27 21:22 ` Chris Packham
  2024-02-28  0:12   ` Andy Shevchenko
  2024-02-27 21:22 ` [PATCH v2 4/4] ARM: dts: marvell: Indicate USB activity " Chris Packham
  2024-02-28  0:05 ` [PATCH v2 0/4] auxdisplay: 7 segment LED display Andy Shevchenko
  4 siblings, 1 reply; 24+ messages in thread
From: Chris Packham @ 2024-02-27 21:22 UTC (permalink / raw)
  To: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel
  Cc: devicetree, linux-leds, linux-kernel, linux-arm-kernel, Chris Packham

The Allied Telesis x530 products have a 7 segment LED display which is
used for node identification when the devices are stacked. Represent
this as a gpio-7seg device.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---

Notes:
    Changes in v2:
    - Use compatible = "generic-gpio=7seg" to keep checkpatch.pl happy

 arch/arm/boot/dts/marvell/armada-385-atl-x530.dts | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/marvell/armada-385-atl-x530.dts b/arch/arm/boot/dts/marvell/armada-385-atl-x530.dts
index 5a9ab8410b7b..f55a3dc6b6de 100644
--- a/arch/arm/boot/dts/marvell/armada-385-atl-x530.dts
+++ b/arch/arm/boot/dts/marvell/armada-385-atl-x530.dts
@@ -43,6 +43,17 @@ uart0: serial@12000 {
 			};
 		};
 	};
+
+	led-7seg {
+		compatible = "generic-gpio-7seg";
+		segment-gpios = <&led_7seg_gpio 0 GPIO_ACTIVE_LOW
+				 &led_7seg_gpio 1 GPIO_ACTIVE_LOW
+				 &led_7seg_gpio 2 GPIO_ACTIVE_LOW
+				 &led_7seg_gpio 3 GPIO_ACTIVE_LOW
+				 &led_7seg_gpio 4 GPIO_ACTIVE_LOW
+				 &led_7seg_gpio 5 GPIO_ACTIVE_LOW
+				 &led_7seg_gpio 6 GPIO_ACTIVE_LOW>;
+	};
 };
 
 &pciec {
@@ -149,7 +160,7 @@ i2c@3 {
 			#size-cells = <0>;
 			reg = <3>;
 
-			gpio@20 {
+			led_7seg_gpio: gpio@20 {
 				compatible = "nxp,pca9554";
 				gpio-controller;
 				#gpio-cells = <2>;
-- 
2.43.2


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

* [PATCH v2 4/4] ARM: dts: marvell: Indicate USB activity on x530
  2024-02-27 21:22 [PATCH v2 0/4] auxdisplay: 7 segment LED display Chris Packham
                   ` (2 preceding siblings ...)
  2024-02-27 21:22 ` [PATCH v2 3/4] ARM: dts: marvell: Add 7 segment LED display on x530 Chris Packham
@ 2024-02-27 21:22 ` Chris Packham
  2024-02-28  0:09   ` Andy Shevchenko
  2024-02-28  0:05 ` [PATCH v2 0/4] auxdisplay: 7 segment LED display Andy Shevchenko
  4 siblings, 1 reply; 24+ messages in thread
From: Chris Packham @ 2024-02-27 21:22 UTC (permalink / raw)
  To: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel
  Cc: devicetree, linux-leds, linux-kernel, linux-arm-kernel, Chris Packham

Use the dot on the 7 segment LED block to indicate USB access on the
x530.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---

Notes:
    Change in v2:
    - New

 arch/arm/boot/dts/marvell/armada-385-atl-x530.dts | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/marvell/armada-385-atl-x530.dts b/arch/arm/boot/dts/marvell/armada-385-atl-x530.dts
index f55a3dc6b6de..94ae9f4ebe1c 100644
--- a/arch/arm/boot/dts/marvell/armada-385-atl-x530.dts
+++ b/arch/arm/boot/dts/marvell/armada-385-atl-x530.dts
@@ -54,6 +54,15 @@ &led_7seg_gpio 4 GPIO_ACTIVE_LOW
 				 &led_7seg_gpio 5 GPIO_ACTIVE_LOW
 				 &led_7seg_gpio 6 GPIO_ACTIVE_LOW>;
 	};
+
+	leds {
+		compatible = "gpio-leds";
+		led-0 {
+			label = "usb";
+			gpios =  <&led_7seg_gpio 7 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "usb-host";
+		};
+	};
 };
 
 &pciec {
-- 
2.43.2


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

* Re: [PATCH v2 1/4] auxdisplay: Add 7 segment LED display driver
  2024-02-27 21:22 ` [PATCH v2 1/4] auxdisplay: Add 7 segment LED display driver Chris Packham
@ 2024-02-27 22:13   ` Randy Dunlap
  2024-02-27 23:56   ` Andy Shevchenko
  1 sibling, 0 replies; 24+ messages in thread
From: Randy Dunlap @ 2024-02-27 22:13 UTC (permalink / raw)
  To: Chris Packham, andy, geert, robh+dt, krzysztof.kozlowski+dt,
	conor+dt, andrew, gregory.clement, sebastian.hesselbarth, ojeda,
	tzimmermann, javierm, robin, lee, pavel
  Cc: devicetree, linux-leds, linux-kernel, linux-arm-kernel

Hi--

On 2/27/24 13:22, Chris Packham wrote:
> diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
> index d4be0a3695ce..52a245ca0c8d 100644
> --- a/drivers/auxdisplay/Kconfig
> +++ b/drivers/auxdisplay/Kconfig
> @@ -211,6 +211,16 @@ config ARM_CHARLCD
>  	  line and the Linux version on the second line, but that's
>  	  still useful.
>  
> +config SEG_LED
> +	tristate "Generic 7 segment LED display"

	                  7-segment

> +	select LINEDISP
> +	help
> +	  This driver supports a generic 7 segment LED display made up

	                                 7-segment

> +	  of GPIO pins connected to the individual segments.
> +
> +	  This driver can also be built as a module. If so, the module
> +	  will be called seg-led.

-- 
#Randy

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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-27 21:22 ` [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED Chris Packham
@ 2024-02-27 22:19   ` Rob Herring
  2024-02-28  0:03   ` Andy Shevchenko
  2024-02-28 14:04   ` Rob Herring
  2 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2024-02-27 22:19 UTC (permalink / raw)
  To: Chris Packham
  Cc: pavel, linux-kernel, lee, robh+dt, gregory.clement, conor+dt,
	ojeda, tzimmermann, devicetree, javierm, krzysztof.kozlowski+dt,
	linux-leds, linux-arm-kernel, geert, andrew, andy,
	sebastian.hesselbarth, robin


On Wed, 28 Feb 2024 10:22:42 +1300, Chris Packham wrote:
> Add bindings for a generic 7 segment LED display using GPIOs.
> 
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> 
> Notes:
>     Changes in v2:
>     - Use compatible = "generic-gpio-7seg" to keep checkpatch.pl happy
> 
>  .../auxdisplay/generic-gpio-7seg.yaml         | 40 +++++++++++++++++++
>  1 file changed, 40 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.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:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml: $id: Cannot determine base path from $id, relative path/filename doesn't match actual path or filename
 	 $id: http://devicetree.org/schemas/auxdisplay/generic,gpio-7seg.yaml
 	file: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20240227212244.262710-3-chris.packham@alliedtelesis.co.nz

The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.

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 after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.


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

* Re: [PATCH v2 1/4] auxdisplay: Add 7 segment LED display driver
  2024-02-27 21:22 ` [PATCH v2 1/4] auxdisplay: Add 7 segment LED display driver Chris Packham
  2024-02-27 22:13   ` Randy Dunlap
@ 2024-02-27 23:56   ` Andy Shevchenko
  1 sibling, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2024-02-27 23:56 UTC (permalink / raw)
  To: Chris Packham
  Cc: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel

On Tue, Feb 27, 2024 at 11:22 PM Chris Packham
<chris.packham@alliedtelesis.co.nz> wrote:
>
> Add a driver for a 7 segment LED display. At the moment only one
> character is supported but it should be possible to expand this to
> support more characters and/or 14 segment displays in the future.

As Randy already pointed out
7-segment (everywhere)
14-segment (also everywhere)

...

>  drivers/auxdisplay/seg-led.c | 119 +++++++++++++++++++++++++++++++++++

I believe we want to have a 'gpio' part in the file name and in the Kconfig.


> +config SEG_LED
> +       tristate "Generic 7 segment LED display"
> +       select LINEDISP
> +       help
> +         This driver supports a generic 7 segment LED display made up
> +         of GPIO pins connected to the individual segments.
> +
> +         This driver can also be built as a module. If so, the module
> +         will be called seg-led.

...

> +#include <linux/container_of.h>
> +#include <linux/errno.h>
> +#include <linux/gpio/consumer.h>

> +#include <linux/kernel.h>

Please, avoid proxy headers. I do not believe kernel.h is anyhow used here.

> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/types.h>
> +#include <linux/workqueue.h>

...

> +struct seg_led_priv {
> +       struct gpio_descs *segment_gpios;
> +       struct delayed_work work;

> +       struct linedisp linedisp;

Make it the first member, so container_of() will be noop for this.

> +};

...

> +static void seg_led_update(struct work_struct *work)
> +{
> +       struct seg_led_priv *priv = container_of(work, struct seg_led_priv, work.work);
> +       struct linedisp_map *map = priv->linedisp.map;
> +       DECLARE_BITMAP(values, 8);

> +       values[0] = map_to_seg7(&map->map.seg7, priv->linedisp.buf[0]);

While it works in this case, it's bad code. You need to use
bitmap_set_value8(). And basically that's the API in a for-loop to be
used in case we have more than one digit. This will require another
header to be included.

> +       gpiod_set_array_value_cansleep(priv->segment_gpios->ndescs, priv->segment_gpios->desc,
> +                                      priv->segment_gpios->info, values);
> +}

...

> +static const struct of_device_id seg_led_of_match[] = {
> +       { .compatible = "generic-gpio-7seg"},
> +       {}
> +};
> +MODULE_DEVICE_TABLE(of, seg_led_of_match);

Move this part closer to its user, i.e. struct platform_driver below.

...

> +       INIT_DELAYED_WORK(&priv->work, seg_led_update);

Move this to ->get_map_type() as other drivers do. Yes, I agree that
->get_map_type() is not the best name currently. You can rename it to
->init_and_get_map_type() if you wish (patches are welcome!) or any
other better name.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-27 21:22 ` [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED Chris Packham
  2024-02-27 22:19   ` Rob Herring
@ 2024-02-28  0:03   ` Andy Shevchenko
  2024-02-28  1:53     ` Chris Packham
  2024-02-28 14:04   ` Rob Herring
  2 siblings, 1 reply; 24+ messages in thread
From: Andy Shevchenko @ 2024-02-28  0:03 UTC (permalink / raw)
  To: Chris Packham
  Cc: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel

On Tue, Feb 27, 2024 at 11:22 PM Chris Packham
<chris.packham@alliedtelesis.co.nz> wrote:

...

> +  segment-gpios:
> +    description:
> +      An array of GPIOs one per segment.

This is a vague description. Please explain the order (e.g., LSB =
'a', MSB = 'g'), use of DP (optional?), etc.

> +    minItems: 7

maxItems?

...

> +    led-7seg {

Probably it should be more human readable. DT people might suggest
something better.

> +        compatible = "generic-gpio-7seg";
> +        segment-gpios = <&gpio 0 GPIO_ACTIVE_LOW
> +                         &gpio 1 GPIO_ACTIVE_LOW
> +                         &gpio 2 GPIO_ACTIVE_LOW
> +                         &gpio 3 GPIO_ACTIVE_LOW
> +                         &gpio 4 GPIO_ACTIVE_LOW
> +                         &gpio 5 GPIO_ACTIVE_LOW
> +                         &gpio 6 GPIO_ACTIVE_LOW>;

Dunno how to handle DP. Either we always expect it to be here (as
placeholder) or with additional property.

> +    };

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v2 0/4] auxdisplay: 7 segment LED display
  2024-02-27 21:22 [PATCH v2 0/4] auxdisplay: 7 segment LED display Chris Packham
                   ` (3 preceding siblings ...)
  2024-02-27 21:22 ` [PATCH v2 4/4] ARM: dts: marvell: Indicate USB activity " Chris Packham
@ 2024-02-28  0:05 ` Andy Shevchenko
  2024-02-28  0:25   ` Chris Packham
  4 siblings, 1 reply; 24+ messages in thread
From: Andy Shevchenko @ 2024-02-28  0:05 UTC (permalink / raw)
  To: Chris Packham
  Cc: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel

On Tue, Feb 27, 2024 at 11:22 PM Chris Packham
<chris.packham@alliedtelesis.co.nz> wrote:
>
> This series adds a driver for a 7 segment LED display.
>
> At this point I've decided not to pursue supporting >1 character. I had
> a look at what would be required to add a devm_fwnode_gpiod_get_array()
> and got bogged down in OF and ACPI code for counting GPIOs.

Out of curiosity, why did it happen? gpiod_count() works in an agnostic way.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v2 4/4] ARM: dts: marvell: Indicate USB activity on x530
  2024-02-27 21:22 ` [PATCH v2 4/4] ARM: dts: marvell: Indicate USB activity " Chris Packham
@ 2024-02-28  0:09   ` Andy Shevchenko
  2024-02-28  1:11     ` Chris Packham
  0 siblings, 1 reply; 24+ messages in thread
From: Andy Shevchenko @ 2024-02-28  0:09 UTC (permalink / raw)
  To: Chris Packham
  Cc: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel

On Tue, Feb 27, 2024 at 11:22 PM Chris Packham
<chris.packham@alliedtelesis.co.nz> wrote:
>
> Use the dot on the 7 segment LED block to indicate USB access on the
> x530.

Not sure if it's a good idea. I have some plans for the compressed
format, i.e. use DP for dots (or compatible pieces) so we may print up
to double characters with that (e.g., '6.4.5.3.' as a single string on
a 4-digit display).

That said, I would like to defer this for a while.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v2 3/4] ARM: dts: marvell: Add 7 segment LED display on x530
  2024-02-27 21:22 ` [PATCH v2 3/4] ARM: dts: marvell: Add 7 segment LED display on x530 Chris Packham
@ 2024-02-28  0:12   ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2024-02-28  0:12 UTC (permalink / raw)
  To: Chris Packham
  Cc: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel

On Tue, Feb 27, 2024 at 11:22 PM Chris Packham
<chris.packham@alliedtelesis.co.nz> wrote:
>
> The Allied Telesis x530 products have a 7 segment LED display which is
> used for node identification when the devices are stacked. Represent
> this as a gpio-7seg device.

Please, be consistent with naming and references. I think the
compatible / driver name are the only two that should be used.

This also needs an Ack from the respective maintainer (I don't know
who that is, you might find in MAINTAINERS, though).

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v2 0/4] auxdisplay: 7 segment LED display
  2024-02-28  0:05 ` [PATCH v2 0/4] auxdisplay: 7 segment LED display Andy Shevchenko
@ 2024-02-28  0:25   ` Chris Packham
  2024-02-28 18:45     ` Andy Shevchenko
  0 siblings, 1 reply; 24+ messages in thread
From: Chris Packham @ 2024-02-28  0:25 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel


On 28/02/24 13:05, Andy Shevchenko wrote:
> On Tue, Feb 27, 2024 at 11:22 PM Chris Packham
> <chris.packham@alliedtelesis.co.nz> wrote:
>> This series adds a driver for a 7 segment LED display.
>>
>> At this point I've decided not to pursue supporting >1 character. I had
>> a look at what would be required to add a devm_fwnode_gpiod_get_array()
>> and got bogged down in OF and ACPI code for counting GPIOs.
> Out of curiosity, why did it happen? gpiod_count() works in an agnostic way.
>
At first I though I could create a fwnode_gpiod_count() out of the body 
of gpiod_count(). But both of_gpio_get_count() and acpi_gpio_count() 
take the dev not the fwnode. It looks like gpiod_count() (and 
of_gpio_spi_cs_get_count()) could probably be re-written (or abstracted) 
to take the device_node instead of the device. I started looking at 
acpi_gpio_count() but I couldn't quite see how I could adapt this.

I'm definitely not saying it can't be done. Just that you probably don't 
want an occasional contributor like me messing with some of these core 
device abstractions.

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

* Re: [PATCH v2 4/4] ARM: dts: marvell: Indicate USB activity on x530
  2024-02-28  0:09   ` Andy Shevchenko
@ 2024-02-28  1:11     ` Chris Packham
  0 siblings, 0 replies; 24+ messages in thread
From: Chris Packham @ 2024-02-28  1:11 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel


On 28/02/24 13:09, Andy Shevchenko wrote:
> On Tue, Feb 27, 2024 at 11:22 PM Chris Packham
> <chris.packham@alliedtelesis.co.nz> wrote:
>> Use the dot on the 7 segment LED block to indicate USB access on the
>> x530.
> Not sure if it's a good idea. I have some plans for the compressed
> format, i.e. use DP for dots (or compatible pieces) so we may print up
> to double characters with that (e.g., '6.4.5.3.' as a single string on
> a 4-digit display).
>
> That said, I would like to defer this for a while.
>
In our case this is how we've matched up other devices which have a 3 
LED tower for "power", "fault" and "usb" with devices which have a 
7-segment LED instead. I just wanted to reflect reality in the upstream dts.

It also answers the question "what about the DP LED"?

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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-28  0:03   ` Andy Shevchenko
@ 2024-02-28  1:53     ` Chris Packham
  2024-02-28 17:22       ` Andy Shevchenko
  0 siblings, 1 reply; 24+ messages in thread
From: Chris Packham @ 2024-02-28  1:53 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: andy, geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel

On 28/02/24 13:03, Andy Shevchenko wrote:
> On Tue, Feb 27, 2024 at 11:22 PM Chris Packham
> <chris.packham@alliedtelesis.co.nz> wrote:
>
> ...
>
>> +  segment-gpios:
>> +    description:
>> +      An array of GPIOs one per segment.
> This is a vague description. Please explain the order (e.g., LSB =
> 'a', MSB = 'g'), use of DP (optional?), etc.
>
>> +    minItems: 7
> maxItems?
>
> ...

I plan on saying maxItems: 7 (more discussion below)

>
>> +    led-7seg {
> Probably it should be more human readable. DT people might suggest
> something better.
>
>> +        compatible = "generic-gpio-7seg";
>> +        segment-gpios = <&gpio 0 GPIO_ACTIVE_LOW
>> +                         &gpio 1 GPIO_ACTIVE_LOW
>> +                         &gpio 2 GPIO_ACTIVE_LOW
>> +                         &gpio 3 GPIO_ACTIVE_LOW
>> +                         &gpio 4 GPIO_ACTIVE_LOW
>> +                         &gpio 5 GPIO_ACTIVE_LOW
>> +                         &gpio 6 GPIO_ACTIVE_LOW>;
> Dunno how to handle DP. Either we always expect it to be here (as
> placeholder) or with additional property.

My current plan was to ignore it. As you see it my later patch I'm 
(ab)using DP as a discrete gpio-led with a different function.

We could either a separate dp-gpios property or set maxItems to 8. Right 
now the driver won't do anything with either option.To actually do 
something in the linedisp driver we'd need to have a new character map 
that includes the extra LED.

>> +    };

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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-27 21:22 ` [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED Chris Packham
  2024-02-27 22:19   ` Rob Herring
  2024-02-28  0:03   ` Andy Shevchenko
@ 2024-02-28 14:04   ` Rob Herring
  2024-02-28 14:57     ` Andy Shevchenko
  2024-02-28 20:01     ` Chris Packham
  2 siblings, 2 replies; 24+ messages in thread
From: Rob Herring @ 2024-02-28 14:04 UTC (permalink / raw)
  To: Chris Packham
  Cc: andy, geert, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel

On Wed, Feb 28, 2024 at 10:22:42AM +1300, Chris Packham wrote:
> Add bindings for a generic 7 segment LED display using GPIOs.
> 
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> 
> Notes:
>     Changes in v2:
>     - Use compatible = "generic-gpio-7seg" to keep checkpatch.pl happy
> 
>  .../auxdisplay/generic-gpio-7seg.yaml         | 40 +++++++++++++++++++
>  1 file changed, 40 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml
> 
> diff --git a/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml b/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml
> new file mode 100644
> index 000000000000..46d53ebdf413
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml
> @@ -0,0 +1,40 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/auxdisplay/generic,gpio-7seg.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: GPIO based LED segment display
> +
> +maintainers:
> +  - Chris Packham <chris.packham@alliedtelesis.co.nz>
> +
> +properties:
> +  compatible:
> +    const: generic-gpio-7seg

'generic' doesn't add anything of value. 7seg is kind of vague. So, 
gpio-7-segment?


> +
> +  segment-gpios:
> +    description:
> +      An array of GPIOs one per segment.
> +    minItems: 7

How does one know which GPIO is which segment?

Rob

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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-28 14:04   ` Rob Herring
@ 2024-02-28 14:57     ` Andy Shevchenko
  2024-02-29  9:23       ` Geert Uytterhoeven
  2024-02-28 20:01     ` Chris Packham
  1 sibling, 1 reply; 24+ messages in thread
From: Andy Shevchenko @ 2024-02-28 14:57 UTC (permalink / raw)
  To: Rob Herring
  Cc: Chris Packham, andy, geert, krzysztof.kozlowski+dt, conor+dt,
	andrew, gregory.clement, sebastian.hesselbarth, ojeda,
	tzimmermann, javierm, robin, lee, pavel, devicetree, linux-leds,
	linux-kernel, linux-arm-kernel

On Wed, Feb 28, 2024 at 4:04 PM Rob Herring <robh@kernel.org> wrote:
> On Wed, Feb 28, 2024 at 10:22:42AM +1300, Chris Packham wrote:

...

> > +  segment-gpios:
> > +    description:
> > +      An array of GPIOs one per segment.
> > +    minItems: 7
>
> How does one know which GPIO is which segment?

I believe we need just to agree on this. Since anybody can shuffle
GPIOs in the DT, there is no need to support arbitrary orders. And
naturally 'a' is bit 0, 'g' is bit 6, 'dp' bit 7 if present.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-28  1:53     ` Chris Packham
@ 2024-02-28 17:22       ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2024-02-28 17:22 UTC (permalink / raw)
  To: Chris Packham
  Cc: geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel

On Wed, Feb 28, 2024 at 01:53:08AM +0000, Chris Packham wrote:
> On 28/02/24 13:03, Andy Shevchenko wrote:
> > On Tue, Feb 27, 2024 at 11:22 PM Chris Packham
> > <chris.packham@alliedtelesis.co.nz> wrote:

...

> >> +  segment-gpios:
> >> +    description:
> >> +      An array of GPIOs one per segment.
> > This is a vague description. Please explain the order (e.g., LSB =
> > 'a', MSB = 'g'), use of DP (optional?), etc.
> >
> >> +    minItems: 7
> > maxItems?

> I plan on saying maxItems: 7 (more discussion below)

...

> >> +    led-7seg {
> > Probably it should be more human readable. DT people might suggest
> > something better.
> >
> >> +        compatible = "generic-gpio-7seg";
> >> +        segment-gpios = <&gpio 0 GPIO_ACTIVE_LOW
> >> +                         &gpio 1 GPIO_ACTIVE_LOW
> >> +                         &gpio 2 GPIO_ACTIVE_LOW
> >> +                         &gpio 3 GPIO_ACTIVE_LOW
> >> +                         &gpio 4 GPIO_ACTIVE_LOW
> >> +                         &gpio 5 GPIO_ACTIVE_LOW
> >> +                         &gpio 6 GPIO_ACTIVE_LOW>;
> > Dunno how to handle DP. Either we always expect it to be here (as
> > placeholder) or with additional property.
> 
> My current plan was to ignore it. As you see it my later patch I'm 
> (ab)using DP as a discrete gpio-led with a different function.

FWIW, I have _no_ indicator _without_ DP. So, my statistics is towards enabling
DP as a part of 7-segment displays.

> We could either a separate dp-gpios property or set maxItems to 8. Right 
> now the driver won't do anything with either option.To actually do 
> something in the linedisp driver we'd need to have a new character map 
> that includes the extra LED.

Yeah, we can leave it open for now.

> >> +    };

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 0/4] auxdisplay: 7 segment LED display
  2024-02-28  0:25   ` Chris Packham
@ 2024-02-28 18:45     ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2024-02-28 18:45 UTC (permalink / raw)
  To: Chris Packham
  Cc: geert, robh+dt, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel

On Wed, Feb 28, 2024 at 12:25:30AM +0000, Chris Packham wrote:
> 
> On 28/02/24 13:05, Andy Shevchenko wrote:
> > On Tue, Feb 27, 2024 at 11:22 PM Chris Packham
> > <chris.packham@alliedtelesis.co.nz> wrote:
> >> This series adds a driver for a 7 segment LED display.
> >>
> >> At this point I've decided not to pursue supporting >1 character. I had
> >> a look at what would be required to add a devm_fwnode_gpiod_get_array()
> >> and got bogged down in OF and ACPI code for counting GPIOs.
> > Out of curiosity, why did it happen? gpiod_count() works in an agnostic way.
> >
> At first I though I could create a fwnode_gpiod_count() out of the body 
> of gpiod_count(). But both of_gpio_get_count() and acpi_gpio_count() 
> take the dev not the fwnode. It looks like gpiod_count() (and 
> of_gpio_spi_cs_get_count()) could probably be re-written (or abstracted) 
> to take the device_node instead of the device. I started looking at 
> acpi_gpio_count() but I couldn't quite see how I could adapt this.
> 
> I'm definitely not saying it can't be done. Just that you probably don't 
> want an occasional contributor like me messing with some of these core 
> device abstractions.

I just sent a series. With it you may split gpiod_count() to
fwnode_gpio_count() and gpiod_count() that uses the former.
I believe you may do that easily as it won't require any special
knowledge.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-28 14:04   ` Rob Herring
  2024-02-28 14:57     ` Andy Shevchenko
@ 2024-02-28 20:01     ` Chris Packham
  2024-02-29  9:24       ` Geert Uytterhoeven
  1 sibling, 1 reply; 24+ messages in thread
From: Chris Packham @ 2024-02-28 20:01 UTC (permalink / raw)
  To: Rob Herring
  Cc: andy, geert, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel


On 29/02/24 03:04, Rob Herring wrote:
> On Wed, Feb 28, 2024 at 10:22:42AM +1300, Chris Packham wrote:
>> Add bindings for a generic 7 segment LED display using GPIOs.
>>
>> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
>> ---
>>
>> Notes:
>>      Changes in v2:
>>      - Use compatible = "generic-gpio-7seg" to keep http://scanmail.trustwave.com/?c=20988&d=7b3f5fUJGtY-Kala5ZOOxaOVYt2BwN-ZLskYi3hWDQ&u=http%3a%2f%2fcheckpatch%2epl happy
>>
>>   .../auxdisplay/generic-gpio-7seg.yaml         | 40 +++++++++++++++++++
>>   1 file changed, 40 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml b/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml
>> new file mode 100644
>> index 000000000000..46d53ebdf413
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/auxdisplay/generic-gpio-7seg.yaml
>> @@ -0,0 +1,40 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://scanmail.trustwave.com/?c=20988&d=7b3f5fUJGtY-Kala5ZOOxaOVYt2BwN-ZLsYdhCQAWQ&u=http%3a%2f%2fdevicetree%2eorg%2fschemas%2fauxdisplay%2fgeneric%2cgpio-7seg%2eyaml%23
>> +$schema: http://scanmail.trustwave.com/?c=20988&d=7b3f5fUJGtY-Kala5ZOOxaOVYt2BwN-ZLsYY0X9WDg&u=http%3a%2f%2fdevicetree%2eorg%2fmeta-schemas%2fcore%2eyaml%23
>> +
>> +title: GPIO based LED segment display
>> +
>> +maintainers:
>> +  - Chris Packham <chris.packham@alliedtelesis.co.nz>
>> +
>> +properties:
>> +  compatible:
>> +    const: generic-gpio-7seg
> 'generic' doesn't add anything of value. 7seg is kind of vague. So,
> gpio-7-segment?

Ack.

>> +
>> +  segment-gpios:
>> +    description:
>> +      An array of GPIOs one per segment.
>> +    minItems: 7
> How does one know which GPIO is which segment?

I've expanded the description in v3.

+ An array of GPIOs one per segment. The first GPIO corresponds to the A
+ segment the last GPIO corresponds to the G segment.

Do you think that's sufficient or do I need to add more? In the driver 
itself I've put a little ascii art diagram of the segments.

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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-28 14:57     ` Andy Shevchenko
@ 2024-02-29  9:23       ` Geert Uytterhoeven
  2024-02-29 10:42         ` Andy Shevchenko
  0 siblings, 1 reply; 24+ messages in thread
From: Geert Uytterhoeven @ 2024-02-29  9:23 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rob Herring, Chris Packham, andy, krzysztof.kozlowski+dt,
	conor+dt, andrew, gregory.clement, sebastian.hesselbarth, ojeda,
	tzimmermann, javierm, robin, lee, pavel, devicetree, linux-leds,
	linux-kernel, linux-arm-kernel

Hi Andy,

On Wed, Feb 28, 2024 at 3:58 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Wed, Feb 28, 2024 at 4:04 PM Rob Herring <robh@kernel.org> wrote:
> > On Wed, Feb 28, 2024 at 10:22:42AM +1300, Chris Packham wrote:
>
> ...
>
> > > +  segment-gpios:
> > > +    description:
> > > +      An array of GPIOs one per segment.
> > > +    minItems: 7
> >
> > How does one know which GPIO is which segment?
>
> I believe we need just to agree on this. Since anybody can shuffle
> GPIOs in the DT, there is no need to support arbitrary orders. And
> naturally 'a' is bit 0, 'g' is bit 6, 'dp' bit 7 if present.

Note that there are no bits involved at this level, only GPIO specifiers.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-28 20:01     ` Chris Packham
@ 2024-02-29  9:24       ` Geert Uytterhoeven
  2024-02-29 10:44         ` andy
  0 siblings, 1 reply; 24+ messages in thread
From: Geert Uytterhoeven @ 2024-02-29  9:24 UTC (permalink / raw)
  To: Chris Packham
  Cc: Rob Herring, andy, krzysztof.kozlowski+dt, conor+dt, andrew,
	gregory.clement, sebastian.hesselbarth, ojeda, tzimmermann,
	javierm, robin, lee, pavel, devicetree, linux-leds, linux-kernel,
	linux-arm-kernel

Hi Chris,

On Wed, Feb 28, 2024 at 9:02 PM Chris Packham
<Chris.Packham@alliedtelesis.co.nz> wrote:
> On 29/02/24 03:04, Rob Herring wrote:
> > On Wed, Feb 28, 2024 at 10:22:42AM +1300, Chris Packham wrote:
> >> +  segment-gpios:
> >> +    description:
> >> +      An array of GPIOs one per segment.
> >> +    minItems: 7
> > How does one know which GPIO is which segment?
>
> I've expanded the description in v3.
>
> + An array of GPIOs one per segment. The first GPIO corresponds to the A
> + segment the last GPIO corresponds to the G segment.
>
> Do you think that's sufficient or do I need to add more? In the driver
> itself I've put a little ascii art diagram of the segments.

Given users are reading the bindings rather than the driver source,
I would move the diagram to the bindings.

Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-29  9:23       ` Geert Uytterhoeven
@ 2024-02-29 10:42         ` Andy Shevchenko
  0 siblings, 0 replies; 24+ messages in thread
From: Andy Shevchenko @ 2024-02-29 10:42 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Rob Herring, Chris Packham, krzysztof.kozlowski+dt, conor+dt,
	andrew, gregory.clement, sebastian.hesselbarth, ojeda,
	tzimmermann, javierm, robin, lee, pavel, devicetree, linux-leds,
	linux-kernel, linux-arm-kernel

On Thu, Feb 29, 2024 at 10:23:15AM +0100, Geert Uytterhoeven wrote:
> On Wed, Feb 28, 2024 at 3:58 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Wed, Feb 28, 2024 at 4:04 PM Rob Herring <robh@kernel.org> wrote:
> > > On Wed, Feb 28, 2024 at 10:22:42AM +1300, Chris Packham wrote:

...

> > > > +  segment-gpios:
> > > > +    description:
> > > > +      An array of GPIOs one per segment.
> > > > +    minItems: 7
> > >
> > > How does one know which GPIO is which segment?
> >
> > I believe we need just to agree on this. Since anybody can shuffle
> > GPIOs in the DT, there is no need to support arbitrary orders. And
> > naturally 'a' is bit 0, 'g' is bit 6, 'dp' bit 7 if present.
> 
> Note that there are no bits involved at this level, only GPIO specifiers.

Right, I meant the sequence in the array of GPIOs in the DT.
I implied that it maps 1:1 to the real bits in HW (in some cases).

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED
  2024-02-29  9:24       ` Geert Uytterhoeven
@ 2024-02-29 10:44         ` andy
  0 siblings, 0 replies; 24+ messages in thread
From: andy @ 2024-02-29 10:44 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Chris Packham, Rob Herring, krzysztof.kozlowski+dt, conor+dt,
	andrew, gregory.clement, sebastian.hesselbarth, ojeda,
	tzimmermann, javierm, robin, lee, pavel, devicetree, linux-leds,
	linux-kernel, linux-arm-kernel

On Thu, Feb 29, 2024 at 10:24:33AM +0100, Geert Uytterhoeven wrote:
> On Wed, Feb 28, 2024 at 9:02 PM Chris Packham
> <Chris.Packham@alliedtelesis.co.nz> wrote:
> > On 29/02/24 03:04, Rob Herring wrote:
> > > On Wed, Feb 28, 2024 at 10:22:42AM +1300, Chris Packham wrote:

...

> > > How does one know which GPIO is which segment?
> >
> > I've expanded the description in v3.
> >
> > + An array of GPIOs one per segment. The first GPIO corresponds to the A
> > + segment the last GPIO corresponds to the G segment.
> >
> > Do you think that's sufficient or do I need to add more? In the driver
> > itself I've put a little ascii art diagram of the segments.
> 
> Given users are reading the bindings rather than the driver source,
> I would move the diagram to the bindings.

+1 here. We have a diagram already in UAPI headers, but that won't be (quickly)
visible for the real users, duplicating in the code doesn't add any value, but
adding it to DT description will be beneficial.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2024-02-29 10:44 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-27 21:22 [PATCH v2 0/4] auxdisplay: 7 segment LED display Chris Packham
2024-02-27 21:22 ` [PATCH v2 1/4] auxdisplay: Add 7 segment LED display driver Chris Packham
2024-02-27 22:13   ` Randy Dunlap
2024-02-27 23:56   ` Andy Shevchenko
2024-02-27 21:22 ` [PATCH v2 2/4] dt-bindings: auxdisplay: Add bindings for generic 7 segment LED Chris Packham
2024-02-27 22:19   ` Rob Herring
2024-02-28  0:03   ` Andy Shevchenko
2024-02-28  1:53     ` Chris Packham
2024-02-28 17:22       ` Andy Shevchenko
2024-02-28 14:04   ` Rob Herring
2024-02-28 14:57     ` Andy Shevchenko
2024-02-29  9:23       ` Geert Uytterhoeven
2024-02-29 10:42         ` Andy Shevchenko
2024-02-28 20:01     ` Chris Packham
2024-02-29  9:24       ` Geert Uytterhoeven
2024-02-29 10:44         ` andy
2024-02-27 21:22 ` [PATCH v2 3/4] ARM: dts: marvell: Add 7 segment LED display on x530 Chris Packham
2024-02-28  0:12   ` Andy Shevchenko
2024-02-27 21:22 ` [PATCH v2 4/4] ARM: dts: marvell: Indicate USB activity " Chris Packham
2024-02-28  0:09   ` Andy Shevchenko
2024-02-28  1:11     ` Chris Packham
2024-02-28  0:05 ` [PATCH v2 0/4] auxdisplay: 7 segment LED display Andy Shevchenko
2024-02-28  0:25   ` Chris Packham
2024-02-28 18:45     ` Andy Shevchenko

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).