From 9e8a8db9dc196153c23a8c861b230099bf379365 Mon Sep 17 00:00:00 2001 From: Michal Smola Date: Tue, 10 Sep 2024 08:10:46 +0200 Subject: [PATCH] boards: frdm_mcxc242: Add pwm support frdm_mcxc242 has tpm ip for pwm generation, but it is not enabled. Configure and enable it. Add pwmleds definition and disable it, as leds and pwmleds are mutually exclusive. Update board documentation. Signed-off-by: Michal Smola --- boards/nxp/frdm_mcxc242/doc/index.rst | 2 + .../frdm_mcxc242/frdm_mcxc242-pinctrl.dtsi | 16 ++++++++ boards/nxp/frdm_mcxc242/frdm_mcxc242.dts | 38 ++++++++++++++++++- boards/nxp/frdm_mcxc242/frdm_mcxc242.yaml | 1 + 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/boards/nxp/frdm_mcxc242/doc/index.rst b/boards/nxp/frdm_mcxc242/doc/index.rst index ecde1643da9..164e079b681 100644 --- a/boards/nxp/frdm_mcxc242/doc/index.rst +++ b/boards/nxp/frdm_mcxc242/doc/index.rst @@ -66,6 +66,8 @@ The ``frdm_mcxc242`` board target supports the following hardware features: +-----------+------------+-------------------------------------+ | I2C | on-chip | i2c | +-----------+------------+-------------------------------------+ +| PWM | on-chip | pwm | ++-----------+------------+-------------------------------------+ Targets available diff --git a/boards/nxp/frdm_mcxc242/frdm_mcxc242-pinctrl.dtsi b/boards/nxp/frdm_mcxc242/frdm_mcxc242-pinctrl.dtsi index 972cba958e7..89e470346f4 100644 --- a/boards/nxp/frdm_mcxc242/frdm_mcxc242-pinctrl.dtsi +++ b/boards/nxp/frdm_mcxc242/frdm_mcxc242-pinctrl.dtsi @@ -25,4 +25,20 @@ slew-rate = "fast"; }; }; + pinmux_tpm1: pinmux_tpm1 { + group0 { + pinmux = , + ; + drive-strength = "low"; + slew-rate = "slow"; + }; + }; + pinmux_tpm2: pinmux_tpm2 { + group0 { + pinmux = , + ; + drive-strength = "low"; + slew-rate = "slow"; + }; + }; }; diff --git a/boards/nxp/frdm_mcxc242/frdm_mcxc242.dts b/boards/nxp/frdm_mcxc242/frdm_mcxc242.dts index 5961363441d..9aabdfc6113 100644 --- a/boards/nxp/frdm_mcxc242/frdm_mcxc242.dts +++ b/boards/nxp/frdm_mcxc242/frdm_mcxc242.dts @@ -17,10 +17,17 @@ aliases { led0 = &red_led; led1 = &green_led; - led2 = &red_led; + led2 = &blue_led; + pwm-led0 = &red_pwm_led; + pwm-led1 = &green_pwm_led; + pwm-led2 = &blue_pwm_led; + red-pwm-led = &red_pwm_led; + green-pwm-led = &green_pwm_led; + blue-pwm-led = &blue_pwm_led; sw0 = &user_button_2; sw1 = &user_button_3; accel0 = &fxls8974; + pwm-0 = &tpm1; }; chosen { @@ -46,6 +53,23 @@ }; }; + pwmleds { + compatible = "pwm-leds"; + status = "disabled"; + red_pwm_led: pwm_led_0 { + pwms = <&tpm2 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>; + label = "PWM Red LED"; + }; + green_pwm_led: pwm_led_1 { + pwms = <&tpm2 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>; + label = "PWM Green LED"; + }; + blue_pwm_led: pwm_led_2 { + pwms = <&tpm1 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>; + label = "PWM Blue LED"; + }; + }; + gpio_keys { compatible = "gpio-keys"; user_button_2: button_2 { @@ -111,3 +135,15 @@ i2c1: &i2c1 { int2-gpios = <&gpioc 3 GPIO_ACTIVE_LOW>; }; }; + +&tpm1 { + status = "okay"; + pinctrl-0 = <&pinmux_tpm1>; + pinctrl-names = "default"; +}; + +&tpm2 { + status = "okay"; + pinctrl-0 = <&pinmux_tpm2>; + pinctrl-names = "default"; +}; diff --git a/boards/nxp/frdm_mcxc242/frdm_mcxc242.yaml b/boards/nxp/frdm_mcxc242/frdm_mcxc242.yaml index 285b86dde68..316f2abf6c0 100644 --- a/boards/nxp/frdm_mcxc242/frdm_mcxc242.yaml +++ b/boards/nxp/frdm_mcxc242/frdm_mcxc242.yaml @@ -17,6 +17,7 @@ toolchain: supported: - gpio - i2c + - pwm testing: ignore_tags: - net