blob: 1aa4eeaa05d9eda5d73ac5f865f1b3b3aaa0017d [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2019
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35
36/*****************************************************************************
37 *
38 * Filename:
39 * ---------
40 * dcl_spmi.h
41 *
42 * Project:
43 * --------
44 * Maui_Software
45 *
46 * Description:
47 * ------------
48 * This file defines structures and functions for SPMI DCL interface.
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 *============================================================================
55 * HISTORY
56 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
57 *------------------------------------------------------------------------------
58 * removed!
59 * removed!
60 * removed!
61 *
62 * removed!
63 * removed!
64 * removed!
65 * removed!
66 *
67 * removed!
68 * removed!
69 *
70 *
71 *------------------------------------------------------------------------------
72 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
73 *============================================================================
74 ****************************************************************************/
75#ifdef DCL_DEFINITION_STRUCT
76
77#ifndef __DCL_SPMI_H_STRUCT__
78#define __DCL_SPMI_H_STRUCT__
79
80/*******************************************************************************
81 * DCL_OPTIONS for SPMI
82 *******************************************************************************/
83#define SPMI_OPTIONS
84
85/*******************************************************************************
86 * DCL_CONFIGURE_T
87 *******************************************************************************/
88#define SPMI_CONFIGS
89
90/*******************************************************************************
91 * DCL_EVENT for SPMI
92 *******************************************************************************/
93#define SPMI_EVENTS
94
95typedef enum
96{
97 DCL_BUCK_CPU,
98 DCL_BUCK_GPU,
99 DCL_BUCK_MD,
100 DCL_BUCK_RF,
101 DCL_MAIN_PMIC,
102 DCL_BUCK_VPU,
103 DCL_SUB_PMIC,
104 DCL_SLV_TYPE_MAX
105}SPMI_SLV_TYPE_ENUM;
106
107/*******************************************************************************
108 * DCL_CTRL_DATA_T: Define the Control data structure for each module's command
109 *******************************************************************************/
110/* For SPMI_CTRL_EXT_REGISTER_READL command. */
111typedef struct
112{
113 DCL_UINT16 type;
114 DCL_UINT16 addr;
115 DCL_UINT16 value;
116 DCL_UINT16 len;
117}SPMI_CTRL_EXT_REGISTER_READL;
118
119/* For SPMI_CTRL_EXT_REGISTER_WRITEL command. */
120typedef struct
121{
122 DCL_UINT16 type;
123 DCL_UINT16 addr;
124 DCL_UINT16 value;
125 DCL_UINT16 len;
126}SPMI_CTRL_EXT_REGISTER_WRITEL;
127
128/* For SPMI_CTRL_EXT_REGISTER_READL_FIELD command. */
129typedef struct
130{
131 DCL_UINT16 type;
132 DCL_UINT16 addr;
133 DCL_UINT16 value;
134 DCL_UINT16 len;
135 DCL_UINT16 mask;
136 DCL_UINT16 shift;
137}SPMI_CTRL_EXT_REGISTER_READL_FIELD;
138
139/* For SPMI_CTRL_EXT_REGISTER_WRITEL_FIELD command. */
140typedef struct
141{
142 DCL_UINT16 type;
143 DCL_UINT16 addr;
144 DCL_UINT16 value;
145 DCL_UINT16 len;
146 DCL_UINT16 mask;
147 DCL_UINT16 shift;
148}SPMI_CTRL_EXT_REGISTER_WRITEL_FIELD;
149
150/*******************************************************************************
151 * DCL_CTRL_DATA_T: Define the Control data structure for each module's command
152 *******************************************************************************/
153#ifdef __BUILD_DOM__
154/* The SPMI Command Parameter Data Structure for Each Command in DCL_CTRL_DATA_T Enum of dcl.h */
155typedef struct
156{
157 SPMI_CTRL_EXT_REGISTER_READL rSPMIExtRegisterReadL;
158 SPMI_CTRL_EXT_REGISTER_WRITEL rSPMIExtRegisterWriteL;
159 SPMI_CTRL_EXT_REGISTER_READL_FIELD rSPMIExtRegisterReadLField;
160 SPMI_CTRL_EXT_REGISTER_WRITEL_FIELD rSPMIExtRegisterWriteLField;
161}SPMI_CTRL_DATA;
162#else /* __BUILD_DOM__ */
163#define SPMI_CTRLS \
164 SPMI_CTRL_EXT_REGISTER_READL rSPMIExtRegisterReadL; \
165 SPMI_CTRL_EXT_REGISTER_WRITEL rSPMIExtRegisterWriteL; \
166 SPMI_CTRL_EXT_REGISTER_READL_FIELD rSPMIExtRegisterReadLField; \
167 SPMI_CTRL_EXT_REGISTER_WRITEL_FIELD rSPMIExtRegisterWriteLField;
168#endif /* __BUILD_DOM__ */
169
170/*******************************************************************************
171 * DCL_CTRL_CMD for SPMI
172 *******************************************************************************/
173 #ifdef __BUILD_DOM__
174typedef enum {
175 EXT_REGISTER_READL = 0,
176 EXT_REGISTER_WRITEL,
177 EXT_REGISTER_READL_FIELD,
178 EXT_REGISTER_WRITEL_FIELD,
179 REGISTER_READ,
180 REGISTER_WRITE,
181 EXT_REGISTER_READ,
182 EXT_REGISTER_WRITE,
183 SPMI_MOD_CMD_MAX
184} SPMI_CTRL_CMD;
185#else /* __BUILD_DOM__ */
186#define SPMI_CMDS \
187 EXT_REGISTER_READL = 0, \
188 EXT_REGISTER_WRITEL, \
189 EXT_REGISTER_READL_FIELD, \
190 EXT_REGISTER_WRITEL_FIELD, \
191 REGISTER_READ, \
192 REGISTER_WRITE, \
193 EXT_REGISTER_READ, \
194 EXT_REGISTER_WRITE, \
195 SPMI_MOD_CMD_MAX,
196#endif /* __BUILD_DOM__ */
197
198#endif /*__DCL_SPMI_H_STRUCT__*/
199
200#endif /*DCL_DEFINITION_STRUCT*/
201
202#ifdef DCL_DEFINITION_PROTOTYPE
203#ifndef __DCL_SPMI_H_PROTOTYPE__
204#define __DCL_SPMI_H_PROTOTYPE__
205
206typedef DCL_STATUS (*SPMI_CONTROL_HANDLER)(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
207/*************************************************************************
208* FUNCTION
209* DclSPMI_Initialize
210*
211* DESCRIPTION
212* This function is to initialize SPMI module
213*
214* PARAMETERS
215* None
216*
217* RETURNS
218* STATUS_OK
219*
220*************************************************************************/
221extern DCL_STATUS DclSPMI_Initialize(void);
222/*************************************************************************
223* FUNCTION
224* DclSPMI_Open
225*
226* DESCRIPTION
227* This function is to open the SPMI module and return a handle
228*
229* PARAMETERS
230* dev: only valid for DCL_SPMI
231* flags: no sepcial flags is needed. Please use FLAGS_NONE
232*
233* RETURNS
234* DCL_HANDLE_INVALID: Open failed.
235* other value: a valid handle
236*
237*************************************************************************/
238extern DCL_HANDLE DclSPMI_Open(DCL_DEV dev, DCL_FLAGS flags);
239/*************************************************************************
240* FUNCTION
241* DclSPMI_ReadData
242*
243* DESCRIPTION
244* This function is not supported for the SPMI module now.
245*
246* PARAMETERS
247* N/A
248*
249* RETURNS
250* STATUS_UNSUPPORTED
251*
252*************************************************************************/
253extern DCL_STATUS DclSPMI_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options);
254/*************************************************************************
255* FUNCTION
256* DclSPMI_WriteData
257*
258* DESCRIPTION
259* This function is not supported for the SPMI module now.
260*
261* PARAMETERS
262* N/A
263*
264* RETURNS
265* STATUS_UNSUPPORTED
266*
267*************************************************************************/
268extern DCL_STATUS DclSPMI_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options);
269/*************************************************************************
270* FUNCTION
271* DclSPMI_Configure
272*
273* DESCRIPTION
274* This function is not supported for the SPMI module now.
275*
276* PARAMETERS
277* N/A
278*
279* RETURNS
280* STATUS_UNSUPPORTED
281*
282*************************************************************************/
283extern DCL_STATUS DclSPMI_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure);
284/*************************************************************************
285* FUNCTION
286* DclSPMI_RegisterCallback
287*
288* DESCRIPTION
289* This function is not supported for the SPMI module now.
290*
291* PARAMETERS
292* N/A
293*
294* RETURNS
295* STATUS_UNSUPPORTED
296*
297*************************************************************************/
298extern DCL_STATUS DclSPMI_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback);
299/*************************************************************************
300* FUNCTION
301* DclSPMI_Control
302*
303* DESCRIPTION
304* This function is to send command to control the SPMI module.
305*
306* PARAMETERS
307* handle: The handle value returned from DclSPMI_Open
308* cmd: a control command for SPMI module
309* RETURNS
310* STATUS_OK: command is executed successfully.
311* STATUS_FAIL: command is failed.
312* STATUS_INVALID_CMD: It's a invalid command.
313* STATUS_UNSUPPORTED: It's a unsupported command.
314*
315*************************************************************************/
316extern DCL_STATUS DclSPMI_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
317/*************************************************************************
318* FUNCTION
319* DclSPMI_Close
320*
321* DESCRIPTION
322* This function is to close the spmi module.
323*
324* PARAMETERS
325* handle: the returned handle value of DclSPMI_Close
326*
327* RETURNS
328* STATUS_OK
329*
330*************************************************************************/
331extern DCL_STATUS DclSPMI_Close(DCL_HANDLE handle);
332#endif /*__DCL_SPMI_H_PROTOTYPE__*/
333#endif //DCL_DEFINITION_PROTOTYPE
334
335