driver: sensor: npcx: add 'thr-sel' prop. for adc comparator

Add `thr-sel` prop. to select the relevant threshold register for adc
comparator since there're two adc modules in npcx4 series.

Signed-off-by: Kate Yen <htyen@nuvoton.com>
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
This commit is contained in:
Mulin Chao 2023-08-28 23:53:25 -07:00 committed by Carles Cufí
commit d2892c1123
3 changed files with 26 additions and 2 deletions

View file

@ -256,7 +256,7 @@ static const struct sensor_driver_api adc_cmp_npcx_api = {
static const struct adc_cmp_npcx_config adc_cmp_npcx_config_##inst = {\
.adc = DEVICE_DT_GET(DT_INST_IO_CHANNELS_CTLR(inst)), \
.chnsel = DT_INST_IO_CHANNELS_INPUT(inst), \
.th_sel = inst, \
.th_sel = DT_INST_STRING_TOKEN_OR(inst, thr_sel, inst), \
.thr_mv = DT_INST_PROP_OR(inst, threshold_mv, \
ADC_CMP_NPCX_UNDEFINED), \
.comparison = DT_INST_STRING_TOKEN_OR(inst, \

View file

@ -1,6 +1,5 @@
# Copyright (c) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
description: |
This will perform signal comparision with threshold established.
@ -28,3 +27,15 @@ properties:
enum:
- ADC_CMP_NPCX_GREATER
- ADC_CMP_NPCX_LESS_OR_EQUAL
thr-sel:
type: string
description: |
Determines the register for threshold control and event.
enum:
- ADC_CMP_NPCX_THRCTL1
- ADC_CMP_NPCX_THRCTL2
- ADC_CMP_NPCX_THRCTL3
- ADC_CMP_NPCX_THRCTL4
- ADC_CMP_NPCX_THRCTL5
- ADC_CMP_NPCX_THRCTL6

View file

@ -12,6 +12,19 @@ enum adc_cmp_npcx_comparison {
ADC_CMP_NPCX_LESS_OR_EQUAL,
};
/* Supported ADC threshold controllers in NPCX series */
enum npcx_adc_cmp_thrctl {
ADC_CMP_NPCX_THRCTL1,
ADC_CMP_NPCX_THRCTL2,
ADC_CMP_NPCX_THRCTL3,
#if !defined(CONFIG_SOC_SERIES_NPCX7)
ADC_CMP_NPCX_THRCTL4,
ADC_CMP_NPCX_THRCTL5,
ADC_CMP_NPCX_THRCTL6,
#endif
ADC_CMP_NPCX_THRCTL_COUNT,
};
enum adc_cmp_npcx_sensor_attribute {
SENSOR_ATTR_LOWER_VOLTAGE_THRESH = SENSOR_ATTR_PRIV_START,
SENSOR_ATTR_UPPER_VOLTAGE_THRESH,