blob: 3851e91359d7b7adc3bb285350cafe1bf9bb864a [file] [log] [blame]
Jacky Bai347599d2020-01-07 14:39:15 +08001/*
2 * Copyright 2020-2022 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef IMX_CSU_H
8#define IMX_CSU_H
9
10#include <lib/utils_def.h>
11
12#include <platform_def.h>
13
14#define CSU_SEC_LEVEL_0 0xff
15#define CSU_SEC_LEVEL_1 0xbb
16#define CSU_SEC_LEVEL_2 0x3f
17#define CSU_SEC_LEVEL_3 0x3b
18#define CSU_SEC_LEVEL_4 0x33
19#define CSU_SEC_LEVEL_5 0x22
20#define CSU_SEC_LEVEL_6 0x03
21#define CSU_SEC_LEVEL_7 0x0
22
Stefan Kerkmannb8c107c2024-02-28 15:23:49 +010023#define SEC_ACCESS 0x0
24#define NON_SEC_ACCESS 0x1
25
Jacky Bai347599d2020-01-07 14:39:15 +080026#define LOCKED 0x1
27#define UNLOCKED 0x0
28
29#define CSLx_REG(x) (IMX_CSU_BASE + ((x) / 2) * 4)
30#define CSLx_LOCK(x) ((0x1 << (((x) % 2) * 16 + 8)))
31#define CSLx_CFG(x, n) ((x) << (((n) % 2) * 16))
32
Stefan Kerkmann75b3f472024-03-05 10:00:33 +010033#define CSU_HP_REG(x) (IMX_CSU_BASE + (((x) / 16) * 4) + 0x200)
Jacky Bai347599d2020-01-07 14:39:15 +080034#define CSU_HP_LOCK(x) ((0x1 << (((x) % 16) * 2 + 1)))
35#define CSU_HP_CFG(x, n) ((x) << (((n) % 16) * 2))
36
Stefan Kerkmann0a0086f2024-02-28 16:38:04 +010037#define CSU_SA_REG(x) (IMX_CSU_BASE + (((x) / 16) * 4) + 0x218)
Jacky Bai347599d2020-01-07 14:39:15 +080038#define CSU_SA_LOCK(x) ((0x1 << (((x) % 16) * 2 + 1)))
39#define CSU_SA_CFG(x, n) ((x) << (((n) % 16) * 2))
40
41#define CSU_HPCONTROL_REG(x) (IMX_CSU_BASE + (((x) / 16) * 4) + 0x358)
42#define CSU_HPCONTROL_LOCK(x) ((0x1 << (((x) % 16) * 2 + 1)))
43#define CSU_HPCONTROL_CFG(x, n) ((x) << (((n) % 16) * 2))
44
45enum csu_cfg_type {
46 CSU_INVALID,
47 CSU_CSL,
48 CSU_HP,
49 CSU_SA,
50 CSU_HPCONTROL,
51};
52
53struct imx_csu_cfg {
54 enum csu_cfg_type type;
55 uint16_t idx;
56 uint16_t lock : 1;
57 uint16_t csl_level : 8;
58 uint16_t hp : 1;
59 uint16_t sa : 1;
60 uint16_t hpctrl : 1;
61};
62
63#define CSU_CSLx(i, level, lk) \
64 {CSU_CSL, .idx = (i), .csl_level = (level), .lock = (lk),}
65
66#define CSU_HPx(i, val, lk) \
67 {CSU_HP, .idx = (i), .hp = (val), .lock = (lk), }
68
69#define CSU_SA(i, val, lk) \
70 {CSU_SA, .idx = (i), .sa = (val), .lock = (lk), }
71
72#define CSU_HPCTRL(i, val, lk) \
73 {CSU_HPCONTROL, .idx = (i), .hpctrl = (val), .lock = (lk), }
74
75void imx_csu_init(const struct imx_csu_cfg *csu_cfg);
76
77#endif /* IMX_CSU_H */