1 /* 2 * Copyright (c) 2022 NXP 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /* 8 * @file 9 * NXP Kinetis SOC specific helpers for pinctrl driver 10 */ 11 12 #ifndef ZEPHYR_SOC_ARM_NXP_KINETIS_COMMON_PINCTRL_SOC_H_ 13 #define ZEPHYR_SOC_ARM_NXP_KINETIS_COMMON_PINCTRL_SOC_H_ 14 15 #include <zephyr/devicetree.h> 16 #include <zephyr/types.h> 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 /** @cond INTERNAL_HIDDEN */ 23 24 typedef uint32_t pinctrl_soc_pin_t; 25 26 /* Kinetis KW/KL/KE series does not support open drain. Define macros to have no effect 27 * Note: KW22 and KW24 do support open drain, rest of KW series does not 28 */ 29 #if (defined(CONFIG_SOC_SERIES_KINETIS_KWX) && \ 30 !(defined(CONFIG_SOC_MKW24D5) || \ 31 defined(CONFIG_SOC_MKW22D5))) || \ 32 defined(CONFIG_SOC_SERIES_KINETIS_KL2X) || \ 33 defined(CONFIG_SOC_SERIES_KINETIS_KE1XF) 34 #define PORT_PCR_ODE(x) 0x0 35 #define PORT_PCR_ODE_MASK 0x0 36 #endif 37 38 /* Kinetis KE series does not support slew rate. Define macros to have no effect */ 39 #if defined(CONFIG_SOC_SERIES_KINETIS_KE1XF) 40 #define PORT_PCR_SRE(x) 0x0 41 #define PORT_PCR_SRE_MASK 0x0 42 #endif 43 44 #define Z_PINCTRL_KINETIS_PINCFG(node_id) \ 45 (PORT_PCR_DSE(DT_ENUM_IDX(node_id, drive_strength)) | \ 46 PORT_PCR_PS(DT_PROP(node_id, bias_pull_up)) | \ 47 PORT_PCR_PE(DT_PROP(node_id, bias_pull_up)) | \ 48 PORT_PCR_PE(DT_PROP(node_id, bias_pull_down)) | \ 49 PORT_PCR_ODE(DT_PROP(node_id, drive_open_drain)) | \ 50 PORT_PCR_SRE(DT_ENUM_IDX(node_id, slew_rate)) | \ 51 PORT_PCR_PFE(DT_PROP(node_id, nxp_passive_filter))) 52 53 #define Z_PINCTRL_KINETIS_PCR_MASK \ 54 (PORT_PCR_MUX_MASK | PORT_PCR_DSE_MASK | PORT_PCR_ODE_MASK | \ 55 PORT_PCR_PFE_MASK | PORT_PCR_SRE_MASK | PORT_PCR_PE_MASK | \ 56 PORT_PCR_PS_MASK) 57 58 59 #define Z_PINCTRL_STATE_PIN_INIT(group, pin_prop, idx) \ 60 DT_PROP_BY_IDX(group, pin_prop, idx) | Z_PINCTRL_KINETIS_PINCFG(group), 61 62 #define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \ 63 {DT_FOREACH_CHILD_VARGS(DT_PHANDLE(node_id, prop), \ 64 DT_FOREACH_PROP_ELEM, pinmux, Z_PINCTRL_STATE_PIN_INIT)}; 65 66 #ifdef __cplusplus 67 } 68 #endif 69 70 #endif /* ZEPHYR_SOC_ARM_NXP_KINETIS_COMMON_PINCTRL_SOC_H_ */ 71