1 /*
2  * Copyright (c) 2006-2023, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2023-02-25     GuEe-GUI     the first version
9  */
10 
11 #ifndef __SYSCON_H__
12 #define __SYSCON_H__
13 
14 #include <drivers/ofw.h>
15 
16 struct rt_syscon
17 {
18     rt_list_t list;
19 
20     struct rt_ofw_node *np;
21 
22     void *iomem_base;
23     rt_size_t iomem_size;
24     struct rt_spinlock rw_lock;
25 };
26 
27 rt_err_t rt_syscon_read(struct rt_syscon *syscon, rt_off_t offset, rt_uint32_t *out_val);
28 rt_err_t rt_syscon_write(struct rt_syscon *syscon, rt_off_t offset, rt_uint32_t val);
29 rt_err_t rt_syscon_update_bits(struct rt_syscon *syscon, rt_off_t offset, rt_uint32_t mask, rt_uint32_t val);
30 
31 struct rt_syscon *rt_syscon_find_by_ofw_node(struct rt_ofw_node *np);
32 struct rt_syscon *rt_syscon_find_by_ofw_compatible(const char *compatible);
33 struct rt_syscon *rt_syscon_find_by_ofw_phandle(struct rt_ofw_node *np, const char *propname);
34 
35 #endif /* __SYSCON_H__ */
36