Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion boards/arm/frdm_k22f/frdm_k22f.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/dts-v1/;

#include <nxp/nxp_k2x.dtsi>
#include <dt-bindings/pwm/pwm.h>

/ {
model = "NXP Freedom MK22F board";
Expand All @@ -18,6 +19,10 @@
led2 = &red_led;
sw0 = &user_button_3;
sw1 = &user_button_2;
pwm-led0 = &green_pwm_led;
green-pwm-led = &green_pwm_led;
blue-pwm-led = &blue_pwm_led;
red-pwm-led = &red_pwm_led;
};

chosen {
Expand Down Expand Up @@ -45,6 +50,23 @@
};
};

pwmleds {
compatible = "pwm-leds";

red_pwm_led: red_pwm_led {
label = "red_led";
pwms = <&ftm0 6 15625000 PWM_POLARITY_INVERTED>;
};
green_pwm_led: green_pwm_led {
label = "green_led";
pwms = <&ftm0 7 15625000 PWM_POLARITY_INVERTED>;
};
blue_pwm_led: blue_pwm_led {
label = "blue_led";
pwms = <&ftm0 5 15625000 PWM_POLARITY_INVERTED>;
};
};

gpio_keys {
compatible = "gpio-keys";
user_button_2: button_0 {
Expand Down Expand Up @@ -112,7 +134,7 @@ arduino_spi: &spi0 {
status = "okay";
};

&ftm3 {
&ftm0 {
status = "okay";
compatible = "nxp,kinetis-ftm-pwm";
#pwm-cells = <3>;
Expand Down
1 change: 1 addition & 0 deletions boards/arm/frdm_k22f/frdm_k22f.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ supported:
- gpio
- i2c
- nvs
- pwm
- spi
- usb_device
- watchdog
9 changes: 8 additions & 1 deletion boards/arm/frdm_k22f/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@ static int frdm_k22f_pinmux_init(const struct device *dev)
/* FXOS8700 INT2 */
pinmux_pin_set(portd, 1, PORT_PCR_MUX(kPORT_MuxAsGpio));

/* Red, green, blue LEDs */
#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));
#else
/* Red, green, blue LEDs as GPIO channels*/
pinmux_pin_set(porta, 1, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(porta, 2, PORT_PCR_MUX(kPORT_MuxAsGpio));
pinmux_pin_set(portd, 5, PORT_PCR_MUX(kPORT_MuxAsGpio));
#endif

#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi0), okay) && CONFIG_SPI
/* SPI0 CS0, SCK, SOUT, SIN */
Expand Down
15 changes: 11 additions & 4 deletions dts/arm/nxp/nxp_k2x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@
};

mcg: clock-controller@40064000 {
compatible = "nxp,k22f-mcg";
compatible = "nxp,kinetis-mcg";
reg = <0x40064000 0xd>;
system-clock-frequency = <120000000>;

clock-controller;
label = "MCG";
#clock-cells = <1>;
};

osc: clock-controller@40065000 {
Expand Down Expand Up @@ -298,6 +297,8 @@
compatible = "nxp,kinetis-ftm";
reg = <0x40038000 0x98>;
interrupts = <42 0>;
clocks = <&mcg KINETIS_MCG_FIXED_FREQ_CLK>,
<&sim KINETIS_SIM_BUS_CLK 0x103C 24>;
prescaler = <16>;
label = "FTM_0";
status = "disabled";
Expand All @@ -307,6 +308,8 @@
compatible = "nxp,kinetis-ftm";
reg = <0x40039000 0x98>;
interrupts = <43 0>;
clocks = <&mcg KINETIS_MCG_FIXED_FREQ_CLK>,
<&sim KINETIS_SIM_BUS_CLK 0x103C 25>;
prescaler = <16>;
label = "FTM_1";
status = "disabled";
Expand All @@ -316,6 +319,8 @@
compatible = "nxp,kinetis-ftm";
reg = <0x4003a000 0x98>;
interrupts = <44 0>;
clocks = <&mcg KINETIS_MCG_FIXED_FREQ_CLK>,
<&sim KINETIS_SIM_BUS_CLK 0x103C 26>;
prescaler = <16>;
label = "FTM_2";
status = "disabled";
Expand All @@ -325,6 +330,8 @@
compatible = "nxp,kinetis-ftm";
reg = <0x400b9000 0x98>;
interrupts = <71 0>;
clocks = <&mcg KINETIS_MCG_FIXED_FREQ_CLK>,
<&sim KINETIS_SIM_BUS_CLK 0x103C 6>;
prescaler = <16>;
label = "FTM_3";
status = "disabled";
Expand Down
8 changes: 7 additions & 1 deletion soc/arm/nxp_kinetis/k2x/Kconfig.defconfig.mk22f12
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ config ADC_MCUX_ADC16
default y
depends on ADC

if CLOCK_CONTROL

config CLOCK_CONTROL_MCUX_MCG
default y

config CLOCK_CONTROL_MCUX_SIM
default y
depends on CLOCK_CONTROL

endif # CLOCK_CONTROL

config PINMUX_MCUX
default y
Expand Down