• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_INTEL_SCU_IPC_LEGACY_H_
3 #define _ASM_X86_INTEL_SCU_IPC_LEGACY_H_
4 
5 #include <linux/notifier.h>
6 
7 #define IPCMSG_INDIRECT_READ	0x02
8 #define IPCMSG_INDIRECT_WRITE	0x05
9 
10 #define IPCMSG_COLD_OFF		0x80	/* Only for Tangier */
11 
12 #define IPCMSG_WARM_RESET	0xF0
13 #define IPCMSG_COLD_RESET	0xF1
14 #define IPCMSG_SOFT_RESET	0xF2
15 #define IPCMSG_COLD_BOOT	0xF3
16 
17 #define IPCMSG_VRTC		0xFA	/* Set vRTC device */
18 /* Command id associated with message IPCMSG_VRTC */
19 #define IPC_CMD_VRTC_SETTIME      1	/* Set time */
20 #define IPC_CMD_VRTC_SETALARM     2	/* Set alarm */
21 
22 /* Don't call these in new code - they will be removed eventually */
23 
24 /* Read single register */
intel_scu_ipc_ioread8(u16 addr,u8 * data)25 static inline int intel_scu_ipc_ioread8(u16 addr, u8 *data)
26 {
27 	return intel_scu_ipc_dev_ioread8(NULL, addr, data);
28 }
29 
30 /* Read a vector */
intel_scu_ipc_readv(u16 * addr,u8 * data,int len)31 static inline int intel_scu_ipc_readv(u16 *addr, u8 *data, int len)
32 {
33 	return intel_scu_ipc_dev_readv(NULL, addr, data, len);
34 }
35 
36 /* Write single register */
intel_scu_ipc_iowrite8(u16 addr,u8 data)37 static inline int intel_scu_ipc_iowrite8(u16 addr, u8 data)
38 {
39 	return intel_scu_ipc_dev_iowrite8(NULL, addr, data);
40 }
41 
42 /* Write a vector */
intel_scu_ipc_writev(u16 * addr,u8 * data,int len)43 static inline int intel_scu_ipc_writev(u16 *addr, u8 *data, int len)
44 {
45 	return intel_scu_ipc_dev_writev(NULL, addr, data, len);
46 }
47 
48 /* Update single register based on the mask */
intel_scu_ipc_update_register(u16 addr,u8 data,u8 mask)49 static inline int intel_scu_ipc_update_register(u16 addr, u8 data, u8 mask)
50 {
51 	return intel_scu_ipc_dev_update(NULL, addr, data, mask);
52 }
53 
54 /* Issue commands to the SCU with or without data */
intel_scu_ipc_simple_command(int cmd,int sub)55 static inline int intel_scu_ipc_simple_command(int cmd, int sub)
56 {
57 	return intel_scu_ipc_dev_simple_command(NULL, cmd, sub);
58 }
59 
intel_scu_ipc_command(int cmd,int sub,u32 * in,int inlen,u32 * out,int outlen)60 static inline int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
61 					u32 *out, int outlen)
62 {
63 	/* New API takes both inlen and outlen as bytes so convert here */
64 	size_t inbytes = inlen * sizeof(u32);
65 	size_t outbytes = outlen * sizeof(u32);
66 
67 	return intel_scu_ipc_dev_command_with_size(NULL, cmd, sub, in, inbytes,
68 						   inlen, out, outbytes);
69 }
70 
71 extern struct blocking_notifier_head intel_scu_notifier;
72 
intel_scu_notifier_add(struct notifier_block * nb)73 static inline void intel_scu_notifier_add(struct notifier_block *nb)
74 {
75 	blocking_notifier_chain_register(&intel_scu_notifier, nb);
76 }
77 
intel_scu_notifier_remove(struct notifier_block * nb)78 static inline void intel_scu_notifier_remove(struct notifier_block *nb)
79 {
80 	blocking_notifier_chain_unregister(&intel_scu_notifier, nb);
81 }
82 
intel_scu_notifier_post(unsigned long v,void * p)83 static inline int intel_scu_notifier_post(unsigned long v, void *p)
84 {
85 	return blocking_notifier_call_chain(&intel_scu_notifier, v, p);
86 }
87 
88 #define		SCU_AVAILABLE		1
89 #define		SCU_DOWN		2
90 
91 #endif
92