blob: 0f0fc2767c11e31a348c3ca2df8258f6eb2b6c37 [file] [log] [blame]
Kevin Scholz521a4ef2019-10-07 19:26:36 +05301/* SPDX-License-Identifier: BSD-3-Clause */
2/**********************************************************************
3 * Copyright (C) 2012-2019 Cadence Design Systems, Inc.
4 **********************************************************************
5 * WARNING: This file is auto-generated using api-generator utility.
6 * api-generator: 12.02.13bb8d5
7 * Do not edit it manually.
8 **********************************************************************
9 * Cadence Core Driver for LPDDR4.
10 **********************************************************************
11 */
12
13/**
14 * This file contains sanity API functions. The purpose of sanity functions
15 * is to check input parameters validity. They take the same parameters as
16 * original API functions and return 0 on success or EINVAL on wrong parameter
17 * value(s).
18 */
19
20#ifndef LPDDR4_SANITY_H
21#define LPDDR4_SANITY_H
22
23#include <errno.h>
24#include <linux/types.h>
25#include "lpddr4_if.h"
26
27#define CDN_EOK 0U /* no error */
28
29static inline uint32_t lpddr4_configsf(const lpddr4_config *obj);
30static inline uint32_t lpddr4_privatedatasf(const lpddr4_privatedata *obj);
31static inline uint32_t lpddr4_reginitdatasf(const lpddr4_reginitdata *obj);
32
33static inline uint32_t lpddr4_sanityfunction1(const lpddr4_config* config, const uint16_t* configsize);
34static inline uint32_t lpddr4_sanityfunction2(const lpddr4_privatedata* pd, const lpddr4_config* cfg);
35static inline uint32_t lpddr4_sanityfunction3(const lpddr4_privatedata* pd);
36static inline uint32_t lpddr4_sanityfunction4(const lpddr4_privatedata* pd, const lpddr4_regblock cpp, const uint32_t* regvalue);
37static inline uint32_t lpddr4_sanityfunction5(const lpddr4_privatedata* pd, const lpddr4_regblock cpp);
38static inline uint32_t lpddr4_sanityfunction6(const lpddr4_privatedata* pd, const uint64_t* mmrvalue, const uint8_t* mmrstatus);
39static inline uint32_t lpddr4_sanityfunction7(const lpddr4_privatedata* pd, const uint8_t* mrwstatus);
40static inline uint32_t lpddr4_sanityfunction8(const lpddr4_privatedata* pd, const lpddr4_reginitdata* regvalues);
41static inline uint32_t lpddr4_sanityfunction11(const lpddr4_privatedata* pd, const lpddr4_reginitdata* regvalues);
42static inline uint32_t lpddr4_sanityfunction14(const lpddr4_privatedata* pd, const uint64_t* mask);
43static inline uint32_t lpddr4_sanityfunction15(const lpddr4_privatedata* pd, const uint64_t* mask);
44static inline uint32_t lpddr4_sanityfunction16(const lpddr4_privatedata* pd, const lpddr4_ctlinterrupt intr, const bool* irqstatus);
45static inline uint32_t lpddr4_sanityfunction17(const lpddr4_privatedata* pd, const lpddr4_ctlinterrupt intr);
46static inline uint32_t lpddr4_sanityfunction18(const lpddr4_privatedata* pd, const uint32_t* mask);
47static inline uint32_t lpddr4_sanityfunction20(const lpddr4_privatedata* pd, const lpddr4_phyindepinterrupt intr, const bool* irqstatus);
48static inline uint32_t lpddr4_sanityfunction21(const lpddr4_privatedata* pd, const lpddr4_phyindepinterrupt intr);
49static inline uint32_t lpddr4_sanityfunction22(const lpddr4_privatedata* pd, const lpddr4_debuginfo* debuginfo);
50static inline uint32_t lpddr4_sanityfunction23(const lpddr4_privatedata* pd, const lpddr4_lpiwakeupparam* lpiwakeupparam, const lpddr4_ctlfspnum* fspnum, const uint32_t* cycles);
51static inline uint32_t lpddr4_sanityfunction25(const lpddr4_privatedata* pd, const lpddr4_eccenable* eccparam);
52static inline uint32_t lpddr4_sanityfunction26(const lpddr4_privatedata* pd, const lpddr4_eccenable* eccparam);
53static inline uint32_t lpddr4_sanityfunction27(const lpddr4_privatedata* pd, const lpddr4_reducmode* mode);
54static inline uint32_t lpddr4_sanityfunction28(const lpddr4_privatedata* pd, const lpddr4_reducmode* mode);
55static inline uint32_t lpddr4_sanityfunction29(const lpddr4_privatedata* pd, const bool* on_off);
56static inline uint32_t lpddr4_sanityfunction31(const lpddr4_privatedata* pd, const lpddr4_dbimode* mode);
57static inline uint32_t lpddr4_sanityfunction32(const lpddr4_privatedata* pd, const lpddr4_ctlfspnum* fspnum, const uint32_t* cycles);
58
59#define lpddr4_probesf lpddr4_sanityfunction1
60#define lpddr4_initsf lpddr4_sanityfunction2
61#define lpddr4_startsf lpddr4_sanityfunction3
62#define lpddr4_readregsf lpddr4_sanityfunction4
63#define lpddr4_writeregsf lpddr4_sanityfunction5
64#define lpddr4_getmmrregistersf lpddr4_sanityfunction6
65#define lpddr4_setmmrregistersf lpddr4_sanityfunction7
66#define lpddr4_writectlconfigsf lpddr4_sanityfunction8
67#define lpddr4_writephyconfigsf lpddr4_sanityfunction8
68#define lpddr4_writephyindepconfigsf lpddr4_sanityfunction8
69#define lpddr4_readctlconfigsf lpddr4_sanityfunction11
70#define lpddr4_readphyconfigsf lpddr4_sanityfunction11
71#define lpddr4_readphyindepconfigsf lpddr4_sanityfunction11
72#define lpddr4_getctlinterruptmasksf lpddr4_sanityfunction14
73#define lpddr4_setctlinterruptmasksf lpddr4_sanityfunction15
74#define lpddr4_checkctlinterruptsf lpddr4_sanityfunction16
75#define lpddr4_ackctlinterruptsf lpddr4_sanityfunction17
76#define lpddr4_getphyindepinterruptmsf lpddr4_sanityfunction18
77#define lpddr4_setphyindepinterruptmsf lpddr4_sanityfunction18
78#define lpddr4_checkphyindepinterrupsf lpddr4_sanityfunction20
79#define lpddr4_ackphyindepinterruptsf lpddr4_sanityfunction21
80#define lpddr4_getdebuginitinfosf lpddr4_sanityfunction22
81#define lpddr4_getlpiwakeuptimesf lpddr4_sanityfunction23
82#define lpddr4_setlpiwakeuptimesf lpddr4_sanityfunction23
83#define lpddr4_geteccenablesf lpddr4_sanityfunction25
84#define lpddr4_seteccenablesf lpddr4_sanityfunction26
85#define lpddr4_getreducmodesf lpddr4_sanityfunction27
86#define lpddr4_setreducmodesf lpddr4_sanityfunction28
87#define lpddr4_getdbireadmodesf lpddr4_sanityfunction29
88#define lpddr4_getdbiwritemodesf lpddr4_sanityfunction29
89#define lpddr4_setdbimodesf lpddr4_sanityfunction31
90#define lpddr4_getrefreshratesf lpddr4_sanityfunction32
91#define lpddr4_setrefreshratesf lpddr4_sanityfunction32
92#define lpddr4_refreshperchipselectsf lpddr4_sanityfunction3
93
94/**
95 * Function to validate struct Config
96 *
97 * @param[in] obj pointer to struct to be verified
98 * @returns 0 for valid
99 * @returns EINVAL for invalid
100 */
101static inline uint32_t lpddr4_configsf(const lpddr4_config *obj)
102{
103 uint32_t ret = 0;
104
105 if (obj == NULL)
106 {
107 ret = EINVAL;
108 }
109
110 return ret;
111}
112
113/**
114 * Function to validate struct PrivateData
115 *
116 * @param[in] obj pointer to struct to be verified
117 * @returns 0 for valid
118 * @returns EINVAL for invalid
119 */
120static inline uint32_t lpddr4_privatedatasf(const lpddr4_privatedata *obj)
121{
122 uint32_t ret = 0;
123
124 if (obj == NULL)
125 {
126 ret = EINVAL;
127 }
128
129 return ret;
130}
131
132/**
133 * Function to validate struct RegInitData
134 *
135 * @param[in] obj pointer to struct to be verified
136 * @returns 0 for valid
137 * @returns EINVAL for invalid
138 */
139static inline uint32_t lpddr4_reginitdatasf(const lpddr4_reginitdata *obj)
140{
141 uint32_t ret = 0;
142
143 if (obj == NULL)
144 {
145 ret = EINVAL;
146 }
147
148 return ret;
149}
150
151/**
152 * A common function to check the validity of API functions with
153 * following parameter types
154 * @param[in] config Driver/hardware configuration required.
155 * @param[out] configSize Size of memory allocations required.
156 * @return 0 success
157 * @return EINVAL invalid parameters
158 */
159static inline uint32_t lpddr4_sanityfunction1(const lpddr4_config* config, const uint16_t* configsize)
160{
161 /* Declaring return variable */
162 uint32_t ret = 0;
163
164 if (configsize == NULL)
165 {
166 ret = EINVAL;
167 }
168 else if (lpddr4_configsf(config) == EINVAL)
169 {
170 ret = EINVAL;
171 }
172 else
173 {
174 /*
175 * All 'if ... else if' constructs shall be terminated with an 'else' statement
176 * (MISRA2012-RULE-15_7-3)
177 */
178 }
179
180 return ret;
181}
182
183/**
184 * A common function to check the validity of API functions with
185 * following parameter types
186 * @param[in] pD Driver state info specific to this instance.
187 * @param[in] cfg Specifies driver/hardware configuration.
188 * @return 0 success
189 * @return EINVAL invalid parameters
190 */
191static inline uint32_t lpddr4_sanityfunction2(const lpddr4_privatedata* pd, const lpddr4_config* cfg)
192{
193 /* Declaring return variable */
194 uint32_t ret = 0;
195
196 if (lpddr4_privatedatasf(pd) == EINVAL)
197 {
198 ret = EINVAL;
199 }
200 else if (lpddr4_configsf(cfg) == EINVAL)
201 {
202 ret = EINVAL;
203 }
204 else
205 {
206 /*
207 * All 'if ... else if' constructs shall be terminated with an 'else' statement
208 * (MISRA2012-RULE-15_7-3)
209 */
210 }
211
212 return ret;
213}
214
215/**
216 * A common function to check the validity of API functions with
217 * following parameter types
218 * @param[in] pD Driver state info specific to this instance.
219 * @return 0 success
220 * @return EINVAL invalid parameters
221 */
222static inline uint32_t lpddr4_sanityfunction3(const lpddr4_privatedata* pd)
223{
224 /* Declaring return variable */
225 uint32_t ret = 0;
226
227 if (lpddr4_privatedatasf(pd) == EINVAL)
228 {
229 ret = EINVAL;
230 }
231
232 return ret;
233}
234
235/**
236 * A common function to check the validity of API functions with
237 * following parameter types
238 * @param[in] pD Driver state info specific to this instance.
239 * @param[in] cpp Indicates whether controller, PHY or PHY Independent Module register
240 * @param[out] regValue Register value read
241 * @return 0 success
242 * @return EINVAL invalid parameters
243 */
244static inline uint32_t lpddr4_sanityfunction4(const lpddr4_privatedata* pd, const lpddr4_regblock cpp, const uint32_t* regvalue)
245{
246 /* Declaring return variable */
247 uint32_t ret = 0;
248
249 if (regvalue == NULL)
250 {
251 ret = EINVAL;
252 }
253 else if (lpddr4_privatedatasf(pd) == EINVAL)
254 {
255 ret = EINVAL;
256 }
257 else if (
258 (cpp != LPDDR4_CTL_REGS) &&
259 (cpp != LPDDR4_PHY_REGS) &&
260 (cpp != LPDDR4_PHY_INDEP_REGS)
261 )
262 {
263 ret = EINVAL;
264 }
265 else
266 {
267 /*
268 * All 'if ... else if' constructs shall be terminated with an 'else' statement
269 * (MISRA2012-RULE-15_7-3)
270 */
271 }
272
273 return ret;
274}
275
276/**
277 * A common function to check the validity of API functions with
278 * following parameter types
279 * @param[in] pD Driver state info specific to this instance.
280 * @param[in] cpp Indicates whether controller, PHY or PHY Independent Module register
281 * @return 0 success
282 * @return EINVAL invalid parameters
283 */
284static inline uint32_t lpddr4_sanityfunction5(const lpddr4_privatedata* pd, const lpddr4_regblock cpp)
285{
286 /* Declaring return variable */
287 uint32_t ret = 0;
288
289 if (lpddr4_privatedatasf(pd) == EINVAL)
290 {
291 ret = EINVAL;
292 }
293 else if (
294 (cpp != LPDDR4_CTL_REGS) &&
295 (cpp != LPDDR4_PHY_REGS) &&
296 (cpp != LPDDR4_PHY_INDEP_REGS)
297 )
298 {
299 ret = EINVAL;
300 }
301 else
302 {
303 /*
304 * All 'if ... else if' constructs shall be terminated with an 'else' statement
305 * (MISRA2012-RULE-15_7-3)
306 */
307 }
308
309 return ret;
310}
311
312/**
313 * A common function to check the validity of API functions with
314 * following parameter types
315 * @param[in] pD Driver state info specific to this instance.
316 * @param[out] mmrValue Value which is read from memory mode register(mmr) for all devices.
317 * @param[out] mmrStatus Status of mode register read(mrr) instruction.
318 * @return 0 success
319 * @return EINVAL invalid parameters
320 */
321static inline uint32_t lpddr4_sanityfunction6(const lpddr4_privatedata* pd, const uint64_t* mmrvalue, const uint8_t* mmrstatus)
322{
323 /* Declaring return variable */
324 uint32_t ret = 0;
325
326 if (mmrvalue == NULL)
327 {
328 ret = EINVAL;
329 }
330 else if (mmrstatus == NULL)
331 {
332 ret = EINVAL;
333 }
334 else if (lpddr4_privatedatasf(pd) == EINVAL)
335 {
336 ret = EINVAL;
337 }
338 else
339 {
340 /*
341 * All 'if ... else if' constructs shall be terminated with an 'else' statement
342 * (MISRA2012-RULE-15_7-3)
343 */
344 }
345
346 return ret;
347}
348
349/**
350 * A common function to check the validity of API functions with
351 * following parameter types
352 * @param[in] pD Driver state info specific to this instance.
353 * @param[out] mrwStatus Status of mode register write(mrw) instruction.
354 * @return 0 success
355 * @return EINVAL invalid parameters
356 */
357static inline uint32_t lpddr4_sanityfunction7(const lpddr4_privatedata* pd, const uint8_t* mrwstatus)
358{
359 /* Declaring return variable */
360 uint32_t ret = 0;
361
362 if (mrwstatus == NULL)
363 {
364 ret = EINVAL;
365 }
366 else if (lpddr4_privatedatasf(pd) == EINVAL)
367 {
368 ret = EINVAL;
369 }
370 else
371 {
372 /*
373 * All 'if ... else if' constructs shall be terminated with an 'else' statement
374 * (MISRA2012-RULE-15_7-3)
375 */
376 }
377
378 return ret;
379}
380
381/**
382 * A common function to check the validity of API functions with
383 * following parameter types
384 * @param[in] pD Driver state info specific to this instance.
385 * @param[in] regValues Register values to be written
386 * @return 0 success
387 * @return EINVAL invalid parameters
388 */
389static inline uint32_t lpddr4_sanityfunction8(const lpddr4_privatedata* pd, const lpddr4_reginitdata* regvalues)
390{
391 /* Declaring return variable */
392 uint32_t ret = 0;
393
394 if (lpddr4_privatedatasf(pd) == EINVAL)
395 {
396 ret = EINVAL;
397 }
398 else if (lpddr4_reginitdatasf(regvalues) == EINVAL)
399 {
400 ret = EINVAL;
401 }
402 else
403 {
404 /*
405 * All 'if ... else if' constructs shall be terminated with an 'else' statement
406 * (MISRA2012-RULE-15_7-3)
407 */
408 }
409
410 return ret;
411}
412
413/**
414 * A common function to check the validity of API functions with
415 * following parameter types
416 * @param[in] pD Driver state info specific to this instance.
417 * @param[out] regValues Register values which are read
418 * @return 0 success
419 * @return EINVAL invalid parameters
420 */
421static inline uint32_t lpddr4_sanityfunction11(const lpddr4_privatedata* pd, const lpddr4_reginitdata* regvalues)
422{
423 /* Declaring return variable */
424 uint32_t ret = 0;
425
426 if (regvalues == NULL)
427 {
428 ret = EINVAL;
429 }
430 else if (lpddr4_privatedatasf(pd) == EINVAL)
431 {
432 ret = EINVAL;
433 }
434 else
435 {
436 /*
437 * All 'if ... else if' constructs shall be terminated with an 'else' statement
438 * (MISRA2012-RULE-15_7-3)
439 */
440 }
441
442 return ret;
443}
444
445/**
446 * A common function to check the validity of API functions with
447 * following parameter types
448 * @param[in] pD Driver state info specific to this instance.
449 * @param[out] mask Value of interrupt mask
450 * @return 0 success
451 * @return EINVAL invalid parameters
452 */
453static inline uint32_t lpddr4_sanityfunction14(const lpddr4_privatedata* pd, const uint64_t* mask)
454{
455 /* Declaring return variable */
456 uint32_t ret = 0;
457
458 if (mask == NULL)
459 {
460 ret = EINVAL;
461 }
462 else if (lpddr4_privatedatasf(pd) == EINVAL)
463 {
464 ret = EINVAL;
465 }
466 else
467 {
468 /*
469 * All 'if ... else if' constructs shall be terminated with an 'else' statement
470 * (MISRA2012-RULE-15_7-3)
471 */
472 }
473
474 return ret;
475}
476
477/**
478 * A common function to check the validity of API functions with
479 * following parameter types
480 * @param[in] pD Driver state info specific to this instance.
481 * @param[in] mask Value of interrupt mask to be written
482 * @return 0 success
483 * @return EINVAL invalid parameters
484 */
485static inline uint32_t lpddr4_sanityfunction15(const lpddr4_privatedata* pd, const uint64_t* mask)
486{
487 /* Declaring return variable */
488 uint32_t ret = 0;
489
490 if (mask == NULL)
491 {
492 ret = EINVAL;
493 }
494 else if (lpddr4_privatedatasf(pd) == EINVAL)
495 {
496 ret = EINVAL;
497 }
498 else
499 {
500 /*
501 * All 'if ... else if' constructs shall be terminated with an 'else' statement
502 * (MISRA2012-RULE-15_7-3)
503 */
504 }
505
506 return ret;
507}
508
509/**
510 * A common function to check the validity of API functions with
511 * following parameter types
512 * @param[in] pD Driver state info specific to this instance.
513 * @param[in] intr Interrupt to be checked
514 * @param[out] irqStatus Status of the interrupt, TRUE if active
515 * @return 0 success
516 * @return EINVAL invalid parameters
517 */
518static inline uint32_t lpddr4_sanityfunction16(const lpddr4_privatedata* pd, const lpddr4_ctlinterrupt intr, const bool* irqstatus)
519{
520 /* Declaring return variable */
521 uint32_t ret = 0;
522
523 if (irqstatus == NULL)
524 {
525 ret = EINVAL;
526 }
527 else if (lpddr4_privatedatasf(pd) == EINVAL)
528 {
529 ret = EINVAL;
530 }
531 else if (
532 (intr != LPDDR4_RESET_DONE) &&
533 (intr != LPDDR4_BUS_ACCESS_ERROR) &&
534 (intr != LPDDR4_MULTIPLE_BUS_ACCESS_ERROR) &&
535 (intr != LPDDR4_ECC_MULTIPLE_CORR_ERROR) &&
536 (intr != LPDDR4_ECC_MULTIPLE_UNCORR_ERROR) &&
537 (intr != LPDDR4_ECC_WRITEBACK_EXEC_ERROR) &&
538 (intr != LPDDR4_ECC_SCRUB_DONE) &&
539 (intr != LPDDR4_ECC_SCRUB_ERROR) &&
540 (intr != LPDDR4_PORT_COMMAND_ERROR) &&
541 (intr != LPDDR4_MC_INIT_DONE) &&
542 (intr != LPDDR4_LP_DONE) &&
543 (intr != LPDDR4_BIST_DONE) &&
544 (intr != LPDDR4_WRAP_ERROR) &&
545 (intr != LPDDR4_INVALID_BURST_ERROR) &&
546 (intr != LPDDR4_RDLVL_ERROR) &&
547 (intr != LPDDR4_RDLVL_GATE_ERROR) &&
548 (intr != LPDDR4_WRLVL_ERROR) &&
549 (intr != LPDDR4_CA_TRAINING_ERROR) &&
550 (intr != LPDDR4_DFI_UPDATE_ERROR) &&
551 (intr != LPDDR4_MRR_ERROR) &&
552 (intr != LPDDR4_PHY_MASTER_ERROR) &&
553 (intr != LPDDR4_WRLVL_REQ) &&
554 (intr != LPDDR4_RDLVL_REQ) &&
555 (intr != LPDDR4_RDLVL_GATE_REQ) &&
556 (intr != LPDDR4_CA_TRAINING_REQ) &&
557 (intr != LPDDR4_LEVELING_DONE) &&
558 (intr != LPDDR4_PHY_ERROR) &&
559 (intr != LPDDR4_MR_READ_DONE) &&
560 (intr != LPDDR4_TEMP_CHANGE) &&
561 (intr != LPDDR4_TEMP_ALERT) &&
562 (intr != LPDDR4_SW_DQS_COMPLETE) &&
563 (intr != LPDDR4_DQS_OSC_BV_UPDATED) &&
564 (intr != LPDDR4_DQS_OSC_OVERFLOW) &&
565 (intr != LPDDR4_DQS_OSC_VAR_OUT) &&
566 (intr != LPDDR4_MR_WRITE_DONE) &&
567 (intr != LPDDR4_INHIBIT_DRAM_DONE) &&
568 (intr != LPDDR4_DFI_INIT_STATE) &&
569 (intr != LPDDR4_DLL_RESYNC_DONE) &&
570 (intr != LPDDR4_TDFI_TO) &&
571 (intr != LPDDR4_DFS_DONE) &&
572 (intr != LPDDR4_DFS_STATUS) &&
573 (intr != LPDDR4_REFRESH_STATUS) &&
574 (intr != LPDDR4_ZQ_STATUS) &&
575 (intr != LPDDR4_SW_REQ_MODE) &&
576 (intr != LPDDR4_LOR_BITS)
577 )
578 {
579 ret = EINVAL;
580 }
581 else
582 {
583 /*
584 * All 'if ... else if' constructs shall be terminated with an 'else' statement
585 * (MISRA2012-RULE-15_7-3)
586 */
587 }
588
589 return ret;
590}
591
592/**
593 * A common function to check the validity of API functions with
594 * following parameter types
595 * @param[in] pD Driver state info specific to this instance.
596 * @param[in] intr Interrupt to be acknowledged
597 * @return 0 success
598 * @return EINVAL invalid parameters
599 */
600static inline uint32_t lpddr4_sanityfunction17(const lpddr4_privatedata* pd, const lpddr4_ctlinterrupt intr)
601{
602 /* Declaring return variable */
603 uint32_t ret = 0;
604
605 if (lpddr4_privatedatasf(pd) == EINVAL)
606 {
607 ret = EINVAL;
608 }
609 else if (
610 (intr != LPDDR4_RESET_DONE) &&
611 (intr != LPDDR4_BUS_ACCESS_ERROR) &&
612 (intr != LPDDR4_MULTIPLE_BUS_ACCESS_ERROR) &&
613 (intr != LPDDR4_ECC_MULTIPLE_CORR_ERROR) &&
614 (intr != LPDDR4_ECC_MULTIPLE_UNCORR_ERROR) &&
615 (intr != LPDDR4_ECC_WRITEBACK_EXEC_ERROR) &&
616 (intr != LPDDR4_ECC_SCRUB_DONE) &&
617 (intr != LPDDR4_ECC_SCRUB_ERROR) &&
618 (intr != LPDDR4_PORT_COMMAND_ERROR) &&
619 (intr != LPDDR4_MC_INIT_DONE) &&
620 (intr != LPDDR4_LP_DONE) &&
621 (intr != LPDDR4_BIST_DONE) &&
622 (intr != LPDDR4_WRAP_ERROR) &&
623 (intr != LPDDR4_INVALID_BURST_ERROR) &&
624 (intr != LPDDR4_RDLVL_ERROR) &&
625 (intr != LPDDR4_RDLVL_GATE_ERROR) &&
626 (intr != LPDDR4_WRLVL_ERROR) &&
627 (intr != LPDDR4_CA_TRAINING_ERROR) &&
628 (intr != LPDDR4_DFI_UPDATE_ERROR) &&
629 (intr != LPDDR4_MRR_ERROR) &&
630 (intr != LPDDR4_PHY_MASTER_ERROR) &&
631 (intr != LPDDR4_WRLVL_REQ) &&
632 (intr != LPDDR4_RDLVL_REQ) &&
633 (intr != LPDDR4_RDLVL_GATE_REQ) &&
634 (intr != LPDDR4_CA_TRAINING_REQ) &&
635 (intr != LPDDR4_LEVELING_DONE) &&
636 (intr != LPDDR4_PHY_ERROR) &&
637 (intr != LPDDR4_MR_READ_DONE) &&
638 (intr != LPDDR4_TEMP_CHANGE) &&
639 (intr != LPDDR4_TEMP_ALERT) &&
640 (intr != LPDDR4_SW_DQS_COMPLETE) &&
641 (intr != LPDDR4_DQS_OSC_BV_UPDATED) &&
642 (intr != LPDDR4_DQS_OSC_OVERFLOW) &&
643 (intr != LPDDR4_DQS_OSC_VAR_OUT) &&
644 (intr != LPDDR4_MR_WRITE_DONE) &&
645 (intr != LPDDR4_INHIBIT_DRAM_DONE) &&
646 (intr != LPDDR4_DFI_INIT_STATE) &&
647 (intr != LPDDR4_DLL_RESYNC_DONE) &&
648 (intr != LPDDR4_TDFI_TO) &&
649 (intr != LPDDR4_DFS_DONE) &&
650 (intr != LPDDR4_DFS_STATUS) &&
651 (intr != LPDDR4_REFRESH_STATUS) &&
652 (intr != LPDDR4_ZQ_STATUS) &&
653 (intr != LPDDR4_SW_REQ_MODE) &&
654 (intr != LPDDR4_LOR_BITS)
655 )
656 {
657 ret = EINVAL;
658 }
659 else
660 {
661 /*
662 * All 'if ... else if' constructs shall be terminated with an 'else' statement
663 * (MISRA2012-RULE-15_7-3)
664 */
665 }
666
667 return ret;
668}
669
670/**
671 * A common function to check the validity of API functions with
672 * following parameter types
673 * @param[in] pD Driver state info specific to this instance.
674 * @param[out] mask Value of interrupt mask
675 * @return 0 success
676 * @return EINVAL invalid parameters
677 */
678static inline uint32_t lpddr4_sanityfunction18(const lpddr4_privatedata* pd, const uint32_t* mask)
679{
680 /* Declaring return variable */
681 uint32_t ret = 0;
682
683 if (mask == NULL)
684 {
685 ret = EINVAL;
686 }
687 else if (lpddr4_privatedatasf(pd) == EINVAL)
688 {
689 ret = EINVAL;
690 }
691 else
692 {
693 /*
694 * All 'if ... else if' constructs shall be terminated with an 'else' statement
695 * (MISRA2012-RULE-15_7-3)
696 */
697 }
698
699 return ret;
700}
701
702/**
703 * A common function to check the validity of API functions with
704 * following parameter types
705 * @param[in] pD Driver state info specific to this instance.
706 * @param[in] intr Interrupt to be checked
707 * @param[out] irqStatus Status of the interrupt, TRUE if active
708 * @return 0 success
709 * @return EINVAL invalid parameters
710 */
711static inline uint32_t lpddr4_sanityfunction20(const lpddr4_privatedata* pd, const lpddr4_phyindepinterrupt intr, const bool* irqstatus)
712{
713 /* Declaring return variable */
714 uint32_t ret = 0;
715
716 if (irqstatus == NULL)
717 {
718 ret = EINVAL;
719 }
720 else if (lpddr4_privatedatasf(pd) == EINVAL)
721 {
722 ret = EINVAL;
723 }
724 else if (
725 (intr != LPDDR4_PHY_INDEP_INIT_DONE_BIT) &&
726 (intr != LPDDR4_PHY_INDEP_CONTROL_ERROR_BIT) &&
727 (intr != LPDDR4_PHY_INDEP_CA_PARITY_ERR_BIT) &&
728 (intr != LPDDR4_PHY_INDEP_RDLVL_ERROR_BIT) &&
729 (intr != LPDDR4_PHY_INDEP_RDLVL_GATE_ERROR_BIT) &&
730 (intr != LPDDR4_PHY_INDEP_WRLVL_ERROR_BIT) &&
731 (intr != LPDDR4_PHY_INDEP_CALVL_ERROR_BIT) &&
732 (intr != LPDDR4_PHY_INDEP_WDQLVL_ERROR_BIT) &&
733 (intr != LPDDR4_PHY_INDEP_UPDATE_ERROR_BIT) &&
734 (intr != LPDDR4_PHY_INDEP_RDLVL_REQ_BIT) &&
735 (intr != LPDDR4_PHY_INDEP_RDLVL_GATE_REQ_BIT) &&
736 (intr != LPDDR4_PHY_INDEP_WRLVL_REQ_BIT) &&
737 (intr != LPDDR4_PHY_INDEP_CALVL_REQ_BIT) &&
738 (intr != LPDDR4_PHY_INDEP_WDQLVL_REQ_BIT) &&
739 (intr != LPDDR4_PHY_INDEP_LVL_DONE_BIT) &&
740 (intr != LPDDR4_PHY_INDEP_BIST_DONE_BIT) &&
741 (intr != LPDDR4_PHY_INDEP_TDFI_INIT_TIME_OUT_BIT) &&
742 (intr != LPDDR4_PHY_INDEP_DLL_LOCK_STATE_CHANGE_BIT)
743 )
744 {
745 ret = EINVAL;
746 }
747 else
748 {
749 /*
750 * All 'if ... else if' constructs shall be terminated with an 'else' statement
751 * (MISRA2012-RULE-15_7-3)
752 */
753 }
754
755 return ret;
756}
757
758/**
759 * A common function to check the validity of API functions with
760 * following parameter types
761 * @param[in] pD Driver state info specific to this instance.
762 * @param[in] intr Interrupt to be acknowledged
763 * @return 0 success
764 * @return EINVAL invalid parameters
765 */
766static inline uint32_t lpddr4_sanityfunction21(const lpddr4_privatedata* pd, const lpddr4_phyindepinterrupt intr)
767{
768 /* Declaring return variable */
769 uint32_t ret = 0;
770
771 if (lpddr4_privatedatasf(pd) == EINVAL)
772 {
773 ret = EINVAL;
774 }
775 else if (
776 (intr != LPDDR4_PHY_INDEP_INIT_DONE_BIT) &&
777 (intr != LPDDR4_PHY_INDEP_CONTROL_ERROR_BIT) &&
778 (intr != LPDDR4_PHY_INDEP_CA_PARITY_ERR_BIT) &&
779 (intr != LPDDR4_PHY_INDEP_RDLVL_ERROR_BIT) &&
780 (intr != LPDDR4_PHY_INDEP_RDLVL_GATE_ERROR_BIT) &&
781 (intr != LPDDR4_PHY_INDEP_WRLVL_ERROR_BIT) &&
782 (intr != LPDDR4_PHY_INDEP_CALVL_ERROR_BIT) &&
783 (intr != LPDDR4_PHY_INDEP_WDQLVL_ERROR_BIT) &&
784 (intr != LPDDR4_PHY_INDEP_UPDATE_ERROR_BIT) &&
785 (intr != LPDDR4_PHY_INDEP_RDLVL_REQ_BIT) &&
786 (intr != LPDDR4_PHY_INDEP_RDLVL_GATE_REQ_BIT) &&
787 (intr != LPDDR4_PHY_INDEP_WRLVL_REQ_BIT) &&
788 (intr != LPDDR4_PHY_INDEP_CALVL_REQ_BIT) &&
789 (intr != LPDDR4_PHY_INDEP_WDQLVL_REQ_BIT) &&
790 (intr != LPDDR4_PHY_INDEP_LVL_DONE_BIT) &&
791 (intr != LPDDR4_PHY_INDEP_BIST_DONE_BIT) &&
792 (intr != LPDDR4_PHY_INDEP_TDFI_INIT_TIME_OUT_BIT) &&
793 (intr != LPDDR4_PHY_INDEP_DLL_LOCK_STATE_CHANGE_BIT)
794 )
795 {
796 ret = EINVAL;
797 }
798 else
799 {
800 /*
801 * All 'if ... else if' constructs shall be terminated with an 'else' statement
802 * (MISRA2012-RULE-15_7-3)
803 */
804 }
805
806 return ret;
807}
808
809/**
810 * A common function to check the validity of API functions with
811 * following parameter types
812 * @param[in] pD Driver state info specific to this instance.
813 * @param[out] debugInfo status
814 * @return 0 success
815 * @return EINVAL invalid parameters
816 */
817static inline uint32_t lpddr4_sanityfunction22(const lpddr4_privatedata* pd, const lpddr4_debuginfo* debuginfo)
818{
819 /* Declaring return variable */
820 uint32_t ret = 0;
821
822 if (debuginfo == NULL)
823 {
824 ret = EINVAL;
825 }
826 else if (lpddr4_privatedatasf(pd) == EINVAL)
827 {
828 ret = EINVAL;
829 }
830 else
831 {
832 /*
833 * All 'if ... else if' constructs shall be terminated with an 'else' statement
834 * (MISRA2012-RULE-15_7-3)
835 */
836 }
837
838 return ret;
839}
840
841/**
842 * A common function to check the validity of API functions with
843 * following parameter types
844 * @param[in] pD Driver state info specific to this instance.
845 * @param[in] lpiWakeUpParam LPI timing parameter
846 * @param[in] fspNum Frequency copy
847 * @param[out] cycles Timing value(in cycles)
848 * @return 0 success
849 * @return EINVAL invalid parameters
850 */
851static inline uint32_t lpddr4_sanityfunction23(const lpddr4_privatedata* pd, const lpddr4_lpiwakeupparam* lpiwakeupparam, const lpddr4_ctlfspnum* fspnum, const uint32_t* cycles)
852{
853 /* Declaring return variable */
854 uint32_t ret = 0;
855
856 if (lpiwakeupparam == NULL)
857 {
858 ret = EINVAL;
859 }
860 else if (fspnum == NULL)
861 {
862 ret = EINVAL;
863 }
864 else if (cycles == NULL)
865 {
866 ret = EINVAL;
867 }
868 else if (lpddr4_privatedatasf(pd) == EINVAL)
869 {
870 ret = EINVAL;
871 }
872 else if (
873 (*lpiwakeupparam != LPDDR4_LPI_PD_WAKEUP_FN) &&
874 (*lpiwakeupparam != LPDDR4_LPI_SR_SHORT_WAKEUP_FN) &&
875 (*lpiwakeupparam != LPDDR4_LPI_SR_LONG_WAKEUP_FN) &&
876 (*lpiwakeupparam != LPDDR4_LPI_SR_LONG_MCCLK_GATE_WAKEUP_FN) &&
877 (*lpiwakeupparam != LPDDR4_LPI_SRPD_SHORT_WAKEUP_FN) &&
878 (*lpiwakeupparam != LPDDR4_LPI_SRPD_LONG_WAKEUP_FN) &&
879 (*lpiwakeupparam != LPDDR4_LPI_SRPD_LONG_MCCLK_GATE_WAKEUP_FN)
880 )
881 {
882 ret = EINVAL;
883 }
884 else if (
885 (*fspnum != LPDDR4_FSP_0) &&
886 (*fspnum != LPDDR4_FSP_1) &&
887 (*fspnum != LPDDR4_FSP_2)
888 )
889 {
890 ret = EINVAL;
891 }
892 else
893 {
894 /*
895 * All 'if ... else if' constructs shall be terminated with an 'else' statement
896 * (MISRA2012-RULE-15_7-3)
897 */
898 }
899
900 return ret;
901}
902
903/**
904 * A common function to check the validity of API functions with
905 * following parameter types
906 * @param[in] pD Driver state info specific to this instance.
907 * @param[out] eccParam ECC parameter setting
908 * @return 0 success
909 * @return EINVAL invalid parameters
910 */
911static inline uint32_t lpddr4_sanityfunction25(const lpddr4_privatedata* pd, const lpddr4_eccenable* eccparam)
912{
913 /* Declaring return variable */
914 uint32_t ret = 0;
915
916 if (eccparam == NULL)
917 {
918 ret = EINVAL;
919 }
920 else if (lpddr4_privatedatasf(pd) == EINVAL)
921 {
922 ret = EINVAL;
923 }
924 else
925 {
926 /*
927 * All 'if ... else if' constructs shall be terminated with an 'else' statement
928 * (MISRA2012-RULE-15_7-3)
929 */
930 }
931
932 return ret;
933}
934
935/**
936 * A common function to check the validity of API functions with
937 * following parameter types
938 * @param[in] pD Driver state info specific to this instance.
939 * @param[in] eccParam ECC control parameter setting
940 * @return 0 success
941 * @return EINVAL invalid parameters
942 */
943static inline uint32_t lpddr4_sanityfunction26(const lpddr4_privatedata* pd, const lpddr4_eccenable* eccparam)
944{
945 /* Declaring return variable */
946 uint32_t ret = 0;
947
948 if (eccparam == NULL)
949 {
950 ret = EINVAL;
951 }
952 else if (lpddr4_privatedatasf(pd) == EINVAL)
953 {
954 ret = EINVAL;
955 }
956 else if (
957 (*eccparam != LPDDR4_ECC_DISABLED) &&
958 (*eccparam != LPDDR4_ECC_ENABLED) &&
959 (*eccparam != LPDDR4_ECC_ERR_DETECT) &&
960 (*eccparam != LPDDR4_ECC_ERR_DETECT_CORRECT)
961 )
962 {
963 ret = EINVAL;
964 }
965 else
966 {
967 /*
968 * All 'if ... else if' constructs shall be terminated with an 'else' statement
969 * (MISRA2012-RULE-15_7-3)
970 */
971 }
972
973 return ret;
974}
975
976/**
977 * A common function to check the validity of API functions with
978 * following parameter types
979 * @param[in] pD Driver state info specific to this instance.
980 * @param[out] mode Half Datapath setting
981 * @return 0 success
982 * @return EINVAL invalid parameters
983 */
984static inline uint32_t lpddr4_sanityfunction27(const lpddr4_privatedata* pd, const lpddr4_reducmode* mode)
985{
986 /* Declaring return variable */
987 uint32_t ret = 0;
988
989 if (mode == NULL)
990 {
991 ret = EINVAL;
992 }
993 else if (lpddr4_privatedatasf(pd) == EINVAL)
994 {
995 ret = EINVAL;
996 }
997 else
998 {
999 /*
1000 * All 'if ... else if' constructs shall be terminated with an 'else' statement
1001 * (MISRA2012-RULE-15_7-3)
1002 */
1003 }
1004
1005 return ret;
1006}
1007
1008/**
1009 * A common function to check the validity of API functions with
1010 * following parameter types
1011 * @param[in] pD Driver state info specific to this instance.
1012 * @param[in] mode Half Datapath setting
1013 * @return 0 success
1014 * @return EINVAL invalid parameters
1015 */
1016static inline uint32_t lpddr4_sanityfunction28(const lpddr4_privatedata* pd, const lpddr4_reducmode* mode)
1017{
1018 /* Declaring return variable */
1019 uint32_t ret = 0;
1020
1021 if (mode == NULL)
1022 {
1023 ret = EINVAL;
1024 }
1025 else if (lpddr4_privatedatasf(pd) == EINVAL)
1026 {
1027 ret = EINVAL;
1028 }
1029 else if (
1030 (*mode != LPDDR4_REDUC_ON) &&
1031 (*mode != LPDDR4_REDUC_OFF)
1032 )
1033 {
1034 ret = EINVAL;
1035 }
1036 else
1037 {
1038 /*
1039 * All 'if ... else if' constructs shall be terminated with an 'else' statement
1040 * (MISRA2012-RULE-15_7-3)
1041 */
1042 }
1043
1044 return ret;
1045}
1046
1047/**
1048 * A common function to check the validity of API functions with
1049 * following parameter types
1050 * @param[in] pD Driver state info specific to this instance.
1051 * @param[out] on_off DBI read value
1052 * @return 0 success
1053 * @return EINVAL invalid parameters
1054 */
1055static inline uint32_t lpddr4_sanityfunction29(const lpddr4_privatedata* pd, const bool* on_off)
1056{
1057 /* Declaring return variable */
1058 uint32_t ret = 0;
1059
1060 if (on_off == NULL)
1061 {
1062 ret = EINVAL;
1063 }
1064 else if (lpddr4_privatedatasf(pd) == EINVAL)
1065 {
1066 ret = EINVAL;
1067 }
1068 else
1069 {
1070 /*
1071 * All 'if ... else if' constructs shall be terminated with an 'else' statement
1072 * (MISRA2012-RULE-15_7-3)
1073 */
1074 }
1075
1076 return ret;
1077}
1078
1079/**
1080 * A common function to check the validity of API functions with
1081 * following parameter types
1082 * @param[in] pD Driver state info specific to this instance.
1083 * @param[in] mode status
1084 * @return 0 success
1085 * @return EINVAL invalid parameters
1086 */
1087static inline uint32_t lpddr4_sanityfunction31(const lpddr4_privatedata* pd, const lpddr4_dbimode* mode)
1088{
1089 /* Declaring return variable */
1090 uint32_t ret = 0;
1091
1092 if (mode == NULL)
1093 {
1094 ret = EINVAL;
1095 }
1096 else if (lpddr4_privatedatasf(pd) == EINVAL)
1097 {
1098 ret = EINVAL;
1099 }
1100 else if (
1101 (*mode != LPDDR4_DBI_RD_ON) &&
1102 (*mode != LPDDR4_DBI_RD_OFF) &&
1103 (*mode != LPDDR4_DBI_WR_ON) &&
1104 (*mode != LPDDR4_DBI_WR_OFF)
1105 )
1106 {
1107 ret = EINVAL;
1108 }
1109 else
1110 {
1111 /*
1112 * All 'if ... else if' constructs shall be terminated with an 'else' statement
1113 * (MISRA2012-RULE-15_7-3)
1114 */
1115 }
1116
1117 return ret;
1118}
1119
1120/**
1121 * A common function to check the validity of API functions with
1122 * following parameter types
1123 * @param[in] pD Driver state info specific to this instance.
1124 * @param[in] fspNum Frequency set number
1125 * @param[out] cycles Refresh rate (in cycles)
1126 * @return 0 success
1127 * @return EINVAL invalid parameters
1128 */
1129static inline uint32_t lpddr4_sanityfunction32(const lpddr4_privatedata* pd, const lpddr4_ctlfspnum* fspnum, const uint32_t* cycles)
1130{
1131 /* Declaring return variable */
1132 uint32_t ret = 0;
1133
1134 if (fspnum == NULL)
1135 {
1136 ret = EINVAL;
1137 }
1138 else if (cycles == NULL)
1139 {
1140 ret = EINVAL;
1141 }
1142 else if (lpddr4_privatedatasf(pd) == EINVAL)
1143 {
1144 ret = EINVAL;
1145 }
1146 else if (
1147 (*fspnum != LPDDR4_FSP_0) &&
1148 (*fspnum != LPDDR4_FSP_1) &&
1149 (*fspnum != LPDDR4_FSP_2)
1150 )
1151 {
1152 ret = EINVAL;
1153 }
1154 else
1155 {
1156 /*
1157 * All 'if ... else if' constructs shall be terminated with an 'else' statement
1158 * (MISRA2012-RULE-15_7-3)
1159 */
1160 }
1161
1162 return ret;
1163}
1164
1165#endif /* LPDDR4_SANITY_H */