mbox series

[v3,00/14] pinctrl: add BCM63XX pincontrol support

Message ID 20210303142310.6371-1-noltari@gmail.com
Headers show
Series pinctrl: add BCM63XX pincontrol support | expand

Message

Álvaro Fernández Rojas March 3, 2021, 2:22 p.m. UTC
First of all, I've based this on the patches sent by Jonas Gorski back in
2016:
https://www.spinics.net/lists/linux-gpio/msg15983.html
http://patchwork.ozlabs.org/project/linux-gpio/patch/1471604025-21575-2-git-send-email-jonas.gorski@gmail.com/

I've tried to address all coments from Linus Walleij, but I know that
this may still need some other modifications

This patchset adds appropriate binding documentation and drivers for
pin controller cores found in the BCM63XX MIPS SoCs currently supported.

While the GPIO part is always the same, the pinmux part varies quite a
lot between different SoCs. Sometimes they have defined groups which
can be muxed into different functions, sometimes each function has a
different group. Sometimes you can mux individual pins. Often it is a
combination of single pins and groups.

Some core versions require the GPIO direction to be set according to the
function, most do not. Sometimes the mux register(s) contain bits for
unrelated other functions.

v3: introduce new files for shared code and add more changes suggested by
 Linus Walleij. Also add a new patch needed for properly parsing gpio-ranges.
v2: introduce changes suggested by Linus Walleij and remove interrupts
 - In order to use GPIO_REGMAP, the need to get gpio_chip from gpio_regmap
 and use it for pinctrl_add_gpio_range() and gpio_chip.direction_input()
 and gpio_chip.direction_output().

Álvaro Fernández Rojas (14):
  gpio: regmap: set gpio_chip of_node
  pinctrl: bcm: add bcm63xx base code
  Documentation: add BCM6328 pincontroller binding documentation
  pinctrl: add a pincontrol driver for BCM6328
  Documentation: add BCM6358 pincontroller binding documentation
  pinctrl: add a pincontrol driver for BCM6358
  Documentation: add BCM6362 pincontroller binding documentation
  pinctrl: add a pincontrol driver for BCM6362
  Documentation: add BCM6368 pincontroller binding documentation
  pinctrl: add a pincontrol driver for BCM6368
  Documentation: add BCM63268 pincontroller binding documentation
  pinctrl: add a pincontrol driver for BCM63268
  Documentation: add BCM6318 pincontroller binding documentation
  pinctrl: add a pincontrol driver for BCM6318

 .../pinctrl/brcm,bcm6318-pinctrl.yaml         | 187 +++++
 .../pinctrl/brcm,bcm63268-pinctrl.yaml        | 208 ++++++
 .../pinctrl/brcm,bcm6328-pinctrl.yaml         | 171 +++++
 .../pinctrl/brcm,bcm6358-pinctrl.yaml         | 137 ++++
 .../pinctrl/brcm,bcm6362-pinctrl.yaml         | 250 +++++++
 .../pinctrl/brcm,bcm6368-pinctrl.yaml         | 261 +++++++
 drivers/gpio/gpio-regmap.c                    |   1 +
 drivers/pinctrl/bcm/Kconfig                   |  57 ++
 drivers/pinctrl/bcm/Makefile                  |   7 +
 drivers/pinctrl/bcm/pinctrl-bcm6318.c         | 496 ++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm63268.c        | 643 ++++++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm6328.c         | 403 +++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm6358.c         | 369 ++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm6362.c         | 617 +++++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm6368.c         | 523 ++++++++++++++
 drivers/pinctrl/bcm/pinctrl-bcm63xx.c         | 113 +++
 drivers/pinctrl/bcm/pinctrl-bcm63xx.h         |  46 ++
 include/linux/gpio/regmap.h                   |   3 +
 18 files changed, 4492 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6318-pinctrl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm63268-pinctrl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6358-pinctrl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6362-pinctrl.yaml
 create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6368-pinctrl.yaml
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6318.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63268.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6328.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6358.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6362.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6368.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63xx.c
 create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63xx.h

