2019-10-07 13:56:36 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause */
|
2021-05-11 15:22:11 +00:00
|
|
|
/*
|
|
|
|
* Cadence DDR Driver
|
|
|
|
*
|
2022-10-24 21:53:28 +00:00
|
|
|
* Copyright (C) 2012-2022 Cadence Design Systems, Inc.
|
|
|
|
* Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
|
2019-10-07 13:56:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LPDDR4_SANITY_H
|
|
|
|
#define LPDDR4_SANITY_H
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include "lpddr4_if.h"
|
2021-05-11 15:22:11 +00:00
|
|
|
|
|
|
|
static inline u32 lpddr4_configsf(const lpddr4_config *obj);
|
|
|
|
static inline u32 lpddr4_privatedatasf(const lpddr4_privatedata *obj);
|
|
|
|
|
|
|
|
static inline u32 lpddr4_sanityfunction1(const lpddr4_config *config, const u16 *configsize);
|
|
|
|
static inline u32 lpddr4_sanityfunction2(const lpddr4_privatedata *pd, const lpddr4_config *cfg);
|
|
|
|
static inline u32 lpddr4_sanityfunction3(const lpddr4_privatedata *pd);
|
|
|
|
static inline u32 lpddr4_sanityfunction4(const lpddr4_privatedata *pd, const lpddr4_regblock cpp, const u32 *regvalue);
|
|
|
|
static inline u32 lpddr4_sanityfunction5(const lpddr4_privatedata *pd, const lpddr4_regblock cpp);
|
|
|
|
static inline u32 lpddr4_sanityfunction6(const lpddr4_privatedata *pd, const u64 *mmrvalue, const u8 *mmrstatus);
|
|
|
|
static inline u32 lpddr4_sanityfunction7(const lpddr4_privatedata *pd, const u8 *mrwstatus);
|
|
|
|
static inline u32 lpddr4_sanityfunction14(const lpddr4_privatedata *pd, const u64 *mask);
|
|
|
|
static inline u32 lpddr4_sanityfunction15(const lpddr4_privatedata *pd, const u64 *mask);
|
|
|
|
static inline u32 lpddr4_sanityfunction16(const lpddr4_privatedata *pd, const u32 *mask);
|
|
|
|
static inline u32 lpddr4_sanityfunction18(const lpddr4_privatedata *pd, const lpddr4_debuginfo *debuginfo);
|
|
|
|
static inline u32 lpddr4_sanityfunction19(const lpddr4_privatedata *pd, const lpddr4_lpiwakeupparam *lpiwakeupparam, const lpddr4_ctlfspnum *fspnum, const u32 *cycles);
|
|
|
|
static inline u32 lpddr4_sanityfunction21(const lpddr4_privatedata *pd, const lpddr4_eccenable *eccparam);
|
|
|
|
static inline u32 lpddr4_sanityfunction22(const lpddr4_privatedata *pd, const lpddr4_eccenable *eccparam);
|
|
|
|
static inline u32 lpddr4_sanityfunction23(const lpddr4_privatedata *pd, const lpddr4_reducmode *mode);
|
|
|
|
static inline u32 lpddr4_sanityfunction24(const lpddr4_privatedata *pd, const lpddr4_reducmode *mode);
|
|
|
|
static inline u32 lpddr4_sanityfunction25(const lpddr4_privatedata *pd, const bool *on_off);
|
|
|
|
static inline u32 lpddr4_sanityfunction27(const lpddr4_privatedata *pd, const lpddr4_dbimode *mode);
|
2022-10-24 21:53:28 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction28(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, const u32 *tref_val, const u32 *tras_max_val);
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction29(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, const u32 *tref, const u32 *tras_max);
|
2019-10-07 13:56:36 +00:00
|
|
|
|
|
|
|
#define lpddr4_probesf lpddr4_sanityfunction1
|
|
|
|
#define lpddr4_initsf lpddr4_sanityfunction2
|
|
|
|
#define lpddr4_startsf lpddr4_sanityfunction3
|
|
|
|
#define lpddr4_readregsf lpddr4_sanityfunction4
|
|
|
|
#define lpddr4_writeregsf lpddr4_sanityfunction5
|
|
|
|
#define lpddr4_getmmrregistersf lpddr4_sanityfunction6
|
|
|
|
#define lpddr4_setmmrregistersf lpddr4_sanityfunction7
|
2021-05-11 15:22:11 +00:00
|
|
|
#define lpddr4_writectlconfigsf lpddr4_sanityfunction3
|
|
|
|
#define lpddr4_writephyconfigsf lpddr4_sanityfunction3
|
|
|
|
#define lpddr4_writephyindepconfigsf lpddr4_sanityfunction3
|
|
|
|
#define lpddr4_readctlconfigsf lpddr4_sanityfunction3
|
|
|
|
#define lpddr4_readphyconfigsf lpddr4_sanityfunction3
|
|
|
|
#define lpddr4_readphyindepconfigsf lpddr4_sanityfunction3
|
2019-10-07 13:56:36 +00:00
|
|
|
#define lpddr4_getctlinterruptmasksf lpddr4_sanityfunction14
|
|
|
|
#define lpddr4_setctlinterruptmasksf lpddr4_sanityfunction15
|
2021-05-11 15:22:11 +00:00
|
|
|
#define lpddr4_getphyindepinterruptmsf lpddr4_sanityfunction16
|
|
|
|
#define lpddr4_setphyindepinterruptmsf lpddr4_sanityfunction16
|
|
|
|
#define lpddr4_getdebuginitinfosf lpddr4_sanityfunction18
|
|
|
|
#define lpddr4_getlpiwakeuptimesf lpddr4_sanityfunction19
|
|
|
|
#define lpddr4_setlpiwakeuptimesf lpddr4_sanityfunction19
|
|
|
|
#define lpddr4_geteccenablesf lpddr4_sanityfunction21
|
|
|
|
#define lpddr4_seteccenablesf lpddr4_sanityfunction22
|
|
|
|
#define lpddr4_getreducmodesf lpddr4_sanityfunction23
|
|
|
|
#define lpddr4_setreducmodesf lpddr4_sanityfunction24
|
|
|
|
#define lpddr4_getdbireadmodesf lpddr4_sanityfunction25
|
|
|
|
#define lpddr4_getdbiwritemodesf lpddr4_sanityfunction25
|
|
|
|
#define lpddr4_setdbimodesf lpddr4_sanityfunction27
|
|
|
|
#define lpddr4_getrefreshratesf lpddr4_sanityfunction28
|
|
|
|
#define lpddr4_setrefreshratesf lpddr4_sanityfunction29
|
2019-10-07 13:56:36 +00:00
|
|
|
#define lpddr4_refreshperchipselectsf lpddr4_sanityfunction3
|
2022-10-24 21:53:28 +00:00
|
|
|
#define lpddr4_deferredregverifysf lpddr4_sanityfunction5
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_configsf(const lpddr4_config *obj)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
|
|
|
if (obj == NULL)
|
|
|
|
ret = EINVAL;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_privatedatasf(const lpddr4_privatedata *obj)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
|
|
|
if (obj == NULL)
|
|
|
|
ret = EINVAL;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction1(const lpddr4_config *config, const u16 *configsize)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (configsize == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_configsf(config) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction2(const lpddr4_privatedata *pd, const lpddr4_config *cfg)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_configsf(cfg) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction3(const lpddr4_privatedata *pd)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
|
|
|
if (lpddr4_privatedatasf(pd) == EINVAL)
|
|
|
|
ret = EINVAL;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction4(const lpddr4_privatedata *pd, const lpddr4_regblock cpp, const u32 *regvalue)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (regvalue == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (
|
2019-10-07 13:56:36 +00:00
|
|
|
(cpp != LPDDR4_CTL_REGS) &&
|
|
|
|
(cpp != LPDDR4_PHY_REGS) &&
|
|
|
|
(cpp != LPDDR4_PHY_INDEP_REGS)
|
2021-05-11 15:22:11 +00:00
|
|
|
) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction5(const lpddr4_privatedata *pd, const lpddr4_regblock cpp)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (
|
2019-10-07 13:56:36 +00:00
|
|
|
(cpp != LPDDR4_CTL_REGS) &&
|
|
|
|
(cpp != LPDDR4_PHY_REGS) &&
|
|
|
|
(cpp != LPDDR4_PHY_INDEP_REGS)
|
2021-05-11 15:22:11 +00:00
|
|
|
) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction6(const lpddr4_privatedata *pd, const u64 *mmrvalue, const u8 *mmrstatus)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (mmrvalue == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (mmrstatus == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction7(const lpddr4_privatedata *pd, const u8 *mrwstatus)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (mrwstatus == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction14(const lpddr4_privatedata *pd, const u64 *mask)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (mask == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction15(const lpddr4_privatedata *pd, const u64 *mask)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (mask == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction16(const lpddr4_privatedata *pd, const u32 *mask)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (mask == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction18(const lpddr4_privatedata *pd, const lpddr4_debuginfo *debuginfo)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (debuginfo == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction19(const lpddr4_privatedata *pd, const lpddr4_lpiwakeupparam *lpiwakeupparam, const lpddr4_ctlfspnum *fspnum, const u32 *cycles)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (lpiwakeupparam == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (fspnum == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (cycles == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (
|
2019-10-07 13:56:36 +00:00
|
|
|
(*lpiwakeupparam != LPDDR4_LPI_PD_WAKEUP_FN) &&
|
|
|
|
(*lpiwakeupparam != LPDDR4_LPI_SR_SHORT_WAKEUP_FN) &&
|
|
|
|
(*lpiwakeupparam != LPDDR4_LPI_SR_LONG_WAKEUP_FN) &&
|
|
|
|
(*lpiwakeupparam != LPDDR4_LPI_SR_LONG_MCCLK_GATE_WAKEUP_FN) &&
|
|
|
|
(*lpiwakeupparam != LPDDR4_LPI_SRPD_SHORT_WAKEUP_FN) &&
|
|
|
|
(*lpiwakeupparam != LPDDR4_LPI_SRPD_LONG_WAKEUP_FN) &&
|
|
|
|
(*lpiwakeupparam != LPDDR4_LPI_SRPD_LONG_MCCLK_GATE_WAKEUP_FN)
|
2021-05-11 15:22:11 +00:00
|
|
|
) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (
|
2019-10-07 13:56:36 +00:00
|
|
|
(*fspnum != LPDDR4_FSP_0) &&
|
|
|
|
(*fspnum != LPDDR4_FSP_1) &&
|
|
|
|
(*fspnum != LPDDR4_FSP_2)
|
2021-05-11 15:22:11 +00:00
|
|
|
) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction21(const lpddr4_privatedata *pd, const lpddr4_eccenable *eccparam)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (eccparam == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction22(const lpddr4_privatedata *pd, const lpddr4_eccenable *eccparam)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (eccparam == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (
|
2019-10-07 13:56:36 +00:00
|
|
|
(*eccparam != LPDDR4_ECC_DISABLED) &&
|
|
|
|
(*eccparam != LPDDR4_ECC_ENABLED) &&
|
|
|
|
(*eccparam != LPDDR4_ECC_ERR_DETECT) &&
|
|
|
|
(*eccparam != LPDDR4_ECC_ERR_DETECT_CORRECT)
|
2021-05-11 15:22:11 +00:00
|
|
|
) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction23(const lpddr4_privatedata *pd, const lpddr4_reducmode *mode)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (mode == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction24(const lpddr4_privatedata *pd, const lpddr4_reducmode *mode)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (mode == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (
|
2019-10-07 13:56:36 +00:00
|
|
|
(*mode != LPDDR4_REDUC_ON) &&
|
|
|
|
(*mode != LPDDR4_REDUC_OFF)
|
2021-05-11 15:22:11 +00:00
|
|
|
) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction25(const lpddr4_privatedata *pd, const bool *on_off)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (on_off == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction27(const lpddr4_privatedata *pd, const lpddr4_dbimode *mode)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (mode == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (
|
2019-10-07 13:56:36 +00:00
|
|
|
(*mode != LPDDR4_DBI_RD_ON) &&
|
|
|
|
(*mode != LPDDR4_DBI_RD_OFF) &&
|
|
|
|
(*mode != LPDDR4_DBI_WR_ON) &&
|
|
|
|
(*mode != LPDDR4_DBI_WR_OFF)
|
2021-05-11 15:22:11 +00:00
|
|
|
) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-10-24 21:53:28 +00:00
|
|
|
static inline u32 lpddr4_sanityfunction28(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, const u32 *tref_val, const u32 *tras_max_val)
|
2019-10-07 13:56:36 +00:00
|
|
|
{
|
2021-05-11 15:22:11 +00:00
|
|
|
u32 ret = 0;
|
2019-10-07 13:56:36 +00:00
|
|
|
|
2021-05-11 15:22:11 +00:00
|
|
|
if (fspnum == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2022-10-24 21:53:28 +00:00
|
|
|
} else if (tref_val == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2022-10-24 21:53:28 +00:00
|
|
|
} else if (tras_max_val == NULL) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
|
|
|
ret = EINVAL;
|
|
|
|
} else if (
|
2019-10-07 13:56:36 +00:00
|
|
|
(*fspnum != LPDDR4_FSP_0) &&
|
|
|
|
(*fspnum != LPDDR4_FSP_1) &&
|
|
|
|
(*fspnum != LPDDR4_FSP_2)
|
2021-05-11 15:22:11 +00:00
|
|
|
) {
|
2019-10-07 13:56:36 +00:00
|
|
|
ret = EINVAL;
|
2021-05-11 15:22:11 +00:00
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
2021-05-11 15:22:11 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 lpddr4_sanityfunction29(const lpddr4_privatedata *pd, const lpddr4_ctlfspnum *fspnum, const u32 *tref, const u32 *tras_max)
|
|
|
|
{
|
|
|
|
u32 ret = 0;
|
|
|
|
|
|
|
|
if (fspnum == NULL) {
|
|
|
|
ret = EINVAL;
|
|
|
|
} else if (tref == NULL) {
|
|
|
|
ret = EINVAL;
|
|
|
|
} else if (tras_max == NULL) {
|
|
|
|
ret = EINVAL;
|
|
|
|
} else if (lpddr4_privatedatasf(pd) == EINVAL) {
|
|
|
|
ret = EINVAL;
|
|
|
|
} else if (
|
|
|
|
(*fspnum != LPDDR4_FSP_0) &&
|
|
|
|
(*fspnum != LPDDR4_FSP_1) &&
|
|
|
|
(*fspnum != LPDDR4_FSP_2)
|
|
|
|
) {
|
|
|
|
ret = EINVAL;
|
|
|
|
} else {
|
2019-10-07 13:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* LPDDR4_SANITY_H */
|