Skip to content

Commit

Permalink
drivers: adc: Add support ADC for Renesas RA4
Browse files Browse the repository at this point in the history
- Support ADC for RA4E2, RA4M2, RA4M3, RA4W1
- Initial overlays for RA4 in test app adc_accuracy_test,
adc_api

Signed-off-by: Khoa Nguyen <[email protected]>
  • Loading branch information
khoa-nguyen-18 committed Nov 1, 2024
1 parent d6e174b commit aac4e23
Show file tree
Hide file tree
Showing 27 changed files with 410 additions and 0 deletions.
2 changes: 2 additions & 0 deletions boards/renesas/ek_ra4e2/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ The below features are currently supported on Zephyr OS for EK-RA4E2 board:
+-----------+------------+----------------------+
| CLOCK | on-chip | clock control |
+-----------+------------+----------------------+
| ADC | on-chip | adc |
+-----------+------------+----------------------+

Other hardware features are currently not supported by the port.

Expand Down
8 changes: 8 additions & 0 deletions boards/renesas/ek_ra4e2/ek_ra4e2-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@
<RA_PSEL(RA_PSEL_SCI_0, 4, 10)>;
};
};

adc0_default: adc0_default {
group1 {
/* input */
psels = <RA_PSEL(RA_PSEL_ADC, 0, 0)>;
renesas,analog-enable;
};
};
};
7 changes: 7 additions & 0 deletions boards/renesas/ek_ra4e2/ek_ra4e2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <renesas/ra/ra4/r7fa4e2b93cfm.dtsi>
#include <dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/adc/adc.h>
#include "ek_ra4e2-pinctrl.dtsi"

/ {
Expand Down Expand Up @@ -76,3 +77,9 @@
&ioport2 {
status = "okay";
};

&adc0 {
status = "okay";
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};
2 changes: 2 additions & 0 deletions boards/renesas/ek_ra4m2/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ The below features are currently supported on Zephyr OS for EK-RA4M2 board:
+-----------+------------+----------------------+
| CLOCK | on-chip | clock control |
+-----------+------------+----------------------+
| ADC | on-chip | adc |
+-----------+------------+----------------------+

Other hardware features are currently not supported by the port.

Expand Down
8 changes: 8 additions & 0 deletions boards/renesas/ek_ra4m2/ek_ra4m2-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@
<RA_PSEL(RA_PSEL_SCI_0, 4, 10)>;
};
};

adc0_default: adc0_default {
group1 {
/* input */
psels = <RA_PSEL(RA_PSEL_ADC, 0, 0)>;
renesas,analog-enable;
};
};
};
7 changes: 7 additions & 0 deletions boards/renesas/ek_ra4m2/ek_ra4m2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <renesas/ra/ra4/r7fa4m2ad3cfp.dtsi>
#include <dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/adc/adc.h>
#include "ek_ra4m2-pinctrl.dtsi"

/ {
Expand Down Expand Up @@ -72,3 +73,9 @@
&ioport4 {
status = "okay";
};

&adc0 {
status = "okay";
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};
2 changes: 2 additions & 0 deletions boards/renesas/ek_ra4m3/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ The below features are currently supported on Zephyr OS for EK-RA4M3 board:
+-----------+------------+----------------------+
| CLOCK | on-chip | clock control |
+-----------+------------+----------------------+
| ADC | on-chip | adc |
+-----------+------------+----------------------+

Other hardware features are currently not supported by the port.

Expand Down
8 changes: 8 additions & 0 deletions boards/renesas/ek_ra4m3/ek_ra4m3-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@
<RA_PSEL(RA_PSEL_SCI_0, 4, 10)>;
};
};

adc0_default: adc0_default {
group1 {
/* input */
psels = <RA_PSEL(RA_PSEL_ADC, 0, 0)>;
renesas,analog-enable;
};
};
};
7 changes: 7 additions & 0 deletions boards/renesas/ek_ra4m3/ek_ra4m3.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <renesas/ra/ra4/r7fa4m3af3cfb.dtsi>
#include <dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/adc/adc.h>
#include "ek_ra4m3-pinctrl.dtsi"

/ {
Expand Down Expand Up @@ -72,3 +73,9 @@
&ioport4 {
status = "okay";
};

&adc0 {
status = "okay";
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};
2 changes: 2 additions & 0 deletions boards/renesas/ek_ra4w1/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ The below features are currently supported on Zephyr OS for EK-RA4W1 board:
+-----------+------------+----------------------+
| CLOCK | on-chip | clock control |
+-----------+------------+----------------------+
| ADC | on-chip | adc |
+-----------+------------+----------------------+

Other hardware features are currently not supported by the port.

Expand Down
8 changes: 8 additions & 0 deletions boards/renesas/ek_ra4w1/ek_ra4w1-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@
<RA_PSEL(RA_PSEL_SCI_0, 1, 0)>;
};
};

adc0_default: adc0_default {
group1 {
/* input */
psels = <RA_PSEL(RA_PSEL_ADC, 0, 4)>;
renesas,analog-enable;
};
};
};
7 changes: 7 additions & 0 deletions boards/renesas/ek_ra4w1/ek_ra4w1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <renesas/ra/ra4/r7fa4w1ad2cng.dtsi>
#include <dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/adc/adc.h>
#include "ek_ra4w1-pinctrl.dtsi"

