blob: 174002f12010c7dff2d1efd5f35c860de7161665 [file] [log] [blame]
Dave Gerlachd712b362021-05-11 10:22:11 -05001/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * Cadence DDR Driver
4 *
Bryan Brattlof85b5cc82022-10-24 16:53:28 -05005 * Copyright (C) 2012-2022 Cadence Design Systems, Inc.
6 * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
Dave Gerlachd712b362021-05-11 10:22:11 -05007 */
8
Bryan Brattlof85b5cc82022-10-24 16:53:28 -05009#ifndef LPDDR4_J721E_SANITY_H
10#define LPDDR4_J721E_SANITY_H
Dave Gerlachd712b362021-05-11 10:22:11 -050011
12#include <errno.h>
13#include <linux/types.h>
14#include <lpddr4_if.h>
Dave Gerlachd712b362021-05-11 10:22:11 -050015
16static inline u32 lpddr4_intr_sanityfunction1(const lpddr4_privatedata *pd, const lpddr4_intr_ctlinterrupt intr, const bool *irqstatus);
17static inline u32 lpddr4_intr_sanityfunction2(const lpddr4_privatedata *pd, const lpddr4_intr_ctlinterrupt intr);
18static inline u32 lpddr4_intr_sanityfunction3(const lpddr4_privatedata *pd, const lpddr4_intr_phyindepinterrupt intr, const bool *irqstatus);
19static 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
26static 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
88static 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
148static 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
183static 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 Brattlof85b5cc82022-10-24 16:53:28 -0500216#endif /* LPDDR4_J721E_SANITY_H */