xref: /linux/drivers/misc/mei/vsc-tp.h (revision 021bc4b9)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2023, Intel Corporation.
4  * Intel Visual Sensing Controller Transport Layer Linux driver
5  */
6 
7 #ifndef _VSC_TP_H_
8 #define _VSC_TP_H_
9 
10 #include <linux/types.h>
11 
12 #define VSC_TP_CMD_WRITE	0x01
13 #define VSC_TP_CMD_READ		0x02
14 
15 #define VSC_TP_CMD_ACK		0x10
16 #define VSC_TP_CMD_NACK		0x11
17 #define VSC_TP_CMD_BUSY		0x12
18 
19 struct vsc_tp;
20 
21 /**
22  * typedef vsc_event_cb_t - event callback function signature
23  * @context: the execution context of who registered this callback
24  *
25  * The callback function is called in interrupt context and the data
26  * payload is only valid during the call. If the user needs access
27  * the data payload later, it must copy the payload.
28  */
29 typedef void (*vsc_tp_event_cb_t)(void *context);
30 
31 int vsc_tp_rom_xfer(struct vsc_tp *tp, const void *obuf, void *ibuf,
32 		    size_t len);
33 
34 int vsc_tp_xfer(struct vsc_tp *tp, u8 cmd, const void *obuf, size_t olen,
35 		void *ibuf, size_t ilen);
36 
37 int vsc_tp_register_event_cb(struct vsc_tp *tp, vsc_tp_event_cb_t event_cb,
38 			     void *context);
39 
40 void vsc_tp_intr_enable(struct vsc_tp *tp);
41 void vsc_tp_intr_disable(struct vsc_tp *tp);
42 void vsc_tp_intr_synchronize(struct vsc_tp *tp);
43 
44 void vsc_tp_reset(struct vsc_tp *tp);
45 
46 bool vsc_tp_need_read(struct vsc_tp *tp);
47 
48 int vsc_tp_init(struct vsc_tp *tp, struct device *dev);
49 
50 #endif
51