[PATCH v1 2/8] pinctrl: npcm8xx: enable RMII outputs from RMII groups

From: Tomer Maimon

Date: Wed Jul 15 2026 - 08:33:02 EST


NPCM8xx uses GCR_INTCR4 bits to release the R1, R2 and RMII3
transmit outputs from Hi-Z.

Those bits need to follow the mandatory r1, r2 and rmii3 pin
groups. The R1_OEn, R2_OEn and R3_OEn side groups are optional and
should not be required just to enable RMII transmit outputs.

Program the INTCR4 bits when the corresponding RMII groups are
selected and clear them again when those pins switch back to GPIO or
another shared function.

Signed-off-by: Tomer Maimon <tmaimon77@xxxxxxxxx>
---
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 61 +++++++++++++++++++++++
1 file changed, 61 insertions(+)

diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
index c859dca4b..1d5b3c648 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
@@ -26,6 +26,7 @@
#define NPCM8XX_GCR_SRCNT 0x068
#define NPCM8XX_GCR_FLOCKR1 0x074
#define NPCM8XX_GCR_DSCNT 0x078
+#define NPCM8XX_GCR_INTCR4 0x0c0
#define NPCM8XX_GCR_I2CSEGSEL 0x0e0
#define NPCM8XX_GCR_MFSEL1 0x260
#define NPCM8XX_GCR_MFSEL2 0x264
@@ -78,6 +79,9 @@
#define NPCM8XX_GPIO_PER_BANK 32
#define NPCM8XX_GPIO_BANK_NUM 8
#define NPCM8XX_GCR_NONE 0
+#define NPCM8XX_INTCR4_R1_RMII_EN BIT(12)
+#define NPCM8XX_INTCR4_R2_RMII_EN BIT(13)
+#define NPCM8XX_INTCR4_RMII3_EN BIT(14)

#define NPCM8XX_DEBOUNCE_MAX 4
#define NPCM8XX_DEBOUNCE_NSEC 40
@@ -1796,6 +1800,61 @@ static const struct pinctrl_pin_desc npcm8xx_pins[] = {
PINCTRL_PIN(251, "JM2/CP1_GPIO"),
};

+static u32 npcm8xx_rmii_output_enable_mask(unsigned int pin)
+{
+ switch (pin) {
+ case 178:
+ case 179:
+ case 180:
+ case 181:
+ case 182:
+ case 193:
+ case 201:
+ return NPCM8XX_INTCR4_R1_RMII_EN;
+ case 84:
+ case 85:
+ case 86:
+ case 87:
+ case 88:
+ case 89:
+ case 200:
+ return NPCM8XX_INTCR4_R2_RMII_EN;
+ case 110:
+ case 111:
+ case 209:
+ case 210:
+ case 211:
+ case 214:
+ case 215:
+ return NPCM8XX_INTCR4_RMII3_EN;
+ default:
+ return 0;
+ }
+}
+
+static void npcm8xx_set_rmii_output_enable(struct regmap *gcr_regmap,
+ const unsigned int *pin,
+ int pin_number, int mode)
+{
+ u32 mask = 0;
+ u32 val = 0;
+ u32 bit;
+ int i;
+
+ for (i = 0; i < pin_number; i++) {
+ bit = npcm8xx_rmii_output_enable_mask(pin[i]);
+ mask |= bit;
+
+ if ((mode == fn_r1 && bit == NPCM8XX_INTCR4_R1_RMII_EN) ||
+ (mode == fn_r2 && bit == NPCM8XX_INTCR4_R2_RMII_EN) ||
+ (mode == fn_rmii3 && bit == NPCM8XX_INTCR4_RMII3_EN))
+ val |= bit;
+ }
+
+ if (mask)
+ regmap_update_bits(gcr_regmap, NPCM8XX_GCR_INTCR4, mask, val);
+}
+
/* Enable mode in pin group */
static void npcm8xx_setfunc(struct regmap *gcr_regmap, const unsigned int *pin,
int pin_number, int mode)
@@ -1834,6 +1893,8 @@ static void npcm8xx_setfunc(struct regmap *gcr_regmap, const unsigned int *pin,
BIT(cfg->bit4) : 0);
}
}
+
+ npcm8xx_set_rmii_output_enable(gcr_regmap, pin, pin_number, mode);
}

static int npcm8xx_get_slew_rate(struct npcm8xx_gpio *bank,
--
2.34.1