Skip to content

Commit ede014c

Browse files
prabhakarladgeertu
authored andcommitted
pinctrl: renesas: rzg2l: Add function pointer for PMC register write
Introduces pmc_writeb() function pointer, in the struct rzg2l_pinctrl_data to facilitate writing to the PMC register. On the RZ/V2H(P) SoC, unlocking the PWPR.REGWE_A bit before writing to PMC registers is required, whereas this is not the case for the existing RZ/G2L family. This addition enables the reuse of existing code for RZ/V2H(P). Additionally, populate this function pointer with appropriate data for existing SoCs. Note that this functionality is only handled in rzg2l_gpio_request(), as PMC unlock/lock during PFC setup will be taken care of in the pwpr_pfc_lock_unlock() function pointer. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> # on RZ/G3S Link: https://lore.kernel.org/r/20240530173857.164073-9-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent 14c32dc commit ede014c

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

drivers/pinctrl/renesas/pinctrl-rzg2l.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ struct rzg2l_pinctrl_data {
254254
const u64 *variable_pin_cfg;
255255
unsigned int n_variable_pin_cfg;
256256
void (*pwpr_pfc_lock_unlock)(struct rzg2l_pinctrl *pctrl, bool lock);
257+
void (*pmc_writeb)(struct rzg2l_pinctrl *pctrl, u8 val, u16 offset);
257258
};
258259

259260
/**
@@ -383,6 +384,11 @@ static const u64 r9a07g043f_variable_pin_cfg[] = {
383384
};
384385
#endif
385386

387+
static void rzg2l_pmc_writeb(struct rzg2l_pinctrl *pctrl, u8 val, u16 offset)
388+
{
389+
writeb(val, pctrl->base + offset);
390+
}
391+
386392
static void rzg2l_pinctrl_set_pfc_mode(struct rzg2l_pinctrl *pctrl,
387393
u8 pin, u8 off, u8 func)
388394
{
@@ -1329,7 +1335,7 @@ static int rzg2l_gpio_request(struct gpio_chip *chip, unsigned int offset)
13291335
/* Select GPIO mode in PMC Register */
13301336
reg8 = readb(pctrl->base + PMC(off));
13311337
reg8 &= ~BIT(bit);
1332-
writeb(reg8, pctrl->base + PMC(off));
1338+
pctrl->data->pmc_writeb(pctrl, reg8, PMC(off));
13331339

13341340
spin_unlock_irqrestore(&pctrl->lock, flags);
13351341

@@ -2616,6 +2622,7 @@ static struct rzg2l_pinctrl_data r9a07g043_data = {
26162622
.n_variable_pin_cfg = ARRAY_SIZE(r9a07g043f_variable_pin_cfg),
26172623
#endif
26182624
.pwpr_pfc_lock_unlock = &rzg2l_pwpr_pfc_lock_unlock,
2625+
.pmc_writeb = &rzg2l_pmc_writeb,
26192626
};
26202627

26212628
static struct rzg2l_pinctrl_data r9a07g044_data = {
@@ -2628,6 +2635,7 @@ static struct rzg2l_pinctrl_data r9a07g044_data = {
26282635
ARRAY_SIZE(rzg2l_dedicated_pins.rzg2l_pins),
26292636
.hwcfg = &rzg2l_hwcfg,
26302637
.pwpr_pfc_lock_unlock = &rzg2l_pwpr_pfc_lock_unlock,
2638+
.pmc_writeb = &rzg2l_pmc_writeb,
26312639
};
26322640

26332641
static struct rzg2l_pinctrl_data r9a08g045_data = {
@@ -2639,6 +2647,7 @@ static struct rzg2l_pinctrl_data r9a08g045_data = {
26392647
.n_dedicated_pins = ARRAY_SIZE(rzg3s_dedicated_pins),
26402648
.hwcfg = &rzg3s_hwcfg,
26412649
.pwpr_pfc_lock_unlock = &rzg2l_pwpr_pfc_lock_unlock,
2650+
.pmc_writeb = &rzg2l_pmc_writeb,
26422651
};
26432652

26442653
static const struct of_device_id rzg2l_pinctrl_of_table[] = {

0 commit comments

Comments
 (0)