Skip to content

Commit ed4520d

Browse files
tmlindSantoshShilimkar
authored andcommitted
soc: ti: Remove pm_runtime_irq_safe() usage for smartreflex
For the smartreflex device, we need to disable smartreflex on SoC idle, and have been using pm_runtime_irq_safe() to do that. But we want to remove the irq_safe usage as PM runtime takes a permanent usage count on the parent device with it. In order to remove the need for pm_runtime_irq_safe(), let's gate the clock directly in the driver. This removes the need to call PM runtime during idle, and allows us to switch to using CPU_PM in the following patch. Note that the smartreflex interconnect target module is configured for smart idle, but the clock does not have autoidle capability, and needs to be gated manually. If the clock supported autoidle, we would not need to even gate the clock. With this change, we can now remove the related quirk flags for ti-sysc also. Signed-off-by: Tony Lindgren <[email protected]> Signed-off-by: Santosh Shilimkar <[email protected]>
1 parent 22ea87e commit ed4520d

File tree

3 files changed

+26
-34
lines changed

3 files changed

+26
-34
lines changed

drivers/bus/ti-sysc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,10 +1444,6 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
14441444
SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_OPT_CLKS_IN_RESET),
14451445
SYSC_QUIRK("sham", 0, 0x100, 0x110, 0x114, 0x40000c03, 0xffffffff,
14461446
SYSC_QUIRK_LEGACY_IDLE),
1447-
SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x24, -ENODEV, 0x00000000, 0xffffffff,
1448-
SYSC_QUIRK_LEGACY_IDLE),
1449-
SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x38, -ENODEV, 0x00000000, 0xffffffff,
1450-
SYSC_QUIRK_LEGACY_IDLE),
14511447
SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000046, 0xffffffff,
14521448
SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_LEGACY_IDLE),
14531449
SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff,
@@ -1583,6 +1579,8 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
15831579
SYSC_QUIRK("sdma", 0, 0, 0x2c, 0x28, 0x00010900, 0xffffffff, 0),
15841580
SYSC_QUIRK("slimbus", 0, 0, 0x10, -ENODEV, 0x40000902, 0xffffffff, 0),
15851581
SYSC_QUIRK("slimbus", 0, 0, 0x10, -ENODEV, 0x40002903, 0xffffffff, 0),
1582+
SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x24, -ENODEV, 0x00000000, 0xffffffff, 0),
1583+
SYSC_QUIRK("smartreflex", 0, -ENODEV, 0x38, -ENODEV, 0x00000000, 0xffffffff, 0),
15861584
SYSC_QUIRK("spinlock", 0, 0, 0x10, -ENODEV, 0x50020000, 0xffffffff, 0),
15871585
SYSC_QUIRK("rng", 0, 0x1fe0, 0x1fe4, -ENODEV, 0x00000020, 0xffffffff, 0),
15881586
SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000013, 0xffffffff, 0),

drivers/soc/ti/smartreflex.c

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,13 @@ static irqreturn_t sr_interrupt(int irq, void *data)
126126

127127
static void sr_set_clk_length(struct omap_sr *sr)
128128
{
129-
struct clk *fck;
130129
u32 fclk_speed;
131130

132131
/* Try interconnect target module fck first if it already exists */
133-
fck = clk_get(sr->pdev->dev.parent, "fck");
134-
if (IS_ERR(fck)) {
135-
fck = clk_get(&sr->pdev->dev, "fck");
136-
if (IS_ERR(fck)) {
137-
dev_err(&sr->pdev->dev,
138-
"%s: unable to get fck for device %s\n",
139-
__func__, dev_name(&sr->pdev->dev));
140-
return;
141-
}
142-
}
132+
if (IS_ERR(sr->fck))
133+
return;
143134

144-
fclk_speed = clk_get_rate(fck);
145-
clk_put(fck);
135+
fclk_speed = clk_get_rate(sr->fck);
146136

147137
switch (fclk_speed) {
148138
case 12000000:
@@ -587,21 +577,25 @@ int sr_enable(struct omap_sr *sr, unsigned long volt)
587577
/* errminlimit is opp dependent and hence linked to voltage */
588578
sr->err_minlimit = nvalue_row->errminlimit;
589579

590-
pm_runtime_get_sync(&sr->pdev->dev);
580+
clk_enable(sr->fck);
591581

592582
/* Check if SR is already enabled. If yes do nothing */
593583
if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE)
594-
return 0;
584+
goto out_enabled;
595585

596586
/* Configure SR */
597587
ret = sr_class->configure(sr);
598588
if (ret)
599-
return ret;
589+
goto out_enabled;
600590

601591
sr_write_reg(sr, NVALUERECIPROCAL, nvalue_row->nvalue);
602592

603593
/* SRCONFIG - enable SR */
604594
sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, SRCONFIG_SRENABLE);
595+
596+
out_enabled:
597+
sr->enabled = 1;
598+
605599
return 0;
606600
}
607601