Comments

Linus Walleij March 3, 2021, 3:27 p.m. UTC | #1
On Wed, Mar 3, 2021 at 3:23 PM Álvaro Fernández Rojas <noltari@gmail.com> wrote:

> This is needed for properly registering gpio regmap as a child of a regmap
> pin controller.
>
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  v3: introduce patch needed for properly parsing gpio-ranges.

Oops a little bug. I suggest that I merge this into the pinctrl tree
together with the rest of the patches when we are done with review.

Yours.
Linus Walleij
Michael Walle March 3, 2021, 3:39 p.m. UTC | #2
Am 2021-03-03 16:27, schrieb Linus Walleij:
> On Wed, Mar 3, 2021 at 3:23 PM Álvaro Fernández Rojas 
> <noltari@gmail.com> wrote:
> 
>> This is needed for properly registering gpio regmap as a child of a 
>> regmap
>> pin controller.
>> 
>> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
>> ---
>>  v3: introduce patch needed for properly parsing gpio-ranges.
> 
> Oops a little bug. I suggest that I merge this into the pinctrl tree
> together with the rest of the patches when we are done with review.

Ha, I've just debugged this because it puzzled me why it was working
for me.

I was about to suggesting using the following instead:
chip->of_node = config->of_node ?: dev_of_node(config->parent);

It turns out this is already done in of_gpio_dev_init():
https://elixir.bootlin.com/linux/v5.12-rc1/source/drivers/gpio/gpiolib-of.c#L1043

So config->of_node is still optional. But I'm not sure if we
should add the line above for clarity in gpio-regmap.c.

-michael
Álvaro Fernández Rojas March 3, 2021, 4:23 p.m. UTC | #3
Hi Linus,

> El 3 mar 2021, a las 16:29, Linus Walleij <linus.walleij@linaro.org> escribió:
> 
> On Wed, Mar 3, 2021 at 3:23 PM Álvaro Fernández Rojas <noltari@gmail.com> wrote:
> 
>> v3: introduce new files for shared code and add more changes suggested by
>> Linus Walleij. Also add a new patch needed for properly parsing gpio-ranges.
> 
> This looks very appetizing, I am ready to merge this once we cut some
> slack for DT review (a week or two).
> 
> I'd like to merge it soon so you can start working on the IRQ add-on.
> 
> I'd probably drop the IRQ-related selects from Kconfig
> when applying though (no big deal, no need to resend over that).

About that, it seems that GPIO_REGMAP should select GPIOLIB_IRQCHIP, since I couldn’t build the kernel due to the following error when I removed the IRQ-related selects:
  LD      vmlinux.o
  MODPOST vmlinux.symvers
  MODINFO modules.builtin.modinfo
  GEN     modules.builtin
  LD      .tmp_vmlinux.kallsyms1
mips-linux-gnu-ld: drivers/gpio/gpio-regmap.o: in function `gpio_regmap_register':
gpio-regmap.c:(.text+0x704): undefined reference to `gpiochip_irqchip_add_domain'
make: *** [Makefile:1197: vmlinux] Error 1

Or maybe we could guard these lines of gpio-regmap.c with #ifdef GPIOLIB_IRQCHIP:
https://github.com/torvalds/linux/blob/f69d02e37a85645aa90d18cacfff36dba370f797/drivers/gpio/gpio-regmap.c#L282-L286

> 
> Yours,
> Linus Walleij

Best regards,
Álvaro.
Linus Walleij March 4, 2021, 8:13 a.m. UTC | #4
On Wed, Mar 3, 2021 at 5:12 PM Álvaro Fernández Rojas <noltari@gmail.com> wrote:

> Do you want me to send v4 with these changes?
> Or maybe just this single patch?

It's usually better to resend the series because then the b4 tool
will pick it all up properly.

Yours,
Linus Walleij