| 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 <[email protected]> |
| 8 |
* Eliot Lee <[email protected]> |
| 9 |
* Moises Veleta <[email protected]> |
| 10 |
* Ricardo Martinez <[email protected]> |
| 11 |
* |
| 12 |
* Contributors: |
| 13 |
* Amir Hanania <[email protected]> |
| 14 |
* Chiranjeevi Rapolu <[email protected]> |
| 15 |
* Sreehari Kancharla <[email protected]> |
| 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 |
enum reset_type { |
| 82 |
FLDR, |
| 83 |
PLDR, |
| 84 |
FASTBOOT, |
| 85 |
}; |
| 86 |
|
| 87 |
void t7xx_md_exception_handshake(struct t7xx_modem *md); |
| 88 |
void t7xx_md_event_notify(struct t7xx_modem *md, enum md_event_id evt_id); |
| 89 |
int t7xx_md_reset(struct t7xx_pci_dev *t7xx_dev); |
| 90 |
int t7xx_md_init(struct t7xx_pci_dev *t7xx_dev); |
| 91 |
void t7xx_md_exit(struct t7xx_pci_dev *t7xx_dev); |
| 92 |
void t7xx_clear_rgu_irq(struct t7xx_pci_dev *t7xx_dev); |
| 93 |
int t7xx_reset_device(struct t7xx_pci_dev *t7xx_dev, enum reset_type type); |
| 94 |
int t7xx_pci_mhccif_isr(struct t7xx_pci_dev *t7xx_dev); |
| 95 |
|
| 96 |
#endif /* __T7XX_MODEM_OPS_H__ */ |