blob: 13f4b137a9fb5f7371004062ff358e41469dc591 [file] [log] [blame]
Etienne Carriere7ad2c012019-12-08 08:14:03 +01001/*
2 * Copyright (c) 2017-2020, STMicroelectronics - All Rights Reserved
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef STM32MP_SHARED_RESOURCES_H
8#define STM32MP_SHARED_RESOURCES_H
9
10#include <stdbool.h>
Etienne Carriere0cfbff92020-05-13 10:16:21 +020011#include <stdint.h>
Etienne Carriere7ad2c012019-12-08 08:14:03 +010012
Etienne Carriere1bbb9242020-05-13 14:22:01 +020013#ifdef STM32MP_SHARED_RESOURCES
14enum stm32mp_shres;
15
Etienne Carriere7ad2c012019-12-08 08:14:03 +010016/* Return true if @clock_id is shared by secure and non-secure worlds */
17bool stm32mp_nsec_can_access_clock(unsigned long clock_id);
18
19/* Return true if and only if @reset_id relates to a non-secure peripheral */
20bool stm32mp_nsec_can_access_reset(unsigned int reset_id);
21
Etienne Carriere1bbb9242020-05-13 14:22:01 +020022/* Register a shared resource assigned to the secure world */
23void stm32mp_register_secure_periph(enum stm32mp_shres id);
24
25/* Register a shared resource assigned to the non-secure world */
26void stm32mp_register_non_secure_periph(enum stm32mp_shres id);
27
Etienne Carriere0cfbff92020-05-13 10:16:21 +020028/* Register a peripheral as secure or non-secure based on IO base address */
29void stm32mp_register_secure_periph_iomem(uintptr_t base);
30void stm32mp_register_non_secure_periph_iomem(uintptr_t base);
31
Etienne Carriere63b22062020-05-13 10:19:50 +020032/* Register a GPIO as secure or non-secure based on its bank and pin numbers */
33void stm32mp_register_secure_gpio(unsigned int bank, unsigned int pin);
34void stm32mp_register_non_secure_gpio(unsigned int bank, unsigned int pin);
35
Etienne Carriere7a4a34f2020-05-13 10:07:45 +020036/* Consolidate peripheral states and lock against new peripheral registering */
37void stm32mp_lock_periph_registering(void);
Etienne Carriere0cfbff92020-05-13 10:16:21 +020038#else
39static inline void stm32mp_register_secure_periph_iomem(uintptr_t base __unused)
40{
41}
42
43static inline
44void stm32mp_register_non_secure_periph_iomem(uintptr_t base __unused)
45{
46}
Etienne Carriere63b22062020-05-13 10:19:50 +020047
48static inline void stm32mp_register_secure_gpio(unsigned int bank __unused,
49 unsigned int pin __unused)
50{
51}
52
53static inline void stm32mp_register_non_secure_gpio(unsigned int bank __unused,
54 unsigned int pin __unused)
55{
56}
Etienne Carriere1bbb9242020-05-13 14:22:01 +020057#endif /* STM32MP_SHARED_RESOURCES */
Etienne Carriere7ad2c012019-12-08 08:14:03 +010058#endif /* STM32MP_SHARED_RESOURCES_H */