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