aboutsummaryrefslogtreecommitdiff
path: root/core/include/drivers/stm32_etzpc.h
blob: 50bbc40bb4a816b35bd228f93ea185ad3f79e15f (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
/* SPDX-License-Identifier: BSD-3-Clause */
/*
 * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
 * Copyright (c) 2018-2019, STMicroelectronics
 */

#ifndef __STM32_ETZPC_H__
#define __STM32_ETZPC_H__

#include <util.h>
#include <types_ext.h>

enum etzpc_decprot_attributes {
	ETZPC_DECPROT_S_RW = 0,
	ETZPC_DECPROT_NS_R_S_W = 1,
	ETZPC_DECPROT_MCU_ISOLATION = 2,
	ETZPC_DECPROT_NS_RW = 3,
	ETZPC_DECPROT_MAX = 4,
};

#define ETZPC_TZMA_ALL_SECURE		GENMASK_32(9, 0)
#define ETZPC_TZMA_ALL_NO_SECURE	0x0

/*
 * Load a DECPROT configuration
 * @decprot_id: ID that is the index of the DECPROT in the ETZPC interface
 * @decprot_attr: Restriction access attributes
 */
void etzpc_configure_decprot(uint32_t decprot_id,
			     enum etzpc_decprot_attributes decprot_attr);

/*
 * Get the DECPROT attribute
 * @decprot_id: ID that is the index of the DECPROT in the ETZPC interface
 * Return attribute of this DECPROT
 */
enum etzpc_decprot_attributes etzpc_get_decprot(uint32_t decprot_id);

/*
 * Lock access to the DECPROT attributes
 * @decprot_id: ID that is the index of the DECPROT in the ETZPC interface
 */
void etzpc_lock_decprot(uint32_t decprot_id);

/*
 * Return the lock status of the target DECPROT
 * @decprot_id: ID that is the index of the DECPROT in the ETZPC interface
 */
bool etzpc_get_lock_decprot(uint32_t decprot_id);

/*
 * Configure the target TZMA read only size
 * @tzma_id: ID that is the index of the TZMA in the ETZPC interface
 * @tzma_value: Read-only size
 */
void etzpc_configure_tzma(uint32_t tzma_id, uint16_t tzma_value);

/*
 * Get the target TZMA read only size
 * @tzma_id: ID that is the index of the TZMA in the ETZPC interface
 * Return the size of read-only area
 */
uint16_t etzpc_get_tzma(uint32_t tzma_id);

/*
 * Lock the target TZMA
 * @tzma_id: ID that is the index of the TZMA in the ETZPC interface
 */
void etzpc_lock_tzma(uint32_t tzma_id);

/*
 * Return the lock status of the target TZMA
 * @tzma_id: ID that is the index of the TZMA in the ETZPC interface
 * Return true if TZMA is locked, false otherwise
 */
bool etzpc_get_lock_tzma(uint32_t tzma_id);

/*
 * Init the ETZPC device, nedded when not using the device tree
 * @base: ETZPC interface registers physcal base address
 */
#ifdef CFG_STM32_ETZPC
void stm32_etzpc_init(paddr_t base);
#else
static inline void stm32_etzpc_init(paddr_t __unused base) {}
#endif

#endif /*__STM32_ETZPC_H__*/