Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rt700 lpadc support #84361

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions boards/nxp/mimxrt700_evk/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ void board_early_init_hook(void)
CLOCK_EnableClock(kCLOCK_Gpio10);
RESET_ClearPeripheralReset(kGPIO10_RST_SHIFT_RSTn);
#endif

#if DT_NODE_HAS_STATUS(DT_NODELABEL(lpadc0), okay)
CLOCK_AttachClk(kFRO1_DIV1_to_SENSE_MAIN);
CLOCK_AttachClk(kSENSE_BASE_to_ADC);
CLOCK_SetClkDiv(kCLOCK_DivAdcClk, 1U);
#endif
}

static void GlikeyWriteEnable(GLIKEY_Type *base, uint8_t idx)
Expand Down
2 changes: 2 additions & 0 deletions boards/nxp/mimxrt700_evk/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ the hardware features below.
+-----------+------------+-------------------------------------+
| CLOCK | on-chip | clock_control |
+-----------+------------+-------------------------------------+
| ADC | on-chip | adc |
+-----------+------------+-------------------------------------+

The default configuration can be found in the defconfig file:

Expand Down
10 changes: 10 additions & 0 deletions boards/nxp/mimxrt700_evk/mimxrt700_evk-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@
drive-strength = "normal";
};
};

pinmux_lpadc0: pinmux_lpadc0 {
group0 {
pinmux = <ADC0_CH0_PIO10_0>,
<ADC0_CH1_PIO10_2>;
slew-rate = "normal";
drive-strength = "normal";
nxp,analog-mode;
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@
status = "okay";
};

&lpadc0 {
status = "okay";
pinctrl-0 = <&pinmux_lpadc0>;
pinctrl-names = "default";
};

&blue_led {
status = "okay";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ toolchain:
supported:
- gpio
- uart
- adc
vendor: nxp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
};
};

&lpadc0 {
status = "okay";
pinctrl-0 = <&pinmux_lpadc0>;
pinctrl-names = "default";
};

&systick {
status = "okay";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ toolchain:
supported:
- gpio
- uart
- adc
vendor: nxp
17 changes: 17 additions & 0 deletions dts/arm/nxp/nxp_rt7xx_cm33_cpu0.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <mem.h>
#include <arm/armv8-m.dtsi>
#include <zephyr/dt-bindings/adc/adc.h>
#include <zephyr/dt-bindings/clock/mcux_lpc_syscon_clock.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/memory-attr/memory-attr-arm.h>
Expand Down Expand Up @@ -107,6 +108,22 @@
* and secure modes (0x50000000).
*/

lpadc0: adc@20c000 {
compatible = "nxp,lpc-lpadc";
reg = <0x20c000 0x304>;
interrupts = <15 0>;
status = "disabled";
clk-divider = <1>;
clk-source = <0>;
voltage-ref= <1>;
calibration-average = <128>;
power-level = <0>;
offset-value-a = <10>;
offset-value-b = <10>;
#io-channel-cells = <1>;
clocks = <&clkctl3 MCUX_LPADC1_CLK>;
};

rstctl0: reset@0 {
compatible = "nxp,rstctl";
reg = <0x0 0x1000>;
Expand Down
17 changes: 17 additions & 0 deletions dts/arm/nxp/nxp_rt7xx_cm33_cpu1.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <mem.h>
#include <arm/armv8-m.dtsi>
#include <zephyr/dt-bindings/adc/adc.h>
#include <zephyr/dt-bindings/clock/mcux_lpc_syscon_clock.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/memory-attr/memory-attr-arm.h>
Expand Down Expand Up @@ -90,6 +91,22 @@
* and secure modes (0x50000000).
*/

lpadc0: adc@20c000 {
compatible = "nxp,lpc-lpadc";
reg = <0x20c000 0x304>;
interrupts = <15 0>;
status = "disabled";
clk-divider = <1>;
clk-source = <0>;
voltage-ref= <1>;
calibration-average = <128>;
power-level = <0>;
offset-value-a = <10>;
offset-value-b = <10>;
#io-channel-cells = <1>;
clocks = <&clkctl3 MCUX_LPADC1_CLK>;
};

rstctl1: reset@40000 {
compatible = "nxp,rstctl";
reg = <0x40000 0x1000>;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2025 NXP
*/

#include <zephyr/dt-bindings/adc/mcux-lpadc.h>

/ {
zephyr,user {
io-channels = <&lpadc0 0>, <&lpadc0 1>;
};
};

&lpadc0 {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_EXTERNAL0";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <MCUX_LPADC_CH0A>;
};

channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_EXTERNAL0";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <MCUX_LPADC_CH1A>;
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2025 NXP
*/

#include <zephyr/dt-bindings/adc/mcux-lpadc.h>

/ {
zephyr,user {
io-channels = <&lpadc0 0>, <&lpadc0 1>;
};
};

&lpadc0 {
#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_EXTERNAL0";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <MCUX_LPADC_CH0A>;
};

channel@1 {
reg = <1>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_EXTERNAL0";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,input-positive = <MCUX_LPADC_CH1A>;
};
};
Loading