Skip to content

Commit e460769

Browse files
Christophe Kerellokrzk
authored andcommitted
memory: stm32-fmc2-ebi: keep power domain on
MP25 FMC2 domain has to be kept on. To handle it throw PSCI OS-initiated, basic PM for keeping domain on is introduced. Signed-off-by: Christophe Kerello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Kozlowski <[email protected]>
1 parent cc7d5cf commit e460769

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

drivers/memory/stm32-fmc2-ebi.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/of_platform.h>
1212
#include <linux/pinctrl/consumer.h>
1313
#include <linux/platform_device.h>
14+
#include <linux/pm_runtime.h>
1415
#include <linux/regmap.h>
1516
#include <linux/reset.h>
1617

@@ -1649,6 +1650,7 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev)
16491650
return -ENOMEM;
16501651

16511652
ebi->dev = dev;
1653+
platform_set_drvdata(pdev, ebi);
16521654

16531655
ebi->data = of_device_get_match_data(dev);
16541656
if (!ebi->data)
@@ -1666,10 +1668,14 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev)
16661668
if (PTR_ERR(rstc) == -EPROBE_DEFER)
16671669
return -EPROBE_DEFER;
16681670

1669-
ret = clk_prepare_enable(ebi->clk);
1671+
ret = devm_pm_runtime_enable(dev);
16701672
if (ret)
16711673
return ret;
16721674

1675+
ret = pm_runtime_resume_and_get(dev);
1676+
if (ret < 0)
1677+
return ret;
1678+
16731679
if (!IS_ERR(rstc)) {
16741680
reset_control_assert(rstc);
16751681
reset_control_deassert(rstc);
@@ -1705,16 +1711,14 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev)
17051711
if (ret)
17061712
goto err_release;
17071713

1708-
platform_set_drvdata(pdev, ebi);
1709-
17101714
return 0;
17111715

17121716
err_release:
17131717
stm32_fmc2_ebi_disable_banks(ebi);
17141718
stm32_fmc2_ebi_disable(ebi);
17151719
if (ebi->data->put_sems)
17161720
ebi->data->put_sems(ebi);
1717-
clk_disable_unprepare(ebi->clk);
1721+
pm_runtime_put_sync_suspend(dev);
17181722

17191723
return ret;
17201724
}
@@ -1728,7 +1732,23 @@ static void stm32_fmc2_ebi_remove(struct platform_device *pdev)
17281732
stm32_fmc2_ebi_disable(ebi);
17291733
if (ebi->data->put_sems)
17301734
ebi->data->put_sems(ebi);
1735+
pm_runtime_put_sync_suspend(&pdev->dev);
1736+
}
1737+
1738+
static int __maybe_unused stm32_fmc2_ebi_runtime_suspend(struct device *dev)
1739+
{
1740+
struct stm32_fmc2_ebi *ebi = dev_get_drvdata(dev);
1741+
17311742
clk_disable_unprepare(ebi->clk);
1743+
1744+
return 0;
1745+
}
1746+
1747+
static int __maybe_unused stm32_fmc2_ebi_runtime_resume(struct device *dev)
1748+
{
1749+
struct stm32_fmc2_ebi *ebi = dev_get_drvdata(dev);
1750+
1751+
return clk_prepare_enable(ebi->clk);
17321752
}
17331753

17341754
static int __maybe_unused stm32_fmc2_ebi_suspend(struct device *dev)
@@ -1738,7 +1758,7 @@ static int __maybe_unused stm32_fmc2_ebi_suspend(struct device *dev)
17381758
stm32_fmc2_ebi_disable(ebi);
17391759
if (ebi->data->put_sems)
17401760
ebi->data->put_sems(ebi);
1741-
clk_disable_unprepare(ebi->clk);
1761+
pm_runtime_put_sync_suspend(dev);
17421762
pinctrl_pm_select_sleep_state(dev);
17431763

17441764
return 0;
@@ -1751,8 +1771,8 @@ static int __maybe_unused stm32_fmc2_ebi_resume(struct device *dev)
17511771

17521772
pinctrl_pm_select_default_state(dev);
17531773

1754-
ret = clk_prepare_enable(ebi->clk);
1755-
if (ret)
1774+
ret = pm_runtime_resume_and_get(dev);
1775+
if (ret < 0)
17561776
return ret;
17571777

17581778
if (ebi->data->get_sems)
@@ -1763,8 +1783,11 @@ static int __maybe_unused stm32_fmc2_ebi_resume(struct device *dev)
17631783
return 0;
17641784
}
17651785

1766-
static SIMPLE_DEV_PM_OPS(stm32_fmc2_ebi_pm_ops, stm32_fmc2_ebi_suspend,
1767-
stm32_fmc2_ebi_resume);
1786+
static const struct dev_pm_ops stm32_fmc2_ebi_pm_ops = {
1787+
SET_RUNTIME_PM_OPS(stm32_fmc2_ebi_runtime_suspend,
1788+
stm32_fmc2_ebi_runtime_resume, NULL)
1789+
SET_SYSTEM_SLEEP_PM_OPS(stm32_fmc2_ebi_suspend, stm32_fmc2_ebi_resume)
1790+
};
17681791

17691792
static const struct stm32_fmc2_ebi_data stm32_fmc2_ebi_mp1_data = {
17701793
.child_props = stm32_fmc2_child_props,

0 commit comments

Comments
 (0)