Re: [TECH TOPIC] Rust for Linux

Linus Walleij
2021-07-08T22:13:38Z

On Thu, Jul 8, 2021 at 10:34 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
> On Thu, Jul 8, 2021 at 9:49 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> > With my GPIO maintainer hat on I'd say a GPIO driver would be quite
> > interesting to look at. We are two GPIO maintainers and Bartosz is
> > doing the heavy lifting for the moment so I'm connecting Bartosz to this
> > discussion. (Now he has to read through the whole backlog,
> > sorry Bart!)
> >
> > This is not to say I promise we will merge it or so, but I just generically
> > like new approaches to old problems so I like this whole thing
> > overall, despite being critical to some details.
> >
> > I am also trying to learn Rust. Baby steps.
>
> Thanks a lot for this offer Linus.
>
> Do you have a particular one in mind? Ideally, it would be one that
> has QEMU support or a test suite of some kind, or at least one that
> you can easily test for us etc.

I don't use QEMU for GPIO development, we are so close to the
real hardware that it's often not appropriate. We have a testing
module but that is not a real world driver and would not meet the
expectations set here of creating real hardware drivers.

I have seen that QEMU has a piece of code for the Arm PrimeCell
PL061 GPIO block which corresponds to drivers/gpio/gpio-pl061.c
Note that this hardware apart from being used in all Arm reference
designs is used on ARMv4T systems that are not supported by
LLVM but only GCC, which might complicate things.

I am a bit oldschool in that I think real hardware is awesome to test
on. GPIO drivers exist in many shapes and sizes, some are directly
memory-mapped to hardware registers, some are I2C or SPI.
Most Raspberry Pis and Beagle Boards have them, albeit the
on-chip GPIOs are often also pin controllers which complicates
things. Expanders on I2C and SPI will be simpler. Maybe look
for an I2C or SPI expander that has no existing kernel support and
implement it in Rust?

Yours,
Linus Walleij