/ {
Expand Down Expand Up @@ -59,3 +60,9 @@
&ioport4 {
status = "okay";
};

&adc0 {
status = "okay";
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
};
7 changes: 7 additions & 0 deletions dts/arm/renesas/ra/ra4/r7fa4e2b93cfm.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <zephyr/dt-bindings/clock/ra_clock.h>
#include <arm/renesas/ra/ra4/ra4-cm33-common.dtsi>

/delete-node/ &adc1;

/ {
soc {
sram0: memory@20000000 {
Expand Down Expand Up @@ -34,6 +36,11 @@
};
};

adc0: adc@40170000 {
channel-count = <12>;
channel-available-mask = <0x139f7>;
};

id_code: id_code@100a120 {
compatible = "zephyr,memory-region";
reg = <0x0100a120 0x10>;
Expand Down
7 changes: 7 additions & 0 deletions dts/arm/renesas/ra/ra4/r7fa4m2ax.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <arm/renesas/ra/ra4/ra4-cm33-common.dtsi>
#include <zephyr/dt-bindings/clock/ra_clock.h>

/delete-node/ &adc1;

/ {
soc {
sram0: memory@20000000 {
Expand Down Expand Up @@ -89,6 +91,11 @@
status = "disabled";
};
};

adc0: adc@40170000 {
channel-count = <13>;
channel-available-mask = <0x139ff>;
};
};

clocks: clocks {
Expand Down
10 changes: 10 additions & 0 deletions dts/arm/renesas/ra/ra4/r7fa4m3ax.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@
status = "disabled";
};
};

adc0: adc@40170000 {
channel-count = <12>;
channel-available-mask = <0x33ff>;
};

adc1: adc@40170200 {
channel-count = <10>;
channel-available-mask = <0x7f0007>;
};
};

clocks: clocks {
Expand Down
8 changes: 8 additions & 0 deletions dts/arm/renesas/ra/ra4/r7fa4w1ad2cng.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <zephyr/dt-bindings/clock/ra_clock.h>
#include <arm/renesas/ra/ra4/ra4-cm4-common.dtsi>

/delete-node/ &adc1;

/ {
soc {
sram0: memory@20000000 {
Expand Down Expand Up @@ -34,6 +36,12 @@
status = "disabled";
};
};

adc0: adc@4005c000 {
interrupts = <20 1>;
channel-count = <8>;
channel-available-mask = <0x1a0670>;
};
};

clocks: clocks {
Expand Down
20 changes: 20 additions & 0 deletions dts/arm/renesas/ra/ra4/ra4-cm33-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,26 @@
};
};

adc0: adc@40170000 {
compatible = "renesas,ra-adc";
interrupts = <40 1>;
interrupt-names = "scanend";
reg = <0x40170000 0x100>;
#io-channel-cells = <1>;
vref-mv = <3300>;
status = "disabled";
};

adc1: adc@40170200 {
compatible = "renesas,ra-adc";
interrupts = <41 1>;
interrupt-names = "scanend";
reg = <0x40170200 0x100>;
#io-channel-cells = <1>;
vref-mv = <3300>;
status = "disabled";
};

option_setting_ofs: option_setting_ofs@100a100 {
compatible = "zephyr,memory-region";
reg = <0x0100a100 0x18>;
Expand Down
18 changes: 18 additions & 0 deletions dts/arm/renesas/ra/ra4/ra4-cm4-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,24 @@
};
};

adc0: adc@4005c000 {
compatible = "renesas,ra-adc";
interrupt-names = "scanend";
reg = <0x4005c000 0x100>;
#io-channel-cells = <1>;
vref-mv = <3300>;
status = "disabled";
};

adc1: adc@4005c200 {
compatible = "renesas,ra-adc";
interrupt-names = "scanend";
reg = <0x4005c200 0x100>;
#io-channel-cells = <1>;
vref-mv = <3300>;
status = "disabled";
};

id_code: id_code@1010018 {
compatible = "zephyr,memory-region";
reg = <0x01010018 0x20>;
Expand Down
28 changes: 28 additions & 0 deletions tests/drivers/adc/adc_accuracy_test/boards/ek_ra4e2.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2024 Renesas Electronics Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
zephyr,user {
io-channels = <&adc0 0>;
reference_mv = <3300>;
expected_accuracy = <32>;
};
};

&adc0{
#address-cells = <1>;
#size-cells = <0>;
status = "okay";

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,vref-mv = <3300>;
};
};
28 changes: 28 additions & 0 deletions tests/drivers/adc/adc_accuracy_test/boards/ek_ra4m2.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2024 Renesas Electronics Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
zephyr,user {
io-channels = <&adc0 0>;
reference_mv = <3300>;
expected_accuracy = <32>;
};
};

&adc0{
#address-cells = <1>;
#size-cells = <0>;
status = "okay";

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,vref-mv = <3300>;
};
};
28 changes: 28 additions & 0 deletions tests/drivers/adc/adc_accuracy_test/boards/ek_ra4m3.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2024 Renesas Electronics Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
zephyr,user {
io-channels = <&adc0 0>;
reference_mv = <3300>;
expected_accuracy = <32>;
};
};

&adc0{
#address-cells = <1>;
#size-cells = <0>;
status = "okay";

channel@0 {
reg = <0>;
zephyr,gain = "ADC_GAIN_1";
zephyr,reference = "ADC_REF_INTERNAL";
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
zephyr,resolution = <12>;
zephyr,vref-mv = <3300>;
};
};
Loading

0 comments on commit aac4e23

Please sign in to comment.