1 /*
2  * Copyright (c) 2020, Seagate
3  * Copyright 2022 NXP
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 /**
9  * @file
10  * @brief Board configuration macros for the nxp_lpc11u6x platform
11  *
12  * This header file is used to specify and describe board-level aspects for the
13  * 'nxp_lpc11u6x' platform.
14  */
15 
16 #ifndef _SOC__H_
17 #define _SOC__H_
18 
19 #ifndef _ASMLANGUAGE
20 #include <zephyr/sys/util.h>
21 
22 
23 #endif /* !_ASMLANGUAGE */
24 
25 /**
26  * @brief Pin control register for standard digital I/O pins:
27  *
28  * [0:2]   function.
29  * [3:4]   mode.
30  * [5]     hysteresis.
31  * [6]     invert input.
32  * [7:9]   reserved.
33  * [10]    open-drain mode.
34  * [11:12] digital filter sample mode.
35  * [13:15] clock divisor.
36  * [16:31] reserved.
37  */
38 
39 #define IOCON_PIO_FUNC(x) (((x) & 0x7))
40 #define IOCON_PIO_FUNC_MASK IOCON_PIO_FUNC(0x7)
41 #define IOCON_PIO_MODE(x) (((x) & 0x3) << 3)
42 #define IOCON_PIO_MODE_MASK IOCON_PIO_MODE(0x3)
43 #define IOCON_PIO_HYS(x) (((x) & 0x1) << 5)
44 #define IOCON_PIO_HYS_MASK IOCON_PIO_HYS(0x1)
45 #define IOCON_PIO_INVERT(x) (((x) & 0x1) << 2)
46 #define IOCON_PIO_INVERT_MASK IOCON_PIO_INVERT(0x1)
47 #define IOCON_PIO_OD(x) (((x) & 0x1) << 10)
48 #define IOCON_PIO_OD_MASK IOCON_PIO_OD(0x1)
49 #define IOCON_PIO_SMODE(x) (((x) & 0x3) << 11)
50 #define IOCON_PIO_SMODE_MASK IOCON_PIO_SMODE(0x3)
51 #define IOCON_PIO_CLKDIV(x) (((x) & 0x7) << 13)
52 #define IOCON_PIO_CLKDIV_MASK IOCON_PIO_CLKDIV(0x7)
53 
54 
55 /**
56  * @brief Control registers for digital/analog I/O pins:
57  *
58  * [0:2]   function.
59  * [3:4]   mode.
60  * [5]     hysteresis.
61  * [6]     invert input.
62  * [7]     analog mode.
63  * [8]     input glitch filter.
64  * [9]     reserved.
65  * [10]    open-drain mode.
66  * [11:12] digital filter sample mode.
67  * [13:15] clock divisor.
68  * [16:31] reserved.
69  */
70 
71 #define IOCON_PIO_ADMODE(x) (((x) & 0x1) << 7)
72 #define IOCON_PIO_ADMODE_MASK IOCON_PIO_ADMODE(0x1)
73 #define IOCON_PIO_FILTER(x) (((x) & 0x1) << 8)
74 #define IOCON_PIO_FILTER_MASK IOCON_PIO_FILTER(0x1)
75 
76 
77 
78 /**
79  * @brief Control registers for open-drain I/O pins (I2C):
80  *
81  * [0:2]   function.
82  * [3:7]   reserved.
83  * [8:9]   I2C mode.
84  * [10]    reserved.
85  * [11:12] digital filter sample mode.
86  * [13:15] clock divisor.
87  * [16:31] reserved.
88  */
89 
90 #define IOCON_PIO_I2CMODE(x) (((x) & 0x3) << 8)
91 #define IOCON_PIO_I2CMODE_MASK IOCON_PIO_I2CMODE(0x3)
92 
93 #define IOCON_FUNC0 0
94 #define IOCON_FUNC1 1
95 #define IOCON_FUNC2 2
96 #define IOCON_FUNC3 3
97 #define IOCON_FUNC4 4
98 #define IOCON_FUNC5 5
99 
100 #endif /* _SOC__H_ */
101