Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: BSD-3-Clause */ |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Cadence DDR Driver |
| 4 | * |
| 5 | * Copyright (C) 2012-2021 Cadence Design Systems, Inc. |
| 6 | * Copyright (C) 2018-2021 Texas Instruments Incorporated - https://www.ti.com/ |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef LPDDR4_SANITY_H |
| 10 | #define LPDDR4_SANITY_H |
| 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 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 18 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 19 | static inline u32 lpddr4_configsf(const lpddr4_config *obj); |
| 20 | static inline u32 lpddr4_privatedatasf(const lpddr4_privatedata *obj); |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 21 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 22 | static inline u32 lpddr4_sanityfunction1(const lpddr4_config *config, const u16 *configsize); |
| 23 | static inline u32 lpddr4_sanityfunction2(const lpddr4_privatedata *pd, const lpddr4_config *cfg); |
| 24 | static inline u32 lpddr4_sanityfunction3(const lpddr4_privatedata *pd); |
| 25 | static inline u32 lpddr4_sanityfunction4(const lpddr4_privatedata *pd, const lpddr4_regblock cpp, const u32 *regvalue); |
| 26 | static inline u32 lpddr4_sanityfunction5(const lpddr4_privatedata *pd, const lpddr4_regblock cpp); |
| 27 | static inline u32 lpddr4_sanityfunction6(const lpddr4_privatedata *pd, const u64 *mmrvalue, const u8 *mmrstatus); |
| 28 | static inline u32 lpddr4_sanityfunction7(const lpddr4_privatedata *pd, const u8 *mrwstatus); |
| 29 | static inline u32 lpddr4_sanityfunction14(const lpddr4_privatedata *pd, const u64 *mask); |
| 30 | static inline u32 lpddr4_sanityfunction15(const lpddr4_privatedata *pd, const u64 *mask); |
| 31 | static inline u32 lpddr4_sanityfunction16(const lpddr4_privatedata *pd, const u32 *mask); |
| 32 | static inline u32 lpddr4_sanityfunction18(const lpddr4_privatedata *pd, const lpddr4_debuginfo *debuginfo); |
| 33 | static inline u32 lpddr4_sanityfunction19(const lpddr4_privatedata *pd, const lpddr4_lpiwakeupparam *lpiwakeupparam, const lpddr4_ctlfspnum *fspnum, const u32 *cycles); |
| 34 | static inline u32 lpddr4_sanityfunction21(const lpddr4_privatedata *pd, const lpddr4_eccenable *eccparam); |
| 35 | static inline u32 lpddr4_sanityfunction22(const lpddr4_privatedata *pd, const lpddr4_eccenable *eccparam); |
| 36 | static inline u32 lpddr4_sanityfunction23(const lpddr4_privatedata *pd, const lpddr4_reducmode *mode); |
| 37 | static inline u32 lpddr4_sanityfunction24(const lpddr4_privatedata *pd, const lpddr4_reducmode *mode); |
| 38 | static inline u32 lpddr4_sanityfunction25(const lpddr4_privatedata *pd, const bool *on_off); |
| 39 | static inline u32 lpddr4_sanityfunction27(const lpddr4_privatedata *pd, const lpddr4_dbimode *mode); |
| 40 | static inline u32 lpddr4_sanityfunction28(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, const u32 *tref, const u32 *tras_max); |
| 41 | static inline u32 lpddr4_sanityfunction29(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, const u32 *tref, const u32 *tras_max); |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 42 | |
| 43 | #define lpddr4_probesf lpddr4_sanityfunction1 |
| 44 | #define lpddr4_initsf lpddr4_sanityfunction2 |
| 45 | #define lpddr4_startsf lpddr4_sanityfunction3 |
| 46 | #define lpddr4_readregsf lpddr4_sanityfunction4 |
| 47 | #define lpddr4_writeregsf lpddr4_sanityfunction5 |
| 48 | #define lpddr4_getmmrregistersf lpddr4_sanityfunction6 |
| 49 | #define lpddr4_setmmrregistersf lpddr4_sanityfunction7 |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 50 | #define lpddr4_writectlconfigsf lpddr4_sanityfunction3 |
| 51 | #define lpddr4_writephyconfigsf lpddr4_sanityfunction3 |
| 52 | #define lpddr4_writephyindepconfigsf lpddr4_sanityfunction3 |
| 53 | #define lpddr4_readctlconfigsf lpddr4_sanityfunction3 |
| 54 | #define lpddr4_readphyconfigsf lpddr4_sanityfunction3 |
| 55 | #define lpddr4_readphyindepconfigsf lpddr4_sanityfunction3 |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 56 | #define lpddr4_getctlinterruptmasksf lpddr4_sanityfunction14 |
| 57 | #define lpddr4_setctlinterruptmasksf lpddr4_sanityfunction15 |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 58 | #define lpddr4_getphyindepinterruptmsf lpddr4_sanityfunction16 |
| 59 | #define lpddr4_setphyindepinterruptmsf lpddr4_sanityfunction16 |
| 60 | #define lpddr4_getdebuginitinfosf lpddr4_sanityfunction18 |
| 61 | #define lpddr4_getlpiwakeuptimesf lpddr4_sanityfunction19 |
| 62 | #define lpddr4_setlpiwakeuptimesf lpddr4_sanityfunction19 |
| 63 | #define lpddr4_geteccenablesf lpddr4_sanityfunction21 |
| 64 | #define lpddr4_seteccenablesf lpddr4_sanityfunction22 |
| 65 | #define lpddr4_getreducmodesf lpddr4_sanityfunction23 |
| 66 | #define lpddr4_setreducmodesf lpddr4_sanityfunction24 |
| 67 | #define lpddr4_getdbireadmodesf lpddr4_sanityfunction25 |
| 68 | #define lpddr4_getdbiwritemodesf lpddr4_sanityfunction25 |
| 69 | #define lpddr4_setdbimodesf lpddr4_sanityfunction27 |
| 70 | #define lpddr4_getrefreshratesf lpddr4_sanityfunction28 |
| 71 | #define lpddr4_setrefreshratesf lpddr4_sanityfunction29 |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 72 | #define lpddr4_refreshperchipselectsf lpddr4_sanityfunction3 |
| 73 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 74 | static inline u32 lpddr4_configsf(const lpddr4_config *obj) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 75 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 76 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 77 | |
| 78 | if (obj == NULL) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 79 | ret = EINVAL; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 80 | |
| 81 | return ret; |
| 82 | } |
| 83 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 84 | static inline u32 lpddr4_privatedatasf(const lpddr4_privatedata *obj) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 85 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 86 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 87 | |
| 88 | if (obj == NULL) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 89 | ret = EINVAL; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 90 | |
| 91 | return ret; |
| 92 | } |
| 93 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 94 | static inline u32 lpddr4_sanityfunction1(const lpddr4_config *config, const u16 *configsize) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 95 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 96 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 97 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 98 | if (configsize == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 99 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 100 | } else if (lpddr4_configsf(config) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 101 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 102 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | return ret; |
| 106 | } |
| 107 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 108 | static inline u32 lpddr4_sanityfunction2(const lpddr4_privatedata *pd, const lpddr4_config *cfg) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 109 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 110 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 111 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 112 | if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 113 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 114 | } else if (lpddr4_configsf(cfg) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 115 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 116 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | return ret; |
| 120 | } |
| 121 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 122 | static inline u32 lpddr4_sanityfunction3(const lpddr4_privatedata *pd) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 123 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 124 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 125 | |
| 126 | if (lpddr4_privatedatasf(pd) == EINVAL) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 127 | ret = EINVAL; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 128 | |
| 129 | return ret; |
| 130 | } |
| 131 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 132 | static inline u32 lpddr4_sanityfunction4(const lpddr4_privatedata *pd, const lpddr4_regblock cpp, const u32 *regvalue) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 133 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 134 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 135 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 136 | if (regvalue == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 137 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 138 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 139 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 140 | } else if ( |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 141 | (cpp != LPDDR4_CTL_REGS) && |
| 142 | (cpp != LPDDR4_PHY_REGS) && |
| 143 | (cpp != LPDDR4_PHY_INDEP_REGS) |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 144 | ) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 145 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 146 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | return ret; |
| 150 | } |
| 151 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 152 | static inline u32 lpddr4_sanityfunction5(const lpddr4_privatedata *pd, const lpddr4_regblock cpp) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 153 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 154 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 155 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 156 | if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 157 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 158 | } else if ( |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 159 | (cpp != LPDDR4_CTL_REGS) && |
| 160 | (cpp != LPDDR4_PHY_REGS) && |
| 161 | (cpp != LPDDR4_PHY_INDEP_REGS) |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 162 | ) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 163 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 164 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | return ret; |
| 168 | } |
| 169 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 170 | static inline u32 lpddr4_sanityfunction6(const lpddr4_privatedata *pd, const u64 *mmrvalue, const u8 *mmrstatus) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 171 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 172 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 173 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 174 | if (mmrvalue == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 175 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 176 | } else if (mmrstatus == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 177 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 178 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 179 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 180 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | return ret; |
| 184 | } |
| 185 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 186 | static inline u32 lpddr4_sanityfunction7(const lpddr4_privatedata *pd, const u8 *mrwstatus) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 187 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 188 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 189 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 190 | if (mrwstatus == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 191 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 192 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 193 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 194 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | return ret; |
| 198 | } |
| 199 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 200 | static inline u32 lpddr4_sanityfunction14(const lpddr4_privatedata *pd, const u64 *mask) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 201 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 202 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 203 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 204 | if (mask == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 205 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 206 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 207 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 208 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | return ret; |
| 212 | } |
| 213 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 214 | static inline u32 lpddr4_sanityfunction15(const lpddr4_privatedata *pd, const u64 *mask) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 215 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 216 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 217 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 218 | if (mask == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 219 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 220 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 221 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 222 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | return ret; |
| 226 | } |
| 227 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 228 | static inline u32 lpddr4_sanityfunction16(const lpddr4_privatedata *pd, const u32 *mask) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 229 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 230 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 231 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 232 | if (mask == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 233 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 234 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 235 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 236 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | return ret; |
| 240 | } |
| 241 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 242 | static inline u32 lpddr4_sanityfunction18(const lpddr4_privatedata *pd, const lpddr4_debuginfo *debuginfo) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 243 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 244 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 245 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 246 | if (debuginfo == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 247 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 248 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 249 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 250 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | return ret; |
| 254 | } |
| 255 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 256 | static inline u32 lpddr4_sanityfunction19(const lpddr4_privatedata *pd, const lpddr4_lpiwakeupparam *lpiwakeupparam, const lpddr4_ctlfspnum *fspnum, const u32 *cycles) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 257 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 258 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 259 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 260 | if (lpiwakeupparam == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 261 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 262 | } else if (fspnum == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 263 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 264 | } else if (cycles == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 265 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 266 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 267 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 268 | } else if ( |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 269 | (*lpiwakeupparam != LPDDR4_LPI_PD_WAKEUP_FN) && |
| 270 | (*lpiwakeupparam != LPDDR4_LPI_SR_SHORT_WAKEUP_FN) && |
| 271 | (*lpiwakeupparam != LPDDR4_LPI_SR_LONG_WAKEUP_FN) && |
| 272 | (*lpiwakeupparam != LPDDR4_LPI_SR_LONG_MCCLK_GATE_WAKEUP_FN) && |
| 273 | (*lpiwakeupparam != LPDDR4_LPI_SRPD_SHORT_WAKEUP_FN) && |
| 274 | (*lpiwakeupparam != LPDDR4_LPI_SRPD_LONG_WAKEUP_FN) && |
| 275 | (*lpiwakeupparam != LPDDR4_LPI_SRPD_LONG_MCCLK_GATE_WAKEUP_FN) |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 276 | ) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 277 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 278 | } else if ( |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 279 | (*fspnum != LPDDR4_FSP_0) && |
| 280 | (*fspnum != LPDDR4_FSP_1) && |
| 281 | (*fspnum != LPDDR4_FSP_2) |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 282 | ) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 283 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 284 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | return ret; |
| 288 | } |
| 289 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 290 | static inline u32 lpddr4_sanityfunction21(const lpddr4_privatedata *pd, const lpddr4_eccenable *eccparam) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 291 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 292 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 293 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 294 | if (eccparam == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 295 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 296 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 297 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 298 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | return ret; |
| 302 | } |
| 303 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 304 | static inline u32 lpddr4_sanityfunction22(const lpddr4_privatedata *pd, const lpddr4_eccenable *eccparam) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 305 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 306 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 307 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 308 | if (eccparam == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 309 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 310 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 311 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 312 | } else if ( |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 313 | (*eccparam != LPDDR4_ECC_DISABLED) && |
| 314 | (*eccparam != LPDDR4_ECC_ENABLED) && |
| 315 | (*eccparam != LPDDR4_ECC_ERR_DETECT) && |
| 316 | (*eccparam != LPDDR4_ECC_ERR_DETECT_CORRECT) |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 317 | ) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 318 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 319 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | return ret; |
| 323 | } |
| 324 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 325 | static inline u32 lpddr4_sanityfunction23(const lpddr4_privatedata *pd, const lpddr4_reducmode *mode) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 326 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 327 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 328 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 329 | if (mode == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 330 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 331 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 332 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 333 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | return ret; |
| 337 | } |
| 338 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 339 | static inline u32 lpddr4_sanityfunction24(const lpddr4_privatedata *pd, const lpddr4_reducmode *mode) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 340 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 341 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 342 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 343 | if (mode == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 344 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 345 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 346 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 347 | } else if ( |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 348 | (*mode != LPDDR4_REDUC_ON) && |
| 349 | (*mode != LPDDR4_REDUC_OFF) |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 350 | ) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 351 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 352 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | return ret; |
| 356 | } |
| 357 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 358 | static inline u32 lpddr4_sanityfunction25(const lpddr4_privatedata *pd, const bool *on_off) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 359 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 360 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 361 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 362 | if (on_off == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 363 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 364 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 365 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 366 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | return ret; |
| 370 | } |
| 371 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 372 | static inline u32 lpddr4_sanityfunction27(const lpddr4_privatedata *pd, const lpddr4_dbimode *mode) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 373 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 374 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 375 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 376 | if (mode == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 377 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 378 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 379 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 380 | } else if ( |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 381 | (*mode != LPDDR4_DBI_RD_ON) && |
| 382 | (*mode != LPDDR4_DBI_RD_OFF) && |
| 383 | (*mode != LPDDR4_DBI_WR_ON) && |
| 384 | (*mode != LPDDR4_DBI_WR_OFF) |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 385 | ) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 386 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 387 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | return ret; |
| 391 | } |
| 392 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 393 | static inline u32 lpddr4_sanityfunction28(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, const u32 *tref, const u32 *tras_max) |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 394 | { |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 395 | u32 ret = 0; |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 396 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 397 | if (fspnum == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 398 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 399 | } else if (tref == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 400 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 401 | } else if (tras_max == NULL) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 402 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 403 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
| 404 | ret = EINVAL; |
| 405 | } else if ( |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 406 | (*fspnum != LPDDR4_FSP_0) && |
| 407 | (*fspnum != LPDDR4_FSP_1) && |
| 408 | (*fspnum != LPDDR4_FSP_2) |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 409 | ) { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 410 | ret = EINVAL; |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 411 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 412 | } |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 413 | |
| 414 | return ret; |
| 415 | } |
| 416 | |
| 417 | static inline u32 lpddr4_sanityfunction29(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, const u32 *tref, const u32 *tras_max) |
| 418 | { |
| 419 | u32 ret = 0; |
| 420 | |
| 421 | if (fspnum == NULL) { |
| 422 | ret = EINVAL; |
| 423 | } else if (tref == NULL) { |
| 424 | ret = EINVAL; |
| 425 | } else if (tras_max == NULL) { |
| 426 | ret = EINVAL; |
| 427 | } else if (lpddr4_privatedatasf(pd) == EINVAL) { |
| 428 | ret = EINVAL; |
| 429 | } else if ( |
| 430 | (*fspnum != LPDDR4_FSP_0) && |
| 431 | (*fspnum != LPDDR4_FSP_1) && |
| 432 | (*fspnum != LPDDR4_FSP_2) |
| 433 | ) { |
| 434 | ret = EINVAL; |
| 435 | } else { |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | return ret; |
| 439 | } |
| 440 | |
Dave Gerlach | d712b36 | 2021-05-11 10:22:11 -0500 | [diff] [blame] | 441 | #ifdef __cplusplus |
| 442 | } |
| 443 | #endif |
| 444 | |
Kevin Scholz | 521a4ef | 2019-10-07 19:26:36 +0530 | [diff] [blame] | 445 | #endif /* LPDDR4_SANITY_H */ |