summaryrefslogtreecommitdiff
path: root/chip/it83xx/dac_chip.h
blob: fa50769c850d17f6286b826cf6a2cf21c6eb13b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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 */