1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2024, STMicroelectronics
4  */
5 
6 #include <drivers/rstctrl.h>
7 #include <stdbool.h>
8 #include <sys/queue.h>
9 
10 /*
11  * struct stm32_reset_cfg - Reset line controller data
12  * @offset: Byte offset in reset controller IOMEM
13  * @bit_index: Bit position of reset line control at IOMEM @offset
14  * @set_clr: True is @offset is an atomic SET/CLR register, false otherwise
15  * @inverted: True is reset line is asserted at level 0, false otherwise
16  * @no_deassert: True is reset line cannot be deasserted, false otherwise
17  * @no_timeout: True if reset state cannot be read back for timeout detection
18  */
19 struct stm32_reset_cfg {
20 	unsigned int offset;
21 	unsigned int bit_index;
22 	bool set_clr;
23 	bool inverted;
24 	bool no_deassert;
25 	bool no_timeout;
26 };
27 
28 /*
29  * struct stm32_reset_data - Reset controller platform data
30  * @nb_lines: Number of reset lines
31  * @rst_lines: Table of reset lines
32  * @get_rstctrl_ops: Handler to retrieve the controller operation handlers
33  */
34 struct stm32_reset_data {
35 	unsigned int nb_lines;
36 	const struct stm32_reset_cfg **rst_lines;
37 	const struct rstctrl_ops * (*get_rstctrl_ops)(unsigned int id);
38 };
39 
40 /*
41  * struct stm32_rstline - Exposed rstctrl instance
42  * @id: Identifier used in the device tree bindings
43  * @rstctrl: Related reset controller instance
44  * @link: Reference in reset controller list
45  */
46 struct stm32_rstline {
47 	unsigned int id;
48 	struct rstctrl rstctrl;
49 	const struct stm32_reset_data *data;
50 	SLIST_ENTRY(stm32_rstline) link;
51 };
52 
53 struct stm32_rstline *to_stm32_rstline(struct rstctrl *rstctrl);
54 
55 TEE_Result stm32_rstctrl_provider_probe(const void *fdt, int offs,
56 					const void *compat_data);
57