Re: [PATCH] r8a77995 Draak SCIF0 LED and KEY Serdev prototype

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Geert,

On Mon, Nov 22, 2021 at 5:02 PM Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
>
> 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!

Thanks! I've been meaning to look into serdev for a while now and
scratching an itch like this is one way to get acquainted with the
code base.

> > --- 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?

In this patch indeed they are, yes. It is quite possible to enable
both LED and key in the DTS today, but during runtime I could not get
both drivers to load.

As you say, the three signals into the SoC (instead of 1) is currently
working around a hardware limitation. The mutual-exclusiveness with
one serdev driver enabled out of two is however working around a
software limitation. It seems that there is room for improvement both
on the hardware and the software side.

The main reason for the software limitation seems to be that currently
the serdev core does not support more than one driver at a time, see
"controller busy" error statement in:
https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git/tree/drivers/tty/serdev/core.c?h=renesas-drivers-2021-11-16-v5.16-rc1

To be honest, my approach of two serdev drivers in parallel with one
serial port device might not exactly be how multi-device support with
serdev was envisioned. At the same time I can't really imagine what
more of a sane multi-device serdev use case would be. Any ideas?

Cheers,

/ magnus



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux