Re: [PATCH 4/5] pinctrl: upboard: fix I2C pinmux-select set CPLD GPIO OUT not function mode

From: GaryWang

Date: Tue Nov 24 2026 - 05:18:56 EST


On Tue, Nov 24, 2026 at 5:17 PM Thomas Richard
<thomas.richard@xxxxxxxxxxx> wrote:
>
> > The CPLD I2C pin mode setting following uart & spi used modes array
> > on device AANT0F04.
> >
> > CC: stable@xxxxxxxxxxxxxxx
> > Fixes: dca2f73cf19f ("pinctrl: Add pin controller driver for AAEON UP boards")
>
> Please explain the real issue you met and how you fixed it.
Ok.
>
> >
> > diff --git a/drivers/pinctrl/pinctrl-upboard.c b/drivers/pinctrl/pinctrl-upboard.c
> > index b9af6dd93c34..66c1c3e3bfe0 100644
> > --- a/drivers/pinctrl/pinctrl-upboard.c
> > +++ b/drivers/pinctrl/pinctrl-upboard.c
> > @@ -225,11 +225,21 @@ static const unsigned int upboard_up_i2c0_pins[] = {
> > UPBOARD_UP_BIT_TO_PIN(I2C0_SDA),
> > };
> >
> > +static const enum upboard_pin_mode upboard_up_i2c0_modes[] = {
> > + UPBOARD_PIN_MODE_FUNCTION,
> > + UPBOARD_PIN_MODE_FUNCTION,
> > +};
> > +
>
> Add a static_assert.
>
> > static const unsigned int upboard_up_i2c1_pins[] = {
> > UPBOARD_UP_BIT_TO_PIN(I2C1_SCL),
> > UPBOARD_UP_BIT_TO_PIN(I2C1_SDA),
> > };
> >
> > +static const enum upboard_pin_mode upboard_up_i2c1_modes[] = {
> > + UPBOARD_PIN_MODE_FUNCTION,
> > + UPBOARD_PIN_MODE_FUNCTION,
> > +};
> > +
>
> Ditto.
>
> > static const unsigned int upboard_up_spi2_pins[] = {
> > UPBOARD_UP_BIT_TO_PIN(SPI_MOSI),
> > UPBOARD_UP_BIT_TO_PIN(SPI_MISO),
> > @@ -289,8 +299,8 @@ static const unsigned int upboard_up_adc0_pins[] = {
> >
> > static const struct upboard_pingroup upboard_up_pin_groups[] = {
> > UPBOARD_PINGROUP("uart1_grp", upboard_up_uart1_pins, &upboard_up_uart1_modes[0]),
> > - UPBOARD_PINGROUP("i2c0_grp", upboard_up_i2c0_pins, UPBOARD_PIN_MODE_GPIO_OUT),
> > - UPBOARD_PINGROUP("i2c1_grp", upboard_up_i2c1_pins, UPBOARD_PIN_MODE_GPIO_OUT),
> > + UPBOARD_PINGROUP("i2c0_grp", upboard_up_i2c0_pins, &upboard_up_i2c0_modes[0]),
> > + UPBOARD_PINGROUP("i2c1_grp", upboard_up_i2c1_pins, &upboard_up_i2c1_modes[0]),
>
> I personnally prefer the actual implementation because it saves some lines.
>
> But if you really want to use modes array even if the mode is the same for all
> pins of the group, you should convert all groups to modes array, drop dead code
> and explain the benefits.
The benefits just have flexibility in the future. if 2 pins mode is
not the same.
AI code review is not the whole accurate, The current code hasn't NULL
pointer modes array in UP2.
However the UPBOARD_PIN_MODE_FUNCTION starts from 0, if there is a pin
that has set UPBOARD_PIN_MODE_FUNCTION then it will get NULL pointer
modes.
So the good fix I'll set UPBOARD_PIN_MODE_FUNCTION as 1 then we can set I2C
to UPBOARD_PIN_MODE_FUNCTION as you wish.



>
> --
> Best Regards,
> Thomas Richard
>