Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_INTEL_SCU_IPC_H_
3#define _ASM_X86_INTEL_SCU_IPC_H_
4
5#include <linux/ioport.h>
6
7struct device;
8struct intel_scu_ipc_dev;
9
10/**
11 * struct intel_scu_ipc_data - Data used to configure SCU IPC
12 * @mem: Base address of SCU IPC MMIO registers
13 * @irq: The IRQ number used for SCU (optional)
14 */
15struct intel_scu_ipc_data {
16 struct resource mem;
17 int irq;
18};
19
20struct intel_scu_ipc_dev *
21__intel_scu_ipc_register(struct device *parent,
22 const struct intel_scu_ipc_data *scu_data,
23 struct module *owner);
24
25#define intel_scu_ipc_register(parent, scu_data) \
26 __intel_scu_ipc_register(parent, scu_data, THIS_MODULE)
27
28void intel_scu_ipc_unregister(struct intel_scu_ipc_dev *scu);
29
30struct intel_scu_ipc_dev *
31__devm_intel_scu_ipc_register(struct device *parent,
32 const struct intel_scu_ipc_data *scu_data,
33 struct module *owner);
34
35#define devm_intel_scu_ipc_register(parent, scu_data) \
36 __devm_intel_scu_ipc_register(parent, scu_data, THIS_MODULE)
37
38struct intel_scu_ipc_dev *intel_scu_ipc_dev_get(void);
39void intel_scu_ipc_dev_put(struct intel_scu_ipc_dev *scu);
40struct intel_scu_ipc_dev *devm_intel_scu_ipc_dev_get(struct device *dev);
41
42int intel_scu_ipc_dev_ioread8(struct intel_scu_ipc_dev *scu, u16 addr,
43 u8 *data);
44int intel_scu_ipc_dev_iowrite8(struct intel_scu_ipc_dev *scu, u16 addr,
45 u8 data);
46int intel_scu_ipc_dev_readv(struct intel_scu_ipc_dev *scu, u16 *addr,
47 u8 *data, size_t len);
48int intel_scu_ipc_dev_writev(struct intel_scu_ipc_dev *scu, u16 *addr,
49 u8 *data, size_t len);
50
51int intel_scu_ipc_dev_update(struct intel_scu_ipc_dev *scu, u16 addr,
52 u8 data, u8 mask);
53
54int intel_scu_ipc_dev_simple_command(struct intel_scu_ipc_dev *scu, int cmd,
55 int sub);
56int intel_scu_ipc_dev_command_with_size(struct intel_scu_ipc_dev *scu, int cmd,
57 int sub, const void *in, size_t inlen,
58 size_t size, void *out, size_t outlen);
59
60static inline int intel_scu_ipc_dev_command(struct intel_scu_ipc_dev *scu, int cmd,
61 int sub, const void *in, size_t inlen,
62 void *out, size_t outlen)
63{
64 return intel_scu_ipc_dev_command_with_size(scu, cmd, sub, in, inlen,
65 inlen, out, outlen);
66}
67
68#endif
1#ifndef _ASM_X86_INTEL_SCU_IPC_H_
2#define _ASM_X86_INTEL_SCU_IPC_H_
3
4#include <linux/notifier.h>
5
6#define IPCMSG_WARM_RESET 0xF0
7#define IPCMSG_COLD_RESET 0xF1
8#define IPCMSG_SOFT_RESET 0xF2
9#define IPCMSG_COLD_BOOT 0xF3
10
11#define IPCMSG_VRTC 0xFA /* Set vRTC device */
12 /* Command id associated with message IPCMSG_VRTC */
13 #define IPC_CMD_VRTC_SETTIME 1 /* Set time */
14 #define IPC_CMD_VRTC_SETALARM 2 /* Set alarm */
15
16/* Read single register */
17int intel_scu_ipc_ioread8(u16 addr, u8 *data);
18
19/* Read two sequential registers */
20int intel_scu_ipc_ioread16(u16 addr, u16 *data);
21
22/* Read four sequential registers */
23int intel_scu_ipc_ioread32(u16 addr, u32 *data);
24
25/* Read a vector */
26int intel_scu_ipc_readv(u16 *addr, u8 *data, int len);
27
28/* Write single register */
29int intel_scu_ipc_iowrite8(u16 addr, u8 data);
30
31/* Write two sequential registers */
32int intel_scu_ipc_iowrite16(u16 addr, u16 data);
33
34/* Write four sequential registers */
35int intel_scu_ipc_iowrite32(u16 addr, u32 data);
36
37/* Write a vector */
38int intel_scu_ipc_writev(u16 *addr, u8 *data, int len);
39
40/* Update single register based on the mask */
41int intel_scu_ipc_update_register(u16 addr, u8 data, u8 mask);
42
43/* Issue commands to the SCU with or without data */
44int intel_scu_ipc_simple_command(int cmd, int sub);
45int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
46 u32 *out, int outlen);
47/* I2C control api */
48int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data);
49
50/* Update FW version */
51int intel_scu_ipc_fw_update(u8 *buffer, u32 length);
52
53extern struct blocking_notifier_head intel_scu_notifier;
54
55static inline void intel_scu_notifier_add(struct notifier_block *nb)
56{
57 blocking_notifier_chain_register(&intel_scu_notifier, nb);
58}
59
60static inline void intel_scu_notifier_remove(struct notifier_block *nb)
61{
62 blocking_notifier_chain_unregister(&intel_scu_notifier, nb);
63}
64
65static inline int intel_scu_notifier_post(unsigned long v, void *p)
66{
67 return blocking_notifier_call_chain(&intel_scu_notifier, v, p);
68}
69
70#define SCU_AVAILABLE 1
71#define SCU_DOWN 2
72
73#endif