blob: e7ab77ed7213a49f15904eddd8de1af5cfc8264f
1 | /* |
2 | * drivers/amlogic/media/frame_provider/decoder/utils/vdec_power_ctrl.h |
3 | * |
4 | * Copyright (C) 2016 Amlogic, Inc. All rights reserved. |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
14 | * more details. |
15 | * |
16 | */ |
17 | |
18 | #include <linux/kernel.h> |
19 | #include <linux/types.h> |
20 | #include <linux/errno.h> |
21 | #include <linux/of.h> |
22 | #include <linux/of_fdt.h> |
23 | #include <linux/of_device.h> |
24 | #include <linux/module.h> |
25 | #include <linux/delay.h> |
26 | #include <linux/version.h> |
27 | #include <linux/device.h> |
28 | #include <linux/platform_device.h> |
29 | #include <linux/pm.h> |
30 | #include <linux/pm_domain.h> |
31 | #include <linux/pm_runtime.h> |
32 | #include "vdec.h" |
33 | |
34 | /* Directly controlled by reading and writing registers. */ |
35 | #define PM_POWER_CTRL_RW_REG (0) |
36 | |
37 | /* Use power_ctrl_xxx family of interface controls. */ |
38 | #define PM_POWER_CTRL_API (1) |
39 | |
40 | /* |
41 | * Power Domain interface control, currently supported |
42 | * in versions 4.19 and above. |
43 | */ |
44 | #define PM_POWER_DOMAIN (2) |
45 | |
46 | /* |
47 | * Controlled by the secure API provided by power domain, |
48 | * version 4.9 supports currently supported platforms (SC2). |
49 | */ |
50 | #define PM_POWER_DOMAIN_SEC_API (3) |
51 | |
52 | /* |
53 | * Use non-secure API control through power domain, version 4.9 support, |
54 | * currently supported platforms (SM1, TM2, TM2-revB). |
55 | */ |
56 | #define PM_POWER_DOMAIN_NONSEC_API (4) |
57 | |
58 | enum pm_pd_e { |
59 | PD_VDEC, |
60 | PD_HCODEC, |
61 | PD_VDEC2, |
62 | PD_HEVC, |
63 | PD_HEVCB, |
64 | PD_WAVE, |
65 | PD_MAX |
66 | }; |
67 | |
68 | struct pm_pd_s { |
69 | u8 *name; |
70 | struct device *dev; |
71 | struct device_link *link; |
72 | }; |
73 | |
74 | struct power_manager_s { |
75 | int pm_type; |
76 | struct pm_pd_s *pd_data; |
77 | int (*init) (struct device *dev); |
78 | void (*release) (struct device *dev); |
79 | void (*power_on) (struct device *dev, int id); |
80 | void (*power_off) (struct device *dev, int id); |
81 | bool (*power_state) (struct device *dev, int id); |
82 | }; |
83 | |
84 | const char *get_pm_name(int type); |
85 | |
86 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) |
87 | #define DL_FLAG_STATELESS BIT(0) |
88 | #define DL_FLAG_AUTOREMOVE_CONSUMER BIT(1) |
89 | #define DL_FLAG_PM_RUNTIME BIT(2) |
90 | #define DL_FLAG_RPM_ACTIVE BIT(3) |
91 | #define DL_FLAG_AUTOREMOVE_SUPPLIER BIT(4) |
92 | |
93 | struct device_link { |
94 | u32 flags; |
95 | /* ... */ |
96 | }; |
97 | |
98 | static inline struct device *dev_pm_domain_attach_by_name(struct device *dev, |
99 | const char *name) |
100 | { return NULL; } |
101 | static inline struct device_link *device_link_add(struct device *consumer, |
102 | struct device *supplier, u32 flags) |
103 | { return NULL; } |
104 | static inline void device_link_del(struct device_link *link) { return; } |
105 | static inline void device_link_remove(void *consumer, struct device *supplier) { return; } |
106 | #endif |
107 | |
108 |