Line data Source code
1 0 : /*
2 : * Copyright (c) 2021 Telink Semiconductor
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : #ifndef ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_B91_PINCTRL_H_
8 : #define ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_B91_PINCTRL_H_
9 :
10 : /* IDs for GPIO functions */
11 :
12 0 : #define B91_FUNC_A 0x00
13 0 : #define B91_FUNC_B 0x01
14 0 : #define B91_FUNC_C 0x02
15 :
16 : /* IDs for GPIO Ports */
17 :
18 0 : #define B91_PORT_A 0x00
19 0 : #define B91_PORT_B 0x01
20 0 : #define B91_PORT_C 0x02
21 0 : #define B91_PORT_D 0x03
22 0 : #define B91_PORT_E 0x04
23 :
24 : /* IDs for GPIO Pins */
25 :
26 0 : #define B91_PIN_0 0x01
27 0 : #define B91_PIN_1 0x02
28 0 : #define B91_PIN_2 0x04
29 0 : #define B91_PIN_3 0x08
30 0 : #define B91_PIN_4 0x10
31 0 : #define B91_PIN_5 0x20
32 0 : #define B91_PIN_6 0x40
33 0 : #define B91_PIN_7 0x80
34 :
35 : /* B91 pinctrl pull-up/down */
36 :
37 0 : #define B91_PULL_NONE 0
38 0 : #define B91_PULL_DOWN 2
39 0 : #define B91_PULL_UP 3
40 :
41 : /* Pin function positions */
42 :
43 0 : #define B91_PIN_0_FUNC_POS 0x00
44 0 : #define B91_PIN_1_FUNC_POS 0x02
45 0 : #define B91_PIN_2_FUNC_POS 0x04
46 0 : #define B91_PIN_3_FUNC_POS 0x06
47 0 : #define B91_PIN_4_FUNC_POS 0x00
48 0 : #define B91_PIN_5_FUNC_POS 0x02
49 0 : #define B91_PIN_6_FUNC_POS 0x04
50 0 : #define B91_PIN_7_FUNC_POS 0x06
51 :
52 : /* B91 pin configuration bit field positions and masks */
53 :
54 0 : #define B91_PULL_POS 19
55 0 : #define B91_PULL_MSK 0x3
56 0 : #define B91_FUNC_POS 16
57 0 : #define B91_FUNC_MSK 0x3
58 0 : #define B91_PORT_POS 8
59 0 : #define B91_PORT_MSK 0xFF
60 0 : #define B91_PIN_POS 0
61 0 : #define B91_PIN_MSK 0xFFFF
62 0 : #define B91_PIN_ID_MSK 0xFF
63 :
64 : /* Setters and getters */
65 :
66 0 : #define B91_PINMUX_SET(port, pin, func) ((func << B91_FUNC_POS) | \
67 : (port << B91_PORT_POS) | \
68 : (pin << B91_PIN_POS))
69 0 : #define B91_PINMUX_GET_PULL(pinmux) ((pinmux >> B91_PULL_POS) & B91_PULL_MSK)
70 0 : #define B91_PINMUX_GET_FUNC(pinmux) ((pinmux >> B91_FUNC_POS) & B91_FUNC_MSK)
71 0 : #define B91_PINMUX_GET_PIN(pinmux) ((pinmux >> B91_PIN_POS) & B91_PIN_MSK)
72 0 : #define B91_PINMUX_GET_PIN_ID(pinmux) ((pinmux >> B91_PIN_POS) & B91_PIN_ID_MSK)
73 :
74 : #endif /* ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_B91_PINCTRL_H_ */
|