Skip to content

Commit 334ef45

Browse files
author
Linus Walleij
committed
Merge tag 'renesas-pinctrl-for-v6.18-tag2' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers into devel
pinctrl: renesas: Updates for v6.18 (take two) - Improve suspend/resume support on RZ/G2L family SoCs, - Miscellaneous fixes and improvements. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2 parents cb730da + 512bf60 commit 334ef45

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

drivers/pinctrl/renesas/pfc-r8a779g0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* R8A779A0 processor support - PFC hardware block.
3+
* R8A779G0 processor support - PFC hardware block.
44
*
55
* Copyright (C) 2021 Renesas Electronics Corp.
66
*

drivers/pinctrl/renesas/pinctrl-rzg2l.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ struct rzg2l_pinctrl_pin_settings {
321321
* @iolh: IOLH registers cache
322322
* @pupd: PUPD registers cache
323323
* @ien: IEN registers cache
324+
* @smt: SMT registers cache
324325
* @sd_ch: SD_CH registers cache
325326
* @eth_poc: ET_POC registers cache
326327
* @oen: Output Enable register cache
@@ -334,6 +335,7 @@ struct rzg2l_pinctrl_reg_cache {
334335
u32 *iolh[2];
335336
u32 *ien[2];
336337
u32 *pupd[2];
338+
u32 *smt;
337339
u8 sd_ch[2];
338340
u8 eth_poc[2];
339341
u8 oen;
@@ -2704,6 +2706,10 @@ static int rzg2l_pinctrl_reg_cache_alloc(struct rzg2l_pinctrl *pctrl)
27042706
if (!cache->pfc)
27052707
return -ENOMEM;
27062708

2709+
cache->smt = devm_kcalloc(pctrl->dev, nports, sizeof(*cache->smt), GFP_KERNEL);
2710+
if (!cache->smt)
2711+
return -ENOMEM;
2712+
27072713
for (u8 i = 0; i < 2; i++) {
27082714
u32 n_dedicated_pins = pctrl->data->n_dedicated_pins;
27092715

@@ -2965,7 +2971,7 @@ static void rzg2l_pinctrl_pm_setup_regs(struct rzg2l_pinctrl *pctrl, bool suspen
29652971
struct rzg2l_pinctrl_reg_cache *cache = pctrl->cache;
29662972

29672973
for (u32 port = 0; port < nports; port++) {
2968-
bool has_iolh, has_ien, has_pupd;
2974+
bool has_iolh, has_ien, has_pupd, has_smt;
29692975
u32 off, caps;
29702976
u8 pincnt;
29712977
u64 cfg;
@@ -2978,6 +2984,7 @@ static void rzg2l_pinctrl_pm_setup_regs(struct rzg2l_pinctrl *pctrl, bool suspen
29782984
has_iolh = !!(caps & (PIN_CFG_IOLH_A | PIN_CFG_IOLH_B | PIN_CFG_IOLH_C));
29792985
has_ien = !!(caps & PIN_CFG_IEN);
29802986
has_pupd = !!(caps & PIN_CFG_PUPD);
2987+
has_smt = !!(caps & PIN_CFG_SMT);
29812988

29822989
if (suspend)
29832990
RZG2L_PCTRL_REG_ACCESS32(suspend, pctrl->base + PFC(off), cache->pfc[port]);
@@ -3016,6 +3023,9 @@ static void rzg2l_pinctrl_pm_setup_regs(struct rzg2l_pinctrl *pctrl, bool suspen
30163023
cache->ien[1][port]);
30173024
}
30183025
}
3026+
3027+
if (has_smt)
3028+
RZG2L_PCTRL_REG_ACCESS32(suspend, pctrl->base + SMT(off), cache->smt[port]);
30193029
}
30203030
}
30213031

@@ -3165,6 +3175,8 @@ static int rzg2l_pinctrl_resume_noirq(struct device *dev)
31653175
const struct rzg2l_hwcfg *hwcfg = pctrl->data->hwcfg;
31663176
const struct rzg2l_register_offsets *regs = &hwcfg->regs;
31673177
struct rzg2l_pinctrl_reg_cache *cache = pctrl->cache;
3178+
unsigned long flags;
3179+
u8 pwpr;
31683180
int ret;
31693181

31703182
if (!atomic_read(&pctrl->wakeup_path)) {
@@ -3174,7 +3186,16 @@ static int rzg2l_pinctrl_resume_noirq(struct device *dev)
31743186
}
31753187

31763188
writeb(cache->qspi, pctrl->base + QSPI);
3189+
if (pctrl->data->hwcfg->oen_pwpr_lock) {
3190+
spin_lock_irqsave(&pctrl->lock, flags);
3191+
pwpr = readb(pctrl->base + regs->pwpr);
3192+
writeb(pwpr | PWPR_REGWE_B, pctrl->base + regs->pwpr);
3193+
}
31773194
writeb(cache->oen, pctrl->base + pctrl->data->hwcfg->regs.oen);
3195+
if (pctrl->data->hwcfg->oen_pwpr_lock) {
3196+
writeb(pwpr & ~PWPR_REGWE_B, pctrl->base + regs->pwpr);
3197+
spin_unlock_irqrestore(&pctrl->lock, flags);
3198+
}
31783199
for (u8 i = 0; i < 2; i++) {
31793200
if (regs->sd_ch)
31803201
writeb(cache->sd_ch[i], pctrl->base + SD_CH(regs->sd_ch, i));

drivers/pinctrl/renesas/pinctrl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,8 @@ static int sh_pfc_pinconf_group_set(struct pinctrl_dev *pctldev, unsigned group,
726726
struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
727727
const unsigned int *pins;
728728
unsigned int num_pins;
729-
unsigned int i, ret;
729+
unsigned int i;
730+
int ret;
730731

731732
pins = pmx->pfc->info->groups[group].pins;
732733
num_pins = pmx->pfc->info->groups[group].nr_pins;

0 commit comments

Comments
 (0)