Skip to content

Commit f599b72

Browse files
Thinh Le Congduynguyenxa
authored andcommitted
drivers: adc: Adding different compatible for ADC16
Adding different compatible to support ADC16 Signed-off-by: Thinh Le Cong <[email protected]>
1 parent e3decfe commit f599b72

File tree

5 files changed

+29
-22
lines changed

5 files changed

+29
-22
lines changed

drivers/adc/Kconfig.renesas_ra

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config ADC_RENESAS_RA
77
bool "Renesas RA ADC"
88
default y
9-
depends on DT_HAS_RENESAS_RA_ADC_ENABLED
9+
depends on DT_HAS_RENESAS_RA_ADC12_ENABLED || DT_HAS_RENESAS_RA_ADC16_ENABLED
1010
select USE_RA_FSP_ADC
1111
select PINCTRL
1212
help

drivers/adc/adc_renesas_ra.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#define DT_DRV_COMPAT renesas_ra_adc
8-
97
#include <zephyr/drivers/adc.h>
108
#include <zephyr/drivers/clock_control.h>
119
#include <zephyr/drivers/pinctrl.h>
@@ -29,9 +27,6 @@ LOG_MODULE_REGISTER(adc_ra, CONFIG_ADC_LOG_LEVEL);
2927
#define ADC_AVERAGE_8 ADC_ADD_AVERAGE_EIGHT
3028
#define ADC_AVERAGE_16 ADC_ADD_AVERAGE_SIXTEEN
3129

32-
#define ADC_RES_12 ADC_RESOLUTION_12_BIT
33-
#define ADC_RES_16 ADC_RESOLUTION_16_BIT
34-
3530
#define ADC_VARIANT_ADC12 12
3631
#define ADC_VARIANT_ADC16 16
3732

@@ -399,7 +394,7 @@ static int adc_ra_init(const struct device *dev)
399394

400395
#define IRQ_CONFIGURE_DEFINE(idx) .irq_configure = adc_ra_configure_func_##idx
401396

402-
#define ADC_RA_INIT(idx) \
397+
#define ADC_RA_INIT_VARIANT(idx, VARIANT, RES_NUM, RES_ENUM) \
403398
IRQ_CONFIGURE_FUNC(idx) \
404399
PINCTRL_DT_INST_DEFINE(idx); \
405400
static adc_extended_cfg_t g_adc_cfg_extend_##idx = { \
@@ -422,9 +417,9 @@ static int adc_ra_init(const struct device *dev)
422417
IF_ENABLED(CONFIG_ADC_ASYNC, (.read_async = adc_ra_read_async))}; \
423418
static const struct adc_ra_config adc_ra_config_##idx = { \
424419
.channel_available_mask = DT_INST_PROP(idx, channel_available_mask), \
425-
.variant = DT_INST_PROP(idx, variant), \
420+
.variant = VARIANT, \
426421
.reference = DT_INST_ENUM_IDX(idx, reference), \
427-
.resolution = DT_INST_PROP(idx, variant), \
422+
.resolution = RES_NUM, \
428423
.sampling_time_ns = DT_INST_PROP_OR(idx, sampling_time_ns, UNSPECIFIED), \
429424
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(idx), \
430425
IRQ_CONFIGURE_DEFINE(idx), \
@@ -438,7 +433,7 @@ static int adc_ra_init(const struct device *dev)
438433
{ \
439434
.unit = DT_INST_PROP(idx, unit), \
440435
.mode = ADC_MODE_SINGLE_SCAN, \
441-
.resolution = UTIL_CAT(ADC_RES_, DT_INST_PROP(idx, variant)), \
436+
.resolution = RES_ENUM, \
442437
.alignment = (adc_alignment_t)ADC_ALIGNMENT_RIGHT, \
443438
.trigger = 0, \
444439
.p_callback = renesas_ra_adc_callback, \
@@ -464,4 +459,10 @@ static int adc_ra_init(const struct device *dev)
464459
DEVICE_DT_INST_DEFINE(idx, adc_ra_init, NULL, &adc_ra_data_##idx, &adc_ra_config_##idx, \
465460
POST_KERNEL, CONFIG_ADC_INIT_PRIORITY, &adc_ra_api_##idx)
466461

467-
DT_INST_FOREACH_STATUS_OKAY(ADC_RA_INIT);
462+
#define DT_DRV_COMPAT renesas_ra_adc12
463+
DT_INST_FOREACH_STATUS_OKAY_VARGS(ADC_RA_INIT_VARIANT, ADC_VARIANT_ADC12, 12, ADC_RESOLUTION_12_BIT)
464+
#undef DT_DRV_COMPAT
465+
466+
#define DT_DRV_COMPAT renesas_ra_adc16
467+
DT_INST_FOREACH_STATUS_OKAY_VARGS(ADC_RA_INIT_VARIANT, ADC_VARIANT_ADC16, 16, ADC_RESOLUTION_16_BIT)
468+
#undef DT_DRV_COMPAT

dts/bindings/adc/renesas,ra-adc.yaml renamed to dts/bindings/adc/renesas,ra-adc-base.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
# Copyright (c) 2024 Renesas Electronics Corporation
1+
# Copyright (c) 2025 Renesas Electronics Corporation
22
# SPDX-License-Identifier: Apache-2.0
33

4-
description: Renesas RA ADC node
5-
6-
compatible: "renesas,ra-adc"
7-
84
include: [adc-controller.yaml, pinctrl-device.yaml]
95

106
properties:
@@ -45,12 +41,6 @@ properties:
4541
- internal: use internal reference
4642
- external: use external reference
4743
48-
variant:
49-
type: int
50-
enum: [12, 16]
51-
default: 12
52-
description: Select ADC variant for RA SoC
53-
5444
sampling-time-ns:
5545
type: int
5646
description: |
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: Renesas RA 12-bit resolution (ADC12) device binding.
5+
6+
compatible: "renesas,ra-adc12"
7+
8+
include: renesas,ra-adc-base.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2025 Renesas Electronics Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: Renesas RA 16-bit resolution (ADC16) device binding.
5+
6+
compatible: "renesas,ra-adc16"
7+
8+
include: renesas,ra-adc-base.yaml

0 commit comments

Comments
 (0)