xref: /rk3399_ARM-atf/plat/mediatek/include/lpm_v2/mt_lp_api.h (revision 06f3c7058c42a9f1a9f7df75ea2de71a000855e8)
1 /*
2  * Copyright (c) 2025, MediaTek Inc. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef MT_LP_API_H
8 #define MT_LP_API_H
9 
10 #include <lpm_v2/mt_lp_rm.h>
11 
12 #if MTK_PUBEVENT_ENABLE
13 #include <vendor_pubsub_events.h>
14 #endif
15 
16 /* UFS clk enum for PLAT_RC_CLKBUF_STATUS */
17 enum rc_update_ex_ufs_ref_clk {
18 	UFS_REF_CLK_OFF = 0,
19 	UFS_REF_CLK_ON,
20 };
21 
22 /* Enum for flight mode  */
23 enum rc_update_ex_flight_mode {
24 	FLIGHT_MODE_OFF = 0,
25 	FLIGHT_MODE_ON,
26 };
27 
28 struct mt_lpm_pubevent_data {
29 	unsigned int u32;
30 };
31 
32 enum mt_lpm_pubevents_id {
33 	MT_LPM_PUBEVENTS_BBLPM_ENTER,
34 	MT_LPM_PUBEVENTS_BBLPM_LEAVE,
35 	MT_LPM_PUBEVENTS_TARGET_CORE,
36 	MT_LPM_PUBEVENTS_SYS_POWER_OFF,
37 	MT_LPM_PUBEVENTS_SYS_POWER_ON,
38 };
39 
40 struct mt_lp_publish_event {
41 	unsigned int id;
42 	struct mt_lpm_pubevent_data val;
43 	unsigned int level;
44 };
45 
46 #if MTK_PUBEVENT_ENABLE
47 #define MT_LP_PUBLISH_EVENT(x) ({ \
48 	PUBLISH_EVENT_ARG(lpm_publish_event, (const void *)(x)); })
49 #define MT_LP_SUSPEND_PUBLISH_EVENT(x) ({ \
50 	PUBLISH_EVENT_ARG(suspend_publish_event, (const void *)(x)); })
51 
52 #define MT_LP_SUBSCRIBE_SUSPEND(func) \
53 	SUBSCRIBE_TO_EVENT(suspend_publish_event, func)
54 #define MT_LP_SUBSCRIBE_LPM(func) \
55 	SUBSCRIBE_TO_EVENT(lpm_publish_event, func)
56 #else
57 #define MT_LP_PUBLISH_EVENT(x)	({ (void)x; })
58 #define MT_LP_SUSPEND_PUBLISH_EVENT(x)	({ (void)x; })
59 #define MT_LP_SUBSCRIBE_SUSPEND(func)
60 #define MT_LP_SUBSCRIBE_LPM(func)
61 #endif
62 
63 /* MTK low power API types for audio */
64 enum mt_lp_api_audio_type {
65 	AUDIO_AFE_ENTER,
66 	AUDIO_AFE_LEAVE,
67 	AUDIO_DSP_ENTER,
68 	AUDIO_DSP_LEAVE,
69 };
70 
71 /* MTK low power API types for usb */
72 enum mt_lp_api_usb_type {
73 	LPM_USB_ENTER,
74 	LPM_USB_LEAVE,
75 	USB_HEADSET_ENTER,
76 	USB_HEADSET_LEAVE,
77 };
78 
79 int mt_audio_update(int type);
80 int mt_usb_update(int type);
81 
82 /* MTK Low Power Scenario Types for logging */
83 enum mtk_lp_scenario_status {
84 	AUDIO_AFE,
85 	AUDIO_DSP,
86 	USB_HEADSET,
87 	MTK_LP_SCENE_NUM,
88 };
89 
90 /* MTK Low Power API Types for CCCI */
91 enum mt_lp_api_ccci_type {
92 	CCCI_AP_MDSRC_REQUEST,
93 	CCCI_AP_MDSRC_RELEASE,
94 	CCCI_AP_MDSRC_ACK,
95 	CCCI_AP_MDSRC_GET_SETTLE,
96 	CCCI_AP_IS_MD_SLEEP,
97 };
98 
99 /* System power level */
100 #define MT_LP_SYSPOWER_LEVEL_APMCU	BIT(0)
101 #define MT_LP_SYSPOWER_LEVEL_DRAM	BIT(1)
102 #define MT_LP_SYSPOWER_LEVEL_SYSPLL	BIT(2)
103 #define MT_LP_SYSPOWER_LEVEL_PMIC_LP	BIT(3)
104 #define MT_LP_SYSPOWER_LEVEL_BUS26M	BIT(4)
105 #define MT_LP_SYSPOWER_LEVEL_VCORE0V	BIT(5)
106 #define MT_LP_SYSPOWER_LEVEL_SUSPEND	BIT(6)
107 
108 
109 enum mt_lpm_pubevent_wake_src {
110 	MT_LPM_WAKE_MD_WAKEUP_CCIF0 = 1,
111 	MT_LPM_WAKE_MD_WAKEUP_CCIF1,
112 	MT_LPM_WAKE_MD_WAKEUP_CLDMA,
113 	MT_LPM_WAKE_MD_WAKEUP_DPMAIF,
114 	MT_LPM_WAKE_MD_WDT,
115 };
116 
117 /* MTK Low Power API Types for GPUEB */
118 enum mt_lp_api_gpueb_type {
119 	GPUEB_PLL_EN,
120 	GPUEB_PLL_DIS,
121 	GPUEB_GET_PWR_STATUS,
122 	GPUEB_GET_MFG0_PWR_CON,
123 };
124 
125 int mt_ccci_hwctrl(int type, void *priv);
126 int mt_gpueb_hwctrl(int type, void *priv);
127 uint64_t mt_get_lp_scenario_status(void);
128 
129 #endif /* MT_LP_API_H */
130