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