From 937af456b82fad241049f02d276ad8f66b25a2de Mon Sep 17 00:00:00 2001 From: tim Date: Thu, 13 Feb 2020 14:37:38 +0800 Subject: it83xx/dac: add DAC module The DAC module has four channels. We can set output voltage when DAC channel is enabled by this driver. BUG=b:149094279 BRANCH=none TEST=The console command #dac set as follows: read: dac [ch] write: dac [ch] [voltage] [ch]:2-5, [voltage]:0(disable)-3300 Change-Id: I8e815cb5bc749467581d5f771fd6f9e0995fca3b Signed-off-by: tim Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2046685 Reviewed-by: Diana Z --- chip/it83xx/dac_chip.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 chip/it83xx/dac_chip.h (limited to 'chip/it83xx/dac_chip.h') diff --git a/chip/it83xx/dac_chip.h b/chip/it83xx/dac_chip.h new file mode 100644 index 0000000000..fa50769c85 --- /dev/null +++ b/chip/it83xx/dac_chip.h @@ -0,0 +1,58 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* IT83xx DAC module for Chrome EC */ + +#ifndef __CROS_EC_DAC_CHIP_H +#define __CROS_EC_DAC_CHIP_H + +#define DAC_AVCC 3300 +/* + * Each channel generates an output ranging + * from 0V to AVCC with 8-bit resolution. + */ +#define DAC_RAW_DATA (BIT(8) - 1) + +/* List of DAC channels. */ +enum chip_dac_channel { + CHIP_DAC_CH2 = 2, + CHIP_DAC_CH3, + CHIP_DAC_CH4, + CHIP_DAC_CH5, +}; + +/** + * DAC module enable. + * + * @param ch Channel to enable. + */ +void dac_enable_channel(enum chip_dac_channel ch); + +/** + * DAC module disable. + * + * @param ch Channel to disable. + */ +void dac_disable_channel(enum chip_dac_channel ch); + +/** + * Set DAC output voltage. + * + * @param ch Channel to set. + * @param mv Setting ch output voltage. + */ +void dac_set_output_voltage(enum chip_dac_channel ch, int mv); + +/** + * Get DAC output voltage. + * + * @param ch Channel to get. + * + * @return Getting ch output voltage. + */ +int dac_get_output_voltage(enum chip_dac_channel ch); + +#endif /* __CROS_EC_DAC_CHIP_H */ + -- cgit v1.2.1