linux/include/linux/mfd/wm8350/comparator.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * comparator.h  --  Comparator Aux ADC for Wolfson WM8350 PMIC
 *
 * Copyright 2007 Wolfson Microelectronics PLC
 */

#ifndef __LINUX_MFD_WM8350_COMPARATOR_H_
#define __LINUX_MFD_WM8350_COMPARATOR_H_

/*
 * Registers
 */

#define WM8350_DIGITISER_CONTROL_1
#define WM8350_DIGITISER_CONTROL_2
#define WM8350_AUX1_READBACK
#define WM8350_AUX2_READBACK
#define WM8350_AUX3_READBACK
#define WM8350_AUX4_READBACK
#define WM8350_CHIP_TEMP_READBACK
#define WM8350_GENERIC_COMPARATOR_CONTROL
#define WM8350_GENERIC_COMPARATOR_1
#define WM8350_GENERIC_COMPARATOR_2
#define WM8350_GENERIC_COMPARATOR_3
#define WM8350_GENERIC_COMPARATOR_4

/*
 * R144 (0x90) - Digitiser Control (1)
 */
#define WM8350_AUXADC_CTC
#define WM8350_AUXADC_POLL
#define WM8350_AUXADC_HIB_MODE
#define WM8350_AUXADC_SEL8
#define WM8350_AUXADC_SEL7
#define WM8350_AUXADC_SEL6
#define WM8350_AUXADC_SEL5
#define WM8350_AUXADC_SEL4
#define WM8350_AUXADC_SEL3
#define WM8350_AUXADC_SEL2
#define WM8350_AUXADC_SEL1

/*
 * R145 (0x91) - Digitiser Control (2)
 */
#define WM8350_AUXADC_MASKMODE_MASK
#define WM8350_AUXADC_CRATE_MASK
#define WM8350_AUXADC_CAL
#define WM8350_AUX_RBMODE
#define WM8350_AUXADC_WAIT

/*
 * R152 (0x98) - AUX1 Readback
 */
#define WM8350_AUXADC_SCALE1_MASK
#define WM8350_AUXADC_REF1
#define WM8350_AUXADC_DATA1_MASK

/*
 * R153 (0x99) - AUX2 Readback
 */
#define WM8350_AUXADC_SCALE2_MASK
#define WM8350_AUXADC_REF2
#define WM8350_AUXADC_DATA2_MASK

/*
 * R154 (0x9A) - AUX3 Readback
 */
#define WM8350_AUXADC_SCALE3_MASK
#define WM8350_AUXADC_REF3
#define WM8350_AUXADC_DATA3_MASK

/*
 * R155 (0x9B) - AUX4 Readback
 */
#define WM8350_AUXADC_SCALE4_MASK
#define WM8350_AUXADC_REF4
#define WM8350_AUXADC_DATA4_MASK

/*
 * R156 (0x9C) - USB Voltage Readback
 */
#define WM8350_AUXADC_DATA_USB_MASK

/*
 * R157 (0x9D) - LINE Voltage Readback
 */
#define WM8350_AUXADC_DATA_LINE_MASK

/*
 * R158 (0x9E) - BATT Voltage Readback
 */
#define WM8350_AUXADC_DATA_BATT_MASK

/*
 * R159 (0x9F) - Chip Temp Readback
 */
#define WM8350_AUXADC_DATA_CHIPTEMP_MASK

/*
 * R163 (0xA3) - Generic Comparator Control
 */
#define WM8350_DCMP4_ENA
#define WM8350_DCMP3_ENA
#define WM8350_DCMP2_ENA
#define WM8350_DCMP1_ENA

/*
 * R164 (0xA4) - Generic comparator 1
 */
#define WM8350_DCMP1_SRCSEL_MASK
#define WM8350_DCMP1_GT
#define WM8350_DCMP1_THR_MASK

/*
 * R165 (0xA5) - Generic comparator 2
 */
#define WM8350_DCMP2_SRCSEL_MASK
#define WM8350_DCMP2_GT
#define WM8350_DCMP2_THR_MASK

/*
 * R166 (0xA6) - Generic comparator 3
 */
#define WM8350_DCMP3_SRCSEL_MASK
#define WM8350_DCMP3_GT
#define WM8350_DCMP3_THR_MASK

/*
 * R167 (0xA7) - Generic comparator 4
 */
#define WM8350_DCMP4_SRCSEL_MASK
#define WM8350_DCMP4_GT
#define WM8350_DCMP4_THR_MASK

/*
 * Interrupts.
 */
#define WM8350_IRQ_AUXADC_DATARDY
#define WM8350_IRQ_AUXADC_DCOMP4
#define WM8350_IRQ_AUXADC_DCOMP3
#define WM8350_IRQ_AUXADC_DCOMP2
#define WM8350_IRQ_AUXADC_DCOMP1
#define WM8350_IRQ_SYS_HYST_COMP_FAIL
#define WM8350_IRQ_SYS_CHIP_GT115
#define WM8350_IRQ_SYS_CHIP_GT140

/*
 * USB/2, LINE & BATT = ((VRTC * 2) / 4095)) * 10e6 uV
 * Where VRTC = 2.7 V
 */
#define WM8350_AUX_COEFF

#define WM8350_AUXADC_AUX1
#define WM8350_AUXADC_AUX2
#define WM8350_AUXADC_AUX3
#define WM8350_AUXADC_AUX4
#define WM8350_AUXADC_USB
#define WM8350_AUXADC_LINE
#define WM8350_AUXADC_BATT
#define WM8350_AUXADC_TEMP

struct wm8350;

/*
 * AUX ADC Readback
 */
int wm8350_read_auxadc(struct wm8350 *wm8350, int channel, int scale,
		       int vref);

#endif