Skip to content

Commit 339cd0e

Browse files
superna9999arndb
authored andcommitted
soc: amlogic: meson-gx-pwrc-vpu: fix power-off when powered by bootloader
In the case the VPU power domain has been powered on by the bootloader and no driver are attached to this power domain, the genpd will power it off after a certain amount of time, but the clocks hasn't been enabled by the kernel itself and the power-off will trigger some faults. This patch enable the clocks to have a coherent state for an eventual poweroff and switches to the pm_domain_always_on_gov governor. Fixes: 75fcb5c ("soc: amlogic: add Meson GX VPU Domains driver") Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Tested-by: Kevin Hilman <khilman@baylibre.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent ad54c3e commit 339cd0e

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

drivers/soc/amlogic/meson-gx-pwrc-vpu.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ struct meson_gx_pwrc_vpu {
3434
struct reset_control *rstc;
3535
struct clk *vpu_clk;
3636
struct clk *vapb_clk;
37-
bool powered;
3837
};
3938

4039
static inline
@@ -78,8 +77,6 @@ static int meson_gx_pwrc_vpu_power_off(struct generic_pm_domain *genpd)
7877
clk_disable_unprepare(pd->vpu_clk);
7978
clk_disable_unprepare(pd->vapb_clk);
8079

81-
pd->powered = false;
82-
8380
return 0;
8481
}
8582

@@ -91,7 +88,11 @@ static int meson_gx_pwrc_vpu_setup_clk(struct meson_gx_pwrc_vpu *pd)
9188
if (ret)
9289
return ret;
9390

94-
return clk_prepare_enable(pd->vapb_clk);
91+
ret = clk_prepare_enable(pd->vapb_clk);
92+
if (ret)
93+
clk_disable_unprepare(pd->vpu_clk);
94+
95+
return ret;
9596
}
9697

9798
static int meson_gx_pwrc_vpu_power_on(struct generic_pm_domain *genpd)
@@ -139,8 +140,6 @@ static int meson_gx_pwrc_vpu_power_on(struct generic_pm_domain *genpd)
139140
if (ret)
140141
return ret;
141142

142-
pd->powered = true;
143-
144143
return 0;
145144
}
146145

@@ -167,6 +166,8 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev)
167166
struct reset_control *rstc;
168167
struct clk *vpu_clk;
169168
struct clk *vapb_clk;
169+
bool powered_off;
170+
int ret;
170171

171172
regmap_ao = syscon_node_to_regmap(of_get_parent(pdev->dev.of_node));
172173
if (IS_ERR(regmap_ao)) {
@@ -205,17 +206,25 @@ static int meson_gx_pwrc_vpu_probe(struct platform_device *pdev)
205206
vpu_hdmi_pd.vpu_clk = vpu_clk;
206207
vpu_hdmi_pd.vapb_clk = vapb_clk;
207208

208-
pm_genpd_init(&vpu_hdmi_pd.genpd, &simple_qos_governor,
209-
meson_gx_pwrc_vpu_get_power(&vpu_hdmi_pd));
209+
powered_off = meson_gx_pwrc_vpu_get_power(&vpu_hdmi_pd);
210+
211+
/* If already powered, sync the clock states */
212+
if (!powered_off) {
213+
ret = meson_gx_pwrc_vpu_setup_clk(&vpu_hdmi_pd);
214+
if (ret)
215+
return ret;
216+
}
217+
218+
pm_genpd_init(&vpu_hdmi_pd.genpd, &pm_domain_always_on_gov,
219+
powered_off);
210220

211221
return of_genpd_add_provider_simple(pdev->dev.of_node,
212222
&vpu_hdmi_pd.genpd);
213223
}
214224

215225
static void meson_gx_pwrc_vpu_shutdown(struct platform_device *pdev)
216226
{
217-
if (vpu_hdmi_pd.powered)
218-
meson_gx_pwrc_vpu_power_off(&vpu_hdmi_pd.genpd);
227+
meson_gx_pwrc_vpu_power_off(&vpu_hdmi_pd.genpd);
219228
}
220229

221230
static const struct of_device_id meson_gx_pwrc_vpu_match_table[] = {

0 commit comments

Comments
 (0)