1 /* SPDX-License-Identifier: GPL-2.0-only 2 * 3 * Copyright (c) 2021, MediaTek Inc. 4 * Copyright (c) 2021-2022, Intel Corporation. 5 * 6 * Authors: 7 * Amir Hanania <amir.hanania@intel.com> 8 * Haijun Liu <haijun.liu@mediatek.com> 9 * Moises Veleta <moises.veleta@intel.com> 10 * Ricardo Martinez <ricardo.martinez@linux.intel.com> 11 * 12 * Contributors: 13 * Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com> 14 * Eliot Lee <eliot.lee@intel.com> 15 * Sreehari Kancharla <sreehari.kancharla@intel.com> 16 */ 17 18 #ifndef __T7XX_PORT_PROXY_H__ 19 #define __T7XX_PORT_PROXY_H__ 20 21 #include <linux/bits.h> 22 #include <linux/device.h> 23 #include <linux/skbuff.h> 24 #include <linux/types.h> 25 26 #include "t7xx_hif_cldma.h" 27 #include "t7xx_modem_ops.h" 28 #include "t7xx_port.h" 29 30 #define MTK_QUEUES 16 31 #define RX_QUEUE_MAXLEN 32 32 #define CTRL_QUEUE_MAXLEN 16 33 34 struct port_proxy { 35 int port_count; 36 struct list_head rx_ch_ports[PORT_CH_ID_MASK + 1]; 37 struct list_head queue_ports[CLDMA_NUM][MTK_QUEUES]; 38 struct device *dev; 39 struct t7xx_port ports[]; 40 }; 41 42 struct ccci_header { 43 __le32 packet_header; 44 __le32 packet_len; 45 __le32 status; 46 __le32 ex_msg; 47 }; 48 49 /* Coupled with HW - indicates if there is data following the CCCI header or not */ 50 #define CCCI_HEADER_NO_DATA 0xffffffff 51 52 #define CCCI_H_AST_BIT BIT(31) 53 #define CCCI_H_SEQ_FLD GENMASK(30, 16) 54 #define CCCI_H_CHN_FLD GENMASK(15, 0) 55 56 struct ctrl_msg_header { 57 __le32 ctrl_msg_id; 58 __le32 ex_msg; 59 __le32 data_length; 60 }; 61 62 /* Control identification numbers for AP<->MD messages */ 63 #define CTL_ID_HS1_MSG 0x0 64 #define CTL_ID_HS2_MSG 0x1 65 #define CTL_ID_HS3_MSG 0x2 66 #define CTL_ID_MD_EX 0x4 67 #define CTL_ID_DRV_VER_ERROR 0x5 68 #define CTL_ID_MD_EX_ACK 0x6 69 #define CTL_ID_MD_EX_PASS 0x8 70 #define CTL_ID_PORT_ENUM 0x9 71 72 /* Modem exception check identification code - "EXCP" */ 73 #define MD_EX_CHK_ID 0x45584350 74 /* Modem exception check acknowledge identification code - "EREC" */ 75 #define MD_EX_CHK_ACK_ID 0x45524543 76 77 #define PORT_INFO_RSRVD GENMASK(31, 16) 78 #define PORT_INFO_ENFLG BIT(15) 79 #define PORT_INFO_CH_ID GENMASK(14, 0) 80 81 #define PORT_ENUM_VER 0 82 #define PORT_ENUM_HEAD_PATTERN 0x5a5a5a5a 83 #define PORT_ENUM_TAIL_PATTERN 0xa5a5a5a5 84 #define PORT_ENUM_VER_MISMATCH 0x00657272 85 86 /* Port operations mapping */ 87 extern struct port_ops wwan_sub_port_ops; 88 extern struct port_ops ctl_port_ops; 89 90 #ifdef CONFIG_WWAN_DEBUGFS 91 extern struct port_ops t7xx_trace_port_ops; 92 #endif 93 94 void t7xx_port_proxy_reset(struct port_proxy *port_prox); 95 void t7xx_port_proxy_uninit(struct port_proxy *port_prox); 96 int t7xx_port_proxy_init(struct t7xx_modem *md); 97 void t7xx_port_proxy_md_status_notify(struct port_proxy *port_prox, unsigned int state); 98 int t7xx_port_enum_msg_handler(struct t7xx_modem *md, void *msg); 99 int t7xx_port_proxy_chl_enable_disable(struct port_proxy *port_prox, unsigned int ch_id, 100 bool en_flag); 101 102 #endif /* __T7XX_PORT_PROXY_H__ */ 103