diff --git a/boards/arm/frdm_k22f/CMakeLists.txt b/boards/arm/frdm_k22f/CMakeLists.txt index e8cb2cf3408f8..5bc4984c3921b 100644 --- a/boards/arm/frdm_k22f/CMakeLists.txt +++ b/boards/arm/frdm_k22f/CMakeLists.txt @@ -3,8 +3,3 @@ # # SPDX-License-Identifier: Apache-2.0 # - -if(CONFIG_PINMUX_MCUX) - zephyr_library() - zephyr_library_sources(pinmux.c) -endif() diff --git a/boards/arm/frdm_k22f/frdm_k22f_defconfig b/boards/arm/frdm_k22f/frdm_k22f_defconfig index ec3700a8e2a6d..be8d0990c82e4 100644 --- a/boards/arm/frdm_k22f/frdm_k22f_defconfig +++ b/boards/arm/frdm_k22f/frdm_k22f_defconfig @@ -13,7 +13,6 @@ CONFIG_UART_CONSOLE=y CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_GPIO=y -CONFIG_PINMUX=y CONFIG_PINCTRL=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=72000000 CONFIG_OSC_LOW_POWER=y diff --git a/boards/arm/frdm_k22f/pinmux.c b/boards/arm/frdm_k22f/pinmux.c deleted file mode 100644 index 8a2209bf34731..0000000000000 --- a/boards/arm/frdm_k22f/pinmux.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2018 Prevas A/S - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -static int frdm_k22f_pinmux_init(const struct device *dev) -{ - ARG_UNUSED(dev); - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused const struct device *porta = - DEVICE_DT_GET(DT_NODELABEL(porta)); - __ASSERT_NO_MSG(device_is_ready(porta)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused const struct device *portd = - DEVICE_DT_GET(DT_NODELABEL(portd)); - __ASSERT_NO_MSG(device_is_ready(portd)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused const struct device *porte = - DEVICE_DT_GET(DT_NODELABEL(porte)); - __ASSERT_NO_MSG(device_is_ready(porte)); -#endif - -#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm0), nxp_kinetis_ftm_pwm, okay) && CONFIG_PWM - /* Red, green, blue LEDs as PWM channels*/ - pinmux_pin_set(porta, 1, PORT_PCR_MUX(kPORT_MuxAlt3)); - pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAlt3)); - pinmux_pin_set(portd, 5, PORT_PCR_MUX(kPORT_MuxAlt4)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi0), okay) && CONFIG_SPI - /* SPI0 CS0, SCK, SOUT, SIN */ - pinmux_pin_set(portc, 4, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 2, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c0), okay) && CONFIG_I2C - /* I2C0 SCL, SDA */ - pinmux_pin_set(portb, 2, PORT_PCR_MUX(kPORT_MuxAlt2) - | PORT_PCR_ODE_MASK); - pinmux_pin_set(portb, 3, PORT_PCR_MUX(kPORT_MuxAlt2) - | PORT_PCR_ODE_MASK); -#endif - - return 0; -} - -SYS_INIT(frdm_k22f_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/boards/arm/frdm_k64f/CMakeLists.txt b/boards/arm/frdm_k64f/CMakeLists.txt index 77353a23d1d5f..9881313609aae 100644 --- a/boards/arm/frdm_k64f/CMakeLists.txt +++ b/boards/arm/frdm_k64f/CMakeLists.txt @@ -1,6 +1 @@ # SPDX-License-Identifier: Apache-2.0 - -if(CONFIG_PINMUX_MCUX) - zephyr_library() - zephyr_library_sources(pinmux.c) -endif() diff --git a/boards/arm/frdm_k64f/frdm_k64f-pinctrl.dtsi b/boards/arm/frdm_k64f/frdm_k64f-pinctrl.dtsi index 010677c5ed8f7..0841553309f23 100644 --- a/boards/arm/frdm_k64f/frdm_k64f-pinctrl.dtsi +++ b/boards/arm/frdm_k64f/frdm_k64f-pinctrl.dtsi @@ -1,6 +1,6 @@ /* - * NOTE: Autogenerated file by kinetis_signal2dts.py - * for MK64FN1M0VLL12/signal_configuration.xml + * NOTE: Autogenerated file by kinetis_cfg_utils.py + * for MK64FN1M0VLL12/signal_configuration.xml * * Copyright (c) 2022, NXP * SPDX-License-Identifier: Apache-2.0 @@ -10,21 +10,33 @@ #include &pinctrl { - enet_default: enet_default { + adc0_default: adc0_default { group0 { - pinmux = ; - drive-strength = "high"; + pinmux = ; + drive-strength = "low"; slew-rate = "fast"; }; - group1 { + }; + + adc1_default: adc1_default { + group0 { + pinmux = ; + drive-strength = "low"; + slew-rate = "fast"; + }; + }; + + enet_default: enet_default { + group0 { pinmux = ; drive-strength = "low"; drive-open-drain; bias-pull-up; slew-rate = "fast"; }; - group2 { - pinmux = , + group1 { + pinmux = , + , , , , @@ -77,6 +89,7 @@ }; }; + /* PTC16 and PTC17 conflict with uart3 pins */ ptp_default: ptp_default { group0 { pinmux = , @@ -87,6 +100,7 @@ }; }; + /* pins conflict with uart2 */ spi0_default: spi0_default { group0 { pinmux = , @@ -107,6 +121,7 @@ }; }; + /* pins conflict with spi0 */ uart2_default: uart2_default { group0 { pinmux = , @@ -118,6 +133,7 @@ }; }; + /* PTC16 and PTC17 conflict with PTP timer pins */ uart3_default: uart3_default { group0 { pinmux = , diff --git a/boards/arm/frdm_k64f/frdm_k64f.dts b/boards/arm/frdm_k64f/frdm_k64f.dts index cc5498644e695..807793e863187 100644 --- a/boards/arm/frdm_k64f/frdm_k64f.dts +++ b/boards/arm/frdm_k64f/frdm_k64f.dts @@ -106,10 +106,14 @@ arduino_serial: &uart3 { &adc0 { status = "okay"; + pinctrl-0 = <&adc0_default>; + pinctrl-names = "default"; }; &adc1 { status = "okay"; + pinctrl-0 = <&adc1_default>; + pinctrl-names = "default"; }; &temp1 { diff --git a/boards/arm/frdm_k64f/frdm_k64f_defconfig b/boards/arm/frdm_k64f/frdm_k64f_defconfig index fe9709f583502..6f3d5c2eb9676 100644 --- a/boards/arm/frdm_k64f/frdm_k64f_defconfig +++ b/boards/arm/frdm_k64f/frdm_k64f_defconfig @@ -8,7 +8,6 @@ CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_GPIO=y CONFIG_PINCTRL=y -CONFIG_PINMUX=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=120000000 CONFIG_OSC_EXTERNAL=y diff --git a/boards/arm/frdm_k64f/pinmux.c b/boards/arm/frdm_k64f/pinmux.c deleted file mode 100644 index e4f02265bed4a..0000000000000 --- a/boards/arm/frdm_k64f/pinmux.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2016 Freescale Semiconductor, Inc. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -static int frdm_k64f_pinmux_init(const struct device *dev) -{ - ARG_UNUSED(dev); - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused const struct device *porta = - DEVICE_DT_GET(DT_NODELABEL(porta)); - __ASSERT_NO_MSG(device_is_ready(porta)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused const struct device *portd = - DEVICE_DT_GET(DT_NODELABEL(portd)); - __ASSERT_NO_MSG(device_is_ready(portd)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused const struct device *porte = - DEVICE_DT_GET(DT_NODELABEL(porte)); - __ASSERT_NO_MSG(device_is_ready(porte)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi0), okay) && CONFIG_SPI - /* SPI0 CS0, SCK, SOUT, SIN */ - pinmux_pin_set(portd, 0, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 2, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c0), okay) && CONFIG_I2C - /* I2C0 SCL, SDA */ - pinmux_pin_set(porte, 24, PORT_PCR_MUX(kPORT_MuxAlt5) - | PORT_PCR_ODE_MASK); - pinmux_pin_set(porte, 25, PORT_PCR_MUX(kPORT_MuxAlt5) - | PORT_PCR_ODE_MASK); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(adc1), okay) && CONFIG_ADC - /* ADC1_SE14 */ - pinmux_pin_set(portb, 10, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); -#endif - -#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm0), nxp_kinetis_ftm_pwm, okay) \ - && CONFIG_PWM - pinmux_pin_set(portc, 1, PORT_PCR_MUX(kPORT_MuxAlt4)); -#endif - -#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm, okay) \ - && CONFIG_PWM - pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3)); - pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET - pinmux_pin_set(porta, 5, PORT_PCR_MUX(kPORT_MuxAlt4)); - pinmux_pin_set(porta, 12, PORT_PCR_MUX(kPORT_MuxAlt4)); - pinmux_pin_set(porta, 13, PORT_PCR_MUX(kPORT_MuxAlt4)); - pinmux_pin_set(porta, 14, PORT_PCR_MUX(kPORT_MuxAlt4)); - pinmux_pin_set(porta, 15, PORT_PCR_MUX(kPORT_MuxAlt4)); - pinmux_pin_set(porta, 16, PORT_PCR_MUX(kPORT_MuxAlt4)); - pinmux_pin_set(porta, 17, PORT_PCR_MUX(kPORT_MuxAlt4)); - - pinmux_pin_set(portb, 0, PORT_PCR_MUX(kPORT_MuxAlt4) - | PORT_PCR_ODE_MASK | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK); - - pinmux_pin_set(portb, 1, PORT_PCR_MUX(kPORT_MuxAlt4)); - -#if DT_NODE_HAS_STATUS(DT_CHILD(DT_NODELABEL(enet), ptp), okay) - pinmux_pin_set(portc, 16, PORT_PCR_MUX(kPORT_MuxAlt4)); - pinmux_pin_set(portc, 17, PORT_PCR_MUX(kPORT_MuxAlt4)); - pinmux_pin_set(portc, 18, PORT_PCR_MUX(kPORT_MuxAlt4)); -#endif -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(flexcan0), okay) && CONFIG_CAN - /* FlexCAN0 RX, TX */ - pinmux_pin_set(portb, 18, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 19, PORT_PCR_MUX(kPORT_MuxAlt2) | - PORT_PCR_PE_MASK | PORT_PCR_PS_MASK); -#endif - - return 0; -} - -SYS_INIT(frdm_k64f_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/boards/arm/frdm_k82f/CMakeLists.txt b/boards/arm/frdm_k82f/CMakeLists.txt index 77353a23d1d5f..9881313609aae 100644 --- a/boards/arm/frdm_k82f/CMakeLists.txt +++ b/boards/arm/frdm_k82f/CMakeLists.txt @@ -1,6 +1 @@ # SPDX-License-Identifier: Apache-2.0 - -if(CONFIG_PINMUX_MCUX) - zephyr_library() - zephyr_library_sources(pinmux.c) -endif() diff --git a/boards/arm/frdm_k82f/frdm_k82f_defconfig b/boards/arm/frdm_k82f/frdm_k82f_defconfig index 4e072b2384b27..830ac1cd089a1 100644 --- a/boards/arm/frdm_k82f/frdm_k82f_defconfig +++ b/boards/arm/frdm_k82f/frdm_k82f_defconfig @@ -7,7 +7,6 @@ CONFIG_SERIAL=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y CONFIG_UART_INTERRUPT_DRIVEN=y -CONFIG_PINMUX=y CONFIG_PINCTRL=y CONFIG_GPIO=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=120000000 diff --git a/boards/arm/frdm_k82f/pinmux.c b/boards/arm/frdm_k82f/pinmux.c deleted file mode 100644 index 606aa5e1e929f..0000000000000 --- a/boards/arm/frdm_k82f/pinmux.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2019 SEAL AG - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -static int frdm_k82f_pinmux_init(const struct device *dev) -{ - ARG_UNUSED(dev); - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused const struct device *porta = - DEVICE_DT_GET(DT_NODELABEL(porta)); - __ASSERT_NO_MSG(device_is_ready(porta)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused const struct device *portd = - DEVICE_DT_GET(DT_NODELABEL(portd)); - __ASSERT_NO_MSG(device_is_ready(portd)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused const struct device *porte = - DEVICE_DT_GET(DT_NODELABEL(porte)); - __ASSERT_NO_MSG(device_is_ready(porte)); -#endif - -#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm, okay) && CONFIG_PWM - /* Red, green, blue LEDs as PWM channels */ - pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3)); - pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3)); - pinmux_pin_set(portc, 10, PORT_PCR_MUX(kPORT_MuxAlt3)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c3), okay) && CONFIG_I2C - /* I2C3 SDA, SCL */ - pinmux_pin_set(porta, 1, PORT_PCR_MUX(kPORT_MuxAlt4) - | PORT_PCR_ODE_MASK); - pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAlt4) - | PORT_PCR_ODE_MASK); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI - /* SPI1 SCK, SOUT, SIN, PCS0 */ - pinmux_pin_set(porte, 1, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(porte, 2, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(porte, 4, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(porte, 5, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c0), okay) && CONFIG_I2C - /* I2C0 SDA, SCL */ - pinmux_pin_set(portb, 3, PORT_PCR_MUX(kPORT_MuxAlt2) - | PORT_PCR_ODE_MASK); - pinmux_pin_set(portb, 2, PORT_PCR_MUX(kPORT_MuxAlt2) - | PORT_PCR_ODE_MASK); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi0), okay) && CONFIG_SPI - /* SPI0 SCK, SOUT, SIN, PCS1 */ - pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 2, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 4, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(adc0), okay) && CONFIG_ADC - /* ADC0_SE15 */ - pinmux_pin_set(portc, 1, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); -#endif - - return 0; -} - -SYS_INIT(frdm_k82f_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/boards/arm/frdm_kl25z/CMakeLists.txt b/boards/arm/frdm_kl25z/CMakeLists.txt index 77353a23d1d5f..9881313609aae 100644 --- a/boards/arm/frdm_kl25z/CMakeLists.txt +++ b/boards/arm/frdm_kl25z/CMakeLists.txt @@ -1,6 +1 @@ # SPDX-License-Identifier: Apache-2.0 - -if(CONFIG_PINMUX_MCUX) - zephyr_library() - zephyr_library_sources(pinmux.c) -endif() diff --git a/boards/arm/frdm_kl25z/frdm_kl25z_defconfig b/boards/arm/frdm_kl25z/frdm_kl25z_defconfig index 9e109926a477e..439878b01476c 100644 --- a/boards/arm/frdm_kl25z/frdm_kl25z_defconfig +++ b/boards/arm/frdm_kl25z/frdm_kl25z_defconfig @@ -6,7 +6,6 @@ CONFIG_UART_CONSOLE=y CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_GPIO=y -CONFIG_PINMUX=y CONFIG_PINCTRL=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=48000000 CONFIG_OSC_LOW_POWER=y diff --git a/boards/arm/frdm_kl25z/pinmux.c b/boards/arm/frdm_kl25z/pinmux.c deleted file mode 100644 index d2fb116d9fc07..0000000000000 --- a/boards/arm/frdm_kl25z/pinmux.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017, NXP - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -static int frdm_kl25z_pinmux_init(const struct device *dev) -{ - ARG_UNUSED(dev); - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused const struct device *porta = - DEVICE_DT_GET(DT_NODELABEL(porta)); - __ASSERT_NO_MSG(device_is_ready(porta)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused const struct device *portd = - DEVICE_DT_GET(DT_NODELABEL(portd)); - __ASSERT_NO_MSG(device_is_ready(portd)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused const struct device *porte = - DEVICE_DT_GET(DT_NODELABEL(porte)); - __ASSERT_NO_MSG(device_is_ready(porte)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c0), okay) && CONFIG_I2C - /* I2C0 SCL, SDA */ - pinmux_pin_set(porte, 24, PORT_PCR_MUX(kPORT_MuxAlt5) - | PORT_PCR_PS_MASK); - pinmux_pin_set(porte, 25, PORT_PCR_MUX(kPORT_MuxAlt5) - | PORT_PCR_PS_MASK); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(adc0), okay) && CONFIG_ADC - /* ADC0_SE12 */ - pinmux_pin_set(portb, 2, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); -#endif - - return 0; -} - -SYS_INIT(frdm_kl25z_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/boards/arm/frdm_kw41z/CMakeLists.txt b/boards/arm/frdm_kw41z/CMakeLists.txt index 9bc25bae4c64e..9881313609aae 100644 --- a/boards/arm/frdm_kw41z/CMakeLists.txt +++ b/boards/arm/frdm_kw41z/CMakeLists.txt @@ -1,4 +1 @@ # SPDX-License-Identifier: Apache-2.0 - -zephyr_library() -zephyr_library_sources(pinmux.c) diff --git a/boards/arm/frdm_kw41z/frdm_kw41z_defconfig b/boards/arm/frdm_kw41z/frdm_kw41z_defconfig index 94199e476abef..10ba1cf3bafc4 100644 --- a/boards/arm/frdm_kw41z/frdm_kw41z_defconfig +++ b/boards/arm/frdm_kw41z/frdm_kw41z_defconfig @@ -7,6 +7,6 @@ CONFIG_UART_CONSOLE=y CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_GPIO=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=40000000 CONFIG_OSC_EXTERNAL=y diff --git a/boards/arm/frdm_kw41z/pinmux.c b/boards/arm/frdm_kw41z/pinmux.c deleted file mode 100644 index 94d9cc1b263ee..0000000000000 --- a/boards/arm/frdm_kw41z/pinmux.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2017, 2020 NXP - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -static int frdm_kw41z_pinmux_init(const struct device *dev) -{ - ARG_UNUSED(dev); - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused const struct device *porta = - DEVICE_DT_GET(DT_NODELABEL(porta)); - __ASSERT_NO_MSG(device_is_ready(porta)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif - - /* Red, green, blue LEDs. Note the red LED and accel INT1 are both - * wired to PTC1. - */ -#if defined(CONFIG_PWM) && DT_NODE_HAS_STATUS(DT_NODELABEL(tpm0), okay) - pinmux_pin_set(portc, 1, PORT_PCR_MUX(kPORT_MuxAlt5)); -#endif - -#if defined(CONFIG_PWM) && DT_NODE_HAS_STATUS(DT_NODELABEL(tpm2), okay) - pinmux_pin_set(porta, 19, PORT_PCR_MUX(kPORT_MuxAlt5)); - pinmux_pin_set(porta, 18, PORT_PCR_MUX(kPORT_MuxAlt5)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C - /* I2C1 SCL, SDA */ - pinmux_pin_set(portc, 2, PORT_PCR_MUX(kPORT_MuxAlt3) - | PORT_PCR_PS_MASK); - pinmux_pin_set(portc, 3, PORT_PCR_MUX(kPORT_MuxAlt3) - | PORT_PCR_PS_MASK); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(adc0), okay) && CONFIG_ADC - /* ADC0_SE3 */ - pinmux_pin_set(portb, 2, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpuart0), okay) && CONFIG_SERIAL - /* UART0 RX, TX */ - pinmux_pin_set(portc, 6, PORT_PCR_MUX(kPORT_MuxAlt4)); - pinmux_pin_set(portc, 7, PORT_PCR_MUX(kPORT_MuxAlt4)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi0), okay) && CONFIG_SPI - /* SPI0 CS0, SCK, SOUT, SIN */ - pinmux_pin_set(portc, 16, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 17, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 18, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 19, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - - return 0; -} - -SYS_INIT(frdm_kw41z_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/boards/arm/hexiwear_k64/hexiwear_k64_defconfig b/boards/arm/hexiwear_k64/hexiwear_k64_defconfig index 020ca2b9a857c..a788e77675c6c 100644 --- a/boards/arm/hexiwear_k64/hexiwear_k64_defconfig +++ b/boards/arm/hexiwear_k64/hexiwear_k64_defconfig @@ -8,7 +8,6 @@ CONFIG_UART_CONSOLE=y CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_GPIO=y -CONFIG_PINMUX=y CONFIG_PINCTRL=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=120000000 CONFIG_OSC_LOW_POWER=y diff --git a/boards/arm/hexiwear_k64/pinmux.c b/boards/arm/hexiwear_k64/pinmux.c index d593f7271c6cc..01a54aee7b240 100644 --- a/boards/arm/hexiwear_k64/pinmux.c +++ b/boards/arm/hexiwear_k64/pinmux.c @@ -5,63 +5,19 @@ */ #include -#include #include -#include static int hexiwear_k64_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused const struct device *portd = - DEVICE_DT_GET(DT_NODELABEL(portd)); - __ASSERT_NO_MSG(device_is_ready(portd)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused const struct device *porte = - DEVICE_DT_GET(DT_NODELABEL(porte)); - __ASSERT_NO_MSG(device_is_ready(porte)); -#endif - -#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm, okay) && CONFIG_PWM - /* Red, green, blue LEDs as PWM channels */ - pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3)); - pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3)); - pinmux_pin_set(portd, 0, PORT_PCR_MUX(kPORT_MuxAlt4)); -#endif - #if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c0), okay) && CONFIG_I2C - /* I2C0 SCL, SDA - heart rate, light, humidity */ - pinmux_pin_set(portb, 0, PORT_PCR_MUX(kPORT_MuxAlt2) - | PORT_PCR_ODE_MASK); - pinmux_pin_set(portb, 1, PORT_PCR_MUX(kPORT_MuxAlt2) - | PORT_PCR_ODE_MASK); - const struct device *gpiob = device_get_binding(DT_LABEL(DT_NODELABEL(gpiob))); gpio_pin_configure(gpiob, 12, GPIO_OUTPUT_LOW); #endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C - /* I2C1 SCL, SDA - accel/mag, gyro, pressure */ - pinmux_pin_set(portc, 10, PORT_PCR_MUX(kPORT_MuxAlt2) - | PORT_PCR_ODE_MASK); - pinmux_pin_set(portc, 11, PORT_PCR_MUX(kPORT_MuxAlt2) - | PORT_PCR_ODE_MASK); -#endif - #if defined(CONFIG_MAX30101) && DT_NODE_HAS_STATUS(DT_NODELABEL(gpioa), okay) const struct device *gpioa = device_get_binding(DT_LABEL(DT_NODELABEL(gpioa))); @@ -79,4 +35,4 @@ static int hexiwear_k64_pinmux_init(const struct device *dev) return 0; } -SYS_INIT(hexiwear_k64_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); +SYS_INIT(hexiwear_k64_pinmux_init, PRE_KERNEL_1, CONFIG_APPLICATION_INIT_PRIORITY); diff --git a/boards/arm/hexiwear_kw40z/CMakeLists.txt b/boards/arm/hexiwear_kw40z/CMakeLists.txt index 9bc25bae4c64e..9881313609aae 100644 --- a/boards/arm/hexiwear_kw40z/CMakeLists.txt +++ b/boards/arm/hexiwear_kw40z/CMakeLists.txt @@ -1,4 +1 @@ # SPDX-License-Identifier: Apache-2.0 - -zephyr_library() -zephyr_library_sources(pinmux.c) diff --git a/boards/arm/hexiwear_kw40z/hexiwear_kw40z_defconfig b/boards/arm/hexiwear_kw40z/hexiwear_kw40z_defconfig index d2800ace2f978..5e22beea4e017 100644 --- a/boards/arm/hexiwear_kw40z/hexiwear_kw40z_defconfig +++ b/boards/arm/hexiwear_kw40z/hexiwear_kw40z_defconfig @@ -7,7 +7,7 @@ CONFIG_CONSOLE=y CONFIG_RTT_CONSOLE=y CONFIG_USE_SEGGER_RTT=y CONFIG_CORTEX_M_SYSTICK=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_GPIO=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=40000000 CONFIG_OSC_EXTERNAL=y diff --git a/boards/arm/hexiwear_kw40z/pinmux.c b/boards/arm/hexiwear_kw40z/pinmux.c deleted file mode 100644 index 3b5021e2b18e6..0000000000000 --- a/boards/arm/hexiwear_kw40z/pinmux.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017, NXP - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -static int hexiwear_kw40z_pinmux_init(const struct device *dev) -{ - ARG_UNUSED(dev); - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpuart0), okay) && CONFIG_SERIAL - /* UART0 RX, TX */ - pinmux_pin_set(portc, 6, PORT_PCR_MUX(kPORT_MuxAlt4)); - pinmux_pin_set(portc, 7, PORT_PCR_MUX(kPORT_MuxAlt4)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(adc0), okay) && CONFIG_ADC - /* ADC0_SE1 */ - pinmux_pin_set(portb, 1, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); -#endif - - return 0; -} - -SYS_INIT(hexiwear_kw40z_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/boards/arm/ip_k66f/CMakeLists.txt b/boards/arm/ip_k66f/CMakeLists.txt index 77353a23d1d5f..9881313609aae 100644 --- a/boards/arm/ip_k66f/CMakeLists.txt +++ b/boards/arm/ip_k66f/CMakeLists.txt @@ -1,6 +1 @@ # SPDX-License-Identifier: Apache-2.0 - -if(CONFIG_PINMUX_MCUX) - zephyr_library() - zephyr_library_sources(pinmux.c) -endif() diff --git a/boards/arm/ip_k66f/ip_k66f-pinctrl.dtsi b/boards/arm/ip_k66f/ip_k66f-pinctrl.dtsi index 675f200c4cfc0..86e0e71a4caf0 100644 --- a/boards/arm/ip_k66f/ip_k66f-pinctrl.dtsi +++ b/boards/arm/ip_k66f/ip_k66f-pinctrl.dtsi @@ -1,6 +1,6 @@ /* - * NOTE: Autogenerated file by kinetis_signal2dts.py - * for MK66FN2M0VMD18/signal_configuration.xml + * NOTE: Autogenerated file by kinetis_cfg_utils.py + * for MK66FN2M0VMD18/signal_configuration.xml * * Copyright (c) 2022, NXP * SPDX-License-Identifier: Apache-2.0 diff --git a/boards/arm/ip_k66f/ip_k66f_defconfig b/boards/arm/ip_k66f/ip_k66f_defconfig index 891223c055e29..dcddc28fb9fd5 100644 --- a/boards/arm/ip_k66f/ip_k66f_defconfig +++ b/boards/arm/ip_k66f/ip_k66f_defconfig @@ -5,7 +5,6 @@ CONFIG_SOC_SERIES_KINETIS_K6X=y CONFIG_BOARD_IP_K66F=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_GPIO=y -CONFIG_PINMUX=y CONFIG_PINCTRL=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=180000000 CONFIG_OSC_LOW_POWER=y diff --git a/boards/arm/ip_k66f/pinmux.c b/boards/arm/ip_k66f/pinmux.c deleted file mode 100644 index c7399b29e86d0..0000000000000 --- a/boards/arm/ip_k66f/pinmux.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2020 DENX Software Engineering GmbH - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -static int ip_k66f_pinmux_init(const struct device *dev) -{ - ARG_UNUSED(dev); - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused const struct device *porta = - DEVICE_DT_GET(DT_NODELABEL(porta)); - __ASSERT_NO_MSG(device_is_ready(porta)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused const struct device *portd = - DEVICE_DT_GET(DT_NODELABEL(portd)); - __ASSERT_NO_MSG(device_is_ready(portd)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused const struct device *porte = - DEVICE_DT_GET(DT_NODELABEL(porte)); - __ASSERT_NO_MSG(device_is_ready(porte)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET - pinmux_pin_set(porta, 12, PORT_PCR_MUX(kPORT_MuxAlt4));/* RMII_RXD1 */ - pinmux_pin_set(porta, 13, PORT_PCR_MUX(kPORT_MuxAlt4));/* RMII_RXD0 */ - pinmux_pin_set(porta, 14, PORT_PCR_MUX(kPORT_MuxAlt4));/* RMII_CRS_DV */ - pinmux_pin_set(porta, 15, PORT_PCR_MUX(kPORT_MuxAlt4));/* RMII_RX_EN */ - pinmux_pin_set(porta, 16, PORT_PCR_MUX(kPORT_MuxAlt4));/* RMII_TXD0 */ - pinmux_pin_set(porta, 17, PORT_PCR_MUX(kPORT_MuxAlt4));/* RMII_TXD1 */ -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - /* RMII_REF_CLK */ - pinmux_pin_set(porte, 26, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI - /* SPI1 CS0, SCK, SOUT, SIN - Control of KSZ8794 */ - pinmux_pin_set(portb, 10, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 11, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 16, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 17, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - - return 0; -} - -SYS_INIT(ip_k66f_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/boards/arm/mimxrt1060_evk/mimxrt1060_evk-pinctrl.dtsi b/boards/arm/mimxrt1060_evk/mimxrt1060_evk-pinctrl.dtsi index 9f54a7aeed25f..9b630aaff8430 100644 --- a/boards/arm/mimxrt1060_evk/mimxrt1060_evk-pinctrl.dtsi +++ b/boards/arm/mimxrt1060_evk/mimxrt1060_evk-pinctrl.dtsi @@ -2,26 +2,221 @@ * Copyright (c) 2022, NXP * SPDX-License-Identifier: Apache-2.0 * - * Generated by rt_cfg_utils.py on 2022-03-02 + * Note: File generated by rt_cfg_utils.py + * from mimxrt1060_evk.mex */ #include &pinctrl { - lpuart1_default: lpuart1_default { + /* ADC1 inputs 0 and 15 */ + pinmux_adc1: pinmux_adc1 { group0 { - pinmux = <&iomuxc_gpio_ad_b0_12_lpuart1_tx - &iomuxc_gpio_ad_b0_13_lpuart1_rx>; + pinmux = <&iomuxc_gpio_ad_b1_11_gpio1_io27>, + <&iomuxc_gpio_ad_b1_10_gpio1_io26>; + bias-disable; drive-strength = "r0-6"; slew-rate = "slow"; nxp,speed = "100-mhz"; }; }; - lpuart1_sleep: pinmux_lpuart1_sleep { + /* conflicts with lpuart3 and flexcan1 */ + pinmux_csi: pinmux_csi { group0 { - pinmux = <&iomuxc_gpio_ad_b0_13_gpio1_io13>; + pinmux = <&iomuxc_gpio_ad_b0_04_gpio1_io04>; + drive-strength = "r0-6"; + bias-pull-down; + bias-pull-down-value = "100k"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + group1 { + pinmux = <&iomuxc_gpio_ad_b1_04_csi_pixclk>, + <&iomuxc_gpio_ad_b1_05_csi_mclk>, + <&iomuxc_gpio_ad_b1_06_csi_vsync>, + <&iomuxc_gpio_ad_b1_07_csi_hsync>, + <&iomuxc_gpio_ad_b1_08_csi_data09>, + <&iomuxc_gpio_ad_b1_09_csi_data08>, + <&iomuxc_gpio_ad_b1_10_csi_data07>, + <&iomuxc_gpio_ad_b1_11_csi_data06>, + <&iomuxc_gpio_ad_b1_12_csi_data05>, + <&iomuxc_gpio_ad_b1_13_csi_data04>, + <&iomuxc_gpio_ad_b1_14_csi_data03>, + <&iomuxc_gpio_ad_b1_15_csi_data02>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + /* Note: USER_LED conflicts with ENET_RST */ + pinmux_enet: pinmux_enet { + group0 { + pinmux = <&iomuxc_gpio_b1_10_enet_ref_clk>; bias-disable; + drive-strength = "r0-6"; + slew-rate = "fast"; + nxp,speed = "50-mhz"; + input-enable; + }; + group1 { + pinmux = <&iomuxc_gpio_ad_b0_10_gpio1_io10>, + <&iomuxc_gpio_ad_b0_09_gpio1_io09>; + drive-strength = "r0-5"; + bias-pull-up; + bias-pull-up-value = "100k"; + slew-rate = "fast"; + nxp,speed = "100-mhz"; + }; + group2 { + pinmux = <&iomuxc_gpio_b1_04_enet_rx_data00>, + <&iomuxc_gpio_b1_05_enet_rx_data01>, + <&iomuxc_gpio_b1_06_enet_rx_en>, + <&iomuxc_gpio_b1_07_enet_tx_data00>, + <&iomuxc_gpio_b1_08_enet_tx_data01>, + <&iomuxc_gpio_b1_09_enet_tx_en>, + <&iomuxc_gpio_b1_11_enet_rx_er>, + <&iomuxc_gpio_emc_40_enet_mdc>, + <&iomuxc_gpio_emc_41_enet_mdio>; + drive-strength = "r0-5"; + bias-pull-up; + bias-pull-up-value = "100k"; + slew-rate = "fast"; + nxp,speed = "200-mhz"; + }; + }; + + /* conflicts with SAI1 */ + pinmux_flexcan1: pinmux_flexcan1 { + group0 { + pinmux = <&iomuxc_gpio_ad_b1_08_flexcan1_tx>, + <&iomuxc_gpio_ad_b1_09_flexcan1_rx>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + pinmux_flexcan2: pinmux_flexcan2 { + group0 { + pinmux = <&iomuxc_gpio_ad_b0_14_flexcan3_tx>, + <&iomuxc_gpio_ad_b0_15_flexcan3_rx>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + pinmux_flexcan3: pinmux_flexcan3 { + group0 { + pinmux = <&iomuxc_gpio_emc_36_flexcan3_tx>, + <&iomuxc_gpio_emc_37_flexcan3_rx>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + pinmux_ft5336_int: pinmux_ft5336_int { + group0 { + pinmux = <&iomuxc_gpio_ad_b0_11_gpio1_io11>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + /* Configures pin routing and optionally pin electrical features. */ + pinmux_lcdif: pinmux_lcdif { + group0 { + pinmux = <&iomuxc_gpio_b0_00_lcd_clk>, + <&iomuxc_gpio_b0_01_lcd_enable>, + <&iomuxc_gpio_b0_02_lcd_hsync>, + <&iomuxc_gpio_b0_03_lcd_vsync>, + <&iomuxc_gpio_b0_04_lcd_data00>, + <&iomuxc_gpio_b0_05_lcd_data01>, + <&iomuxc_gpio_b0_06_lcd_data02>, + <&iomuxc_gpio_b0_07_lcd_data03>, + <&iomuxc_gpio_b0_08_lcd_data04>, + <&iomuxc_gpio_b0_09_lcd_data05>, + <&iomuxc_gpio_b0_10_lcd_data06>, + <&iomuxc_gpio_b0_11_lcd_data07>, + <&iomuxc_gpio_b0_12_lcd_data08>, + <&iomuxc_gpio_b0_13_lcd_data09>, + <&iomuxc_gpio_b0_14_lcd_data10>, + <&iomuxc_gpio_b0_15_lcd_data11>, + <&iomuxc_gpio_b1_00_lcd_data12>, + <&iomuxc_gpio_b1_01_lcd_data13>, + <&iomuxc_gpio_b1_02_lcd_data14>, + <&iomuxc_gpio_b1_03_lcd_data15>; + drive-strength = "r0-6"; + input-schmitt-enable; + bias-pull-up; + bias-pull-up-value = "100k"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + group1 { + pinmux = <&iomuxc_gpio_ad_b0_02_gpio1_io02>, + <&iomuxc_gpio_b1_15_gpio2_io31>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + pinmux_lpi2c1: pinmux_lpi2c1 { + group0 { + pinmux = <&iomuxc_gpio_ad_b1_01_lpi2c1_sda>, + <&iomuxc_gpio_ad_b1_00_lpi2c1_scl>; + drive-strength = "r0-6"; + drive-open-drain; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + input-enable; + }; + }; + + /* Conflicts with USDHC pins. Connect R278, R279, R280, and R281 on evk board */ + pinmux_lpspi1: pinmux_lpspi1 { + group0 { + pinmux = <&iomuxc_gpio_sd_b0_01_lpspi1_pcs0>, + <&iomuxc_gpio_sd_b0_00_lpspi1_sck>, + <&iomuxc_gpio_sd_b0_03_lpspi1_sdi>, + <&iomuxc_gpio_sd_b0_02_lpspi1_sdo>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + /* conflicts with lcdif pins */ + pinmux_lpspi3: pinmux_lpspi3 { + group0 { + pinmux = <&iomuxc_gpio_ad_b0_03_lpspi3_pcs0>, + <&iomuxc_gpio_ad_b0_00_lpspi3_sck>, + <&iomuxc_gpio_ad_b0_02_lpspi3_sdi>, + <&iomuxc_gpio_ad_b0_01_lpspi3_sdo>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + pinmux_lpuart1: pinmux_lpuart1 { + group0 { + pinmux = <&iomuxc_gpio_ad_b0_13_lpuart1_rx>, + <&iomuxc_gpio_ad_b0_12_lpuart1_tx>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + pinmux_lpuart1_sleep: pinmux_lpuart1_sleep { + group0 { + pinmux = <&iomuxc_gpio_ad_b0_13_gpio1_io13>; drive-strength = "r0"; bias-pull-up; bias-pull-up-value = "100k"; @@ -36,17 +231,199 @@ }; }; - sai1_default: sai1_default { + pinmux_lpuart3: pinmux_lpuart3 { group0 { - pinmux = <&iomuxc_gpio_ad_b1_09_sai1_mclk - &iomuxc_gpio_ad_b1_13_sai1_tx_data00 - &iomuxc_gpio_ad_b1_12_sai1_rx_data00 - &iomuxc_gpio_ad_b1_14_sai1_tx_bclk - &iomuxc_gpio_ad_b1_15_sai1_tx_sync>; + pinmux = <&iomuxc_gpio_ad_b1_06_lpuart3_tx>, + <&iomuxc_gpio_ad_b1_07_lpuart3_rx>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + /* Flow control for lpuart3 */ + pinmux_lpuart3_flow_control: pinmux_lpuart3_flow_control { + group0 { + pinmux = <&iomuxc_gpio_ad_b1_06_lpuart3_tx>, + <&iomuxc_gpio_ad_b1_07_lpuart3_rx>, + <&iomuxc_gpio_ad_b1_04_lpuart3_cts_b>, + <&iomuxc_gpio_ad_b1_05_lpuart3_rts_b>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + pinmux_lpuart3_sleep: pinmux_lpuart3_sleep { + group0 { + pinmux = <&iomuxc_gpio_ad_b1_06_gpio1_io22>; + drive-strength = "r0"; + bias-pull-up; + bias-pull-up-value = "100k"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + group1 { + pinmux = <&iomuxc_gpio_ad_b1_07_lpuart3_rx>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + pinmux_ptp: pinmux_ptp { + group0 { + pinmux = <&iomuxc_gpio_ad_b1_02_enet_1588_event2_out>, + <&iomuxc_gpio_ad_b1_03_enet_1588_event2_in>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + pinmux_sai1: pinmux_sai1 { + group0 { + pinmux = <&iomuxc_gpio_ad_b1_09_sai1_mclk>, + <&iomuxc_gpio_ad_b1_13_sai1_tx_data00>, + <&iomuxc_gpio_ad_b1_12_sai1_rx_data00>, + <&iomuxc_gpio_ad_b1_14_sai1_tx_bclk>, + <&iomuxc_gpio_ad_b1_15_sai1_tx_sync>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + pinmux_usdhc1: pinmux_usdhc1 { + group0 { + pinmux = <&iomuxc_gpio_sd_b0_01_usdhc1_clk>; + bias-disable; + drive-strength = "r0"; + input-schmitt-enable; + slew-rate = "fast"; + nxp,speed = "100-mhz"; + }; + group1 { + pinmux = <&iomuxc_gpio_b1_12_gpio2_io28>, + <&iomuxc_gpio_sd_b0_00_usdhc1_cmd>, + <&iomuxc_gpio_sd_b0_02_usdhc1_data0>, + <&iomuxc_gpio_sd_b0_03_usdhc1_data1>, + <&iomuxc_gpio_sd_b0_04_usdhc1_data2>, + <&iomuxc_gpio_sd_b0_05_usdhc1_data3>; + drive-strength = "r0"; + input-schmitt-enable; + bias-pull-up; + bias-pull-up-value = "47k"; + slew-rate = "fast"; + nxp,speed = "100-mhz"; + }; + group2 { + pinmux = <&iomuxc_gpio_b1_14_usdhc1_vselect>; + drive-strength = "r0-4"; + input-schmitt-enable; + bias-pull-up; + bias-pull-up-value = "47k"; + slew-rate = "fast"; + nxp,speed = "100-mhz"; + }; + group3 { + pinmux = <&iomuxc_gpio_ad_b0_05_gpio1_io05>; + drive-strength = "r0-6"; + slew-rate = "slow"; + nxp,speed = "100-mhz"; + }; + }; + + /* fast pinmux settings for USDHC (over 100 Mhz) */ + pinmux_usdhc1_fast: pinmux_usdhc1_fast { + group0 { + pinmux = <&iomuxc_gpio_sd_b0_01_usdhc1_clk>; + bias-disable; + drive-strength = "r0-7"; + input-schmitt-enable; + slew-rate = "fast"; + nxp,speed = "200-mhz"; + }; + group1 { + pinmux = <&iomuxc_gpio_sd_b0_00_usdhc1_cmd>, + <&iomuxc_gpio_sd_b0_02_usdhc1_data0>, + <&iomuxc_gpio_sd_b0_03_usdhc1_data1>, + <&iomuxc_gpio_sd_b0_04_usdhc1_data2>, + <&iomuxc_gpio_sd_b0_05_usdhc1_data3>; + drive-strength = "r0-7"; + input-schmitt-enable; + bias-pull-up; + bias-pull-up-value = "47k"; + slew-rate = "fast"; + nxp,speed = "200-mhz"; + }; + }; + + /* medium pinmux settings for USDHC (under 100 Mhz) */ + pinmux_usdhc1_med: pinmux_usdhc1_med { + group0 { + pinmux = <&iomuxc_gpio_sd_b0_01_usdhc1_clk>; + bias-disable; + drive-strength = "r0-7"; + input-schmitt-enable; + slew-rate = "fast"; + nxp,speed = "100-mhz"; + }; + group1 { + pinmux = <&iomuxc_gpio_sd_b0_00_usdhc1_cmd>, + <&iomuxc_gpio_sd_b0_02_usdhc1_data0>, + <&iomuxc_gpio_sd_b0_03_usdhc1_data1>, + <&iomuxc_gpio_sd_b0_04_usdhc1_data2>, + <&iomuxc_gpio_sd_b0_05_usdhc1_data3>; + drive-strength = "r0-7"; + input-schmitt-enable; + bias-pull-up; + bias-pull-up-value = "47k"; + slew-rate = "fast"; + nxp,speed = "100-mhz"; + }; + }; + + /* slow pinmux settings for USDHC (under 50 Mhz) */ + pinmux_usdhc1_slow: pinmux_usdhc1_slow { + group0 { + pinmux = <&iomuxc_gpio_sd_b0_01_usdhc1_clk>; + bias-disable; + drive-strength = "r0-7"; + input-schmitt-enable; + slew-rate = "fast"; + nxp,speed = "50-mhz"; + }; + group1 { + pinmux = <&iomuxc_gpio_sd_b0_00_usdhc1_cmd>, + <&iomuxc_gpio_sd_b0_02_usdhc1_data0>, + <&iomuxc_gpio_sd_b0_03_usdhc1_data1>, + <&iomuxc_gpio_sd_b0_04_usdhc1_data2>, + <&iomuxc_gpio_sd_b0_05_usdhc1_data3>; + drive-strength = "r0-7"; + input-schmitt-enable; + bias-pull-up; + bias-pull-up-value = "47k"; + slew-rate = "fast"; + nxp,speed = "50-mhz"; + }; + }; + + /* enable user led and SW0. Conflicts with ENET pinmux */ + pinmux_user: pinmux_user { + group0 { + pinmux = <&iomuxc_snvs_wakeup_gpio5_io00>; + drive-strength = "r0-4"; + input-schmitt-enable; + bias-pull-up; + bias-pull-up-value = "100k"; + slew-rate = "slow"; + }; + group1 { + pinmux = <&iomuxc_gpio_ad_b0_09_gpio1_io09>; drive-strength = "r0-6"; slew-rate = "slow"; nxp,speed = "100-mhz"; - input-enable; }; }; diff --git a/boards/arm/mimxrt1060_evk/mimxrt1060_evk.dts b/boards/arm/mimxrt1060_evk/mimxrt1060_evk.dts index d7298bc5da9c5..780632af7ad0e 100644 --- a/boards/arm/mimxrt1060_evk/mimxrt1060_evk.dts +++ b/boards/arm/mimxrt1060_evk/mimxrt1060_evk.dts @@ -176,14 +176,18 @@ arduino_serial: &lpuart3 {}; &lpuart1 { status = "okay"; current-speed = <115200>; - pinctrl-0 = <&lpuart1_default>; - pinctrl-1 = <&lpuart1_sleep>; + pinctrl-0 = <&pinmux_lpuart1>; + pinctrl-1 = <&pinmux_lpuart1_sleep>; pinctrl-names = "default", "sleep"; }; &enet { status = "okay"; + pinctrl-0 = <&pinmux_enet>; + pinctrl-names = "default"; ptp { + pinctrl-0 = <&pinmux_ptp>; + pinctrl-names = "default"; status = "okay"; }; }; @@ -211,6 +215,8 @@ zephyr_udc0: &usb1 { &flexcan2 { status = "okay"; bus-speed = <125000>; + pinctrl-0 = <&pinmux_flexcan2>; + pinctrl-names = "default"; can-transceiver { max-bitrate = <5000000>; @@ -226,6 +232,8 @@ zephyr_udc0: &usb1 { /* DMA channels 0 and 1, muxed to LPSPI1 RX and TX */ dmas = <&edma0 0 13>, <&edma0 1 14>; dma-names = "rx", "tx"; + pinctrl-0 = <&pinmux_lpspi1>; + pinctrl-names = "default"; }; &lpspi3 { @@ -233,11 +241,14 @@ zephyr_udc0: &usb1 { /* DMA channels 2 and 3, muxed to LPSPI3 RX and TX */ dmas = <&edma0 2 15>, <&edma0 3 16>; dma-names = "rx", "tx"; + pinctrl-0 = <&pinmux_lpspi3>; + pinctrl-names = "default"; + }; &sai1 { status = "okay"; - pinctrl-0 = <&sai1_default>; + pinctrl-0 = <&pinmux_sai1>; pinctrl-names = "default"; }; diff --git a/boards/arm/rddrone_fmuk66/CMakeLists.txt b/boards/arm/rddrone_fmuk66/CMakeLists.txt index 6040b7754b0a8..9881313609aae 100644 --- a/boards/arm/rddrone_fmuk66/CMakeLists.txt +++ b/boards/arm/rddrone_fmuk66/CMakeLists.txt @@ -1,6 +1 @@ # SPDX-License-Identifier: Apache-2.0 - -if(CONFIG_PINMUX_MCUX) - zephyr_library() - zephyr_library_sources(pinmux.c) -endif() diff --git a/boards/arm/rddrone_fmuk66/pinmux.c b/boards/arm/rddrone_fmuk66/pinmux.c deleted file mode 100644 index 755c93c8ed0aa..0000000000000 --- a/boards/arm/rddrone_fmuk66/pinmux.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2021 Electromaticus LLC, 2021 NXP - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -static int rddrone_fmuk66_pinmux_init(const struct device *dev) -{ - ARG_UNUSED(dev); - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused const struct device *porta = - DEVICE_DT_GET(DT_NODELABEL(porta)); - __ASSERT_NO_MSG(device_is_ready(porta)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused const struct device *portd = - DEVICE_DT_GET(DT_NODELABEL(portd)); - __ASSERT_NO_MSG(device_is_ready(portd)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused const struct device *porte = - DEVICE_DT_GET(DT_NODELABEL(porte)); - __ASSERT_NO_MSG(device_is_ready(porte)); -#endif - - - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpuart0), okay) && CONFIG_SERIAL - /* LPUART0 RX, TX */ - pinmux_pin_set(portd, 8, PORT_PCR_MUX(kPORT_MuxAlt5)); - pinmux_pin_set(portd, 9, PORT_PCR_MUX(kPORT_MuxAlt5)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(flexcan0), okay) && CONFIG_CAN - /* CAN0 TX, RX */ - pinmux_pin_set(portb, 18, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 19, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(flexcan1), okay) && CONFIG_CAN - /* CAN1 TX, RX */ - pinmux_pin_set(portc, 17, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 16, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c0), okay) && CONFIG_I2C - /* I2C0 SCL, SDA */ - pinmux_pin_set(porte, 24, PORT_PCR_MUX(kPORT_MuxAlt5)); - pinmux_pin_set(porte, 25, PORT_PCR_MUX(kPORT_MuxAlt5)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C - /* I2C0 SCL, SDA */ - pinmux_pin_set(portc, 10, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 11, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi0), okay) && CONFIG_SPI - /* SPI0 CS2, SCK, SIN, SOUT */ - pinmux_pin_set(portc, 2, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 5, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 6, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 7, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI - /* SPI1 CS0, CS1, SCK, SIN, SOUT */ - pinmux_pin_set(portb, 10, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 9, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 11, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 16, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 17, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi2), okay) && CONFIG_SPI - /* SPI2 CS0, SCK, SIN, SOUT */ - pinmux_pin_set(portb, 20, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 21, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 22, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 23, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - - -#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm0), nxp_kinetis_ftm_pwm, okay) && CONFIG_PWM - /* FlexTimer0 Channels for FMU (servo control) */ - /* fmu ch1 */ - pinmux_pin_set(portc, 1, PORT_PCR_MUX(kPORT_MuxAlt4)); - /* fmu ch2 */ - pinmux_pin_set(porta, 4, PORT_PCR_MUX(kPORT_MuxAlt3)); - /* fmu ch3 */ - pinmux_pin_set(portd, 4, PORT_PCR_MUX(kPORT_MuxAlt4)); - /* fmu ch4 */ - pinmux_pin_set(portd, 5, PORT_PCR_MUX(kPORT_MuxAlt4)); -#endif - -#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm, okay) && CONFIG_PWM - /* FlexTimer3 Channels for PWM controlled RGB light and FMU (servo control) */ - /* red */ - pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAlt4)); - /* green */ - pinmux_pin_set(portc, 9, PORT_PCR_MUX(kPORT_MuxAlt3)); - /* blue */ - pinmux_pin_set(portc, 8, PORT_PCR_MUX(kPORT_MuxAlt3)); - /* fmu ch5 */ - pinmux_pin_set(porte, 11, PORT_PCR_MUX(kPORT_MuxAlt6)); - /* fmu ch6 */ - pinmux_pin_set(porte, 12, PORT_PCR_MUX(kPORT_MuxAlt6)); -#endif - - return 0; -} - -SYS_INIT(rddrone_fmuk66_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/boards/arm/rddrone_fmuk66/rddrone_fmuk66-pinctrl.dtsi b/boards/arm/rddrone_fmuk66/rddrone_fmuk66-pinctrl.dtsi index 49383e232bbbc..56d676239b8cc 100644 --- a/boards/arm/rddrone_fmuk66/rddrone_fmuk66-pinctrl.dtsi +++ b/boards/arm/rddrone_fmuk66/rddrone_fmuk66-pinctrl.dtsi @@ -1,6 +1,6 @@ /* - * NOTE: Autogenerated file by kinetis_signal2dts.py - * for MK66FN2M0VMD18/signal_configuration.xml + * NOTE: Autogenerated file by kinetis_cfg_utils.py + * for MK66FN2M0VMD18/signal_configuration.xml * * Copyright (c) 2022, NXP * SPDX-License-Identifier: Apache-2.0 @@ -76,6 +76,7 @@ }; }; + /* conflicts with UART2 */ ftm3_default: ftm3_default { group0 { pinmux = , @@ -168,6 +169,7 @@ }; }; + /* conflicts with FTM3 */ uart2_default: uart2_default { group0 { pinmux = , diff --git a/boards/arm/rddrone_fmuk66/rddrone_fmuk66_defconfig b/boards/arm/rddrone_fmuk66/rddrone_fmuk66_defconfig index 759bbd8276488..e1cc7a5e8e0e9 100644 --- a/boards/arm/rddrone_fmuk66/rddrone_fmuk66_defconfig +++ b/boards/arm/rddrone_fmuk66/rddrone_fmuk66_defconfig @@ -8,7 +8,6 @@ CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_GPIO=y CONFIG_PINCTRL=y -CONFIG_PINMUX=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=160000000 CONFIG_OSC_EXTERNAL=y diff --git a/boards/arm/twr_ke18f/CMakeLists.txt b/boards/arm/twr_ke18f/CMakeLists.txt index 77353a23d1d5f..d36febf202d61 100644 --- a/boards/arm/twr_ke18f/CMakeLists.txt +++ b/boards/arm/twr_ke18f/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 -if(CONFIG_PINMUX_MCUX) +if(CONFIG_BOARD_TWR_KE18F_FLEXIO_CLKOUT) zephyr_library() zephyr_library_sources(pinmux.c) endif() diff --git a/boards/arm/twr_ke18f/Kconfig b/boards/arm/twr_ke18f/Kconfig index 6bd7fa0344899..55f834aea2098 100644 --- a/boards/arm/twr_ke18f/Kconfig +++ b/boards/arm/twr_ke18f/Kconfig @@ -10,19 +10,4 @@ config BOARD_TWR_KE18F_FLEXIO_CLKOUT help Enable the CLKOUT signal on FlexIO header pin 7 (PTE10). -config BOARD_TWR_KE18F_SPI_0_PCS2 - bool "Use PTE6 as dedicated SPI_0 PCS2 chip select" - depends on "$(dt_nodelabel_enabled,lpspi0)" - default y - -config BOARD_TWR_KE18F_SPI_1_PCS0 - bool "Use PTD3 as dedicated SPI_1 PCS0 chip select" - depends on "$(dt_nodelabel_enabled,lpspi1)" - default y - -config BOARD_TWR_KE18F_SPI_1_PCS2 - bool "Use PTA16 as dedicated SPI_1 PCS2 chip select" - depends on "$(dt_nodelabel_enabled,lpspi1)" - default y - endif # BOARD_TWR_KE18F diff --git a/boards/arm/twr_ke18f/dts/bindings/nxp,flexio.yaml b/boards/arm/twr_ke18f/dts/bindings/nxp,flexio.yaml new file mode 100644 index 0000000000000..d167e7960cd2b --- /dev/null +++ b/boards/arm/twr_ke18f/dts/bindings/nxp,flexio.yaml @@ -0,0 +1,17 @@ +# Copyright (c) 2022, NXP +# SPDX-License-Identifier: Apache-2.0 + +description: | + NXP FlexIO binding. This binding does not represent a full FlexIO driver, but + declares pinctrl properties, so that the user can MUX pins at the board level + for the FlexIO. + +compatible: "nxp,flexio" + +include: [base.yaml, pinctrl-device.yaml] + +properties: + pinctrl-0: + required: true + pinctrl-names: + required: true diff --git a/boards/arm/twr_ke18f/dts/lpspi0_pcs2.overlay b/boards/arm/twr_ke18f/dts/lpspi0_pcs2.overlay new file mode 100644 index 0000000000000..d43a2a8ea4aa1 --- /dev/null +++ b/boards/arm/twr_ke18f/dts/lpspi0_pcs2.overlay @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2022, NXP + * SPDX-License-Identifier: Apache-2.0 + */ +#include "../twr_ke18f-pinctrl.dtsi" + +&lpspi0 { + pinctrl-0 = <&lpspi0_pcs2>; + pinctrl-names = "default"; +}; diff --git a/boards/arm/twr_ke18f/dts/lpspi1_pcs0.overlay b/boards/arm/twr_ke18f/dts/lpspi1_pcs0.overlay new file mode 100644 index 0000000000000..ecaa6a057c0a1 --- /dev/null +++ b/boards/arm/twr_ke18f/dts/lpspi1_pcs0.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2022, NXP + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "../twr_ke18f-pinctrl.dtsi" + +&lpspi1 { + pinctrl-0 = <&lpspi1_pcs0>; + pinctrl-names = "default"; +}; diff --git a/boards/arm/twr_ke18f/dts/lpspi1_pcs0_pcs2.overlay b/boards/arm/twr_ke18f/dts/lpspi1_pcs0_pcs2.overlay new file mode 100644 index 0000000000000..479b028ffa02d --- /dev/null +++ b/boards/arm/twr_ke18f/dts/lpspi1_pcs0_pcs2.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2022, NXP + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "../twr_ke18f-pinctrl.dtsi" + +&lpspi1 { + pinctrl-0 = <&lpspi1_pcs0_pcs2>; + pinctrl-names = "default"; +}; diff --git a/boards/arm/twr_ke18f/dts/lpspi1_pcs2.overlay b/boards/arm/twr_ke18f/dts/lpspi1_pcs2.overlay new file mode 100644 index 0000000000000..9a80f6d62aa23 --- /dev/null +++ b/boards/arm/twr_ke18f/dts/lpspi1_pcs2.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2022, NXP + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "../twr_ke18f-pinctrl.dtsi" + +&lpspi1 { + pinctrl-0 = <&lpspi1_pcs2>; + pinctrl-names = "default"; +}; diff --git a/boards/arm/twr_ke18f/pinmux.c b/boards/arm/twr_ke18f/pinmux.c index d4a9b5574ca08..a461b1099e378 100644 --- a/boards/arm/twr_ke18f/pinmux.c +++ b/boards/arm/twr_ke18f/pinmux.c @@ -1,140 +1,30 @@ /* * Copyright (c) 2019 Vestas Wind Systems A/S + * Copyright (c) 2022 NXP * * SPDX-License-Identifier: Apache-2.0 */ #include -#include -#include +#include static int twr_ke18f_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused const struct device *porta = - DEVICE_DT_GET(DT_NODELABEL(porta)); - __ASSERT_NO_MSG(device_is_ready(porta)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused const struct device *portd = - DEVICE_DT_GET(DT_NODELABEL(portd)); - __ASSERT_NO_MSG(device_is_ready(portd)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused const struct device *porte = - DEVICE_DT_GET(DT_NODELABEL(porte)); - __ASSERT_NO_MSG(device_is_ready(porte)); -#endif + int err; /* Used by pinctrl functions */ -#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm0), nxp_kinetis_ftm_pwm, okay) && CONFIG_PWM - /* Tri-color LED as PWM */ - pinmux_pin_set(portb, 5, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 15, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 16, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif + /* Declare pin configuration state for flexio pin here */ + PINCTRL_DT_DEFINE(DT_NODELABEL(flexio)); -#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm2), nxp_kinetis_ftm_pwm, okay) && CONFIG_PWM - /* PWM output on J20 pin 5 */ - pinmux_pin_set(porte, 15, PORT_PCR_MUX(kPORT_MuxAlt4)); -#endif - -#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(ftm3), nxp_kinetis_ftm_pwm, okay) && CONFIG_PWM - /* User LEDs as PWM */ - pinmux_pin_set(portc, 10, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 11, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 12, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portc, 13, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(pwt), okay) && CONFIG_PWM_CAPTURE - /* PWM capture input on J20 pin 8 */ - pinmux_pin_set(porte, 11, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpuart0), okay) && CONFIG_SERIAL - /* UART0 RX, TX */ - pinmux_pin_set(portb, 0, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 1, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpspi0), okay) && CONFIG_SPI - /* SPI0 SCK, SIN, SOUT */ - pinmux_pin_set(porte, 0, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(porte, 1, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(porte, 2, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif -#ifdef CONFIG_BOARD_TWR_KE18F_SPI_0_PCS2 - /* SPI0 PCS2 */ - pinmux_pin_set(porte, 6, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpspi1), okay) && CONFIG_SPI - /* SPI1 SCK, SIN, SOUT */ - pinmux_pin_set(portd, 0, PORT_PCR_MUX(kPORT_MuxAlt3)); - pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAlt3)); - pinmux_pin_set(portd, 2, PORT_PCR_MUX(kPORT_MuxAlt3)); -#endif -#ifdef CONFIG_BOARD_TWR_KE18F_SPI_1_PCS0 - /* SPI1 PCS0 */ - pinmux_pin_set(portd, 3, PORT_PCR_MUX(kPORT_MuxAlt3)); -#endif -#ifdef CONFIG_BOARD_TWR_KE18F_SPI_1_PCS2 - /* SPI1 PCS2 */ - pinmux_pin_set(porta, 16, PORT_PCR_MUX(kPORT_MuxAlt3)); -#endif - -#ifdef CONFIG_BOARD_TWR_KE18F_FLEXIO_CLKOUT - /* CLKOUT */ - pinmux_pin_set(porte, 10, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpi2c0), okay) && CONFIG_I2C - /* LPI2C0 SCL, SDA - FXOS8700 */ - pinmux_pin_set(porta, 3, PORT_PCR_MUX(kPORT_MuxAlt3)); - pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAlt3)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpi2c1), okay) && CONFIG_I2C - /* LPI2C1 SCL, SDA - Elevator connector */ - pinmux_pin_set(portd, 9, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portd, 8, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(flexcan0), okay) && CONFIG_CAN - /* FlexCAN0 RX, TX */ - pinmux_pin_set(porte, 4, PORT_PCR_MUX(kPORT_MuxAlt5)); - pinmux_pin_set(porte, 5, PORT_PCR_MUX(kPORT_MuxAlt5)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(adc0), okay) && CONFIG_ADC - /* Thermistor A, B */ - pinmux_pin_set(porta, 0, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); - pinmux_pin_set(porta, 1, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); -#endif - -#if (DT_NODE_HAS_STATUS(DT_NODELABEL(adc0), okay) && CONFIG_ADC) || \ - (DT_NODE_HAS_STATUS(DT_NODELABEL(cmp2), okay) && CONFIG_MCUX_ACMP) - /* Potentiometer */ - pinmux_pin_set(portc, 14, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(dac0), okay) && CONFIG_DAC - pinmux_pin_set(porte, 9, PORT_PCR_MUX(kPORT_PinDisabledOrAnalog)); -#endif + /* Apply pinctrl state directly, since there is no flexio device driver */ + err = pinctrl_apply_state(PINCTRL_DT_DEV_CONFIG_GET(DT_NODELABEL(flexio)), + PINCTRL_STATE_DEFAULT); + if (err) { + return err; + } return 0; } -SYS_INIT(twr_ke18f_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); +SYS_INIT(twr_ke18f_pinmux_init, PRE_KERNEL_1, 0); diff --git a/boards/arm/twr_ke18f/twr_ke18f-pinctrl.dtsi b/boards/arm/twr_ke18f/twr_ke18f-pinctrl.dtsi index 18e95254b9033..4e8f4849f75e7 100644 --- a/boards/arm/twr_ke18f/twr_ke18f-pinctrl.dtsi +++ b/boards/arm/twr_ke18f/twr_ke18f-pinctrl.dtsi @@ -1,6 +1,6 @@ /* - * NOTE: Autogenerated file by kinetis_signal2dts.py - * for MKE18F512VLL16/signal_configuration.xml + * NOTE: Autogenerated file by kinetis_cfg_utils.py + * for MKE18F512VLL16/signal_configuration.xml * * Copyright (c) 2022, NXP * SPDX-License-Identifier: Apache-2.0 @@ -37,6 +37,15 @@ }; }; + /* Route FLEXIO CLOCKOUT pin */ + flexio_clockout: flexio_clockout { + group0 { + pinmux = ; + drive-strength = "low"; + slew-rate = "slow"; + }; + }; + ftm0_default: ftm0_default { group0 { pinmux = , @@ -77,6 +86,17 @@ }; lpspi0_default: lpspi0_default { + group0 { + pinmux = , + , + ; + drive-strength = "low"; + slew-rate = "slow"; + }; + }; + + /* Enable PCS2 for SPI0 */ + lpspi0_pcs2: lpspi0_pcs2 { group0 { pinmux = , , @@ -89,32 +109,55 @@ lpspi1_default: lpspi1_default { group0 { - pinmux = ; + pinmux = , + , + ; drive-strength = "low"; - bias-pull-up; slew-rate = "slow"; }; - group1 { + }; + + /* select PCS0 for lpspi1 */ + lpspi1_pcs0: lpspi1_pcs0 { + group0 { pinmux = , , - ; + , + ; drive-strength = "low"; slew-rate = "slow"; }; }; - lpuart0_default: lpuart0_default { + /* select PCS0 and PCS2 for lpspi1 */ + lpspi1_pcs0_pcs2: lpspi1_pcs0_pcs2 { group0 { - pinmux = , - ; + pinmux = , + , + , + , + ; drive-strength = "low"; slew-rate = "slow"; }; }; - sim0_default: sim0_default { + /* select PCS2 for lpspi1 */ + lpspi1_pcs2: lpspi1_pcs2 { group0 { - pinmux = ; + pinmux = , + , + , + ; + drive-strength = "low"; + slew-rate = "slow"; + }; + }; + + lpuart0_default: lpuart0_default { + group0 { + pinmux = , + ; drive-strength = "low"; slew-rate = "slow"; }; diff --git a/boards/arm/twr_ke18f/twr_ke18f.dts b/boards/arm/twr_ke18f/twr_ke18f.dts index 280767419491e..b5a9e572b5c8d 100644 --- a/boards/arm/twr_ke18f/twr_ke18f.dts +++ b/boards/arm/twr_ke18f/twr_ke18f.dts @@ -121,6 +121,13 @@ gpios = <&gpiod 6 GPIO_ACTIVE_LOW>; }; }; + + flexio: flexio@4005a000 { + reg = <0x4005a000 0x1000>; + compatible = "nxp,flexio"; + pinctrl-0 = <&flexio_clockout>; + pinctrl-names = "default"; + }; }; &cpu0 { @@ -140,8 +147,6 @@ &sim { clkout-source = <1>; clkout-divider = <0>; - pinctrl-0 = <&sim0_default>; - pinctrl-names = "default"; }; &scg { diff --git a/boards/arm/twr_ke18f/twr_ke18f_defconfig b/boards/arm/twr_ke18f/twr_ke18f_defconfig index 41446449ea7d0..05247818cabeb 100644 --- a/boards/arm/twr_ke18f/twr_ke18f_defconfig +++ b/boards/arm/twr_ke18f/twr_ke18f_defconfig @@ -7,7 +7,7 @@ CONFIG_SERIAL=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y CONFIG_UART_INTERRUPT_DRIVEN=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_GPIO=y # Enable MPU diff --git a/boards/arm/twr_kv58f220m/CMakeLists.txt b/boards/arm/twr_kv58f220m/CMakeLists.txt index 77353a23d1d5f..9881313609aae 100644 --- a/boards/arm/twr_kv58f220m/CMakeLists.txt +++ b/boards/arm/twr_kv58f220m/CMakeLists.txt @@ -1,6 +1 @@ # SPDX-License-Identifier: Apache-2.0 - -if(CONFIG_PINMUX_MCUX) - zephyr_library() - zephyr_library_sources(pinmux.c) -endif() diff --git a/boards/arm/twr_kv58f220m/pinmux.c b/boards/arm/twr_kv58f220m/pinmux.c deleted file mode 100644 index ca5031247d71e..0000000000000 --- a/boards/arm/twr_kv58f220m/pinmux.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2019 SEAL AG - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -static int twr_kv58f220m_pinmux_init(const struct device *dev) -{ - ARG_UNUSED(dev); - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused const struct device *porta = - DEVICE_DT_GET(DT_NODELABEL(porta)); - __ASSERT_NO_MSG(device_is_ready(porta)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused const struct device *portd = - DEVICE_DT_GET(DT_NODELABEL(portd)); - __ASSERT_NO_MSG(device_is_ready(portd)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused const struct device *porte = - DEVICE_DT_GET(DT_NODELABEL(porte)); - __ASSERT_NO_MSG(device_is_ready(porte)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C - /* I2C1 SCL, SDA */ - pinmux_pin_set(portd, 8, PORT_PCR_MUX(kPORT_MuxAlt2) - | PORT_PCR_ODE_MASK); - pinmux_pin_set(portd, 9, PORT_PCR_MUX(kPORT_MuxAlt2) - | PORT_PCR_ODE_MASK); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart0), okay) && CONFIG_SERIAL - /* UART0 RX, TX */ - pinmux_pin_set(portb, 0, PORT_PCR_MUX(kPORT_MuxAlt7)); - pinmux_pin_set(portb, 1, PORT_PCR_MUX(kPORT_MuxAlt7)); -#endif - - return 0; -} - -SYS_INIT(twr_kv58f220m_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/boards/arm/twr_kv58f220m/twr_kv58f220m_defconfig b/boards/arm/twr_kv58f220m/twr_kv58f220m_defconfig index 99619a0bec3a7..9ad426f1edfc9 100644 --- a/boards/arm/twr_kv58f220m/twr_kv58f220m_defconfig +++ b/boards/arm/twr_kv58f220m/twr_kv58f220m_defconfig @@ -8,7 +8,7 @@ CONFIG_SERIAL=y CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y CONFIG_UART_INTERRUPT_DRIVEN=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_GPIO=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=237500000 diff --git a/boards/arm/usb_kw24d512/CMakeLists.txt b/boards/arm/usb_kw24d512/CMakeLists.txt index 77353a23d1d5f..9881313609aae 100644 --- a/boards/arm/usb_kw24d512/CMakeLists.txt +++ b/boards/arm/usb_kw24d512/CMakeLists.txt @@ -1,6 +1 @@ # SPDX-License-Identifier: Apache-2.0 - -if(CONFIG_PINMUX_MCUX) - zephyr_library() - zephyr_library_sources(pinmux.c) -endif() diff --git a/boards/arm/usb_kw24d512/pinmux.c b/boards/arm/usb_kw24d512/pinmux.c deleted file mode 100644 index fd23091163f9a..0000000000000 --- a/boards/arm/usb_kw24d512/pinmux.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2017 Phytec Messtechnik GmbH - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include - -static int usb_kw24d512_pinmux_init(const struct device *dev) -{ - ARG_UNUSED(dev); - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused const struct device *porta = - DEVICE_DT_GET(DT_NODELABEL(porta)); - __ASSERT_NO_MSG(device_is_ready(porta)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused const struct device *portb = - DEVICE_DT_GET(DT_NODELABEL(portb)); - __ASSERT_NO_MSG(device_is_ready(portb)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused const struct device *portc = - DEVICE_DT_GET(DT_NODELABEL(portc)); - __ASSERT_NO_MSG(device_is_ready(portc)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused const struct device *portd = - DEVICE_DT_GET(DT_NODELABEL(portd)); - __ASSERT_NO_MSG(device_is_ready(portd)); -#endif -#if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused const struct device *porte = - DEVICE_DT_GET(DT_NODELABEL(porte)); - __ASSERT_NO_MSG(device_is_ready(porte)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart0), okay) && CONFIG_SERIAL - /* UART0 RX, TX */ - pinmux_pin_set(porta, 1, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - -#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI - /* SPI1 CS0, SCK, SOUT, SIN */ - pinmux_pin_set(portb, 10, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 11, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 16, PORT_PCR_MUX(kPORT_MuxAlt2)); - pinmux_pin_set(portb, 17, PORT_PCR_MUX(kPORT_MuxAlt2)); -#endif - - return 0; -} - -SYS_INIT(usb_kw24d512_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/boards/arm/usb_kw24d512/usb_kw24d512_defconfig b/boards/arm/usb_kw24d512/usb_kw24d512_defconfig index 6e21588376f15..79681927f275a 100644 --- a/boards/arm/usb_kw24d512/usb_kw24d512_defconfig +++ b/boards/arm/usb_kw24d512/usb_kw24d512_defconfig @@ -9,6 +9,6 @@ CONFIG_USE_SEGGER_RTT=y CONFIG_SERIAL=y CONFIG_CORTEX_M_SYSTICK=y CONFIG_GPIO=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=48000000 CONFIG_OSC_EXTERNAL=y diff --git a/drivers/adc/Kconfig.mcux b/drivers/adc/Kconfig.mcux index 23415ee2d3abb..6e80b068e6984 100644 --- a/drivers/adc/Kconfig.mcux +++ b/drivers/adc/Kconfig.mcux @@ -6,12 +6,14 @@ config ADC_MCUX_ADC12 bool "MCUX ADC12 driver" depends on HAS_MCUX_ADC12 + select PINCTRL help Enable the MCUX ADC12 driver. config ADC_MCUX_ADC16 bool "MCUX ADC16 driver" depends on HAS_MCUX_ADC16 + select PINCTRL help Enable the MCUX ADC16 driver. diff --git a/drivers/adc/adc_mcux_adc12.c b/drivers/adc/adc_mcux_adc12.c index b87ff9bd38ecb..60f8da329dc2f 100644 --- a/drivers/adc/adc_mcux_adc12.c +++ b/drivers/adc/adc_mcux_adc12.c @@ -11,6 +11,7 @@ #include #include +#include #define LOG_LEVEL CONFIG_ADC_LOG_LEVEL #include @@ -26,6 +27,7 @@ struct mcux_adc12_config { adc12_reference_voltage_source_t ref_src; uint32_t sample_clk_count; void (*irq_config_func)(const struct device *dev); + const struct pinctrl_dev_config *pincfg; }; struct mcux_adc12_data { @@ -216,6 +218,7 @@ static int mcux_adc12_init(const struct device *dev) struct mcux_adc12_data *data = dev->data; ADC_Type *base = config->base; adc12_config_t adc_config; + int err; ADC12_GetDefaultConfig(&adc_config); @@ -233,6 +236,11 @@ static int mcux_adc12_init(const struct device *dev) config->irq_config_func(dev); data->dev = dev; + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err) { + return err; + } + adc_context_unlock_unconditionally(&data->ctx); return 0; @@ -261,6 +269,8 @@ static const struct adc_driver_api mcux_adc12_driver_api = { #define ACD12_MCUX_INIT(n) \ static void mcux_adc12_config_func_##n(const struct device *dev); \ \ + PINCTRL_DT_INST_DEFINE(n); \ + \ ASSERT_WITHIN_RANGE(DT_INST_PROP(n, clk_source), 0, 3, \ "Invalid clock source"); \ ASSERT_ADC12_CLK_DIV_VALID(DT_INST_PROP(n, clk_divider), \ @@ -275,6 +285,7 @@ static const struct adc_driver_api mcux_adc12_driver_api = { .ref_src = ADC12_REF_SRC(n), \ .sample_clk_count = DT_INST_PROP(n, sample_time), \ .irq_config_func = mcux_adc12_config_func_##n, \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ }; \ \ static struct mcux_adc12_data mcux_adc12_data_##n = { \ diff --git a/drivers/adc/adc_mcux_adc16.c b/drivers/adc/adc_mcux_adc16.c index e85b6e24135cb..c1fb624ffda58 100644 --- a/drivers/adc/adc_mcux_adc16.c +++ b/drivers/adc/adc_mcux_adc16.c @@ -8,6 +8,7 @@ #include #include +#include #ifdef CONFIG_ADC_MCUX_ADC16_ENABLE_EDMA #include #include @@ -42,6 +43,7 @@ struct mcux_adc16_config { bool channel_mux_b; bool high_speed; /* ADC enable high speed mode*/ bool continuous_convert; /* ADC enable continuous convert*/ + const struct pinctrl_dev_config *pincfg; }; #ifdef CONFIG_ADC_MCUX_ADC16_ENABLE_EDMA @@ -322,6 +324,7 @@ static int mcux_adc16_init(const struct device *dev) struct mcux_adc16_data *data = dev->data; ADC_Type *base = config->base; adc16_config_t adc_config; + int err; LOG_DBG("init adc"); ADC16_GetDefaultConfig(&adc_config); @@ -366,6 +369,11 @@ static int mcux_adc16_init(const struct device *dev) ADC16_EnableHardwareTrigger(base, false); } + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err != 0) { + return err; + } + data->dev = dev; /* dma related init */ @@ -427,30 +435,57 @@ static const struct adc_driver_api mcux_adc16_driver_api = { }; #ifdef CONFIG_ADC_MCUX_ADC16_ENABLE_EDMA +#define ADC16_MCUX_EDMA_INIT(n) \ + .hw_trigger_src = \ + DT_INST_PROP_OR(n, hw_trigger_src, 0), \ + .dma_slot = DT_INST_DMAS_CELL_BY_IDX(n, 0, source), \ + .trg_offset = DT_INST_CLOCKS_CELL_BY_IDX(n, 0, offset), \ + .trg_bits = DT_INST_CLOCKS_CELL_BY_IDX(n, 0, bits), \ + .alt_offset = DT_INST_CLOCKS_CELL_BY_IDX(n, 1, offset), \ + .alt_bits = DT_INST_CLOCKS_CELL_BY_IDX(n, 1, bits), +#define ADC16_MCUX_EDMA_DATA(n) \ + .dev_dma = DEVICE_DT_GET(DT_INST_DMAS_CTLR_BY_NAME(n, adc##n)) +#define ADC16_MCUX_IRQ_INIT(n) +#define ADC16_MCUX_IRQ_DECLARE(n) +#else +#define ADC16_MCUX_EDMA_INIT(n) +#define ADC16_MCUX_EDMA_DATA(n) +#define ADC16_MCUX_IRQ_INIT(n) .irq_config_func = mcux_adc16_config_func_##n, +#define ADC16_MCUX_IRQ_DECLARE(n) \ + static void mcux_adc16_config_func_##n(const struct device *dev) \ + { \ + IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), \ + mcux_adc16_isr, \ + DEVICE_DT_INST_GET(n), 0); \ + \ + irq_enable(DT_INST_IRQN(n)); \ + } +#endif /* CONFIG_ADC_MCUX_ADC16_ENABLE_EDMA */ + + #define ACD16_MCUX_INIT(n) \ + ADC16_MCUX_IRQ_DECLARE(n) \ + PINCTRL_DT_INST_DEFINE(n); \ + \ static const struct mcux_adc16_config mcux_adc16_config_##n = { \ .base = (ADC_Type *)DT_INST_REG_ADDR(n), \ + ADC16_MCUX_IRQ_INIT(n) \ .channel_mux_b = DT_INST_PROP(n, channel_mux_b), \ .clk_source = DT_INST_PROP_OR(n, clk_source, 0), \ .long_sample = DT_INST_PROP_OR(n, long_sample, 0), \ .high_speed = DT_INST_PROP(n, high_speed), \ .periodic_trigger = DT_INST_PROP(n, periodic_trigger), \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ .continuous_convert = \ DT_INST_PROP(n, continuous_convert), \ - .hw_trigger_src = \ - DT_INST_PROP_OR(n, hw_trigger_src, 0), \ - .dma_slot = DT_INST_DMAS_CELL_BY_IDX(n, 0, source), \ - .trg_offset = DT_INST_CLOCKS_CELL_BY_IDX(n, 0, offset), \ - .trg_bits = DT_INST_CLOCKS_CELL_BY_IDX(n, 0, bits), \ - .alt_offset = DT_INST_CLOCKS_CELL_BY_IDX(n, 1, offset), \ - .alt_bits = DT_INST_CLOCKS_CELL_BY_IDX(n, 1, bits), \ + ADC16_MCUX_EDMA_INIT(n) \ }; \ \ static struct mcux_adc16_data mcux_adc16_data_##n = { \ ADC_CONTEXT_INIT_TIMER(mcux_adc16_data_##n, ctx), \ ADC_CONTEXT_INIT_LOCK(mcux_adc16_data_##n, ctx), \ ADC_CONTEXT_INIT_SYNC(mcux_adc16_data_##n, ctx), \ - .dev_dma = DEVICE_DT_GET(DT_INST_DMAS_CTLR_BY_NAME(n, adc##n)), \ + ADC16_MCUX_EDMA_DATA(n) \ }; \ \ DEVICE_DT_INST_DEFINE(n, &mcux_adc16_init, \ @@ -459,42 +494,6 @@ static const struct adc_driver_api mcux_adc16_driver_api = { &mcux_adc16_config_##n, \ POST_KERNEL, \ CONFIG_ADC_INIT_PRIORITY, \ - &mcux_adc16_driver_api); -#else -#define ACD16_MCUX_INIT(n) \ - static void mcux_adc16_config_func_##n(const struct device *dev); \ - static const struct mcux_adc16_config mcux_adc16_config_##n = { \ - .base = (ADC_Type *)DT_INST_REG_ADDR(n), \ - .irq_config_func = mcux_adc16_config_func_##n, \ - .channel_mux_b = DT_INST_PROP(n, channel_mux_b), \ - .clk_source = DT_INST_PROP_OR(n, clk_source, 0), \ - .long_sample = DT_INST_PROP_OR(n, long_sample, 0), \ - .high_speed = DT_INST_PROP(n, high_speed), \ - .continuous_convert = \ - DT_INST_PROP(n, continuous_convert), \ - }; \ - static struct mcux_adc16_data mcux_adc16_data_##n = { \ - ADC_CONTEXT_INIT_TIMER(mcux_adc16_data_##n, ctx), \ - ADC_CONTEXT_INIT_LOCK(mcux_adc16_data_##n, ctx), \ - ADC_CONTEXT_INIT_SYNC(mcux_adc16_data_##n, ctx), \ - }; \ - \ - DEVICE_DT_INST_DEFINE(n, &mcux_adc16_init, \ - NULL, \ - &mcux_adc16_data_##n, \ - &mcux_adc16_config_##n, \ - POST_KERNEL, \ - CONFIG_ADC_INIT_PRIORITY, \ - &mcux_adc16_driver_api); \ - \ - static void mcux_adc16_config_func_##n(const struct device *dev) \ - { \ - IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), \ - mcux_adc16_isr, \ - DEVICE_DT_INST_GET(n), 0); \ - \ - irq_enable(DT_INST_IRQN(n)); \ - } -#endif + &mcux_adc16_driver_api); \ DT_INST_FOREACH_STATUS_OKAY(ACD16_MCUX_INIT) diff --git a/drivers/can/can_mcux_flexcan.c b/drivers/can/can_mcux_flexcan.c index e0959ae442ee4..88215fc0917fd 100644 --- a/drivers/can/can_mcux_flexcan.c +++ b/drivers/can/can_mcux_flexcan.c @@ -16,6 +16,10 @@ #include #include +#ifdef CONFIG_PINCTRL +#include +#endif + LOG_MODULE_REGISTER(can_mcux_flexcan, CONFIG_CAN_LOG_LEVEL); #define SP_IS_SET(inst) DT_INST_NODE_HAS_PROP(inst, sample_point) || @@ -87,6 +91,9 @@ struct mcux_flexcan_config { void (*irq_config_func)(const struct device *dev); const struct device *phy; uint32_t max_bitrate; +#ifdef CONFIG_PINCTRL + const struct pinctrl_dev_config *pincfg; +#endif }; struct mcux_flexcan_rx_callback { @@ -724,6 +731,13 @@ static int mcux_flexcan_init(const struct device *dev) } } +#ifdef CONFIG_PINCTRL + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err != 0) { + return err; + } +#endif + err = mcux_flexcan_set_mode(dev, CAN_NORMAL_MODE); if (err) { return err; @@ -797,7 +811,18 @@ static const struct can_driver_api mcux_flexcan_driver_api = { COND_CODE_1(DT_INST_IRQ_HAS_NAME(id, name), \ (FLEXCAN_IRQ_CODE(id, name)), ()) +#ifdef CONFIG_PINCTRL +#define FLEXCAN_PINCTRL_DEFINE(id) PINCTRL_DT_INST_DEFINE(id); +#define FLEXCAN_PINCTRL_INIT(id) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(id), +#else +#define FLEXCAN_PINCTRL_DEFINE(id) +#define FLEXCAN_PINCTRL_INIT(id) +#endif /* CONFIG_PINCTRL */ + + #define FLEXCAN_DEVICE_INIT_MCUX(id) \ + FLEXCAN_PINCTRL_DEFINE(id) \ + \ static void mcux_flexcan_irq_config_##id(const struct device *dev); \ \ static const struct mcux_flexcan_config mcux_flexcan_config_##id = { \ @@ -815,6 +840,7 @@ static const struct can_driver_api mcux_flexcan_driver_api = { .irq_config_func = mcux_flexcan_irq_config_##id, \ .phy = DEVICE_DT_GET_OR_NULL(DT_INST_PHANDLE(id, phys)),\ .max_bitrate = DT_INST_CAN_TRANSCEIVER_MAX_BITRATE(id, 1000000), \ + FLEXCAN_PINCTRL_INIT(id) \ }; \ \ static struct mcux_flexcan_data mcux_flexcan_data_##id; \ diff --git a/drivers/dac/Kconfig.mcux b/drivers/dac/Kconfig.mcux index fe66b5a475eb9..21269c717fe9f 100644 --- a/drivers/dac/Kconfig.mcux +++ b/drivers/dac/Kconfig.mcux @@ -13,6 +13,7 @@ config DAC_MCUX_DAC config DAC_MCUX_DAC32 bool "NXP Kinetis MCUX DAC32 driver" depends on HAS_MCUX_DAC32 + select PINCTRL help Enable the driver for the NXP Kinetis MCUX DAC32. diff --git a/drivers/dac/dac_mcux_dac32.c b/drivers/dac/dac_mcux_dac32.c index f3420386ed1ea..ccd2a929dbdd4 100644 --- a/drivers/dac/dac_mcux_dac32.c +++ b/drivers/dac/dac_mcux_dac32.c @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -19,6 +20,7 @@ struct mcux_dac32_config { dac32_reference_voltage_source_t reference; bool buffered; bool low_power; + const struct pinctrl_dev_config *pincfg; }; struct mcux_dac32_data { @@ -89,7 +91,9 @@ static int mcux_dac32_write_value(const struct device *dev, uint8_t channel, static int mcux_dac32_init(const struct device *dev) { - return 0; + const struct mcux_dac32_config *config = dev->config; + + return pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); } static const struct dac_driver_api mcux_dac32_driver_api = { @@ -103,12 +107,15 @@ static const struct dac_driver_api mcux_dac32_driver_api = { #define MCUX_DAC32_INIT(n) \ static struct mcux_dac32_data mcux_dac32_data_##n; \ \ + PINCTRL_DT_INST_DEFINE(n); \ + \ static const struct mcux_dac32_config mcux_dac32_config_##n = { \ .base = (DAC_Type *)DT_INST_REG_ADDR(n), \ .reference = \ TO_DAC32_VREF_SRC(DT_INST_PROP(n, voltage_reference)), \ .buffered = DT_INST_PROP(n, buffered), \ .low_power = DT_INST_PROP(n, low_power_mode), \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ }; \ \ DEVICE_DT_INST_DEFINE(n, mcux_dac32_init, NULL, \ diff --git a/drivers/ethernet/eth_mcux.c b/drivers/ethernet/eth_mcux.c index 1ae1b42ac7339..fd55bdb8077f9 100644 --- a/drivers/ethernet/eth_mcux.c +++ b/drivers/ethernet/eth_mcux.c @@ -49,6 +49,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include #endif #include +#if defined(CONFIG_PINCTRL) +#include +#endif #include "eth.h" @@ -209,6 +212,9 @@ struct eth_context { struct k_mutex rx_frame_buf_mutex; uint8_t *tx_frame_buf; /* Max MTU + ethernet header */ uint8_t *rx_frame_buf; /* Max MTU + ethernet header */ +#if defined(CONFIG_PINCTRL) + const struct pinctrl_dev_config *pincfg; +#endif }; /* Use ENET_FRAME_MAX_VLANFRAMELEN for VLAN frame size @@ -1092,6 +1098,9 @@ static void eth_mcux_init(const struct device *dev) static int eth_init(const struct device *dev) { struct eth_context *context = dev->data; +#if defined(CONFIG_PINCTRL) + int err; +#endif #if defined(CONFIG_NET_POWER_MANAGEMENT) const uint32_t inst = ENET_GetInstance(context->base); @@ -1139,6 +1148,13 @@ static int eth_init(const struct device *dev) context->mac_addr[2], context->mac_addr[3], context->mac_addr[4], context->mac_addr[5]); +#if defined(CONFIG_PINCTRL) + err = pinctrl_apply_state(context->pincfg, PINCTRL_STATE_DEFAULT); + if (err) { + return err; + } +#endif /* CONFIG_PINCTRL */ + return 0; } @@ -1505,9 +1521,19 @@ static void eth_mcux_err_isr(const struct device *dev) #endif #define ETH_MCUX_MAC_ADDR_TO_BOOL(n) ETH_MCUX_MAC_ADDR_TO_BOOL_##n +#if defined(CONFIG_PINCTRL) +#define ETH_MCUX_PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n); +#define ETH_MCUX_PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), +#else +#define ETH_MCUX_PINCTRL_DEFINE(n) +#define ETH_MCUX_PINCTRL_INIT(n) +#endif + #define ETH_MCUX_INIT(n) \ ETH_MCUX_GEN_MAC(n) \ \ + ETH_MCUX_PINCTRL_DEFINE(n) \ + \ static void eth##n##_config_func(void); \ static NOCACHE uint8_t \ tx_enet_frame_##n##_buf[NET_ETH_MAX_FRAME_SIZE]; \ @@ -1531,6 +1557,7 @@ static void eth_mcux_err_isr(const struct device *dev) .phy_handle = ð##n##_phy_handle, \ .tx_frame_buf = tx_enet_frame_##n##_buf, \ .rx_frame_buf = rx_enet_frame_##n##_buf, \ + ETH_MCUX_PINCTRL_INIT(n) \ ETH_MCUX_MAC_ADDR(n) \ ETH_MCUX_POWER(n) \ }; \ @@ -1592,9 +1619,24 @@ DT_INST_FOREACH_STATUS_OKAY(ETH_MCUX_INIT) #if defined(CONFIG_PTP_CLOCK_MCUX) struct ptp_context { struct eth_context *eth_context; +#if defined(CONFIG_PINCTRL) + const struct pinctrl_dev_config *pincfg; +#endif /* CONFIG_PINCTRL */ }; -static struct ptp_context ptp_mcux_0_context; +#if defined(CONFIG_PINCTRL) +#define ETH_MCUX_PTP_PINCTRL_DEFINE(n) PINCTRL_DT_DEFINE(n); +#define ETH_MCUX_PTP_PINCTRL_INIT(n) .pincfg = PINCTRL_DT_DEV_CONFIG_GET(n), +#else +#define ETH_MCUX_PTP_PINCTRL_DEFINE(n) +#define ETH_MCUX_PTP_PINCTRL_INIT(n) +#endif /* CONFIG_PINCTRL */ + +ETH_MCUX_PTP_PINCTRL_DEFINE(DT_NODELABEL(ptp)) + +static struct ptp_context ptp_mcux_0_context = { + ETH_MCUX_PTP_PINCTRL_INIT(DT_NODELABEL(ptp)) +}; static int ptp_clock_mcux_set(const struct device *dev, struct net_ptp_time *tm) @@ -1716,6 +1758,14 @@ static int ptp_mcux_init(const struct device *port) const struct device *eth_dev = DEVICE_DT_GET(DT_NODELABEL(enet)); struct eth_context *context = eth_dev->data; struct ptp_context *ptp_context = port->data; +#if defined(CONFIG_PINCTRL) + int err; + + err = pinctrl_apply_state(ptp_context->pincfg, PINCTRL_STATE_DEFAULT); + if (err) { + return err; + } +#endif /* CONFIG_PINCTRL */ context->ptp_clock = port; ptp_context->eth_context = context; diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index 9ee860bb41a51..cbe32fe56860d 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -91,6 +91,7 @@ config I2C_SAM_TWI config I2C_MCUX bool "MCUX I2C driver" depends on HAS_MCUX + select PINCTRL help Enable the mcux I2C driver. diff --git a/drivers/i2c/i2c_mcux.c b/drivers/i2c/i2c_mcux.c index 40c070b49a4d3..d2e16d549f43b 100644 --- a/drivers/i2c/i2c_mcux.c +++ b/drivers/i2c/i2c_mcux.c @@ -13,6 +13,8 @@ #include #include +#include + #include LOG_MODULE_REGISTER(i2c_mcux); @@ -26,6 +28,7 @@ struct i2c_mcux_config { clock_name_t clock_source; void (*irq_config_func)(const struct device *dev); uint32_t bitrate; + const struct pinctrl_dev_config *pincfg; }; struct i2c_mcux_data { @@ -199,6 +202,11 @@ static int i2c_mcux_init(const struct device *dev) bitrate_cfg = i2c_map_dt_bitrate(config->bitrate); + error = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (error) { + return error; + } + error = i2c_mcux_configure(dev, I2C_MODE_MASTER | bitrate_cfg); if (error) { return error; @@ -215,6 +223,8 @@ static const struct i2c_driver_api i2c_mcux_driver_api = { }; #define I2C_DEVICE_INIT_MCUX(n) \ + PINCTRL_DT_INST_DEFINE(n); \ + \ static void i2c_mcux_config_func_ ## n(const struct device *dev); \ \ static const struct i2c_mcux_config i2c_mcux_config_ ## n = { \ @@ -222,6 +232,7 @@ static const struct i2c_driver_api i2c_mcux_driver_api = { .clock_source = I2C ## n ## _CLK_SRC, \ .irq_config_func = i2c_mcux_config_func_ ## n, \ .bitrate = DT_INST_PROP(n, clock_frequency), \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ }; \ \ static struct i2c_mcux_data i2c_mcux_data_ ## n; \ diff --git a/drivers/i2c/i2c_mcux_lpi2c.c b/drivers/i2c/i2c_mcux_lpi2c.c index 80b979c0228fc..1126af8c01d51 100644 --- a/drivers/i2c/i2c_mcux_lpi2c.c +++ b/drivers/i2c/i2c_mcux_lpi2c.c @@ -12,9 +12,14 @@ #include #include +#ifdef CONFIG_PINCTRL +#include +#endif /* CONFIG_PINCTRL */ + #include LOG_MODULE_REGISTER(mcux_lpi2c); + #include "i2c-priv.h" /* Wait for the duration of 12 bits to detect a NAK after a bus * address scan. (10 appears sufficient, 20% safety factor.) @@ -28,6 +33,9 @@ struct mcux_lpi2c_config { void (*irq_config_func)(const struct device *dev); uint32_t bitrate; uint32_t bus_idle_timeout_ns; +#ifdef CONFIG_PINCTRL + const struct pinctrl_dev_config *pincfg; +#endif /* CONFIG_PINCTRL */ }; struct mcux_lpi2c_data { @@ -233,6 +241,13 @@ static int mcux_lpi2c_init(const struct device *dev) return error; } +#ifdef CONFIG_PINCTRL + error = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (error) { + return error; + } +#endif /* CONFIG_PINCTRL */ + config->irq_config_func(dev); return 0; @@ -243,7 +258,17 @@ static const struct i2c_driver_api mcux_lpi2c_driver_api = { .transfer = mcux_lpi2c_transfer, }; +#ifdef CONFIG_PINCTRL +#define I2C_MCUX_LPI2C_PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n); +#define I2C_MCUX_LPI2C_PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), +#else +#define I2C_MCUX_LPI2C_PINCTRL_DEFINE(n) +#define I2C_MCUX_LPI2C_PINCTRL_INIT(n) +#endif /* CONFIG_PINCTRL */ + #define I2C_MCUX_LPI2C_INIT(n) \ + I2C_MCUX_LPI2C_PINCTRL_DEFINE(n) \ + \ static void mcux_lpi2c_config_func_##n(const struct device *dev); \ \ static const struct mcux_lpi2c_config mcux_lpi2c_config_##n = { \ @@ -253,6 +278,7 @@ static const struct i2c_driver_api mcux_lpi2c_driver_api = { (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\ .irq_config_func = mcux_lpi2c_config_func_##n, \ .bitrate = DT_INST_PROP(n, clock_frequency), \ + I2C_MCUX_LPI2C_PINCTRL_INIT(n) \ .bus_idle_timeout_ns = \ UTIL_AND(DT_INST_NODE_HAS_PROP(n, bus_idle_timeout),\ DT_INST_PROP(n, bus_idle_timeout)), \ diff --git a/drivers/pwm/Kconfig.mcux_ftm b/drivers/pwm/Kconfig.mcux_ftm index febd0c349f4f8..1db289f82b668 100644 --- a/drivers/pwm/Kconfig.mcux_ftm +++ b/drivers/pwm/Kconfig.mcux_ftm @@ -6,6 +6,7 @@ config PWM_MCUX_FTM bool "MCUX FTM PWM driver" depends on HAS_MCUX_FTM + select PINCTRL help Enable support for mcux ftm pwm driver. diff --git a/drivers/pwm/Kconfig.mcux_pwt b/drivers/pwm/Kconfig.mcux_pwt index 6ad2980363337..fd82ef83201a2 100644 --- a/drivers/pwm/Kconfig.mcux_pwt +++ b/drivers/pwm/Kconfig.mcux_pwt @@ -6,5 +6,6 @@ config PWM_MCUX_PWT bool "MCUX PWT PWM capture driver" depends on HAS_MCUX_PWT && CLOCK_CONTROL && PWM_CAPTURE + select PINCTRL help Enable the MCUX Pulse Width Timer (PWT) PWM capture driver. diff --git a/drivers/pwm/Kconfig.mcux_tpm b/drivers/pwm/Kconfig.mcux_tpm index 36571e6d7bc26..07902531273a4 100644 --- a/drivers/pwm/Kconfig.mcux_tpm +++ b/drivers/pwm/Kconfig.mcux_tpm @@ -6,5 +6,6 @@ config PWM_MCUX_TPM bool "MCUX TPM PWM driver" depends on HAS_MCUX_TPM && CLOCK_CONTROL + select PINCTRL help Enable the MCUX TPM PWM driver. diff --git a/drivers/pwm/pwm_mcux_ftm.c b/drivers/pwm/pwm_mcux_ftm.c index b8748d1eb6fc2..da9aad91eeca6 100644 --- a/drivers/pwm/pwm_mcux_ftm.c +++ b/drivers/pwm/pwm_mcux_ftm.c @@ -13,6 +13,7 @@ #include #include #include +#include #define LOG_LEVEL CONFIG_PWM_LOG_LEVEL #include @@ -36,6 +37,7 @@ struct mcux_ftm_config { #ifdef CONFIG_PWM_CAPTURE void (*irq_config_func)(const struct device *dev); #endif /* CONFIG_PWM_CAPTURE */ + const struct pinctrl_dev_config *pincfg; }; struct mcux_ftm_capture_data { @@ -390,6 +392,12 @@ static int mcux_ftm_init(const struct device *dev) ftm_chnl_pwm_config_param_t *channel = data->channel; ftm_config_t ftm_config; int i; + int err; + + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err != 0) { + return err; + } if (config->channel_count > ARRAY_SIZE(data->channel)) { LOG_ERR("Invalid channel count"); @@ -469,10 +477,12 @@ static const struct mcux_ftm_config mcux_ftm_config_##n = { \ .channel_count = FSL_FEATURE_FTM_CHANNEL_COUNTn((FTM_Type *) \ DT_INST_REG_ADDR(n)), \ .mode = kFTM_EdgeAlignedPwm, \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ CAPTURE_INIT \ } #define FTM_DEVICE(n) \ + PINCTRL_DT_INST_DEFINE(n); \ static struct mcux_ftm_data mcux_ftm_data_##n; \ static const struct mcux_ftm_config mcux_ftm_config_##n; \ DEVICE_DT_INST_DEFINE(n, &mcux_ftm_init, \ diff --git a/drivers/pwm/pwm_mcux_pwt.c b/drivers/pwm/pwm_mcux_pwt.c index 92ff84e780677..fde5830ce9d6f 100644 --- a/drivers/pwm/pwm_mcux_pwt.c +++ b/drivers/pwm/pwm_mcux_pwt.c @@ -12,6 +12,7 @@ #include #include #include +#include #include LOG_MODULE_REGISTER(pwm_mcux_pwt, CONFIG_PWM_LOG_LEVEL); @@ -26,6 +27,7 @@ struct mcux_pwt_config { pwt_clock_source_t pwt_clock_source; pwt_clock_prescale_t prescale; void (*irq_config_func)(const struct device *dev); + const struct pinctrl_dev_config *pincfg; }; struct mcux_pwt_data { @@ -279,6 +281,7 @@ static int mcux_pwt_init(const struct device *dev) const struct mcux_pwt_config *config = dev->config; struct mcux_pwt_data *data = dev->data; pwt_config_t *pwt_config = &data->pwt_config; + int err; if (clock_control_get_rate(config->clock_dev, config->clock_subsys, &data->clock_freq)) { @@ -292,6 +295,11 @@ static int mcux_pwt_init(const struct device *dev) pwt_config->enableFirstCounterLoad = true; PWT_Init(config->base, pwt_config); + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err) { + return err; + } + config->irq_config_func(dev); return 0; @@ -310,6 +318,8 @@ static const struct pwm_driver_api mcux_pwt_driver_api = { #define PWT_DEVICE(n) \ static void mcux_pwt_config_func_##n(const struct device *dev); \ \ + PINCTRL_DT_INST_DEFINE(n); \ + \ static const struct mcux_pwt_config mcux_pwt_config_##n = { \ .base = (PWT_Type *)DT_INST_REG_ADDR(n), \ .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \ @@ -319,6 +329,7 @@ static const struct pwm_driver_api mcux_pwt_driver_api = { .prescale = \ TO_PWT_PRESCALE_DIVIDE(DT_INST_PROP(n, prescaler)), \ .irq_config_func = mcux_pwt_config_func_##n, \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ }; \ \ static struct mcux_pwt_data mcux_pwt_data_##n; \ diff --git a/drivers/pwm/pwm_mcux_tpm.c b/drivers/pwm/pwm_mcux_tpm.c index c02ea30cd5c2e..a0135dd86899d 100644 --- a/drivers/pwm/pwm_mcux_tpm.c +++ b/drivers/pwm/pwm_mcux_tpm.c @@ -16,6 +16,7 @@ #include #include #include +#include #define LOG_LEVEL CONFIG_PWM_LOG_LEVEL #include @@ -31,6 +32,7 @@ struct mcux_tpm_config { tpm_clock_prescale_t prescale; uint8_t channel_count; tpm_pwm_mode_t mode; + const struct pinctrl_dev_config *pincfg; }; struct mcux_tpm_data { @@ -134,6 +136,7 @@ static int mcux_tpm_init(const struct device *dev) tpm_chnl_pwm_signal_param_t *channel = data->channel; tpm_config_t tpm_config; int i; + int err; if (config->channel_count > ARRAY_SIZE(data->channel)) { LOG_ERR("Invalid channel count"); @@ -159,6 +162,11 @@ static int mcux_tpm_init(const struct device *dev) channel++; } + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err) { + return err; + } + TPM_GetDefaultConfig(&tpm_config); tpm_config.prescale = config->prescale; @@ -173,6 +181,7 @@ static const struct pwm_driver_api mcux_tpm_driver_api = { }; #define TPM_DEVICE(n) \ + PINCTRL_DT_INST_DEFINE(n); \ static const struct mcux_tpm_config mcux_tpm_config_##n = { \ .base = (TPM_Type *) \ DT_INST_REG_ADDR(n), \ @@ -184,6 +193,7 @@ static const struct pwm_driver_api mcux_tpm_driver_api = { .channel_count = FSL_FEATURE_TPM_CHANNEL_COUNTn((TPM_Type *) \ DT_INST_REG_ADDR(n)), \ .mode = kTPM_EdgeAlignedPwm, \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ }; \ static struct mcux_tpm_data mcux_tpm_data_##n; \ DEVICE_DT_INST_DEFINE(n, &mcux_tpm_init, NULL, \ diff --git a/drivers/sensor/mcux_acmp/Kconfig b/drivers/sensor/mcux_acmp/Kconfig index c7842b48fcc62..809ed79a23db3 100644 --- a/drivers/sensor/mcux_acmp/Kconfig +++ b/drivers/sensor/mcux_acmp/Kconfig @@ -6,6 +6,7 @@ config MCUX_ACMP bool "NXP MCUX Analog Comparator (ACMP)" depends on HAS_MCUX_ACMP + select PINCTRL help Enable driver for the NXP MCUX Analog Comparator (ACMP). diff --git a/drivers/sensor/mcux_acmp/mcux_acmp.c b/drivers/sensor/mcux_acmp/mcux_acmp.c index 0967cf94cce14..4b0f2b790e838 100644 --- a/drivers/sensor/mcux_acmp/mcux_acmp.c +++ b/drivers/sensor/mcux_acmp/mcux_acmp.c @@ -11,6 +11,7 @@ #include #include #include +#include LOG_MODULE_REGISTER(mcux_acmp, CONFIG_SENSOR_LOG_LEVEL); @@ -58,6 +59,7 @@ BUILD_ASSERT(kACMP_PortInputFromMux == 1); struct mcux_acmp_config { CMP_Type *base; acmp_filter_config_t filter; + const struct pinctrl_dev_config *pincfg; #ifdef CONFIG_MCUX_ACMP_TRIGGER void (*irq_config_func)(const struct device *dev); #endif /* CONFIG_MCUX_ACMP_TRIGGER */ @@ -351,6 +353,12 @@ static int mcux_acmp_init(const struct device *dev) { const struct mcux_acmp_config *config = dev->config; struct mcux_acmp_data *data = dev->data; + int err; + + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err) { + return err; + } ACMP_GetDefaultConfig(&data->config); data->config.enableHighSpeed = config->high_speed; @@ -402,6 +410,7 @@ static const struct mcux_acmp_config mcux_acmp_config_##n = { \ .unfiltered = DT_INST_PROP(n, nxp_use_unfiltered_output), \ .output = DT_INST_PROP(n, nxp_enable_output_pin), \ .window = DT_INST_PROP(n, nxp_window_mode), \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ config_func_init \ } @@ -431,6 +440,8 @@ static const struct mcux_acmp_config mcux_acmp_config_##n = { \ \ static const struct mcux_acmp_config mcux_acmp_config_##n; \ \ + PINCTRL_DT_INST_DEFINE(n); \ + \ DEVICE_DT_INST_DEFINE(n, &mcux_acmp_init, \ NULL, \ &mcux_acmp_data_##n, \ diff --git a/drivers/serial/uart_mcux_lpsci.c b/drivers/serial/uart_mcux_lpsci.c index cab60ca1f77c9..8aa4bd3d0c3f1 100644 --- a/drivers/serial/uart_mcux_lpsci.c +++ b/drivers/serial/uart_mcux_lpsci.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -21,6 +22,7 @@ struct mcux_lpsci_config { #ifdef CONFIG_UART_INTERRUPT_DRIVEN void (*irq_config_func)(const struct device *dev); #endif + const struct pinctrl_dev_config *pincfg; }; struct mcux_lpsci_data { @@ -237,6 +239,7 @@ static int mcux_lpsci_init(const struct device *dev) const struct mcux_lpsci_config *config = dev->config; lpsci_config_t uart_config; uint32_t clock_freq; + int err; if (clock_control_get_rate(config->clock_dev, config->clock_subsys, &clock_freq)) { @@ -250,6 +253,11 @@ static int mcux_lpsci_init(const struct device *dev) LPSCI_Init(config->base, &uart_config, clock_freq); + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err < 0) { + return err; + } + #ifdef CONFIG_UART_INTERRUPT_DRIVEN config->irq_config_func(dev); #endif @@ -306,10 +314,12 @@ static const struct mcux_lpsci_config mcux_lpsci_##n##_config = { \ .clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \ .clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\ .baud_rate = DT_INST_PROP(n, current_speed), \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ IRQ_FUNC_INIT \ } #define MCUX_LPSCI_INIT(n) \ + PINCTRL_DT_INST_DEFINE(n); \ \ static struct mcux_lpsci_data mcux_lpsci_##n##_data; \ \ diff --git a/drivers/spi/Kconfig.mcux_dspi b/drivers/spi/Kconfig.mcux_dspi index 1fef7982000e9..c4947702e1acb 100644 --- a/drivers/spi/Kconfig.mcux_dspi +++ b/drivers/spi/Kconfig.mcux_dspi @@ -7,6 +7,7 @@ config SPI_MCUX_DSPI bool "MCUX SPI driver" depends on HAS_MCUX && CLOCK_CONTROL + select PINCTRL help Enable support for mcux spi driver. diff --git a/drivers/spi/spi_mcux_dspi.c b/drivers/spi/spi_mcux_dspi.c index 86554bfda3b6b..5eb8da0f1cf3c 100644 --- a/drivers/spi/spi_mcux_dspi.c +++ b/drivers/spi/spi_mcux_dspi.c @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef CONFIG_DSPI_MCUX_EDMA #include #include @@ -47,6 +48,7 @@ struct spi_mcux_config { bool enable_rxfifo_overwrite; bool enable_modified_timing_format; bool is_dma_chn_shared; + const struct pinctrl_dev_config *pincfg; }; struct spi_mcux_data { @@ -752,6 +754,8 @@ static int spi_mcux_init(const struct device *dev) { int err; struct spi_mcux_data *data = dev->data; + const struct spi_mcux_config *config = dev->config; + #ifdef CONFIG_DSPI_MCUX_EDMA enum dma_channel_filter spi_filter = DMA_CHANNEL_NORMAL; const struct device *dma_dev; @@ -763,10 +767,13 @@ static int spi_mcux_init(const struct device *dev) data->tx_dma_config.dma_channel = dma_request_channel(dma_dev, (void *)&spi_filter); #else - const struct spi_mcux_config *config = dev->config; - config->irq_config_func(dev); #endif + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err != 0) { + return err; + } + data->dev = dev; err = spi_context_cs_configure_all(&data->ctx); @@ -861,6 +868,7 @@ static const struct spi_driver_api spi_mcux_driver_api = { #endif #define SPI_MCUX_DSPI_DEVICE(id) \ + PINCTRL_DT_INST_DEFINE(id); \ static void spi_mcux_config_func_##id(const struct device *dev);\ TX_BUFFER(id); \ RX_BUFFER(id); \ @@ -894,6 +902,7 @@ static const struct spi_driver_api spi_mcux_driver_api = { DT_INST_PROP(id, modified_timing_format), \ .is_dma_chn_shared = \ DT_INST_PROP(id, nxp_rx_tx_chn_share), \ + .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(id), \ }; \ DEVICE_DT_INST_DEFINE(id, \ &spi_mcux_init, \ diff --git a/drivers/spi/spi_mcux_lpspi.c b/drivers/spi/spi_mcux_lpspi.c index e75303727560a..3e1698971b8fe 100644 --- a/drivers/spi/spi_mcux_lpspi.c +++ b/drivers/spi/spi_mcux_lpspi.c @@ -14,6 +14,9 @@ #ifdef CONFIG_SPI_MCUX_LPSPI_DMA #include #endif +#ifdef CONFIG_PINCTRL +#include +#endif /* CONFIG_PINCTRL */ LOG_MODULE_REGISTER(spi_mcux_lpspi, CONFIG_SPI_LOG_LEVEL); @@ -30,6 +33,9 @@ struct spi_mcux_config { uint32_t pcs_sck_delay; uint32_t sck_pcs_delay; uint32_t transfer_delay; +#ifdef CONFIG_PINCTRL + const struct pinctrl_dev_config *pincfg; +#endif /* CONFIG_PINCTRL */ }; #ifdef CONFIG_SPI_MCUX_LPSPI_DMA @@ -543,6 +549,13 @@ static int spi_mcux_init(const struct device *dev) } #endif /* CONFIG_SPI_MCUX_LPSPI_DMA */ +#ifdef CONFIG_PINCTRL + err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); + if (err) { + return err; + } +#endif /* CONFIG_PINCTRL */ + spi_context_unlock_unconditionally(&data->ctx); return 0; @@ -586,9 +599,20 @@ static const struct spi_driver_api spi_mcux_driver_api = { } #else #define SPI_DMA_CHANNELS(n) -#endif +#endif /* CONFIG_SPI_MCUX_LPSPI_DMA */ + +#ifdef CONFIG_PINCTRL +#define SPI_MCUX_LPSPI_PINCTRL_DEFINE(n) PINCTRL_DT_INST_DEFINE(n); +#define SPI_MCUX_LPSPI_PINCTRL_INIT(n) .pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), +#else +#define SPI_MCUX_LPSPI_PINCTRL_DEFINE(n) +#define SPI_MCUX_LPSPI_PINCTRL_INIT(n) +#endif /* CONFIG_PINCTRL */ + #define SPI_MCUX_LPSPI_INIT(n) \ + SPI_MCUX_LPSPI_PINCTRL_DEFINE(n) \ + \ static void spi_mcux_config_func_##n(const struct device *dev); \ \ static const struct spi_mcux_config spi_mcux_config_##n = { \ @@ -606,13 +630,14 @@ static const struct spi_driver_api spi_mcux_driver_api = { .transfer_delay = UTIL_AND( \ DT_INST_NODE_HAS_PROP(n, transfer_delay), \ DT_INST_PROP(n, transfer_delay)), \ + SPI_MCUX_LPSPI_PINCTRL_INIT(n) \ }; \ \ static struct spi_mcux_data spi_mcux_data_##n = { \ SPI_CONTEXT_INIT_LOCK(spi_mcux_data_##n, ctx), \ SPI_CONTEXT_INIT_SYNC(spi_mcux_data_##n, ctx), \ SPI_CONTEXT_CS_GPIOS_INITIALIZE(DT_DRV_INST(n), ctx) \ - SPI_DMA_CHANNELS(n) \ + SPI_DMA_CHANNELS(n) \ }; \ \ DEVICE_DT_INST_DEFINE(n, &spi_mcux_init, NULL, \ diff --git a/dts/arm/nxp/nxp_k6x.dtsi b/dts/arm/nxp/nxp_k6x.dtsi index 88a2aaa8c62df..45741d52bf1e6 100644 --- a/dts/arm/nxp/nxp_k6x.dtsi +++ b/dts/arm/nxp/nxp_k6x.dtsi @@ -515,7 +515,7 @@ label = "ETH_0"; phy-addr = <0>; clocks = <&sim KINETIS_SIM_CORESYS_CLK 0 0>; - ptp { + ptp: ptp { compatible = "nxp,kinetis-ptp"; status = "disabled"; interrupts = <82 0>; diff --git a/dts/arm/nxp/nxp_kw2xd.dtsi b/dts/arm/nxp/nxp_kw2xd.dtsi index f584c30f68e27..0fa256e8c3cb3 100644 --- a/dts/arm/nxp/nxp_kw2xd.dtsi +++ b/dts/arm/nxp/nxp_kw2xd.dtsi @@ -289,6 +289,7 @@ #size-cells = <0>; pinctrl-0 = <&spi1_modem>; + pinctrl-names = "default"; mcr20a@0 { compatible = "nxp,mcr20a"; diff --git a/dts/arm/nxp/nxp_rt.dtsi b/dts/arm/nxp/nxp_rt.dtsi index 1bb0ae3641d7a..20a17321d2dd3 100644 --- a/dts/arm/nxp/nxp_rt.dtsi +++ b/dts/arm/nxp/nxp_rt.dtsi @@ -579,7 +579,7 @@ status = "disabled"; label = "ETH_0"; phy-addr = <0>; - ptp { + ptp: ptp { compatible = "nxp,kinetis-ptp"; status = "disabled"; interrupts = <115 0>; diff --git a/dts/arm/nxp/nxp_rt11xx.dtsi b/dts/arm/nxp/nxp_rt11xx.dtsi index f50c2e15694b3..081b786648720 100644 --- a/dts/arm/nxp/nxp_rt11xx.dtsi +++ b/dts/arm/nxp/nxp_rt11xx.dtsi @@ -715,7 +715,7 @@ status = "disabled"; label = "ETH_0"; phy-addr = <2>; - ptp { + ptp: ptp { compatible = "nxp,kinetis-ptp"; status = "disabled"; interrupts = <138 0>; diff --git a/dts/bindings/adc/nxp,kinetis-adc12.yaml b/dts/bindings/adc/nxp,kinetis-adc12.yaml index 914adcf7ee724..1b6952bdf2648 100644 --- a/dts/bindings/adc/nxp,kinetis-adc12.yaml +++ b/dts/bindings/adc/nxp,kinetis-adc12.yaml @@ -5,7 +5,7 @@ description: NXP Kinetis ADC12 compatible: "nxp,kinetis-adc12" -include: adc-controller.yaml +include: [adc-controller.yaml, pinctrl-device.yaml] properties: reg: diff --git a/dts/bindings/adc/nxp,kinetis-adc16.yaml b/dts/bindings/adc/nxp,kinetis-adc16.yaml index 8558374c349a1..897cee4622af2 100644 --- a/dts/bindings/adc/nxp,kinetis-adc16.yaml +++ b/dts/bindings/adc/nxp,kinetis-adc16.yaml @@ -5,7 +5,7 @@ description: Kinetis ADC16 compatible: "nxp,kinetis-adc16" -include: adc-controller.yaml +include: ["adc-controller.yaml", "pinctrl-device.yaml"] properties: reg: diff --git a/dts/bindings/can/nxp,kinetis-flexcan.yaml b/dts/bindings/can/nxp,kinetis-flexcan.yaml index 1d618d434eb5a..31e72ec594def 100644 --- a/dts/bindings/can/nxp,kinetis-flexcan.yaml +++ b/dts/bindings/can/nxp,kinetis-flexcan.yaml @@ -5,7 +5,7 @@ description: NXP FlexCAN controller compatible: "nxp,kinetis-flexcan" -include: can-controller.yaml +include: ["can-controller.yaml", "pinctrl-device.yaml"] properties: reg: diff --git a/dts/bindings/dac/nxp,kinetis-dac32.yaml b/dts/bindings/dac/nxp,kinetis-dac32.yaml index 2feca3b3447ac..d6339ec0444c2 100644 --- a/dts/bindings/dac/nxp,kinetis-dac32.yaml +++ b/dts/bindings/dac/nxp,kinetis-dac32.yaml @@ -5,7 +5,7 @@ description: NXP Kinetis MCUX DAC32 compatible: "nxp,kinetis-dac32" -include: dac-controller.yaml +include: [dac-controller.yaml, pinctrl-device.yaml] properties: reg: diff --git a/dts/bindings/ethernet/nxp,kinetis-ethernet.yaml b/dts/bindings/ethernet/nxp,kinetis-ethernet.yaml index ed1516ad87e1a..13d55c91dfffb 100644 --- a/dts/bindings/ethernet/nxp,kinetis-ethernet.yaml +++ b/dts/bindings/ethernet/nxp,kinetis-ethernet.yaml @@ -5,7 +5,7 @@ description: NXP Kinetis Ethernet compatible: "nxp,kinetis-ethernet" -include: ["ethernet.yaml", "ethernet,fixed-link.yaml"] +include: ["ethernet.yaml", "ethernet,fixed-link.yaml", "pinctrl-device.yaml"] properties: reg: diff --git a/dts/bindings/ethernet/nxp,kinetis-ptp.yaml b/dts/bindings/ethernet/nxp,kinetis-ptp.yaml index 0d8b56bbc5229..d8f8faf288eac 100644 --- a/dts/bindings/ethernet/nxp,kinetis-ptp.yaml +++ b/dts/bindings/ethernet/nxp,kinetis-ptp.yaml @@ -5,7 +5,7 @@ description: NXP Kinetis Ethernet PTP (Precision Time Protocol) compatible: "nxp,kinetis-ptp" -include: base.yaml +include: ["base.yaml", "pinctrl-device.yaml"] properties: interrupts: diff --git a/dts/bindings/i2c/nxp,imx-lpi2c.yaml b/dts/bindings/i2c/nxp,imx-lpi2c.yaml index adcd1d8ff1ac3..3f0e34ff665e4 100644 --- a/dts/bindings/i2c/nxp,imx-lpi2c.yaml +++ b/dts/bindings/i2c/nxp,imx-lpi2c.yaml @@ -5,7 +5,7 @@ description: NXP i.MX LPI2C controller compatible: "nxp,imx-lpi2c" -include: i2c-controller.yaml +include: [i2c-controller.yaml, pinctrl-device.yaml] properties: reg: diff --git a/dts/bindings/i2c/nxp,kinetis-i2c.yaml b/dts/bindings/i2c/nxp,kinetis-i2c.yaml index 21f642321f547..8e64083e1cd2c 100644 --- a/dts/bindings/i2c/nxp,kinetis-i2c.yaml +++ b/dts/bindings/i2c/nxp,kinetis-i2c.yaml @@ -5,7 +5,7 @@ description: Kinetis I2C node compatible: "nxp,kinetis-i2c" -include: i2c-controller.yaml +include: ["i2c-controller.yaml", "pinctrl-device.yaml"] properties: reg: diff --git a/dts/bindings/pinctrl/nxp,kinetis-pinctrl.yaml b/dts/bindings/pinctrl/nxp,kinetis-pinctrl.yaml index 02bff96bc7a48..2b9f66e66b7a4 100644 --- a/dts/bindings/pinctrl/nxp,kinetis-pinctrl.yaml +++ b/dts/bindings/pinctrl/nxp,kinetis-pinctrl.yaml @@ -66,12 +66,12 @@ child-binding: required: true type: string enum: - - "slow" - "fast" + - "slow" description: | Pin output slew rate. Sets the SRE field in the PORTx_PCRn register. - 0 SRE_0_slow- slow slew rate when pin is configured as output - 1 SRE_1_fast- fast slew rate when pin is configured as output + 0 SRE_0_fast- fast slew rate when pin is configured as output + 1 SRE_1_slow- slow slew rate when pin is configured as output nxp,passive-filter: type: boolean description: | diff --git a/dts/bindings/pwm/nxp,kinetis-ftm-pwm.yaml b/dts/bindings/pwm/nxp,kinetis-ftm-pwm.yaml index 091cc430cc7b9..4732436f97297 100644 --- a/dts/bindings/pwm/nxp,kinetis-ftm-pwm.yaml +++ b/dts/bindings/pwm/nxp,kinetis-ftm-pwm.yaml @@ -5,7 +5,7 @@ description: Kinetis FTM PWM compatible: "nxp,kinetis-ftm-pwm" -include: [pwm-controller.yaml, "nxp,kinetis-ftm.yaml"] +include: [pwm-controller.yaml, "nxp,kinetis-ftm.yaml", "pinctrl-device.yaml"] properties: "#pwm-cells": diff --git a/dts/bindings/pwm/nxp,kinetis-pwt.yaml b/dts/bindings/pwm/nxp,kinetis-pwt.yaml index 02e928298880c..c158f1149b71c 100644 --- a/dts/bindings/pwm/nxp,kinetis-pwt.yaml +++ b/dts/bindings/pwm/nxp,kinetis-pwt.yaml @@ -5,7 +5,7 @@ description: Kinetis PWT PWM Capture compatible: "nxp,kinetis-pwt" -include: [pwm-controller.yaml, base.yaml] +include: [pwm-controller.yaml, base.yaml, pinctrl-device.yaml] properties: reg: diff --git a/dts/bindings/pwm/nxp,kinetis-tpm.yaml b/dts/bindings/pwm/nxp,kinetis-tpm.yaml index fa381b3cca1a4..b71a85c5cc20a 100644 --- a/dts/bindings/pwm/nxp,kinetis-tpm.yaml +++ b/dts/bindings/pwm/nxp,kinetis-tpm.yaml @@ -5,7 +5,7 @@ description: MCUX Timer/PWM Module (TPM) compatible: "nxp,kinetis-tpm" -include: [pwm-controller.yaml, base.yaml] +include: [pwm-controller.yaml, base.yaml, pinctrl-device.yaml] properties: reg: diff --git a/dts/bindings/sensor/nxp,kinetis-acmp.yaml b/dts/bindings/sensor/nxp,kinetis-acmp.yaml index 5789d858ba27c..40ad9c0060e23 100644 --- a/dts/bindings/sensor/nxp,kinetis-acmp.yaml +++ b/dts/bindings/sensor/nxp,kinetis-acmp.yaml @@ -5,7 +5,7 @@ description: NXP Kinetis Analog Comparator (ACMP) compatible: "nxp,kinetis-acmp" -include: base.yaml +include: [base.yaml, pinctrl-device.yaml] properties: interrupts: diff --git a/dts/bindings/serial/nxp,kinetis-lpsci.yaml b/dts/bindings/serial/nxp,kinetis-lpsci.yaml index d74ec03f09d8c..0105da9efc579 100644 --- a/dts/bindings/serial/nxp,kinetis-lpsci.yaml +++ b/dts/bindings/serial/nxp,kinetis-lpsci.yaml @@ -2,7 +2,7 @@ description: Kinetis LPSCI UART compatible: "nxp,kinetis-lpsci" -include: uart-controller.yaml +include: [uart-controller.yaml, pinctrl-device.yaml] properties: reg: diff --git a/dts/bindings/spi/nxp,imx-lpspi.yaml b/dts/bindings/spi/nxp,imx-lpspi.yaml index 48804a863a588..24919bd37ab8e 100644 --- a/dts/bindings/spi/nxp,imx-lpspi.yaml +++ b/dts/bindings/spi/nxp,imx-lpspi.yaml @@ -5,7 +5,7 @@ description: NXP i.MX LPSPI controller compatible: "nxp,imx-lpspi" -include: spi-controller.yaml +include: ["spi-controller.yaml", "pinctrl-device.yaml"] properties: reg: diff --git a/dts/bindings/spi/nxp,kinetis-dspi.yaml b/dts/bindings/spi/nxp,kinetis-dspi.yaml index cf617ed03c508..3d523f45b888b 100644 --- a/dts/bindings/spi/nxp,kinetis-dspi.yaml +++ b/dts/bindings/spi/nxp,kinetis-dspi.yaml @@ -5,7 +5,7 @@ description: NXP Kinetis DSPI controller compatible: "nxp,kinetis-dspi" -include: spi-controller.yaml +include: ["spi-controller.yaml", "pinctrl-device.yaml"] properties: reg: diff --git a/samples/drivers/adc/boards/frdm_k64f.overlay b/samples/drivers/adc/boards/frdm_k64f.overlay new file mode 100644 index 0000000000000..973875668438a --- /dev/null +++ b/samples/drivers/adc/boards/frdm_k64f.overlay @@ -0,0 +1,12 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2022 NXP + */ + +/ { + zephyr,user { + /* adjust channel number according to pinmux in board.dts */ + io-channels = <&adc1 14>; + }; +}; diff --git a/samples/sensor/mcux_acmp/boards/twr_ke18f.overlay b/samples/sensor/mcux_acmp/boards/twr_ke18f.overlay index 72f4c0c03de1b..a9b6a3e558ca3 100644 --- a/samples/sensor/mcux_acmp/boards/twr_ke18f.overlay +++ b/samples/sensor/mcux_acmp/boards/twr_ke18f.overlay @@ -17,4 +17,5 @@ &cmp2 { status = "okay"; pinctrl-0 = <&cmp2_default>; + pinctrl-names = "default"; }; diff --git a/soc/arm/nxp_kinetis/common/pinctrl_soc.h b/soc/arm/nxp_kinetis/common/pinctrl_soc.h index e756c53048316..0b1b19ff2b31d 100644 --- a/soc/arm/nxp_kinetis/common/pinctrl_soc.h +++ b/soc/arm/nxp_kinetis/common/pinctrl_soc.h @@ -23,8 +23,12 @@ extern "C" { typedef uint32_t pinctrl_soc_pin_t; -/* Kinetis KW/KL/KE series does not support open drain. Define macros to have no effect */ -#if defined(CONFIG_SOC_SERIES_KINETIS_KWX) || \ +/* Kinetis KW/KL/KE series does not support open drain. Define macros to have no effect + * Note: KW22 and KW24 do support open drain, rest of KW series does not + */ +#if (defined(CONFIG_SOC_SERIES_KINETIS_KWX) && \ + !(defined(CONFIG_SOC_MKW24D5) || \ + defined(CONFIG_SOC_MKW22D5))) || \ defined(CONFIG_SOC_SERIES_KINETIS_KL2X) || \ defined(CONFIG_SOC_SERIES_KINETIS_KE1XF) #define PORT_PCR_ODE(x) 0x0 diff --git a/soc/arm/nxp_kinetis/k2x/Kconfig.defconfig.mk22f12 b/soc/arm/nxp_kinetis/k2x/Kconfig.defconfig.mk22f12 index 5650209bfa947..2204198e43281 100644 --- a/soc/arm/nxp_kinetis/k2x/Kconfig.defconfig.mk22f12 +++ b/soc/arm/nxp_kinetis/k2x/Kconfig.defconfig.mk22f12 @@ -26,10 +26,6 @@ config CLOCK_CONTROL_MCUX_SIM endif # CLOCK_CONTROL -config PINMUX_MCUX - default y - depends on PINMUX - config GPIO default y diff --git a/soc/arm/nxp_kinetis/k6x/Kconfig.defconfig.mk64f12 b/soc/arm/nxp_kinetis/k6x/Kconfig.defconfig.mk64f12 index 4e0576871255e..35254d2525d40 100644 --- a/soc/arm/nxp_kinetis/k6x/Kconfig.defconfig.mk64f12 +++ b/soc/arm/nxp_kinetis/k6x/Kconfig.defconfig.mk64f12 @@ -34,10 +34,6 @@ config CLOCK_CONTROL_MCUX_MCG endif # CLOCK_CONTROL -config PINMUX_MCUX - default y - depends on PINMUX - config GPIO default y diff --git a/soc/arm/nxp_kinetis/k6x/Kconfig.defconfig.mk66f18 b/soc/arm/nxp_kinetis/k6x/Kconfig.defconfig.mk66f18 index 70c3d11d6c981..4c70a812d4569 100644 --- a/soc/arm/nxp_kinetis/k6x/Kconfig.defconfig.mk66f18 +++ b/soc/arm/nxp_kinetis/k6x/Kconfig.defconfig.mk66f18 @@ -34,10 +34,6 @@ config CLOCK_CONTROL_MCUX_MCG endif # CLOCK_CONTROL -config PINMUX_MCUX - default y - depends on PINMUX - config GPIO default y diff --git a/soc/arm/nxp_kinetis/k8x/Kconfig.defconfig.series b/soc/arm/nxp_kinetis/k8x/Kconfig.defconfig.series index d547357400933..2468b56d6c168 100644 --- a/soc/arm/nxp_kinetis/k8x/Kconfig.defconfig.series +++ b/soc/arm/nxp_kinetis/k8x/Kconfig.defconfig.series @@ -52,10 +52,6 @@ config I2C_MCUX default y depends on I2C -config PINMUX_MCUX - default y - depends on PINMUX - config PWM_MCUX_FTM default y depends on PWM diff --git a/soc/arm/nxp_kinetis/ke1xf/Kconfig.defconfig.series b/soc/arm/nxp_kinetis/ke1xf/Kconfig.defconfig.series index 2b48882fa3dbc..e984cc5334d4f 100644 --- a/soc/arm/nxp_kinetis/ke1xf/Kconfig.defconfig.series +++ b/soc/arm/nxp_kinetis/ke1xf/Kconfig.defconfig.series @@ -64,10 +64,6 @@ config PWM_MCUX_PWT default y depends on PWM_CAPTURE -config PINMUX_MCUX - default y - depends on PINMUX - config GPIO default y diff --git a/soc/arm/nxp_kinetis/kl2x/Kconfig.defconfig.mkl25z4 b/soc/arm/nxp_kinetis/kl2x/Kconfig.defconfig.mkl25z4 index 76ddfd06eaf38..73299dbec1395 100644 --- a/soc/arm/nxp_kinetis/kl2x/Kconfig.defconfig.mkl25z4 +++ b/soc/arm/nxp_kinetis/kl2x/Kconfig.defconfig.mkl25z4 @@ -19,10 +19,6 @@ config CLOCK_CONTROL_MCUX_SIM default y depends on CLOCK_CONTROL -config PINMUX_MCUX - default y - depends on PINMUX - config GPIO_MCUX default y depends on GPIO diff --git a/soc/arm/nxp_kinetis/kv5x/Kconfig.defconfig.series b/soc/arm/nxp_kinetis/kv5x/Kconfig.defconfig.series index 11f21f213b963..267d0ddca7f91 100644 --- a/soc/arm/nxp_kinetis/kv5x/Kconfig.defconfig.series +++ b/soc/arm/nxp_kinetis/kv5x/Kconfig.defconfig.series @@ -35,10 +35,6 @@ config I2C_MCUX default y depends on I2C -config PINMUX_MCUX - default y - depends on PINMUX - config PWM_MCUX_FTM default y depends on PWM diff --git a/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw2xd512 b/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw2xd512 index f0aaa53844fe8..11e11f0933e2c 100644 --- a/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw2xd512 +++ b/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw2xd512 @@ -30,10 +30,6 @@ config CLOCK_CONTROL_MCUX_MCG endif # CLOCK_CONTROL -config PINMUX_MCUX - default y - depends on PINMUX - config GPIO_MCUX default y depends on GPIO diff --git a/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw40z4 b/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw40z4 index e3178c2d6ad7c..a4dce7dedc4cf 100644 --- a/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw40z4 +++ b/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw40z4 @@ -18,10 +18,6 @@ config CLOCK_CONTROL_MCUX_SIM default y depends on CLOCK_CONTROL -config PINMUX_MCUX - default y - depends on PINMUX - config GPIO_MCUX default y depends on GPIO diff --git a/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw41z4 b/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw41z4 index 40b227db50b08..4151992017cd3 100644 --- a/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw41z4 +++ b/soc/arm/nxp_kinetis/kwx/Kconfig.defconfig.mkw41z4 @@ -23,10 +23,6 @@ config COUNTER_MCUX_RTC default y depends on COUNTER -config PINMUX_MCUX - default y - depends on PINMUX - config GPIO_MCUX default y depends on GPIO diff --git a/tests/drivers/pwm/pwm_loopback/boards/twr_ke18f.overlay b/tests/drivers/pwm/pwm_loopback/boards/twr_ke18f.overlay index e8e6e39133029..396b23381750a 100644 --- a/tests/drivers/pwm/pwm_loopback/boards/twr_ke18f.overlay +++ b/tests/drivers/pwm/pwm_loopback/boards/twr_ke18f.overlay @@ -36,6 +36,7 @@ status = "okay"; prescaler = <32>; pinctrl-0 = <&pwt_default>; + pinctrl-names = "default"; }; &ftm2 { @@ -44,4 +45,5 @@ prescaler = <128>; #pwm-cells = <3>; pinctrl-0 = <&ftm2_default>; + pinctrl-names = "default"; };