xref: /linux/arch/powerpc/include/asm/hvsi.h (revision 17bdc6c0e979ae61879806e4dd93ec3b169d0931)
1725e789fSBenjamin Herrenschmidt #ifndef _HVSI_H
2725e789fSBenjamin Herrenschmidt #define _HVSI_H
3725e789fSBenjamin Herrenschmidt 
4725e789fSBenjamin Herrenschmidt #define VS_DATA_PACKET_HEADER           0xff
5725e789fSBenjamin Herrenschmidt #define VS_CONTROL_PACKET_HEADER        0xfe
6725e789fSBenjamin Herrenschmidt #define VS_QUERY_PACKET_HEADER          0xfd
7725e789fSBenjamin Herrenschmidt #define VS_QUERY_RESPONSE_PACKET_HEADER 0xfc
8725e789fSBenjamin Herrenschmidt 
9725e789fSBenjamin Herrenschmidt /* control verbs */
10725e789fSBenjamin Herrenschmidt #define VSV_SET_MODEM_CTL    1 /* to service processor only */
11725e789fSBenjamin Herrenschmidt #define VSV_MODEM_CTL_UPDATE 2 /* from service processor only */
12725e789fSBenjamin Herrenschmidt #define VSV_CLOSE_PROTOCOL   3
13725e789fSBenjamin Herrenschmidt 
14725e789fSBenjamin Herrenschmidt /* query verbs */
15725e789fSBenjamin Herrenschmidt #define VSV_SEND_VERSION_NUMBER 1
16725e789fSBenjamin Herrenschmidt #define VSV_SEND_MODEM_CTL_STATUS 2
17725e789fSBenjamin Herrenschmidt 
18725e789fSBenjamin Herrenschmidt /* yes, these masks are not consecutive. */
19725e789fSBenjamin Herrenschmidt #define HVSI_TSDTR 0x01
20725e789fSBenjamin Herrenschmidt #define HVSI_TSCD  0x20
21725e789fSBenjamin Herrenschmidt 
22725e789fSBenjamin Herrenschmidt #define HVSI_MAX_OUTGOING_DATA 12
23725e789fSBenjamin Herrenschmidt #define HVSI_VERSION 1
24725e789fSBenjamin Herrenschmidt 
25725e789fSBenjamin Herrenschmidt struct hvsi_header {
26725e789fSBenjamin Herrenschmidt 	uint8_t  type;
27725e789fSBenjamin Herrenschmidt 	uint8_t  len;
28725e789fSBenjamin Herrenschmidt 	uint16_t seqno;
29725e789fSBenjamin Herrenschmidt } __attribute__((packed));
30725e789fSBenjamin Herrenschmidt 
31725e789fSBenjamin Herrenschmidt struct hvsi_data {
32048bee77SBenjamin Herrenschmidt 	struct hvsi_header hdr;
33725e789fSBenjamin Herrenschmidt 	uint8_t  data[HVSI_MAX_OUTGOING_DATA];
34725e789fSBenjamin Herrenschmidt } __attribute__((packed));
35725e789fSBenjamin Herrenschmidt 
36725e789fSBenjamin Herrenschmidt struct hvsi_control {
37048bee77SBenjamin Herrenschmidt 	struct hvsi_header hdr;
38725e789fSBenjamin Herrenschmidt 	uint16_t verb;
39725e789fSBenjamin Herrenschmidt 	/* optional depending on verb: */
40725e789fSBenjamin Herrenschmidt 	uint32_t word;
41725e789fSBenjamin Herrenschmidt 	uint32_t mask;
42725e789fSBenjamin Herrenschmidt } __attribute__((packed));
43725e789fSBenjamin Herrenschmidt 
44725e789fSBenjamin Herrenschmidt struct hvsi_query {
45048bee77SBenjamin Herrenschmidt 	struct hvsi_header hdr;
46725e789fSBenjamin Herrenschmidt 	uint16_t verb;
47725e789fSBenjamin Herrenschmidt } __attribute__((packed));
48725e789fSBenjamin Herrenschmidt 
49725e789fSBenjamin Herrenschmidt struct hvsi_query_response {
50048bee77SBenjamin Herrenschmidt 	struct hvsi_header hdr;
51725e789fSBenjamin Herrenschmidt 	uint16_t verb;
52725e789fSBenjamin Herrenschmidt 	uint16_t query_seqno;
53725e789fSBenjamin Herrenschmidt 	union {
54725e789fSBenjamin Herrenschmidt 		uint8_t  version;
55725e789fSBenjamin Herrenschmidt 		uint32_t mctrl_word;
56725e789fSBenjamin Herrenschmidt 	} u;
57725e789fSBenjamin Herrenschmidt } __attribute__((packed));
58725e789fSBenjamin Herrenschmidt 
59*17bdc6c0SBenjamin Herrenschmidt /* hvsi lib struct definitions */
60*17bdc6c0SBenjamin Herrenschmidt #define HVSI_INBUF_SIZE		255
61*17bdc6c0SBenjamin Herrenschmidt struct tty_struct;
62*17bdc6c0SBenjamin Herrenschmidt struct hvsi_priv {
63*17bdc6c0SBenjamin Herrenschmidt 	unsigned int	inbuf_len;	/* data in input buffer */
64*17bdc6c0SBenjamin Herrenschmidt 	unsigned char	inbuf[HVSI_INBUF_SIZE];
65*17bdc6c0SBenjamin Herrenschmidt 	unsigned int	inbuf_cur;	/* Cursor in input buffer */
66*17bdc6c0SBenjamin Herrenschmidt 	unsigned int	inbuf_pktlen;	/* packet lenght from cursor */
67*17bdc6c0SBenjamin Herrenschmidt 	atomic_t	seqno;		/* packet sequence number */
68*17bdc6c0SBenjamin Herrenschmidt 	unsigned int	opened:1;	/* driver opened */
69*17bdc6c0SBenjamin Herrenschmidt 	unsigned int	established:1;	/* protocol established */
70*17bdc6c0SBenjamin Herrenschmidt 	unsigned int 	is_console:1;	/* used as a kernel console device */
71*17bdc6c0SBenjamin Herrenschmidt 	unsigned int	mctrl_update:1;	/* modem control updated */
72*17bdc6c0SBenjamin Herrenschmidt 	unsigned short	mctrl;		/* modem control */
73*17bdc6c0SBenjamin Herrenschmidt 	struct tty_struct *tty;		/* tty structure */
74*17bdc6c0SBenjamin Herrenschmidt 	int (*get_chars)(uint32_t termno, char *buf, int count);
75*17bdc6c0SBenjamin Herrenschmidt 	int (*put_chars)(uint32_t termno, const char *buf, int count);
76*17bdc6c0SBenjamin Herrenschmidt 	uint32_t	termno;
77*17bdc6c0SBenjamin Herrenschmidt };
78*17bdc6c0SBenjamin Herrenschmidt 
79*17bdc6c0SBenjamin Herrenschmidt /* hvsi lib functions */
80*17bdc6c0SBenjamin Herrenschmidt struct hvc_struct;
81*17bdc6c0SBenjamin Herrenschmidt extern void hvsi_init(struct hvsi_priv *pv,
82*17bdc6c0SBenjamin Herrenschmidt 		      int (*get_chars)(uint32_t termno, char *buf, int count),
83*17bdc6c0SBenjamin Herrenschmidt 		      int (*put_chars)(uint32_t termno, const char *buf,
84*17bdc6c0SBenjamin Herrenschmidt 				       int count),
85*17bdc6c0SBenjamin Herrenschmidt 		      int termno, int is_console);
86*17bdc6c0SBenjamin Herrenschmidt extern int hvsi_open(struct hvsi_priv *pv, struct hvc_struct *hp);
87*17bdc6c0SBenjamin Herrenschmidt extern void hvsi_close(struct hvsi_priv *pv, struct hvc_struct *hp);
88*17bdc6c0SBenjamin Herrenschmidt extern int hvsi_read_mctrl(struct hvsi_priv *pv);
89*17bdc6c0SBenjamin Herrenschmidt extern int hvsi_write_mctrl(struct hvsi_priv *pv, int dtr);
90*17bdc6c0SBenjamin Herrenschmidt extern void hvsi_establish(struct hvsi_priv *pv);
91*17bdc6c0SBenjamin Herrenschmidt extern int hvsi_get_chars(struct hvsi_priv *pv, char *buf, int count);
92*17bdc6c0SBenjamin Herrenschmidt extern int hvsi_put_chars(struct hvsi_priv *pv, const char *buf, int count);
93725e789fSBenjamin Herrenschmidt 
94725e789fSBenjamin Herrenschmidt #endif /* _HVSI_H */
95