Hi Magnus, On Sat, Nov 20, 2021 at 5:32 PM Magnus Damm <damm@xxxxxxxxxxxxx> wrote: > From: Magnus Damm <damm+renesas@xxxxxxxxxxxxx> > > Here's a work-in-progress patch for shared pin LED and KEY functionality: > - UART TX Serdev LED driver prototype (functional) > - UART RX Serdev KEY driver prototype (partial) > - r8a77995 Draak DTS modifications to use above drivers with SCIF0 > > With this code my hope is to use hardware to drive an LED and allow > detection of a key press without software performing any kind of polling. > > In theory on SoCs that support UART RX and TX on the same pin (and also > open drain output) with the above software it is possible to handle boards > with single pin shared LED and KEY functionality. > > This prototype on r8a77995 Draak makes use of 3 pins and an external circuit: > - LED13/SW59/GP4_07 <-> EXIO_A:10 (CN46) > - SCIF0_RX/GP4_20 <- EXIO_A:38 (CN46) > - SCIF0_TX/GP4_21 -> EXIO_A:36 (CN46) > Ether-AVB PHY connector (CN23) has 3.3V on pin 54 and 56 and GND on 14 > In the future SCIF1 and SCIF3 may also be used for other LEDs and switches. > > Currently two inverters on SN74HC05 together with pull-ups are used to extend > the D3 SoC and the Draak board with open drain functionality and also tie > together the TX and RX pins with LED13/SW59. > > The prototype LED driver allows user space to turn on/off the LED using: > # echo 1 > /sys/class/leds/serial0-0/brightness > # echo 0 > /sys/class/leds/serial0-0/brightness > Must be easy to extend the driver with some degree of brightness control. > > Apart from some general brush up the following issues have surfaced: > - "controller busy" error happens when more than one serdev is used > - it is unclear how to take RX errors from serdev and generate key events > - there seem to be no way to silence "sh-sci e6e60000.serial: frame error" > - the DTS "current-speed" property looks like sw config and not hw description > > Obviously not for upstream merge as-is. Might however be useful as SCIF error > test bench and/or as potential (corner) use case for serdev. > > Not-Yet-Signed-off-by: Magnus Damm <damm+renesas@xxxxxxxxxxxxx> Thanks for your patch, which is definitely an interesting approach! > --- 0001/arch/arm64/boot/dts/renesas/r8a77995-draak.dts > +++ work/arch/arm64/boot/dts/renesas/r8a77995-draak.dts 2021-11-20 23:47:14.965609878 +0900 > @@ -479,13 +495,29 @@ > status = "okay"; > }; > > +&scif0 { > + pinctrl-0 = <&scif0_pins>; > + pinctrl-names = "default"; > + > + status = "okay"; > +#if 1 > + led { > + compatible = "serdev,led"; > + current-speed = <9600>; > + }; > +#else > + key { > + compatible = "serdev,key"; > + current-speed = <9600>; > + }; > +#endif So LED and key are still mutually-exclusive, despite using 3 signals into the SoC? > +}; Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx 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