Line data Source code
1 0 : /*
2 : * Copyright (c) 2023 Silicon Labs
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 :
6 : #ifndef ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_GECKO_PINCTRL_S1_H_
7 : #define ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_GECKO_PINCTRL_S1_H_
8 :
9 :
10 0 : #define GECKO_PORT_A 0
11 0 : #define GECKO_PORT_B 1
12 0 : #define GECKO_PORT_C 2
13 0 : #define GECKO_PORT_D 3
14 0 : #define GECKO_PORT_E 4
15 0 : #define GECKO_PORT_F 5
16 0 : #define GECKO_PORT_G 6
17 0 : #define GECKO_PORT_H 7
18 0 : #define GECKO_PORT_I 8
19 0 : #define GECKO_PORT_J 9
20 0 : #define GECKO_PORT_K 10
21 :
22 0 : #define GECKO_PIN(n) (n)
23 0 : #define GECKO_LOCATION(n) (n)
24 :
25 : /*
26 : * The whole GECKO_pin configuration information is encoded in a 32-bit bitfield
27 : * organized as follows:
28 : *
29 : * - 31..24: Pin function.
30 : * - 23..16: Reserved.
31 : * - 15..8: Port for UART_RX/UART_TX functions.
32 : * - 7..0: Pin number for UART_RX/UART_TX functions.
33 : * - 15..8: Reserved for UART_LOC function.
34 : * - 7..0: Loc for UART_LOC function.
35 : */
36 :
37 : /**
38 : * @name GECKO_pin configuration bit field positions and masks.
39 : * @{
40 : */
41 :
42 : /** Position of the function field. */
43 1 : #define GECKO_FUN_POS 24U
44 : /** Mask for the function field. */
45 1 : #define GECKO_FUN_MSK 0xFFU
46 :
47 : /** Position of the pin field. */
48 1 : #define GECKO_PIN_POS 0U
49 : /** Mask for the pin field. */
50 1 : #define GECKO_PIN_MSK 0xFFU
51 :
52 : /** Position of the port field. */
53 1 : #define GECKO_PORT_POS 8U
54 : /** Mask for the port field. */
55 1 : #define GECKO_PORT_MSK 0xFFU
56 :
57 : /** Position of the loc field. */
58 1 : #define GECKO_LOC_POS 0U
59 : /** Mask for the pin field. */
60 1 : #define GECKO_LOC_MSK 0xFFU
61 :
62 : /** @} */
63 :
64 : /**
65 : * @name GECKO_pinctrl pin functions.
66 : * @{
67 : */
68 :
69 : /** UART TX */
70 1 : #define GECKO_FUN_UART_TX 0U
71 : /** UART RX */
72 1 : #define GECKO_FUN_UART_RX 1U
73 : /** UART RTS */
74 1 : #define GECKO_FUN_UART_RTS 2U
75 : /** UART CTS */
76 1 : #define GECKO_FUN_UART_CTS 3U
77 : /** UART RX LOCATION */
78 1 : #define GECKO_FUN_UART_RX_LOC 4U
79 : /** UART TX LOCATION */
80 1 : #define GECKO_FUN_UART_TX_LOC 5U
81 : /** UART RTS LOCATION */
82 1 : #define GECKO_FUN_UART_RTS_LOC 6U
83 : /** UART CTS LOCATION */
84 1 : #define GECKO_FUN_UART_CTS_LOC 7U
85 :
86 0 : #define GECKO_FUN_SPIM_MISO 8U
87 0 : #define GECKO_FUN_SPIM_MOSI 9U
88 0 : #define GECKO_FUN_SPIM_CS 10U
89 0 : #define GECKO_FUN_SPIM_SCK 11U
90 :
91 0 : #define GECKO_FUN_LEUART_RX_LOC 12U
92 0 : #define GECKO_FUN_LEUART_TX_LOC 13U
93 :
94 0 : #define GECKO_FUN_SPIS_MISO 14U
95 0 : #define GECKO_FUN_SPIS_MOSI 15U
96 0 : #define GECKO_FUN_SPIS_CS 16U
97 0 : #define GECKO_FUN_SPIS_SCK 17U
98 :
99 0 : #define GECKO_FUN_SPI_MISO_LOC 18U
100 0 : #define GECKO_FUN_SPI_MOSI_LOC 19U
101 0 : #define GECKO_FUN_SPI_CS_LOC 20U
102 0 : #define GECKO_FUN_SPI_SCK_LOC 21U
103 :
104 0 : #define GECKO_FUN_I2C_SDA 22U
105 0 : #define GECKO_FUN_I2C_SCL 23U
106 0 : #define GECKO_FUN_I2C_SDA_LOC 24U
107 0 : #define GECKO_FUN_I2C_SCL_LOC 25U
108 :
109 :
110 : /** @} */
111 :
112 : /**
113 : * @brief Utility macro to build GECKO psels property entry.
114 : *
115 : * @param fun Pin function configuration (see GECKO_FUNC_{name} macros).
116 : * @param port Port (0 or 1).
117 : * @param pin Pin (0..31).
118 : */
119 1 : #define GECKO_PSEL(fun, port, pin) \
120 : (((GECKO_PORT_##port & GECKO_PORT_MSK) << GECKO_PORT_POS) | \
121 : ((GECKO_PIN(##pin##) & GECKO_PIN_MSK) << GECKO_PIN_POS) | \
122 : ((GECKO_FUN_##fun & GECKO_FUN_MSK) << GECKO_FUN_POS))
123 :
124 : /**
125 : * @brief Utility macro to build GECKO_psels property entry.
126 : *
127 : * @param fun Pin function configuration (see GECKO_FUNC_{name} macros).
128 : * @param loc Location.
129 : */
130 1 : #define GECKO_LOC(fun, loc) \
131 : (((GECKO_LOCATION(##loc##) & GECKO_LOC_MSK) << GECKO_LOC_POS) | \
132 : ((GECKO_FUN_##fun##_LOC & GECKO_FUN_MSK) << GECKO_FUN_POS))
133 :
134 : #endif /* ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_GECKO_PINCTRL_S1_H_ */
|