2 * Nuvoton NPCM7xx ADC Module
4 * Copyright 2020 Google LLC
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 #include "hw/sysbus.h"
22 #include "qemu/timer.h"
24 #define NPCM7XX_ADC_NUM_INPUTS 8
26 * This value should not be changed unless write_adc_calibration function in
27 * hw/arm/npcm7xx.c is also changed.
29 #define NPCM7XX_ADC_NUM_CALIB 2
32 * struct NPCM7xxADCState - Analog to Digital Converter Module device state.
33 * @parent: System bus device.
34 * @iomem: Memory region through which registers are accessed.
35 * @conv_timer: The timer counts down remaining cycles for the conversion.
36 * @irq: GIC interrupt line to fire on expiration (if enabled).
37 * @con: The Control Register.
38 * @data: The Data Buffer.
39 * @clock: The ADC Clock.
40 * @adci: The input voltage in units of uV. 1uv = 1e-6V.
41 * @vref: The external reference voltage.
42 * @iref: The internal reference voltage, initialized at launch time.
43 * @rv: The calibrated output values of 0.5V and 1.5V for the ADC.
57 /* Voltages are in unit of uV. 1V = 1000000uV. */
58 uint32_t adci
[NPCM7XX_ADC_NUM_INPUTS
];
62 uint16_t calibration_r_values
[NPCM7XX_ADC_NUM_CALIB
];
65 #define TYPE_NPCM7XX_ADC "npcm7xx-adc"
66 #define NPCM7XX_ADC(obj) \
67 OBJECT_CHECK(NPCM7xxADCState, (obj), TYPE_NPCM7XX_ADC)
69 #endif /* NPCM7XX_ADC_H */