summaryrefslogtreecommitdiff
path: root/drivers/ram/k3-ddrss/lpddr4_sanity.h
blob: 1de9273f488810b45782c47d818b525b154e433c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
/* SPDX-License-Identifier: BSD-3-Clause */
/*
 * Cadence DDR Driver
 *
 * Copyright (C) 2012-2021 Cadence Design Systems, Inc.
 * Copyright (C) 2018-2021 Texas Instruments Incorporated - http://www.ti.com/
 */




#ifndef LPDDR4_SANITY_H
#define LPDDR4_SANITY_H

#include "cdn_errno.h"
#include "cdn_stdtypes.h"
#include "lpddr4_if.h"
#ifdef __cplusplus
extern "C" {
#endif

static inline uint32_t lpddr4_configsf(const lpddr4_config *obj);
static inline uint32_t lpddr4_privatedatasf(const lpddr4_privatedata *obj);

static inline uint32_t lpddr4_sanityfunction1(const lpddr4_config *config, const uint16_t *configSize);
static inline uint32_t lpddr4_sanityfunction2(const lpddr4_privatedata *pD, const lpddr4_config *cfg);
static inline uint32_t lpddr4_sanityfunction3(const lpddr4_privatedata *pD);
static inline uint32_t lpddr4_sanityfunction4(const lpddr4_privatedata *pD, const lpddr4_regblock cpp, const uint32_t *regValue);
static inline uint32_t lpddr4_sanityfunction5(const lpddr4_privatedata *pD, const lpddr4_regblock cpp);
static inline uint32_t lpddr4_sanityfunction6(const lpddr4_privatedata *pD, const uint64_t *mmrValue, const uint8_t *mmrStatus);
static inline uint32_t lpddr4_sanityfunction7(const lpddr4_privatedata *pD, const uint8_t *mrwStatus);
static inline uint32_t lpddr4_sanityfunction14(const lpddr4_privatedata *pD, const uint64_t *mask);
static inline uint32_t lpddr4_sanityfunction15(const lpddr4_privatedata *pD, const uint64_t *mask);
static inline uint32_t lpddr4_sanityfunction16(const lpddr4_privatedata *pD, const uint32_t *mask);
static inline uint32_t lpddr4_sanityfunction18(const lpddr4_privatedata *pD, const lpddr4_debuginfo *debugInfo);
static inline uint32_t lpddr4_sanityfunction19(const lpddr4_privatedata *pD, const lpddr4_lpiwakeupparam *lpiWakeUpParam, const lpddr4_ctlfspnum *fspNum, const uint32_t *cycles);
static inline uint32_t lpddr4_sanityfunction21(const lpddr4_privatedata *pD, const lpddr4_eccenable *eccParam);
static inline uint32_t lpddr4_sanityfunction22(const lpddr4_privatedata *pD, const lpddr4_eccenable *eccParam);
static inline uint32_t lpddr4_sanityfunction23(const lpddr4_privatedata *pD, const lpddr4_reducmode *mode);
static inline uint32_t lpddr4_sanityfunction24(const lpddr4_privatedata *pD, const lpddr4_reducmode *mode);
static inline uint32_t lpddr4_sanityfunction25(const lpddr4_privatedata *pD, const bool *on_off);
static inline uint32_t lpddr4_sanityfunction27(const lpddr4_privatedata *pD, const lpddr4_dbimode *mode);
static inline uint32_t lpddr4_sanityfunction28(const lpddr4_privatedata *pD, const lpddr4_ctlfspnum *fspNum, const uint32_t *tref, const uint32_t *tras_max);
static inline uint32_t lpddr4_sanityfunction29(const lpddr4_privatedata *pD, const lpddr4_ctlfspnum *fspNum, const uint32_t *tref, const uint32_t *tras_max);

#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
#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
#define lpddr4_getctlinterruptmaskSF lpddr4_sanityfunction14
#define lpddr4_setctlinterruptmaskSF lpddr4_sanityfunction15
#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
#define lpddr4_refreshperchipselectSF lpddr4_sanityfunction3

static inline uint32_t lpddr4_configsf(const lpddr4_config *obj)
{
	uint32_t ret = 0;

	if (obj == NULL)
		ret = CDN_EINVAL;

	return ret;
}

static inline uint32_t lpddr4_privatedatasf(const lpddr4_privatedata *obj)
{
	uint32_t ret = 0;

	if (obj == NULL)
		ret = CDN_EINVAL;

	return ret;
}

static inline uint32_t lpddr4_sanityfunction1(const lpddr4_config *config, const uint16_t *configSize)
{
	uint32_t ret = 0;

	if (configSize == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_configsf(config) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction2(const lpddr4_privatedata *pD, const lpddr4_config *cfg)
{
	uint32_t ret = 0;

	if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_configsf(cfg) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction3(const lpddr4_privatedata *pD)
{
	uint32_t ret = 0;

	if (lpddr4_privatedatasf(pD) == CDN_EINVAL)
		ret = CDN_EINVAL;

	return ret;
}

static inline uint32_t lpddr4_sanityfunction4(const lpddr4_privatedata *pD, const lpddr4_regblock cpp, const uint32_t *regValue)
{
	uint32_t ret = 0;

	if (regValue == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else if (
		(cpp != LPDDR4_CTL_REGS) &&
		(cpp != LPDDR4_PHY_REGS) &&
		(cpp != LPDDR4_PHY_INDEP_REGS)
		) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction5(const lpddr4_privatedata *pD, const lpddr4_regblock cpp)
{
	uint32_t ret = 0;

	if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else if (
		(cpp != LPDDR4_CTL_REGS) &&
		(cpp != LPDDR4_PHY_REGS) &&
		(cpp != LPDDR4_PHY_INDEP_REGS)
		) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction6(const lpddr4_privatedata *pD, const uint64_t *mmrValue, const uint8_t *mmrStatus)
{
	uint32_t ret = 0;

	if (mmrValue == NULL) {
		ret = CDN_EINVAL;
	} else if (mmrStatus == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction7(const lpddr4_privatedata *pD, const uint8_t *mrwStatus)
{
	uint32_t ret = 0;

	if (mrwStatus == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction14(const lpddr4_privatedata *pD, const uint64_t *mask)
{
	uint32_t ret = 0;

	if (mask == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction15(const lpddr4_privatedata *pD, const uint64_t *mask)
{
	uint32_t ret = 0;

	if (mask == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction16(const lpddr4_privatedata *pD, const uint32_t *mask)
{
	uint32_t ret = 0;

	if (mask == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction18(const lpddr4_privatedata *pD, const lpddr4_debuginfo *debugInfo)
{
	uint32_t ret = 0;

	if (debugInfo == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction19(const lpddr4_privatedata *pD, const lpddr4_lpiwakeupparam *lpiWakeUpParam, const lpddr4_ctlfspnum *fspNum, const uint32_t *cycles)
{
	uint32_t ret = 0;

	if (lpiWakeUpParam == NULL) {
		ret = CDN_EINVAL;
	} else if (fspNum == NULL) {
		ret = CDN_EINVAL;
	} else if (cycles == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else if (
		(*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)
		) {
		ret = CDN_EINVAL;
	} else if (
		(*fspNum != LPDDR4_FSP_0) &&
		(*fspNum != LPDDR4_FSP_1) &&
		(*fspNum != LPDDR4_FSP_2)
		) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction21(const lpddr4_privatedata *pD, const lpddr4_eccenable *eccParam)
{
	uint32_t ret = 0;

	if (eccParam == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction22(const lpddr4_privatedata *pD, const lpddr4_eccenable *eccParam)
{
	uint32_t ret = 0;

	if (eccParam == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else if (
		(*eccParam != LPDDR4_ECC_DISABLED) &&
		(*eccParam != LPDDR4_ECC_ENABLED) &&
		(*eccParam != LPDDR4_ECC_ERR_DETECT) &&
		(*eccParam != LPDDR4_ECC_ERR_DETECT_CORRECT)
		) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction23(const lpddr4_privatedata *pD, const lpddr4_reducmode *mode)
{
	uint32_t ret = 0;

	if (mode == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction24(const lpddr4_privatedata *pD, const lpddr4_reducmode *mode)
{
	uint32_t ret = 0;

	if (mode == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else if (
		(*mode != LPDDR4_REDUC_ON) &&
		(*mode != LPDDR4_REDUC_OFF)
		) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction25(const lpddr4_privatedata *pD, const bool *on_off)
{
	uint32_t ret = 0;

	if (on_off == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction27(const lpddr4_privatedata *pD, const lpddr4_dbimode *mode)
{
	uint32_t ret = 0;

	if (mode == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else if (
		(*mode != LPDDR4_DBI_RD_ON) &&
		(*mode != LPDDR4_DBI_RD_OFF) &&
		(*mode != LPDDR4_DBI_WR_ON) &&
		(*mode != LPDDR4_DBI_WR_OFF)
		) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction28(const lpddr4_privatedata *pD, const lpddr4_ctlfspnum *fspNum, const uint32_t *tref, const uint32_t *tras_max)
{
	uint32_t ret = 0;

	if (fspNum == NULL) {
		ret = CDN_EINVAL;
	} else if (tref == NULL) {
		ret = CDN_EINVAL;
	} else if (tras_max == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else if (
		(*fspNum != LPDDR4_FSP_0) &&
		(*fspNum != LPDDR4_FSP_1) &&
		(*fspNum != LPDDR4_FSP_2)
		) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

static inline uint32_t lpddr4_sanityfunction29(const lpddr4_privatedata *pD, const lpddr4_ctlfspnum *fspNum, const uint32_t *tref, const uint32_t *tras_max)
{
	uint32_t ret = 0;

	if (fspNum == NULL) {
		ret = CDN_EINVAL;
	} else if (tref == NULL) {
		ret = CDN_EINVAL;
	} else if (tras_max == NULL) {
		ret = CDN_EINVAL;
	} else if (lpddr4_privatedatasf(pD) == CDN_EINVAL) {
		ret = CDN_EINVAL;
	} else if (
		(*fspNum != LPDDR4_FSP_0) &&
		(*fspNum != LPDDR4_FSP_1) &&
		(*fspNum != LPDDR4_FSP_2)
		) {
		ret = CDN_EINVAL;
	} else {
	}

	return ret;
}

#ifdef __cplusplus
}
#endif


#endif  /* LPDDR4_SANITY_H */