Commit a38eb9b2 authored by Manuel Argüelles's avatar Manuel Argüelles Committed by Carles Cufi
Browse files

boards: arm: ucans32k1sic: enable FlexTimer/PWM support



Enable FlexTimer (FTM) as a PWM controller for this board. Use the RGB
LED controlled by FTM0 as PWM-LEDs for the samples and tests.

Signed-off-by: default avatarManuel Argüelles <manuel.arguelles@nxp.com>
parent aeebe484
Loading
Loading
Loading
Loading
+25 −9
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ GPIO on-chip gpio
LPUART        on-chip     serial
LPI2C         on-chip     i2c
LPSPI         on-chip     spi
FTM           on-chip     pwm
============  ==========  ================================

The default configuration can be found in the Kconfig file
@@ -67,15 +68,30 @@ children nodes with the desired pinmux configuration to the singleton node
LEDs
----

The UCANS32K1SIC board has one user RGB LED:

=======================  ==============  =====
Devicetree node          Label           Pin
=======================  ==============  =====
led0 / led1_red          LED1_RGB_RED    PTD15
led1 / led1_green        LED1_RGB_GREEN  PTD16
led2 / led1_blue         LED1_RGB_BLUE   PTD0
=======================  ==============  =====
The UCANS32K1SIC board has one user RGB LED that can be used either as a GPIO
LED or as a PWM LED.

.. table:: RGB LED as GPIO LED
   :widths: auto

   ===============  ================  ===============  =====
   Devicetree node  Devicetree alias  Label            Pin
   ===============  ================  ===============  =====
   led1_red         led0              LED1_RGB_RED     PTD15
   led1_green       led1              LED1_RGB_GREEN   PTD16
   led1_blue        led2              LED1_RGB_BLUE    PTD0
   ===============  ================  ===============  =====

.. table:: RGB LED as PWM LED
   :widths: auto

   ===============  ========================  ==================  ================
   Devicetree node  Devicetree alias          Label               Pin
   ===============  ========================  ==================  ================
   led1_red_pwm     pwm-led0 / red-pwm-led    LED1_RGB_RED_PWM    PTD15 / FTM0_CH0
   led1_green_pwm   pwm-led1 / green-pwm-led  LED1_RGB_GREEN_PWM  PTD16 / FTM0_CH1
   led1_blue_pwm    pwm-led2 / blue-pwm-led   LED1_RGB_BLUE_PWM   PTD0 / FTM0_CH2
   ===============  ========================  ==================  ================

The user can control the LEDs in any way. An output of ``0`` illuminates the LED.

+23 −0
Original line number Diff line number Diff line
@@ -37,4 +37,27 @@
			drive-strength = "low";
		};
	};

	ftm0_default: ftm0_default {
		group0 {
			pinmux = <FTM0_CH0_PTD15>,
				<FTM0_CH1_PTD16>,
				<FTM0_CH2_PTD0>;
			drive-strength = "low";
		};
	};

	ftm1_default: ftm1_default {
		group0 {
			pinmux = <FTM1_CH1_PTA1>;
			drive-strength = "low";
		};
	};

	ftm2_default: ftm2_default {
		group0 {
			pinmux = <FTM2_CH1_PTA0>;
			drive-strength = "low";
		};
	};
};
+50 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
/dts-v1/;
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <arm/nxp/nxp_s32k146.dtsi>
#include "ucans32k1sic-pinctrl.dtsi"

@@ -26,6 +27,13 @@
		led0 = &led1_red;
		led1 = &led1_green;
		led2 = &led1_blue;
		pwm-led0 = &led1_red_pwm;
		pwm-led1 = &led1_green_pwm;
		pwm-led2 = &led1_blue_pwm;
		red-pwm-led = &led1_red_pwm;
		green-pwm-led = &led1_green_pwm;
		blue-pwm-led = &led1_blue_pwm;
		pwm-0 = &ftm0;
		sw0 = &button_3;
		i2c-0 = &lpi2c0;
	};
@@ -47,6 +55,23 @@
		};
	};

	pwmleds {
		compatible = "pwm-leds";

		led1_red_pwm: led_pwm_0 {
			pwms = <&ftm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
			label = "LED1_RGB_RED_PWM";
		};
		led1_green_pwm: led_pwm_1 {
			pwms = <&ftm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
			label = "LED1_RGB_GREEN_PWM";
		};
		led1_blue_pwm: led_pwm_2 {
			pwms = <&ftm0 2 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
			label = "LED1_RGB_BLUE_PWM";
		};
	};

	gpio_keys {
		compatible = "gpio-keys";

@@ -104,3 +129,28 @@
	pinctrl-names = "default";
	status = "okay";
};

&ftm0 {
	compatible = "nxp,kinetis-ftm-pwm";
	pinctrl-0 = <&ftm0_default>;
	pinctrl-names = "default";
	prescaler = <128>;
	#pwm-cells = <3>;
	status = "okay";
};

&ftm1 {
	compatible = "nxp,kinetis-ftm-pwm";
	pinctrl-0 = <&ftm1_default>;
	pinctrl-names = "default";
	#pwm-cells = <3>;
	status = "okay";
};

&ftm2 {
	compatible = "nxp,kinetis-ftm-pwm";
	pinctrl-0 = <&ftm2_default>;
	pinctrl-names = "default";
	#pwm-cells = <3>;
	status = "okay";
};
+1 −0
Original line number Diff line number Diff line
@@ -17,3 +17,4 @@ supported:
  - pinctrl
  - i2c
  - spi
  - pwm