mbox series

[0/2] pinctrl: renesas: rcar-gen4: Fix GPIO function on I2C-capable pins

Message ID cover.1650610471.git.geert+renesas@glider.be
Headers show
Series pinctrl: renesas: rcar-gen4: Fix GPIO function on I2C-capable pins | expand

Message

Geert Uytterhoeven April 22, 2022, 7:29 a.m. UTC
Hi all,

Configuring I2C-capable pins for GPIO may not work on R-Car V3U and
S4-8, as R-Car Gen4 SoCs need additional configuration in a Module
Select Register (MODSELn) register, which is currently missing from the
pin control subdrivers.

Hence when using i2c-gpio instead of i2c-rcar using the commented-out
patch below, I2C
  - fails on the Spider development board (with R-Car S4-8), as the
    firmware/bootloader has configured the corresponding MODSEL bits for
    I2C,
  - still works on the Falcon development board (with R-Car V3U), as the
    firmware/bootloader has configured the corresponding MODSEL bits for
    GPIO.
    It can be made to fail by changing the MODSEL bits from U-Boot,
    before booting Linux:
      1. Write ffff0000 to e6050800 (unlock PMMR using inverted value),
      2. Write 0000ffff to e6050900 (enable I2C functions in MODSEL).

This patch series adds the missing configuration, by temporarily
overriding the GP_*_FN function enums to expand to two enums: the
original GP_*_FN enum to configure the GSPR register bits, and the
missing FN_SEL_I2Cn_0 enum to configure the MODSEL register bits.

I picked this solution as it is simpler than the alternative, which
would be:
  1. Add a copy of the CPU_ALL_GP() macro to describe all GPIO pins that
     are not I2C-capable,
  2. Add a copy of the PINMUX_DATA_GP_ALL() macro to emit mark/function
     enums in pinmux_data[] for GPIO pins that are not I2C-capable,
  3. Add a copy of the _GP_DATA() macro to emit mark/function 
     enums in pinmux_data[] for an I2C-capable GPIO pin,
  4. Invoke the macro above for all I2C-capable GPIO pins.

I intend to queue this in renesas-pinctrl-for-v5.19.

Thanks for your comments!

Geert Uytterhoeven (2):
  pinctrl: renesas: r8a779a0: Fix GPIO function on I2C-capable pins
  pinctrl: renesas: r8a779f0: Fix GPIO function on I2C-capable pins

 drivers/pinctrl/renesas/pfc-r8a779a0.c | 29 ++++++++++++++++++++++++++
 drivers/pinctrl/renesas/pfc-r8a779f0.c | 21 +++++++++++++++++++
 2 files changed, 50 insertions(+)