Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
| 2 | /* |
| 3 | * Cadence DDR Driver |
| 4 | * |
Bryan Brattlof | 85b5cc8 | 2022-10-24 16:53:28 -0500 | [diff] [blame] | 5 | * Copyright (C) 2012-2022 Cadence Design Systems, Inc. |
| 6 | * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/ |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 7 | */ |
| 8 | |
Bryan Brattlof | 85b5cc8 | 2022-10-24 16:53:28 -0500 | [diff] [blame] | 9 | #ifndef LPDDR4_J721E_SANITY_H |
| 10 | #define LPDDR4_J721E_SANITY_H |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 11 | |
| 12 | #include <errno.h> |
| 13 | #include <linux/types.h> |
| 14 | #include <lpddr4_if.h> |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 15 | |
| 16 | static inline u32 lpddr4_intr_sanityfunction1(const lpddr4_privatedata *pd, const lpddr4_intr_ctlinterrupt intr, const bool *irqstatus); |
| 17 | static inline u32 lpddr4_intr_sanityfunction2(const lpddr4_privatedata *pd, const lpddr4_intr_ctlinterrupt intr); |
| 18 | static inline u32 lpddr4_intr_sanityfunction3(const lpddr4_privatedata *pd, const lpddr4_intr_phyindepinterrupt intr, const bool *irqstatus); |
| 19 | static inline u32 lpddr4_intr_sanityfunction4(const lpddr4_privatedata *pd, const lpddr4_intr_phyindepinterrupt intr); |
| 20 | |
| 21 | #define LPDDR4_INTR_CheckCtlIntSF lpddr4_intr_sanityfunction1 |
| 22 | #define LPDDR4_INTR_AckCtlIntSF lpddr4_intr_sanityfunction2 |
| 23 | #define LPDDR4_INTR_CheckPhyIndepIntSF lpddr4_intr_sanityfunction3 |
| 24 | #define LPDDR4_INTR_AckPhyIndepIntSF lpddr4_intr_sanityfunction4 |
| 25 | |
| 26 | static inline u32 lpddr4_intr_sanityfunction1(const lpddr4_privatedata *pd, const lpddr4_intr_ctlinterrupt intr, const bool *irqstatus) |
| 27 | { |
| 28 | u32 ret = 0; |
| 29 | |
| 30 | if (pd == NULL) { |
| 31 | ret = EINVAL; |
| 32 | } else if (irqstatus == NULL) { |
| 33 | ret = EINVAL; |
| 34 | } else if ( |
| 35 | (intr != LPDDR4_INTR_RESET_DONE) && |
| 36 | (intr != LPDDR4_INTR_BUS_ACCESS_ERROR) && |
| 37 | (intr != LPDDR4_INTR_MULTIPLE_BUS_ACCESS_ERROR) && |
| 38 | (intr != LPDDR4_INTR_ECC_MULTIPLE_CORR_ERROR) && |
| 39 | (intr != LPDDR4_INTR_ECC_MULTIPLE_UNCORR_ERROR) && |
| 40 | (intr != LPDDR4_INTR_ECC_WRITEBACK_EXEC_ERROR) && |
| 41 | (intr != LPDDR4_INTR_ECC_SCRUB_DONE) && |
| 42 | (intr != LPDDR4_INTR_ECC_SCRUB_ERROR) && |
| 43 | (intr != LPDDR4_INTR_PORT_COMMAND_ERROR) && |
| 44 | (intr != LPDDR4_INTR_MC_INIT_DONE) && |
| 45 | (intr != LPDDR4_INTR_LP_DONE) && |
| 46 | (intr != LPDDR4_INTR_BIST_DONE) && |
| 47 | (intr != LPDDR4_INTR_WRAP_ERROR) && |
| 48 | (intr != LPDDR4_INTR_INVALID_BURST_ERROR) && |
| 49 | (intr != LPDDR4_INTR_RDLVL_ERROR) && |
| 50 | (intr != LPDDR4_INTR_RDLVL_GATE_ERROR) && |
| 51 | (intr != LPDDR4_INTR_WRLVL_ERROR) && |
| 52 | (intr != LPDDR4_INTR_CA_TRAINING_ERROR) && |
| 53 | (intr != LPDDR4_INTR_DFI_UPDATE_ERROR) && |
| 54 | (intr != LPDDR4_INTR_MRR_ERROR) && |
| 55 | (intr != LPDDR4_INTR_PHY_MASTER_ERROR) && |
| 56 | (intr != LPDDR4_INTR_WRLVL_REQ) && |
| 57 | (intr != LPDDR4_INTR_RDLVL_REQ) && |
| 58 | (intr != LPDDR4_INTR_RDLVL_GATE_REQ) && |
| 59 | (intr != LPDDR4_INTR_CA_TRAINING_REQ) && |
| 60 | (intr != LPDDR4_INTR_LEVELING_DONE) && |
| 61 | (intr != LPDDR4_INTR_PHY_ERROR) && |
| 62 | (intr != LPDDR4_INTR_MR_READ_DONE) && |
| 63 | (intr != LPDDR4_INTR_TEMP_CHANGE) && |
| 64 | (intr != LPDDR4_INTR_TEMP_ALERT) && |
| 65 | (intr != LPDDR4_INTR_SW_DQS_COMPLETE) && |
| 66 | (intr != LPDDR4_INTR_DQS_OSC_BV_UPDATED) && |
| 67 | (intr != LPDDR4_INTR_DQS_OSC_OVERFLOW) && |
| 68 | (intr != LPDDR4_INTR_DQS_OSC_VAR_OUT) && |
| 69 | (intr != LPDDR4_INTR_MR_WRITE_DONE) && |
| 70 | (intr != LPDDR4_INTR_INHIBIT_DRAM_DONE) && |
| 71 | (intr != LPDDR4_INTR_DFI_INIT_STATE) && |
| 72 | (intr != LPDDR4_INTR_DLL_RESYNC_DONE) && |
| 73 | (intr != LPDDR4_INTR_TDFI_TO) && |
| 74 | (intr != LPDDR4_INTR_DFS_DONE) && |
| 75 | (intr != LPDDR4_INTR_DFS_STATUS) && |
| 76 | (intr != LPDDR4_INTR_REFRESH_STATUS) && |
| 77 | (intr != LPDDR4_INTR_ZQ_STATUS) && |
| 78 | (intr != LPDDR4_INTR_SW_REQ_MODE) && |
| 79 | (intr != LPDDR4_INTR_LOR_BITS) |
| 80 | ) { |
| 81 | ret = EINVAL; |
| 82 | } else { |
| 83 | } |
| 84 | |
| 85 | return ret; |
| 86 | } |
| 87 | |
| 88 | static inline u32 lpddr4_intr_sanityfunction2(const lpddr4_privatedata *pd, const lpddr4_intr_ctlinterrupt intr) |
| 89 | { |
| 90 | u32 ret = 0; |
| 91 | |
| 92 | if (pd == NULL) { |
| 93 | ret = EINVAL; |
| 94 | } else if ( |
| 95 | (intr != LPDDR4_INTR_RESET_DONE) && |
| 96 | (intr != LPDDR4_INTR_BUS_ACCESS_ERROR) && |
| 97 | (intr != LPDDR4_INTR_MULTIPLE_BUS_ACCESS_ERROR) && |
| 98 | (intr != LPDDR4_INTR_ECC_MULTIPLE_CORR_ERROR) && |
| 99 | (intr != LPDDR4_INTR_ECC_MULTIPLE_UNCORR_ERROR) && |
| 100 | (intr != LPDDR4_INTR_ECC_WRITEBACK_EXEC_ERROR) && |
| 101 | (intr != LPDDR4_INTR_ECC_SCRUB_DONE) && |
| 102 | (intr != LPDDR4_INTR_ECC_SCRUB_ERROR) && |
| 103 | (intr != LPDDR4_INTR_PORT_COMMAND_ERROR) && |
| 104 | (intr != LPDDR4_INTR_MC_INIT_DONE) && |
| 105 | (intr != LPDDR4_INTR_LP_DONE) && |
| 106 | (intr != LPDDR4_INTR_BIST_DONE) && |
| 107 | (intr != LPDDR4_INTR_WRAP_ERROR) && |
| 108 | (intr != LPDDR4_INTR_INVALID_BURST_ERROR) && |
| 109 | (intr != LPDDR4_INTR_RDLVL_ERROR) && |
| 110 | (intr != LPDDR4_INTR_RDLVL_GATE_ERROR) && |
| 111 | (intr != LPDDR4_INTR_WRLVL_ERROR) && |
| 112 | (intr != LPDDR4_INTR_CA_TRAINING_ERROR) && |
| 113 | (intr != LPDDR4_INTR_DFI_UPDATE_ERROR) && |
| 114 | (intr != LPDDR4_INTR_MRR_ERROR) && |
| 115 | (intr != LPDDR4_INTR_PHY_MASTER_ERROR) && |
| 116 | (intr != LPDDR4_INTR_WRLVL_REQ) && |
| 117 | (intr != LPDDR4_INTR_RDLVL_REQ) && |
| 118 | (intr != LPDDR4_INTR_RDLVL_GATE_REQ) && |
| 119 | (intr != LPDDR4_INTR_CA_TRAINING_REQ) && |
| 120 | (intr != LPDDR4_INTR_LEVELING_DONE) && |
| 121 | (intr != LPDDR4_INTR_PHY_ERROR) && |
| 122 | (intr != LPDDR4_INTR_MR_READ_DONE) && |
| 123 | (intr != LPDDR4_INTR_TEMP_CHANGE) && |
| 124 | (intr != LPDDR4_INTR_TEMP_ALERT) && |
| 125 | (intr != LPDDR4_INTR_SW_DQS_COMPLETE) && |
| 126 | (intr != LPDDR4_INTR_DQS_OSC_BV_UPDATED) && |
| 127 | (intr != LPDDR4_INTR_DQS_OSC_OVERFLOW) && |
| 128 | (intr != LPDDR4_INTR_DQS_OSC_VAR_OUT) && |
| 129 | (intr != LPDDR4_INTR_MR_WRITE_DONE) && |
| 130 | (intr != LPDDR4_INTR_INHIBIT_DRAM_DONE) && |
| 131 | (intr != LPDDR4_INTR_DFI_INIT_STATE) && |
| 132 | (intr != LPDDR4_INTR_DLL_RESYNC_DONE) && |
| 133 | (intr != LPDDR4_INTR_TDFI_TO) && |
| 134 | (intr != LPDDR4_INTR_DFS_DONE) && |
| 135 | (intr != LPDDR4_INTR_DFS_STATUS) && |
| 136 | (intr != LPDDR4_INTR_REFRESH_STATUS) && |
| 137 | (intr != LPDDR4_INTR_ZQ_STATUS) && |
| 138 | (intr != LPDDR4_INTR_SW_REQ_MODE) && |
| 139 | (intr != LPDDR4_INTR_LOR_BITS) |
| 140 | ) { |
| 141 | ret = EINVAL; |
| 142 | } else { |
| 143 | } |
| 144 | |
| 145 | return ret; |
| 146 | } |
| 147 | |
| 148 | static inline u32 lpddr4_intr_sanityfunction3(const lpddr4_privatedata *pd, const lpddr4_intr_phyindepinterrupt intr, const bool *irqstatus) |
| 149 | { |
| 150 | u32 ret = 0; |
| 151 | |
| 152 | if (pd == NULL) { |
| 153 | ret = EINVAL; |
| 154 | } else if (irqstatus == NULL) { |
| 155 | ret = EINVAL; |
| 156 | } else if ( |
| 157 | (intr != LPDDR4_INTR_PHY_INDEP_INIT_DONE_BIT) && |
| 158 | (intr != LPDDR4_INTR_PHY_INDEP_CONTROL_ERROR_BIT) && |
| 159 | (intr != LPDDR4_INTR_PHY_INDEP_CA_PARITY_ERR_BIT) && |
| 160 | (intr != LPDDR4_INTR_PHY_INDEP_RDLVL_ERROR_BIT) && |
| 161 | (intr != LPDDR4_INTR_PHY_INDEP_RDLVL_G_ERROR_BIT) && |
| 162 | (intr != LPDDR4_INTR_PHY_INDEP_WRLVL_ERROR_BIT) && |
| 163 | (intr != LPDDR4_INTR_PHY_INDEP_CALVL_ERROR_BIT) && |
| 164 | (intr != LPDDR4_INTR_PHY_INDEP_WDQLVL_ERROR_BIT) && |
| 165 | (intr != LPDDR4_INTR_PHY_INDEP_UPDATE_ERROR_BIT) && |
| 166 | (intr != LPDDR4_INTR_PHY_INDEP_RDLVL_REQ_BIT) && |
| 167 | (intr != LPDDR4_INTR_PHY_INDEP_RDLVL_GATE_REQ_BIT) && |
| 168 | (intr != LPDDR4_INTR_PHY_INDEP_WRLVL_REQ_BIT) && |
| 169 | (intr != LPDDR4_INTR_PHY_INDEP_CALVL_REQ_BIT) && |
| 170 | (intr != LPDDR4_INTR_PHY_INDEP_WDQLVL_REQ_BIT) && |
| 171 | (intr != LPDDR4_INTR_PHY_INDEP_LVL_DONE_BIT) && |
| 172 | (intr != LPDDR4_INTR_PHY_INDEP_BIST_DONE_BIT) && |
| 173 | (intr != LPDDR4_INTR_PHY_INDEP_TDFI_INIT_TIME_OUT_BIT) && |
| 174 | (intr != LPDDR4_INTR_PHY_INDEP_DLL_LOCK_STATE_CHANGE_BIT) |
| 175 | ) { |
| 176 | ret = EINVAL; |
| 177 | } else { |
| 178 | } |
| 179 | |
| 180 | return ret; |
| 181 | } |
| 182 | |
| 183 | static inline u32 lpddr4_intr_sanityfunction4(const lpddr4_privatedata *pd, const lpddr4_intr_phyindepinterrupt intr) |
| 184 | { |
| 185 | u32 ret = 0; |
| 186 | |
| 187 | if (pd == NULL) { |
| 188 | ret = EINVAL; |
| 189 | } else if ( |
| 190 | (intr != LPDDR4_INTR_PHY_INDEP_INIT_DONE_BIT) && |
| 191 | (intr != LPDDR4_INTR_PHY_INDEP_CONTROL_ERROR_BIT) && |
| 192 | (intr != LPDDR4_INTR_PHY_INDEP_CA_PARITY_ERR_BIT) && |
| 193 | (intr != LPDDR4_INTR_PHY_INDEP_RDLVL_ERROR_BIT) && |
| 194 | (intr != LPDDR4_INTR_PHY_INDEP_RDLVL_G_ERROR_BIT) && |
| 195 | (intr != LPDDR4_INTR_PHY_INDEP_WRLVL_ERROR_BIT) && |
| 196 | (intr != LPDDR4_INTR_PHY_INDEP_CALVL_ERROR_BIT) && |
| 197 | (intr != LPDDR4_INTR_PHY_INDEP_WDQLVL_ERROR_BIT) && |
| 198 | (intr != LPDDR4_INTR_PHY_INDEP_UPDATE_ERROR_BIT) && |
| 199 | (intr != LPDDR4_INTR_PHY_INDEP_RDLVL_REQ_BIT) && |
| 200 | (intr != LPDDR4_INTR_PHY_INDEP_RDLVL_GATE_REQ_BIT) && |
| 201 | (intr != LPDDR4_INTR_PHY_INDEP_WRLVL_REQ_BIT) && |
| 202 | (intr != LPDDR4_INTR_PHY_INDEP_CALVL_REQ_BIT) && |
| 203 | (intr != LPDDR4_INTR_PHY_INDEP_WDQLVL_REQ_BIT) && |
| 204 | (intr != LPDDR4_INTR_PHY_INDEP_LVL_DONE_BIT) && |
| 205 | (intr != LPDDR4_INTR_PHY_INDEP_BIST_DONE_BIT) && |
| 206 | (intr != LPDDR4_INTR_PHY_INDEP_TDFI_INIT_TIME_OUT_BIT) && |
| 207 | (intr != LPDDR4_INTR_PHY_INDEP_DLL_LOCK_STATE_CHANGE_BIT) |
| 208 | ) { |
| 209 | ret = EINVAL; |
| 210 | } else { |
| 211 | } |
| 212 | |
| 213 | return ret; |
| 214 | } |
| 215 | |
Bryan Brattlof | 85b5cc8 | 2022-10-24 16:53:28 -0500 | [diff] [blame] | 216 | #endif /* LPDDR4_J721E_SANITY_H */ |