1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2725e789fSBenjamin Herrenschmidt #ifndef _HVSI_H 3725e789fSBenjamin Herrenschmidt #define _HVSI_H 4725e789fSBenjamin Herrenschmidt 5725e789fSBenjamin Herrenschmidt #define VS_DATA_PACKET_HEADER 0xff 6725e789fSBenjamin Herrenschmidt #define VS_CONTROL_PACKET_HEADER 0xfe 7725e789fSBenjamin Herrenschmidt #define VS_QUERY_PACKET_HEADER 0xfd 8725e789fSBenjamin Herrenschmidt #define VS_QUERY_RESPONSE_PACKET_HEADER 0xfc 9725e789fSBenjamin Herrenschmidt 10725e789fSBenjamin Herrenschmidt /* control verbs */ 11725e789fSBenjamin Herrenschmidt #define VSV_SET_MODEM_CTL 1 /* to service processor only */ 12725e789fSBenjamin Herrenschmidt #define VSV_MODEM_CTL_UPDATE 2 /* from service processor only */ 13725e789fSBenjamin Herrenschmidt #define VSV_CLOSE_PROTOCOL 3 14725e789fSBenjamin Herrenschmidt 15725e789fSBenjamin Herrenschmidt /* query verbs */ 16725e789fSBenjamin Herrenschmidt #define VSV_SEND_VERSION_NUMBER 1 17725e789fSBenjamin Herrenschmidt #define VSV_SEND_MODEM_CTL_STATUS 2 18725e789fSBenjamin Herrenschmidt 19725e789fSBenjamin Herrenschmidt /* yes, these masks are not consecutive. */ 20725e789fSBenjamin Herrenschmidt #define HVSI_TSDTR 0x01 21725e789fSBenjamin Herrenschmidt #define HVSI_TSCD 0x20 22725e789fSBenjamin Herrenschmidt 23725e789fSBenjamin Herrenschmidt #define HVSI_MAX_OUTGOING_DATA 12 24725e789fSBenjamin Herrenschmidt #define HVSI_VERSION 1 25725e789fSBenjamin Herrenschmidt 26725e789fSBenjamin Herrenschmidt struct hvsi_header { 27725e789fSBenjamin Herrenschmidt uint8_t type; 28725e789fSBenjamin Herrenschmidt uint8_t len; 2999fc1d91SBenjamin Herrenschmidt __be16 seqno; 30725e789fSBenjamin Herrenschmidt } __attribute__((packed)); 31725e789fSBenjamin Herrenschmidt 32725e789fSBenjamin Herrenschmidt struct hvsi_data { 33048bee77SBenjamin Herrenschmidt struct hvsi_header hdr; 34725e789fSBenjamin Herrenschmidt uint8_t data[HVSI_MAX_OUTGOING_DATA]; 35725e789fSBenjamin Herrenschmidt } __attribute__((packed)); 36725e789fSBenjamin Herrenschmidt 37725e789fSBenjamin Herrenschmidt struct hvsi_control { 38048bee77SBenjamin Herrenschmidt struct hvsi_header hdr; 3999fc1d91SBenjamin Herrenschmidt __be16 verb; 40725e789fSBenjamin Herrenschmidt /* optional depending on verb: */ 4199fc1d91SBenjamin Herrenschmidt __be32 word; 4299fc1d91SBenjamin Herrenschmidt __be32 mask; 43725e789fSBenjamin Herrenschmidt } __attribute__((packed)); 44725e789fSBenjamin Herrenschmidt 45725e789fSBenjamin Herrenschmidt struct hvsi_query { 46048bee77SBenjamin Herrenschmidt struct hvsi_header hdr; 4799fc1d91SBenjamin Herrenschmidt __be16 verb; 48725e789fSBenjamin Herrenschmidt } __attribute__((packed)); 49725e789fSBenjamin Herrenschmidt 50725e789fSBenjamin Herrenschmidt struct hvsi_query_response { 51048bee77SBenjamin Herrenschmidt struct hvsi_header hdr; 5299fc1d91SBenjamin Herrenschmidt __be16 verb; 5399fc1d91SBenjamin Herrenschmidt __be16 query_seqno; 54725e789fSBenjamin Herrenschmidt union { 55725e789fSBenjamin Herrenschmidt uint8_t version; 5699fc1d91SBenjamin Herrenschmidt __be32 mctrl_word; 57725e789fSBenjamin Herrenschmidt } u; 58725e789fSBenjamin Herrenschmidt } __attribute__((packed)); 59725e789fSBenjamin Herrenschmidt 6017bdc6c0SBenjamin Herrenschmidt /* hvsi lib struct definitions */ 6117bdc6c0SBenjamin Herrenschmidt #define HVSI_INBUF_SIZE 255 6217bdc6c0SBenjamin Herrenschmidt struct tty_struct; 6317bdc6c0SBenjamin Herrenschmidt struct hvsi_priv { 6417bdc6c0SBenjamin Herrenschmidt unsigned int inbuf_len; /* data in input buffer */ 6517bdc6c0SBenjamin Herrenschmidt unsigned char inbuf[HVSI_INBUF_SIZE]; 6617bdc6c0SBenjamin Herrenschmidt unsigned int inbuf_cur; /* Cursor in input buffer */ 6717bdc6c0SBenjamin Herrenschmidt unsigned int inbuf_pktlen; /* packet lenght from cursor */ 6817bdc6c0SBenjamin Herrenschmidt atomic_t seqno; /* packet sequence number */ 6917bdc6c0SBenjamin Herrenschmidt unsigned int opened:1; /* driver opened */ 7017bdc6c0SBenjamin Herrenschmidt unsigned int established:1; /* protocol established */ 7117bdc6c0SBenjamin Herrenschmidt unsigned int is_console:1; /* used as a kernel console device */ 7217bdc6c0SBenjamin Herrenschmidt unsigned int mctrl_update:1; /* modem control updated */ 7317bdc6c0SBenjamin Herrenschmidt unsigned short mctrl; /* modem control */ 7417bdc6c0SBenjamin Herrenschmidt struct tty_struct *tty; /* tty structure */ 7517bdc6c0SBenjamin Herrenschmidt int (*get_chars)(uint32_t termno, char *buf, int count); 7617bdc6c0SBenjamin Herrenschmidt int (*put_chars)(uint32_t termno, const char *buf, int count); 7717bdc6c0SBenjamin Herrenschmidt uint32_t termno; 7817bdc6c0SBenjamin Herrenschmidt }; 7917bdc6c0SBenjamin Herrenschmidt 8017bdc6c0SBenjamin Herrenschmidt /* hvsi lib functions */ 8117bdc6c0SBenjamin Herrenschmidt struct hvc_struct; 8287fa35ddSBenjamin Herrenschmidt extern void hvsilib_init(struct hvsi_priv *pv, 8317bdc6c0SBenjamin Herrenschmidt int (*get_chars)(uint32_t termno, char *buf, int count), 8417bdc6c0SBenjamin Herrenschmidt int (*put_chars)(uint32_t termno, const char *buf, 8517bdc6c0SBenjamin Herrenschmidt int count), 8617bdc6c0SBenjamin Herrenschmidt int termno, int is_console); 8787fa35ddSBenjamin Herrenschmidt extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp); 8887fa35ddSBenjamin Herrenschmidt extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp); 8987fa35ddSBenjamin Herrenschmidt extern int hvsilib_read_mctrl(struct hvsi_priv *pv); 9087fa35ddSBenjamin Herrenschmidt extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr); 9187fa35ddSBenjamin Herrenschmidt extern void hvsilib_establish(struct hvsi_priv *pv); 9287fa35ddSBenjamin Herrenschmidt extern int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count); 9387fa35ddSBenjamin Herrenschmidt extern int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count); 94725e789fSBenjamin Herrenschmidt 95725e789fSBenjamin Herrenschmidt #endif /* _HVSI_H */ 96