@@ -621,7 +615,7 @@ void sr_disable(struct omap_sr *sr)
621615
}
622616

623617
/* Check if SR clocks are already disabled. If yes do nothing */
624-
if (pm_runtime_suspended(&sr->pdev->dev))
618+
if (!sr->enabled)
625619
return;
626620

627621
/*
@@ -642,7 +636,8 @@ void sr_disable(struct omap_sr *sr)
642636
}
643637
}
644638

645-
pm_runtime_put_sync_suspend(&sr->pdev->dev);
639+
clk_disable(sr->fck);
640+
sr->enabled = 0;
646641
}
647642

648643
/**
@@ -851,8 +846,12 @@ static int omap_sr_probe(struct platform_device *pdev)
851846

852847
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
853848

849+
sr_info->fck = devm_clk_get(pdev->dev.parent, "fck");
850+
if (IS_ERR(sr_info->fck))
851+
return PTR_ERR(sr_info->fck);
852+
clk_prepare(sr_info->fck);
853+
854854
pm_runtime_enable(&pdev->dev);
855-
pm_runtime_irq_safe(&pdev->dev);
856855

857856
snprintf(sr_info->name, SMARTREFLEX_NAME_LEN, "%s", pdata->name);
858857

@@ -878,12 +877,6 @@ static int omap_sr_probe(struct platform_device *pdev)
878877

879878
list_add(&sr_info->node, &sr_list);
880879

881-
ret = pm_runtime_get_sync(&pdev->dev);
882-
if (ret < 0) {
883-
pm_runtime_put_noidle(&pdev->dev);
884-
goto err_list_del;
885-
}
886-
887880
/*
888881
* Call into late init to do initializations that require
889882
* both sr driver and sr class driver to be initiallized.
@@ -933,23 +926,21 @@ static int omap_sr_probe(struct platform_device *pdev)
933926

934927
}
935928

936-
pm_runtime_put_sync(&pdev->dev);
937-
938929
return ret;
939930

940931
err_debugfs:
941932
debugfs_remove_recursive(sr_info->dbg_dir);
942933
err_list_del:
943934
list_del(&sr_info->node);
944-
945-
pm_runtime_put_sync(&pdev->dev);
935+
clk_unprepare(sr_info->fck);
946936

947937
return ret;
948938
}
949939

950940
static int omap_sr_remove(struct platform_device *pdev)
951941
{
952942
struct omap_sr_data *pdata = pdev->dev.platform_data;
943+
struct device *dev = &pdev->dev;
953944
struct omap_sr *sr_info;
954945

955946
if (!pdata) {
@@ -968,7 +959,8 @@ static int omap_sr_remove(struct platform_device *pdev)
968959
sr_stop_vddautocomp(sr_info);
969960
debugfs_remove_recursive(sr_info->dbg_dir);
970961

971-
pm_runtime_disable(&pdev->dev);
962+
pm_runtime_disable(dev);
963+
clk_unprepare(sr_info->fck);
972964
list_del(&sr_info->node);
973965
return 0;
974966
}

include/linux/power/smartreflex.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ struct omap_sr {
155155
struct voltagedomain *voltdm;
156156
struct dentry *dbg_dir;
157157
unsigned int irq;
158+
struct clk *fck;
158159
int srid;
159160
int ip_type;
160161
int nvalue_count;
@@ -169,6 +170,7 @@ struct omap_sr {
169170
u32 senp_mod;
170171
u32 senn_mod;
171172
void __iomem *base;
173+
unsigned long enabled:1;
172174
};
173175

174176
/**

0 commit comments

Comments
 (0)