Commit 4688f385 authored by Sascha Hauer's avatar Sascha Hauer Committed by Matthias Brugger

soc: mediatek: SCPSYS: Add regulator support

The power domains are supplied by regulators. Add support for them so
that the regulators are properly turned on before a domain is powered up
and turned off when a domain is powered down.
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarMatthias Brugger <matthias.bgg@gmail.com>
parent 8005c49d
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/pm_domain.h> #include <linux/pm_domain.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/soc/mediatek/infracfg.h> #include <linux/soc/mediatek/infracfg.h>
#include <linux/regulator/consumer.h>
#include <dt-bindings/power/mt8173-power.h> #include <dt-bindings/power/mt8173-power.h>
#define SPM_VDE_PWR_CON 0x0210 #define SPM_VDE_PWR_CON 0x0210
...@@ -179,6 +180,7 @@ struct scp_domain { ...@@ -179,6 +180,7 @@ struct scp_domain {
u32 sram_pdn_ack_bits; u32 sram_pdn_ack_bits;
u32 bus_prot_mask; u32 bus_prot_mask;
bool active_wakeup; bool active_wakeup;
struct regulator *supply;
}; };
struct scp { struct scp {
...@@ -221,6 +223,12 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) ...@@ -221,6 +223,12 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
int ret; int ret;
int i; int i;
if (scpd->supply) {
ret = regulator_enable(scpd->supply);
if (ret)
return ret;
}
for (i = 0; i < MAX_CLKS && scpd->clk[i]; i++) { for (i = 0; i < MAX_CLKS && scpd->clk[i]; i++) {
ret = clk_prepare_enable(scpd->clk[i]); ret = clk_prepare_enable(scpd->clk[i]);
if (ret) { if (ret) {
...@@ -299,6 +307,9 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) ...@@ -299,6 +307,9 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
clk_disable_unprepare(scpd->clk[i]); clk_disable_unprepare(scpd->clk[i]);
} }
err_clk: err_clk:
if (scpd->supply)
regulator_disable(scpd->supply);
dev_err(scp->dev, "Failed to power on domain %s\n", genpd->name); dev_err(scp->dev, "Failed to power on domain %s\n", genpd->name);
return ret; return ret;
...@@ -379,6 +390,9 @@ static int scpsys_power_off(struct generic_pm_domain *genpd) ...@@ -379,6 +390,9 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
for (i = 0; i < MAX_CLKS && scpd->clk[i]; i++) for (i = 0; i < MAX_CLKS && scpd->clk[i]; i++)
clk_disable_unprepare(scpd->clk[i]); clk_disable_unprepare(scpd->clk[i]);
if (scpd->supply)
regulator_disable(scpd->supply);
return 0; return 0;
out: out:
...@@ -448,6 +462,19 @@ static int __init scpsys_probe(struct platform_device *pdev) ...@@ -448,6 +462,19 @@ static int __init scpsys_probe(struct platform_device *pdev)
return PTR_ERR(scp->infracfg); return PTR_ERR(scp->infracfg);
} }
for (i = 0; i < NUM_DOMAINS; i++) {
struct scp_domain *scpd = &scp->domains[i];
const struct scp_domain_data *data = &scp_domain_data[i];
scpd->supply = devm_regulator_get_optional(&pdev->dev, data->name);
if (IS_ERR(scpd->supply)) {
if (PTR_ERR(scpd->supply) == -ENODEV)
scpd->supply = NULL;
else
return PTR_ERR(scpd->supply);
}
}
pd_data->num_domains = NUM_DOMAINS; pd_data->num_domains = NUM_DOMAINS;
for (i = 0; i < NUM_DOMAINS; i++) { for (i = 0; i < NUM_DOMAINS; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment