summaryrefslogtreecommitdiff
path: root/chip/npcx/adc_chip.h
diff options
context:
space:
mode:
authorWealian Liao <whliao@nuvoton.corp-partner.google.com>2020-09-15 13:08:41 +0800
committerCommit Bot <commit-bot@chromium.org>2020-09-25 12:24:02 +0000
commita309b7aa4cd11ff1b19cf60c4b561e3c0e67564d (patch)
treef0d9fe3b8a2d03450db9ed4ee9fcc5d8f25c430b /chip/npcx/adc_chip.h
parentd0a1ed5604e6a80c17a4bc5f1b4a8a57ad331c35 (diff)
downloadchrome-ec-a309b7aa4cd11ff1b19cf60c4b561e3c0e67564d.tar.gz
npcx: fix ADC repetitive mode and single mode switch
This CL fix ADC repetitive/single mode switch and repetitive mode channel enable toggle issue. 1. ADC repetitive mode doesn't work after invoking adc_read_channel(). After invoking adc_read_channel(), the ADC module sets to single channel operation mode. ADC doesn't set back to repetitive mode. This CL sets ADC back to the repetitive mode in adc_read_channel() if anyone uses repetitive mode. Moreover, Add a adc_read_data() function for ADC data read directly. 2. When repetitive channel disable, npcx_set_adc_repetitive() sets ADC to one-shot mode. It makes ADC stop repetitively scan. This CL adds ADC stop before ADC setting in npcx_set_adc_repetitive() and moves the ADC mode setting to all channel disable. 3. THR_STS bit in THRCTS register is R/W1C. It will be clear by read-modify-write other bits. 4. ADC driver shared the same IRQ. Add event enable check for different ADC events. BRANCH=none BUG=b:167319238 TEST=pass "make buildall" TEST= 1. enable ADC repetitive mode 2. read ADC data by console command "ADC" 3. check whether the ADC repetitive mode works correctly 4. toggle ADC channel enable for repetitive mode 5. check whether another channel works correctly Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Signed-off-by: CHLin <CHLin56@nuvoton.com> Change-Id: Ie9183163de49235f551218af93ddd75ea87d7af2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2409718 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'chip/npcx/adc_chip.h')
-rw-r--r--chip/npcx/adc_chip.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/chip/npcx/adc_chip.h b/chip/npcx/adc_chip.h
index 74f18c66d6..b9efb9bf6c 100644
--- a/chip/npcx/adc_chip.h
+++ b/chip/npcx/adc_chip.h
@@ -105,4 +105,13 @@ void npcx_set_adc_repetitive(enum npcx_adc_input_channel input_ch, int enable);
* @param enable - 1 to enable, 0 to disable
*/
void npcx_adc_thresh_int_enable(int threshold_idx, int enable);
+
+/**
+ * Return the ADC value from CHNDAT register directly when the channel is
+ * configured in the repetitive mode.
+ *
+ * @param input_ch channel number
+ * @return ADC data
+ */
+int adc_read_data(enum npcx_adc_input_channel input_ch);
#endif /* __CROS_EC_ADC_CHIP_H */