xref: /OK3568_Linux_fs/kernel/arch/powerpc/include/asm/hvsi.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _HVSI_H
3*4882a593Smuzhiyun #define _HVSI_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #define VS_DATA_PACKET_HEADER           0xff
6*4882a593Smuzhiyun #define VS_CONTROL_PACKET_HEADER        0xfe
7*4882a593Smuzhiyun #define VS_QUERY_PACKET_HEADER          0xfd
8*4882a593Smuzhiyun #define VS_QUERY_RESPONSE_PACKET_HEADER 0xfc
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun /* control verbs */
11*4882a593Smuzhiyun #define VSV_SET_MODEM_CTL    1 /* to service processor only */
12*4882a593Smuzhiyun #define VSV_MODEM_CTL_UPDATE 2 /* from service processor only */
13*4882a593Smuzhiyun #define VSV_CLOSE_PROTOCOL   3
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun /* query verbs */
16*4882a593Smuzhiyun #define VSV_SEND_VERSION_NUMBER 1
17*4882a593Smuzhiyun #define VSV_SEND_MODEM_CTL_STATUS 2
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun /* yes, these masks are not consecutive. */
20*4882a593Smuzhiyun #define HVSI_TSDTR 0x01
21*4882a593Smuzhiyun #define HVSI_TSCD  0x20
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun #define HVSI_MAX_OUTGOING_DATA 12
24*4882a593Smuzhiyun #define HVSI_VERSION 1
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun struct hvsi_header {
27*4882a593Smuzhiyun 	uint8_t  type;
28*4882a593Smuzhiyun 	uint8_t  len;
29*4882a593Smuzhiyun 	__be16 seqno;
30*4882a593Smuzhiyun } __attribute__((packed));
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun struct hvsi_data {
33*4882a593Smuzhiyun 	struct hvsi_header hdr;
34*4882a593Smuzhiyun 	uint8_t  data[HVSI_MAX_OUTGOING_DATA];
35*4882a593Smuzhiyun } __attribute__((packed));
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun struct hvsi_control {
38*4882a593Smuzhiyun 	struct hvsi_header hdr;
39*4882a593Smuzhiyun 	__be16 verb;
40*4882a593Smuzhiyun 	/* optional depending on verb: */
41*4882a593Smuzhiyun 	__be32 word;
42*4882a593Smuzhiyun 	__be32 mask;
43*4882a593Smuzhiyun } __attribute__((packed));
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun struct hvsi_query {
46*4882a593Smuzhiyun 	struct hvsi_header hdr;
47*4882a593Smuzhiyun 	__be16 verb;
48*4882a593Smuzhiyun } __attribute__((packed));
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun struct hvsi_query_response {
51*4882a593Smuzhiyun 	struct hvsi_header hdr;
52*4882a593Smuzhiyun 	__be16 verb;
53*4882a593Smuzhiyun 	__be16 query_seqno;
54*4882a593Smuzhiyun 	union {
55*4882a593Smuzhiyun 		uint8_t  version;
56*4882a593Smuzhiyun 		__be32 mctrl_word;
57*4882a593Smuzhiyun 	} u;
58*4882a593Smuzhiyun } __attribute__((packed));
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun /* hvsi lib struct definitions */
61*4882a593Smuzhiyun #define HVSI_INBUF_SIZE		255
62*4882a593Smuzhiyun struct tty_struct;
63*4882a593Smuzhiyun struct hvsi_priv {
64*4882a593Smuzhiyun 	unsigned int	inbuf_len;	/* data in input buffer */
65*4882a593Smuzhiyun 	unsigned char	inbuf[HVSI_INBUF_SIZE];
66*4882a593Smuzhiyun 	unsigned int	inbuf_cur;	/* Cursor in input buffer */
67*4882a593Smuzhiyun 	unsigned int	inbuf_pktlen;	/* packet length from cursor */
68*4882a593Smuzhiyun 	atomic_t	seqno;		/* packet sequence number */
69*4882a593Smuzhiyun 	unsigned int	opened:1;	/* driver opened */
70*4882a593Smuzhiyun 	unsigned int	established:1;	/* protocol established */
71*4882a593Smuzhiyun 	unsigned int 	is_console:1;	/* used as a kernel console device */
72*4882a593Smuzhiyun 	unsigned int	mctrl_update:1;	/* modem control updated */
73*4882a593Smuzhiyun 	unsigned short	mctrl;		/* modem control */
74*4882a593Smuzhiyun 	struct tty_struct *tty;		/* tty structure */
75*4882a593Smuzhiyun 	int (*get_chars)(uint32_t termno, char *buf, int count);
76*4882a593Smuzhiyun 	int (*put_chars)(uint32_t termno, const char *buf, int count);
77*4882a593Smuzhiyun 	uint32_t	termno;
78*4882a593Smuzhiyun };
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun /* hvsi lib functions */
81*4882a593Smuzhiyun struct hvc_struct;
82*4882a593Smuzhiyun extern void hvsilib_init(struct hvsi_priv *pv,
83*4882a593Smuzhiyun 			 int (*get_chars)(uint32_t termno, char *buf, int count),
84*4882a593Smuzhiyun 			 int (*put_chars)(uint32_t termno, const char *buf,
85*4882a593Smuzhiyun 					  int count),
86*4882a593Smuzhiyun 			 int termno, int is_console);
87*4882a593Smuzhiyun extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp);
88*4882a593Smuzhiyun extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp);
89*4882a593Smuzhiyun extern int hvsilib_read_mctrl(struct hvsi_priv *pv);
90*4882a593Smuzhiyun extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr);
91*4882a593Smuzhiyun extern void hvsilib_establish(struct hvsi_priv *pv);
92*4882a593Smuzhiyun extern int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count);
93*4882a593Smuzhiyun extern int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count);
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun #endif /* _HVSI_H */
96