xref: /linux/drivers/net/wwan/t7xx/t7xx_modem_ops.h (revision fd7d598270724cc787982ea48bbe17ad383a8b7f)
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  *  Haijun Liu <haijun.liu@mediatek.com>
8  *  Eliot Lee <eliot.lee@intel.com>
9  *  Moises Veleta <moises.veleta@intel.com>
10  *  Ricardo Martinez <ricardo.martinez@linux.intel.com>
11  *
12  * Contributors:
13  *  Amir Hanania <amir.hanania@intel.com>
14  *  Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>
15  *  Sreehari Kancharla <sreehari.kancharla@intel.com>
16  */
17 
18 #ifndef __T7XX_MODEM_OPS_H__
19 #define __T7XX_MODEM_OPS_H__
20 
21 #include <linux/spinlock.h>
22 #include <linux/types.h>
23 #include <linux/workqueue.h>
24 
25 #include "t7xx_hif_cldma.h"
26 #include "t7xx_pci.h"
27 
28 #define FEATURE_COUNT		64
29 
30 /**
31  * enum hif_ex_stage -	HIF exception handshake stages with the HW.
32  * @HIF_EX_INIT:        Disable and clear TXQ.
33  * @HIF_EX_INIT_DONE:   Polling for initialization to be done.
34  * @HIF_EX_CLEARQ_DONE: Disable RX, flush TX/RX workqueues and clear RX.
35  * @HIF_EX_ALLQ_RESET:  HW is back in safe mode for re-initialization and restart.
36  */
37 enum hif_ex_stage {
38 	HIF_EX_INIT,
39 	HIF_EX_INIT_DONE,
40 	HIF_EX_CLEARQ_DONE,
41 	HIF_EX_ALLQ_RESET,
42 };
43 
44 struct mtk_runtime_feature {
45 	u8				feature_id;
46 	u8				support_info;
47 	u8				reserved[2];
48 	__le32				data_len;
49 	__le32				data[];
50 };
51 
52 enum md_event_id {
53 	FSM_PRE_START,
54 	FSM_START,
55 	FSM_READY,
56 };
57 
58 struct t7xx_sys_info {
59 	bool				ready;
60 	bool				handshake_ongoing;
61 	u8				feature_set[FEATURE_COUNT];
62 	struct t7xx_port		*ctl_port;
63 };
64 
65 struct t7xx_modem {
66 	struct cldma_ctrl		*md_ctrl[CLDMA_NUM];
67 	struct t7xx_pci_dev		*t7xx_dev;
68 	struct t7xx_sys_info		core_md;
69 	struct t7xx_sys_info		core_ap;
70 	bool				md_init_finish;
71 	bool				rgu_irq_asserted;
72 	struct workqueue_struct		*handshake_wq;
73 	struct work_struct		handshake_work;
74 	struct work_struct		ap_handshake_work;
75 	struct t7xx_fsm_ctl		*fsm_ctl;
76 	struct port_proxy		*port_prox;
77 	unsigned int			exp_id;
78 	spinlock_t			exp_lock; /* Protects exception events */
79 };
80 
81 void t7xx_md_exception_handshake(struct t7xx_modem *md);
82 void t7xx_md_event_notify(struct t7xx_modem *md, enum md_event_id evt_id);
83 int t7xx_md_reset(struct t7xx_pci_dev *t7xx_dev);
84 int t7xx_md_init(struct t7xx_pci_dev *t7xx_dev);
85 void t7xx_md_exit(struct t7xx_pci_dev *t7xx_dev);
86 void t7xx_clear_rgu_irq(struct t7xx_pci_dev *t7xx_dev);
87 int t7xx_acpi_fldr_func(struct t7xx_pci_dev *t7xx_dev);
88 int t7xx_pci_mhccif_isr(struct t7xx_pci_dev *t7xx_dev);
89 
90 #endif	/* __T7XX_MODEM_OPS_H__ */
91