1 /*
2 * Copyright (c) 2021 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #ifndef __INCLUDE_IO__
8 #define __INCLUDE_IO__
9
10 #include <stdint.h>
11 #include <soc/memory.h>
12 #include <zephyr/sys/sys_io.h>
13 #include <zephyr/arch/common/sys_io.h>
14
io_reg_read(uint32_t reg)15 static inline uint32_t io_reg_read(uint32_t reg)
16 {
17 return sys_read32(reg);
18 }
19
io_reg_write(uint32_t reg,uint32_t val)20 static inline void io_reg_write(uint32_t reg, uint32_t val)
21 {
22 sys_write32(val, reg);
23 }
24
io_reg_update_bits(uint32_t reg,uint32_t mask,uint32_t value)25 static inline void io_reg_update_bits(uint32_t reg, uint32_t mask,
26 uint32_t value)
27 {
28 io_reg_write(reg, (io_reg_read(reg) & (~mask)) | (value & mask));
29 }
30
io_reg_read16(uint32_t reg)31 static inline uint16_t io_reg_read16(uint32_t reg)
32 {
33 return sys_read16(reg);
34 }
35
io_reg_write16(uint32_t reg,uint16_t val)36 static inline void io_reg_write16(uint32_t reg, uint16_t val)
37 {
38 sys_write16(val, reg);
39 }
40
41 #endif
42