bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0157-drm-v3d-Hook-up-the-runtime-PM-ops.patch
1 From 9d058ec3839e19637efc1957cdbbdafd69878acb Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Mon, 14 Jan 2019 14:47:57 -0800
4 Subject: [PATCH] drm/v3d: Hook up the runtime PM ops.
5
6 In translating the runtime PM code from vc4, I missed the ".pm"
7 assignment to actually connect them up. Fixes missing MMU setup if
8 runtime PM resets V3D.
9
10 Signed-off-by: Eric Anholt <eric@anholt.net>
11 (cherry picked from commit ca197699af29baa8236c74c53d4904ca8957ee06)
12 ---
13 drivers/gpu/drm/v3d/v3d_drv.c | 37 +++++++++++++++++++++++++++++++++++
14 1 file changed, 37 insertions(+)
15
16 --- a/drivers/gpu/drm/v3d/v3d_drv.c
17 +++ b/drivers/gpu/drm/v3d/v3d_drv.c
18 @@ -38,6 +38,42 @@
19 #define DRIVER_MINOR 0
20 #define DRIVER_PATCHLEVEL 0
21
22 +#ifdef CONFIG_PM
23 +static int v3d_runtime_suspend(struct device *dev)
24 +{
25 + struct drm_device *drm = dev_get_drvdata(dev);
26 + struct v3d_dev *v3d = to_v3d_dev(drm);
27 +
28 + v3d_irq_disable(v3d);
29 +
30 + clk_disable_unprepare(v3d->clk);
31 +
32 + return 0;
33 +}
34 +
35 +static int v3d_runtime_resume(struct device *dev)
36 +{
37 + struct drm_device *drm = dev_get_drvdata(dev);
38 + struct v3d_dev *v3d = to_v3d_dev(drm);
39 + int ret;
40 +
41 + ret = clk_prepare_enable(v3d->clk);
42 + if (ret != 0)
43 + return ret;
44 +
45 + /* XXX: VPM base */
46 +
47 + v3d_mmu_set_page_table(v3d);
48 + v3d_irq_enable(v3d);
49 +
50 + return 0;
51 +}
52 +#endif
53 +
54 +static const struct dev_pm_ops v3d_pm_ops = {
55 + SET_RUNTIME_PM_OPS(v3d_runtime_suspend, v3d_runtime_resume, NULL)
56 +};
57 +
58 static int v3d_get_param_ioctl(struct drm_device *dev, void *data,
59 struct drm_file *file_priv)
60 {
61 @@ -332,6 +368,7 @@ static struct platform_driver v3d_platfo
62 .driver = {
63 .name = "v3d",
64 .of_match_table = v3d_of_match,
65 + .pm = &v3d_pm_ops,
66 },
67 };
68