On 23/02/24 11:13, Andy Shevchenko wrote: > On Fri, Feb 23, 2024 at 12:08 AM Chris Packham > <Chris.Packham@xxxxxxxxxxxxxxxxxxx> wrote: >> On 23/02/24 10:59, Andy Shevchenko wrote: >>> On Thu, Feb 22, 2024 at 11:53 PM Chris Packham >>> <Chris.Packham@xxxxxxxxxxxxxxxxxxx> wrote: >>>> On 23/02/24 10:34, andy.shevchenko@xxxxxxxxx wrote: >>>>> Sun, Feb 11, 2024 at 08:46:12PM +0000, Chris Packham kirjoitti: >>>>>> Hi Blinkenlight enthusiasts, >>>>>> >>>>>> I'm looking for something that I figured must exists but maybe it's so >>>>>> niche that no-one has bothered to upstream a driver for it. >>>>>> >>>>>> I have a requirement to support a 7-segment LED display[1] (one that can >>>>>> display a single digit from 0-9). Hardware wise it's just a bunch of >>>>>> individual GPIOs connected to each segment (plus an extra one for a >>>>>> dot). I can't see anything obvious in drivers/leds but maybe I'm looking >>>>>> in the wrong place. Or maybe it's the kind of thing on PC hardware that >>>>>> is just driven by the BIOS without the operating system knowing about it. >>>>>> >>>>>> Is there an existing in-kernel driver for such a thing? >>>>> No, and can't be. Here is just a mapping table and other drivers that use >>>>> 7-segment LED displays to be connected to. >>>>> >>>>> What you need is something else, i.e. special case of leds-gpio (which should >>>>> be somewhere else) that does something like this. To me it sounds like a >>>>> mixture between line-display.h (from auxdisplay) and gpio-aggregator. >>>>> >>>>> How many digits do you want to connect? How are they going to be connected >>>>> (static display, or dynamic when you need to refresh in certain periods of >>>>> time)? Depending on the answer it might take one or another approach. >>>> It sounds like a auxdisplay driver might be the way to go. My hardware >>>> happens to have a single 7seg block but there's no reason the driver >>>> needs to be restricted to that. At some point it obviously becomes >>>> better to fit something like the ht16k33 to offload the character >>>> display but for one or 2 digits a PCA953x plus the LED block would do >>>> just fine. >>> I have hc595 (SPI GPIO) connected to a single digit 7-segment LED. >>> Since it can be also serialized, line display APIs seem plausible to >>> fit. What we need is a proxy between the two. And I think >>> gpio-aggregator is the best for that. It needs an additional >>> compatible string and the registration for line display (overall >>> something like 50 LoCs). We can even call that hardware compatible as >>> line-display-gpio (or so). >>> >>> Cc: Geert and Krzysztof (for the comments on the idea above). >> Would the gpio-aggregator be necessary? > Probably not. we just need to consume GPIOs, no need to provide... > >> I was thinking something like >> this in the devicetree >> >> \{ >> led-7seg { >> compatible = "kingbright,sa36"; >> seg-gpios = <&gpioN 0 GPIO_ACTIVE_HIGH>, >> <&gpioN 1 GPIO_ACTIVE_HIGH>, >> <&gpioN 2 GPIO_ACTIVE_HIGH>, >> <&gpioN 3 GPIO_ACTIVE_HIGH>, >> <&gpioN 4 GPIO_ACTIVE_HIGH>, >> <&gpioN 5 GPIO_ACTIVE_HIGH>, >> <&gpioN 6 GPIO_ACTIVE_HIGH>; >> }; >> }; > Right, but also with some additional properties, like > - type of the indicator (7, 14, etc segments, for now we have only > these two supported) > - use-dot (+1 led per each digit) > - characters (how many digits we have, so we need respective amount of GPIOs) > > With this it's indeed belongs directly to auxdisplay as we have almost > everything is done already there. I've been playing about with this. I've got an auxdisplay driver that's basically working (I won't bother spamming list with it yet). But I'm wondering how I'd represent multiple characters. I kind of feel the natural representation would be something like. led-7seg { compatible = "generic,7-segment-on-gpio"; char-0 { 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>; }; char-1 { segment-gpios = <&gpio 8 GPIO_ACTIVE_LOW &gpio 9 GPIO_ACTIVE_LOW &gpio 10 GPIO_ACTIVE_LOW &gpio 11 GPIO_ACTIVE_LOW &gpio 12 GPIO_ACTIVE_LOW &gpio 13 GPIO_ACTIVE_LOW &gpio 14 GPIO_ACTIVE_LOW>; }; }; But having those sub-nodes means I can't just use devm_gpiod_get_array() instead I'd have to use device_for_each_child_node() and devm_fwnode_gpiod_get_index(). Am I missing something? I could do away with the sub-nodes and have properties like "segment-0-gpios", "segment-1-gpios" but that feels awkward. > >>>> The information we want to display is mostly static (basically a numeric >>>> unit identifier) but there are cases where we may want to alternate >>>> between this and "F" to indicate some fault condition