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