Skip to content

Commit 5061c47

Browse files
mtk-rogerlumbgg
authored andcommitted
soc: mediatek: mtk-svs: use common function to disable restore voltages
The timing of disabling SVS bank and restore default voltage is more than one place. Therefore, add a common function to use for removing the superfluous codes. Signed-off-by: Roger Lu <roger.lu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230202124104.16504-3-roger.lu@mediatek.com Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
1 parent 9f195f3 commit 5061c47

1 file changed

Lines changed: 22 additions & 32 deletions

File tree

drivers/soc/mediatek/mtk-svs.c

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,25 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svsb)
624624
return ret;
625625
}
626626

627+
static void svs_bank_disable_and_restore_default_volts(struct svs_platform *svsp,
628+
struct svs_bank *svsb)
629+
{
630+
unsigned long flags;
631+
632+
if (svsb->mode_support == SVSB_MODE_ALL_DISABLE)
633+
return;
634+
635+
spin_lock_irqsave(&svs_lock, flags);
636+
svsp->pbank = svsb;
637+
svs_switch_bank(svsp);
638+
svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN);
639+
svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS);
640+
spin_unlock_irqrestore(&svs_lock, flags);
641+
642+
svsb->phase = SVSB_PHASE_ERROR;
643+
svs_adjust_pm_opp_volts(svsb);
644+
}
645+
627646
#ifdef CONFIG_DEBUG_FS
628647
static int svs_dump_debug_show(struct seq_file *m, void *p)
629648
{
@@ -700,7 +719,6 @@ static ssize_t svs_enable_debug_write(struct file *filp,
700719
{
701720
struct svs_bank *svsb = file_inode(filp)->i_private;
702721
struct svs_platform *svsp = dev_get_drvdata(svsb->dev);
703-
unsigned long flags;
704722
int enabled, ret;
705723
char *buf = NULL;
706724

@@ -716,16 +734,8 @@ static ssize_t svs_enable_debug_write(struct file *filp,
716734
return ret;
717735

718736
if (!enabled) {
719-
spin_lock_irqsave(&svs_lock, flags);
720-
svsp->pbank = svsb;
737+
svs_bank_disable_and_restore_default_volts(svsp, svsb);
721738
svsb->mode_support = SVSB_MODE_ALL_DISABLE;
722-
svs_switch_bank(svsp);
723-
svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN);
724-
svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS);
725-
spin_unlock_irqrestore(&svs_lock, flags);
726-
727-
svsb->phase = SVSB_PHASE_ERROR;
728-
svs_adjust_pm_opp_volts(svsb);
729739
}
730740

731741
kfree(buf);
@@ -1508,16 +1518,7 @@ static int svs_init02(struct svs_platform *svsp)
15081518
out_of_init02:
15091519
for (idx = 0; idx < svsp->bank_max; idx++) {
15101520
svsb = &svsp->banks[idx];
1511-
1512-
spin_lock_irqsave(&svs_lock, flags);
1513-
svsp->pbank = svsb;
1514-
svs_switch_bank(svsp);
1515-
svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN);
1516-
svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS);
1517-
spin_unlock_irqrestore(&svs_lock, flags);
1518-
1519-
svsb->phase = SVSB_PHASE_ERROR;
1520-
svs_adjust_pm_opp_volts(svsb);
1521+
svs_bank_disable_and_restore_default_volts(svsp, svsb);
15211522
}
15221523

15231524
return ret;
@@ -1563,23 +1564,12 @@ static int svs_suspend(struct device *dev)
15631564
{
15641565
struct svs_platform *svsp = dev_get_drvdata(dev);
15651566
struct svs_bank *svsb;
1566-
unsigned long flags;
15671567
int ret;
15681568
u32 idx;
15691569

15701570
for (idx = 0; idx < svsp->bank_max; idx++) {
15711571
svsb = &svsp->banks[idx];
1572-
1573-
/* This might wait for svs_isr() process */
1574-
spin_lock_irqsave(&svs_lock, flags);
1575-
svsp->pbank = svsb;
1576-
svs_switch_bank(svsp);
1577-
svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN);
1578-
svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS);
1579-
spin_unlock_irqrestore(&svs_lock, flags);
1580-
1581-
svsb->phase = SVSB_PHASE_ERROR;
1582-
svs_adjust_pm_opp_volts(svsb);
1572+
svs_bank_disable_and_restore_default_volts(svsp, svsb);
15831573
}
15841574

15851575
ret = reset_control_assert(svsp->rst);

0 commit comments

Comments
 (0)