blob: d4a5315718ca454a6a4d01ceab9d4a0e767ac267 [file] [log] [blame]
Benjamin Herrenschmidt725e7892011-06-16 15:08:12 +00001#ifndef _HVSI_H
2#define _HVSI_H
3
4#define VS_DATA_PACKET_HEADER 0xff
5#define VS_CONTROL_PACKET_HEADER 0xfe
6#define VS_QUERY_PACKET_HEADER 0xfd
7#define VS_QUERY_RESPONSE_PACKET_HEADER 0xfc
8
9/* control verbs */
10#define VSV_SET_MODEM_CTL 1 /* to service processor only */
11#define VSV_MODEM_CTL_UPDATE 2 /* from service processor only */
12#define VSV_CLOSE_PROTOCOL 3
13
14/* query verbs */
15#define VSV_SEND_VERSION_NUMBER 1
16#define VSV_SEND_MODEM_CTL_STATUS 2
17
18/* yes, these masks are not consecutive. */
19#define HVSI_TSDTR 0x01
20#define HVSI_TSCD 0x20
21
22#define HVSI_MAX_OUTGOING_DATA 12
23#define HVSI_VERSION 1
24
25struct hvsi_header {
26 uint8_t type;
27 uint8_t len;
Benjamin Herrenschmidt99fc1d92013-09-23 12:05:07 +100028 __be16 seqno;
Benjamin Herrenschmidt725e7892011-06-16 15:08:12 +000029} __attribute__((packed));
30
31struct hvsi_data {
Benjamin Herrenschmidt048bee72011-06-16 15:08:24 +000032 struct hvsi_header hdr;
Benjamin Herrenschmidt725e7892011-06-16 15:08:12 +000033 uint8_t data[HVSI_MAX_OUTGOING_DATA];
34} __attribute__((packed));
35
36struct hvsi_control {
Benjamin Herrenschmidt048bee72011-06-16 15:08:24 +000037 struct hvsi_header hdr;
Benjamin Herrenschmidt99fc1d92013-09-23 12:05:07 +100038 __be16 verb;
Benjamin Herrenschmidt725e7892011-06-16 15:08:12 +000039 /* optional depending on verb: */
Benjamin Herrenschmidt99fc1d92013-09-23 12:05:07 +100040 __be32 word;
41 __be32 mask;
Benjamin Herrenschmidt725e7892011-06-16 15:08:12 +000042} __attribute__((packed));
43
44struct hvsi_query {
Benjamin Herrenschmidt048bee72011-06-16 15:08:24 +000045 struct hvsi_header hdr;
Benjamin Herrenschmidt99fc1d92013-09-23 12:05:07 +100046 __be16 verb;
Benjamin Herrenschmidt725e7892011-06-16 15:08:12 +000047} __attribute__((packed));
48
49struct hvsi_query_response {
Benjamin Herrenschmidt048bee72011-06-16 15:08:24 +000050 struct hvsi_header hdr;
Benjamin Herrenschmidt99fc1d92013-09-23 12:05:07 +100051 __be16 verb;
52 __be16 query_seqno;
Benjamin Herrenschmidt725e7892011-06-16 15:08:12 +000053 union {
54 uint8_t version;
Benjamin Herrenschmidt99fc1d92013-09-23 12:05:07 +100055 __be32 mctrl_word;
Benjamin Herrenschmidt725e7892011-06-16 15:08:12 +000056 } u;
57} __attribute__((packed));
58
Benjamin Herrenschmidt17bdc6c2011-04-29 16:44:24 +100059/* hvsi lib struct definitions */
60#define HVSI_INBUF_SIZE 255
61struct tty_struct;
62struct hvsi_priv {
63 unsigned int inbuf_len; /* data in input buffer */
64 unsigned char inbuf[HVSI_INBUF_SIZE];
65 unsigned int inbuf_cur; /* Cursor in input buffer */
66 unsigned int inbuf_pktlen; /* packet lenght from cursor */
67 atomic_t seqno; /* packet sequence number */
68 unsigned int opened:1; /* driver opened */
69 unsigned int established:1; /* protocol established */
70 unsigned int is_console:1; /* used as a kernel console device */
71 unsigned int mctrl_update:1; /* modem control updated */
72 unsigned short mctrl; /* modem control */
73 struct tty_struct *tty; /* tty structure */
74 int (*get_chars)(uint32_t termno, char *buf, int count);
75 int (*put_chars)(uint32_t termno, const char *buf, int count);
76 uint32_t termno;
77};
78
79/* hvsi lib functions */
80struct hvc_struct;
Benjamin Herrenschmidt87fa35d2011-07-01 13:10:21 +100081extern void hvsilib_init(struct hvsi_priv *pv,
82 int (*get_chars)(uint32_t termno, char *buf, int count),
83 int (*put_chars)(uint32_t termno, const char *buf,
84 int count),
85 int termno, int is_console);
86extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp);
87extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp);
88extern int hvsilib_read_mctrl(struct hvsi_priv *pv);
89extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr);
90extern void hvsilib_establish(struct hvsi_priv *pv);
91extern int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count);
92extern int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count);
Benjamin Herrenschmidt725e7892011-06-16 15:08:12 +000093
94#endif /* _HVSI_H */