Skip to content

Commit 0274d80

Browse files
Andrei Stefanesculinusw
authored andcommitted
pinctrl: s32cc: add update and overwrite options when setting pinconf
The previous pinconf settings(made by the bootloader) need to be overwritten when configuring the pinctrl of a driver during the boot process. Configuring the bias of a GPIO at runtime (e.g. pull-up) needs to preserve the other settings unaltered. This patch introduces changes to differentiate between the two cases. Signed-off-by: Radu Pirea <[email protected]> Signed-off-by: Florin Buica <[email protected]> Signed-off-by: Andrei Stefanescu <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 522875e commit 0274d80

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

drivers/pinctrl/nxp/pinctrl-s32cc.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
#define S32_MSCR_ODE BIT(20)
4040
#define S32_MSCR_OBE BIT(21)
4141

42+
enum s32_write_type {
43+
S32_PINCONF_UPDATE_ONLY,
44+
S32_PINCONF_OVERWRITE,
45+
};
46+
4247
static struct regmap_config s32_regmap_config = {
4348
.reg_bits = 32,
4449
.val_bits = 32,
@@ -552,10 +557,11 @@ static int s32_parse_pincfg(unsigned long pincfg, unsigned int *mask,
552557
return 0;
553558
}
554559

555-
static int s32_pinconf_mscr_update(struct pinctrl_dev *pctldev,
560+
static int s32_pinconf_mscr_write(struct pinctrl_dev *pctldev,
556561
unsigned int pin_id,
557562
unsigned long *configs,
558-
unsigned int num_configs)
563+
unsigned int num_configs,
564+
enum s32_write_type write_type)
559565
{
560566
struct s32_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
561567
unsigned int config = 0, mask = 0;
@@ -574,10 +580,20 @@ static int s32_pinconf_mscr_update(struct pinctrl_dev *pctldev,
574580
return ret;
575581
}
576582

583+
/* If the MSCR configuration has to be written,
584+
* the SSS field should not be touched.
585+
*/
586+
if (write_type == S32_PINCONF_OVERWRITE)
587+
mask = (unsigned int)~S32_MSCR_SSS_MASK;
588+
577589
if (!config && !mask)
578590
return 0;
579591

580-
dev_dbg(ipctl->dev, "update: pin %u cfg 0x%x\n", pin_id, config);
592+
if (write_type == S32_PINCONF_OVERWRITE)
593+
dev_dbg(ipctl->dev, "set: pin %u cfg 0x%x\n", pin_id, config);
594+
else
595+
dev_dbg(ipctl->dev, "update: pin %u cfg 0x%x\n", pin_id,
596+
config);
581597

582598
return s32_regmap_update(pctldev, pin_id, mask, config);
583599
}
@@ -593,8 +609,8 @@ static int s32_pinconf_set(struct pinctrl_dev *pctldev,
593609
unsigned int pin_id, unsigned long *configs,
594610
unsigned int num_configs)
595611
{
596-
return s32_pinconf_mscr_update(pctldev, pin_id, configs,
597-
num_configs);
612+
return s32_pinconf_mscr_write(pctldev, pin_id, configs,
613+
num_configs, S32_PINCONF_UPDATE_ONLY);
598614
}
599615

600616
static int s32_pconf_group_set(struct pinctrl_dev *pctldev, unsigned int selector,
@@ -607,8 +623,8 @@ static int s32_pconf_group_set(struct pinctrl_dev *pctldev, unsigned int selecto
607623

608624
grp = &info->groups[selector];
609625
for (i = 0; i < grp->data.npins; i++) {
610-
ret = s32_pinconf_mscr_update(pctldev, grp->data.pins[i],
611-
configs, num_configs);
626+
ret = s32_pinconf_mscr_write(pctldev, grp->data.pins[i],
627+
configs, num_configs, S32_PINCONF_OVERWRITE);
612628
if (ret)
613629
return ret;
614630
}

0 commit comments

Comments
 (0)