Thread (50 messages) 50 messages, 8 authors, 2021-10-19

Re: [PATCH v1 12/16] pinctrl: starfive: Add pinctrl driver for StarFive SoCs

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2021-10-13 17:50:49
Also in: linux-clk, linux-gpio, linux-riscv, linux-serial, lkml

On Wed, Oct 13, 2021 at 6:58 PM Andy Shevchenko
[off-list ref] wrote:
On Wed, Oct 13, 2021 at 06:38:14PM +0200, Emil Renner Berthing wrote:
quoted
On Tue, 12 Oct 2021 at 19:03, Andy Shevchenko [off-list ref] wrote:
quoted
On Tue, Oct 12, 2021 at 4:43 PM Emil Renner Berthing [off-list ref] wrote:
quoted
quoted
quoted
+               v = pinmux[i];
+               dout = ((v & BIT(7)) << (31 - 7)) | ((v >> 24) & 0xffU);
+               doen = ((v & BIT(6)) << (31 - 6)) | ((v >> 16) & 0xffU);
+               din  = (v >> 8) & 0xffU;
What is this voodoo for?
In order to do pinmux we need the following pieces of information from
the device tree for each pin ("GPIO" they call it):

output signal: 0-133 + 1bit reverse flag
output enable signal: 0-133 + 1bit reverse flag
optional input signal: 0-74 + special "none" value, right now 0xff
gpio number: 0-63

As the code is now all that info is packed into a u32 for each pin
using the GPIOMUX macro defined in the dt-binding header added in
patch 10. There is also a diagram for how this packing is done. The
above voodoo is for unpacking that.

I'd very much like to hear if you have a better solution for how to
convey that information from the device tree to here.
At very least this code should have something like above in the comment.
And perhaps introduce some helper macros to access the fields?

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help