linux/drivers/w1/slaves/w1_ds2781.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * 1-Wire implementation for the ds2780 chip
 *
 * Author: Renata Sayakhova <[email protected]>
 *
 * Based on w1-ds2760 driver
 */

#ifndef _W1_DS2781_H
#define _W1_DS2781_H

/* Function commands */
#define W1_DS2781_READ_DATA
#define W1_DS2781_WRITE_DATA
#define W1_DS2781_COPY_DATA
#define W1_DS2781_RECALL_DATA
#define W1_DS2781_LOCK

/* Register map */
/* Register 0x00 Reserved */
#define DS2781_STATUS
#define DS2781_RAAC_MSB
#define DS2781_RAAC_LSB
#define DS2781_RSAC_MSB
#define DS2781_RSAC_LSB
#define DS2781_RARC
#define DS2781_RSRC
#define DS2781_IAVG_MSB
#define DS2781_IAVG_LSB
#define DS2781_TEMP_MSB
#define DS2781_TEMP_LSB
#define DS2781_VOLT_MSB
#define DS2781_VOLT_LSB
#define DS2781_CURRENT_MSB
#define DS2781_CURRENT_LSB
#define DS2781_ACR_MSB
#define DS2781_ACR_LSB
#define DS2781_ACRL_MSB
#define DS2781_ACRL_LSB
#define DS2781_AS
#define DS2781_SFR
#define DS2781_FULL_MSB
#define DS2781_FULL_LSB
#define DS2781_AE_MSB
#define DS2781_AE_LSB
#define DS2781_SE_MSB
#define DS2781_SE_LSB
/* Register 0x1C - 0x1E Reserved */
#define DS2781_EEPROM
#define DS2781_EEPROM_BLOCK0_START
/* Register 0x20 - 0x2F User EEPROM */
#define DS2781_EEPROM_BLOCK0_END
/* Register 0x30 - 0x5F Reserved */
#define DS2781_EEPROM_BLOCK1_START
#define DS2781_CONTROL
#define DS2781_AB
#define DS2781_AC_MSB
#define DS2781_AC_LSB
#define DS2781_VCHG
#define DS2781_IMIN
#define DS2781_VAE
#define DS2781_IAE
#define DS2781_AE_40
#define DS2781_RSNSP
#define DS2781_FULL_40_MSB
#define DS2781_FULL_40_LSB
#define DS2781_FULL_4_SLOPE
#define DS2781_FULL_3_SLOPE
#define DS2781_FULL_2_SLOPE
#define DS2781_FULL_1_SLOPE
#define DS2781_AE_4_SLOPE
#define DS2781_AE_3_SLOPE
#define DS2781_AE_2_SLOPE
#define DS2781_AE_1_SLOPE
#define DS2781_SE_4_SLOPE
#define DS2781_SE_3_SLOPE
#define DS2781_SE_2_SLOPE
#define DS2781_SE_1_SLOPE
#define DS2781_RSGAIN_MSB
#define DS2781_RSGAIN_LSB
#define DS2781_RSTC
#define DS2781_COB
#define DS2781_TBP34
#define DS2781_TBP23
#define DS2781_TBP12
#define DS2781_EEPROM_BLOCK1_END
/* Register 0x7D - 0xFF Reserved */

#define DS2781_FSGAIN_MSB
#define DS2781_FSGAIN_LSB

/* Number of valid register addresses */
#define DS2781_DATA_SIZE

/* Status register bits */
#define DS2781_STATUS_CHGTF
#define DS2781_STATUS_AEF
#define DS2781_STATUS_SEF
#define DS2781_STATUS_LEARNF
/* Bit 3 Reserved */
#define DS2781_STATUS_UVF
#define DS2781_STATUS_PORF
/* Bit 0 Reserved */

/* Control register bits */
/* Bit 7 Reserved */
#define DS2781_CONTROL_NBEN
#define DS2781_CONTROL_UVEN
#define DS2781_CONTROL_PMOD
#define DS2781_CONTROL_RNAOP
#define DS1781_CONTROL_UVTH
/* Bit 0 - 2 Reserved */

/* Special feature register bits */
/* Bit 1 - 7 Reserved */
#define DS2781_SFR_PIOSC

/* EEPROM register bits */
#define DS2781_EEPROM_EEC
#define DS2781_EEPROM_LOCK
/* Bit 2 - 6 Reserved */
#define DS2781_EEPROM_BL1
#define DS2781_EEPROM_BL0

extern int w1_ds2781_io(struct device *dev, char *buf, int addr, size_t count,
			int io);
extern int w1_ds2781_eeprom_cmd(struct device *dev, int addr, int cmd);

#endif /* !_W1_DS2781_H */