xref: /linux/include/linux/scmi_imx_protocol.h (revision 297d9111e9fcf47dd1dcc6f79bba915f35378d01)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * SCMI Message Protocol driver NXP extension header
4  *
5  * Copyright 2024 NXP.
6  */
7 
8 #ifndef _LINUX_SCMI_NXP_PROTOCOL_H
9 #define _LINUX_SCMI_NXP_PROTOCOL_H
10 
11 #include <linux/bitfield.h>
12 #include <linux/device.h>
13 #include <linux/notifier.h>
14 #include <linux/scmi_protocol.h>
15 #include <linux/types.h>
16 
17 #define SCMI_PROTOCOL_IMX_LMM	0x80
18 #define	SCMI_PROTOCOL_IMX_BBM	0x81
19 #define SCMI_PROTOCOL_IMX_CPU	0x82
20 #define	SCMI_PROTOCOL_IMX_MISC	0x84
21 
22 #define SCMI_IMX_VENDOR		"NXP"
23 #define SCMI_IMX_SUBVENDOR	"IMX"
24 
25 struct scmi_imx_bbm_proto_ops {
26 	int (*rtc_time_set)(const struct scmi_protocol_handle *ph, u32 id,
27 			    uint64_t sec);
28 	int (*rtc_time_get)(const struct scmi_protocol_handle *ph, u32 id,
29 			    u64 *val);
30 	int (*rtc_alarm_set)(const struct scmi_protocol_handle *ph, u32 id,
31 			     bool enable, u64 sec);
32 	int (*button_get)(const struct scmi_protocol_handle *ph, u32 *state);
33 };
34 
35 enum scmi_nxp_notification_events {
36 	SCMI_EVENT_IMX_BBM_RTC = 0x0,
37 	SCMI_EVENT_IMX_BBM_BUTTON = 0x1,
38 	SCMI_EVENT_IMX_MISC_CONTROL = 0x0,
39 };
40 
41 struct scmi_imx_bbm_notif_report {
42 	bool			is_rtc;
43 	bool			is_button;
44 	ktime_t			timestamp;
45 	unsigned int		rtc_id;
46 	unsigned int		rtc_evt;
47 };
48 
49 struct scmi_imx_misc_ctrl_notify_report {
50 	ktime_t			timestamp;
51 	unsigned int		ctrl_id;
52 	unsigned int		flags;
53 };
54 
55 struct scmi_imx_misc_proto_ops {
56 	int (*misc_ctrl_set)(const struct scmi_protocol_handle *ph, u32 id,
57 			     u32 num, u32 *val);
58 	int (*misc_ctrl_get)(const struct scmi_protocol_handle *ph, u32 id,
59 			     u32 *num, u32 *val);
60 	int (*misc_ctrl_req_notify)(const struct scmi_protocol_handle *ph,
61 				    u32 ctrl_id, u32 evt_id, u32 flags);
62 };
63 
64 /* See LMM_ATTRIBUTES in imx95.rst */
65 #define	LMM_ID_DISCOVER	0xFFFFFFFFU
66 #define	LMM_MAX_NAME	16
67 
68 enum scmi_imx_lmm_state {
69 	LMM_STATE_LM_OFF,
70 	LMM_STATE_LM_ON,
71 	LMM_STATE_LM_SUSPEND,
72 	LMM_STATE_LM_POWERED,
73 };
74 
75 struct scmi_imx_lmm_info {
76 	u32 lmid;
77 	enum scmi_imx_lmm_state state;
78 	u32 errstatus;
79 	u8 name[LMM_MAX_NAME];
80 };
81 
82 struct scmi_imx_lmm_proto_ops {
83 	int (*lmm_power_boot)(const struct scmi_protocol_handle *ph, u32 lmid,
84 			      bool boot);
85 	int (*lmm_info)(const struct scmi_protocol_handle *ph, u32 lmid,
86 			struct scmi_imx_lmm_info *info);
87 	int (*lmm_reset_vector_set)(const struct scmi_protocol_handle *ph,
88 				    u32 lmid, u32 cpuid, u32 flags, u64 vector);
89 	int (*lmm_shutdown)(const struct scmi_protocol_handle *ph, u32 lmid,
90 			    u32 flags);
91 };
92 
93 struct scmi_imx_cpu_proto_ops {
94 	int (*cpu_reset_vector_set)(const struct scmi_protocol_handle *ph,
95 				    u32 cpuid, u64 vector, bool start,
96 				    bool boot, bool resume);
97 	int (*cpu_start)(const struct scmi_protocol_handle *ph, u32 cpuid,
98 			 bool start);
99 	int (*cpu_started)(const struct scmi_protocol_handle *ph, u32 cpuid,
100 			   bool *started);
101 };
102 #endif
103