xref: /linux/include/linux/scmi_imx_protocol.h (revision bdbddf72a2ab1cfea699959795d70df3931eefe7)
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 	int (*misc_syslog)(const struct scmi_protocol_handle *ph, u16 *size,
63 			   void *array);
64 };
65 
66 /* See LMM_ATTRIBUTES in imx95.rst */
67 #define	LMM_ID_DISCOVER	0xFFFFFFFFU
68 #define	LMM_MAX_NAME	16
69 
70 enum scmi_imx_lmm_state {
71 	LMM_STATE_LM_OFF,
72 	LMM_STATE_LM_ON,
73 	LMM_STATE_LM_SUSPEND,
74 	LMM_STATE_LM_POWERED,
75 };
76 
77 struct scmi_imx_lmm_info {
78 	u32 lmid;
79 	enum scmi_imx_lmm_state state;
80 	u32 errstatus;
81 	u8 name[LMM_MAX_NAME];
82 };
83 
84 struct scmi_imx_lmm_proto_ops {
85 	int (*lmm_power_boot)(const struct scmi_protocol_handle *ph, u32 lmid,
86 			      bool boot);
87 	int (*lmm_info)(const struct scmi_protocol_handle *ph, u32 lmid,
88 			struct scmi_imx_lmm_info *info);
89 	int (*lmm_reset_vector_set)(const struct scmi_protocol_handle *ph,
90 				    u32 lmid, u32 cpuid, u32 flags, u64 vector);
91 	int (*lmm_shutdown)(const struct scmi_protocol_handle *ph, u32 lmid,
92 			    u32 flags);
93 };
94 
95 struct scmi_imx_cpu_proto_ops {
96 	int (*cpu_reset_vector_set)(const struct scmi_protocol_handle *ph,
97 				    u32 cpuid, u64 vector, bool start,
98 				    bool boot, bool resume);
99 	int (*cpu_start)(const struct scmi_protocol_handle *ph, u32 cpuid,
100 			 bool start);
101 	int (*cpu_started)(const struct scmi_protocol_handle *ph, u32 cpuid,
102 			   bool *started);
103 };
104 #endif
105