162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * 1-Wire implementation for the ds2780 chip
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2010 Indesign, LLC
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Author: Clifton Barnes <cabarnes@indesign-llc.com>
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * Based on w1-ds2760 driver
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef _W1_DS2780_H
1362306a36Sopenharmony_ci#define _W1_DS2780_H
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci/* Function commands */
1662306a36Sopenharmony_ci#define W1_DS2780_READ_DATA		0x69
1762306a36Sopenharmony_ci#define W1_DS2780_WRITE_DATA		0x6C
1862306a36Sopenharmony_ci#define W1_DS2780_COPY_DATA		0x48
1962306a36Sopenharmony_ci#define W1_DS2780_RECALL_DATA		0xB8
2062306a36Sopenharmony_ci#define W1_DS2780_LOCK			0x6A
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/* Register map */
2362306a36Sopenharmony_ci/* Register 0x00 Reserved */
2462306a36Sopenharmony_ci#define DS2780_STATUS_REG		0x01
2562306a36Sopenharmony_ci#define DS2780_RAAC_MSB_REG		0x02
2662306a36Sopenharmony_ci#define DS2780_RAAC_LSB_REG		0x03
2762306a36Sopenharmony_ci#define DS2780_RSAC_MSB_REG		0x04
2862306a36Sopenharmony_ci#define DS2780_RSAC_LSB_REG		0x05
2962306a36Sopenharmony_ci#define DS2780_RARC_REG			0x06
3062306a36Sopenharmony_ci#define DS2780_RSRC_REG			0x07
3162306a36Sopenharmony_ci#define DS2780_IAVG_MSB_REG		0x08
3262306a36Sopenharmony_ci#define DS2780_IAVG_LSB_REG		0x09
3362306a36Sopenharmony_ci#define DS2780_TEMP_MSB_REG		0x0A
3462306a36Sopenharmony_ci#define DS2780_TEMP_LSB_REG		0x0B
3562306a36Sopenharmony_ci#define DS2780_VOLT_MSB_REG		0x0C
3662306a36Sopenharmony_ci#define DS2780_VOLT_LSB_REG		0x0D
3762306a36Sopenharmony_ci#define DS2780_CURRENT_MSB_REG		0x0E
3862306a36Sopenharmony_ci#define DS2780_CURRENT_LSB_REG		0x0F
3962306a36Sopenharmony_ci#define DS2780_ACR_MSB_REG		0x10
4062306a36Sopenharmony_ci#define DS2780_ACR_LSB_REG		0x11
4162306a36Sopenharmony_ci#define DS2780_ACRL_MSB_REG		0x12
4262306a36Sopenharmony_ci#define DS2780_ACRL_LSB_REG		0x13
4362306a36Sopenharmony_ci#define DS2780_AS_REG			0x14
4462306a36Sopenharmony_ci#define DS2780_SFR_REG			0x15
4562306a36Sopenharmony_ci#define DS2780_FULL_MSB_REG		0x16
4662306a36Sopenharmony_ci#define DS2780_FULL_LSB_REG		0x17
4762306a36Sopenharmony_ci#define DS2780_AE_MSB_REG		0x18
4862306a36Sopenharmony_ci#define DS2780_AE_LSB_REG		0x19
4962306a36Sopenharmony_ci#define DS2780_SE_MSB_REG		0x1A
5062306a36Sopenharmony_ci#define DS2780_SE_LSB_REG		0x1B
5162306a36Sopenharmony_ci/* Register 0x1C - 0x1E Reserved */
5262306a36Sopenharmony_ci#define DS2780_EEPROM_REG		0x1F
5362306a36Sopenharmony_ci#define DS2780_EEPROM_BLOCK0_START	0x20
5462306a36Sopenharmony_ci/* Register 0x20 - 0x2F User EEPROM */
5562306a36Sopenharmony_ci#define DS2780_EEPROM_BLOCK0_END	0x2F
5662306a36Sopenharmony_ci/* Register 0x30 - 0x5F Reserved */
5762306a36Sopenharmony_ci#define DS2780_EEPROM_BLOCK1_START	0x60
5862306a36Sopenharmony_ci#define DS2780_CONTROL_REG		0x60
5962306a36Sopenharmony_ci#define DS2780_AB_REG			0x61
6062306a36Sopenharmony_ci#define DS2780_AC_MSB_REG		0x62
6162306a36Sopenharmony_ci#define DS2780_AC_LSB_REG		0x63
6262306a36Sopenharmony_ci#define DS2780_VCHG_REG			0x64
6362306a36Sopenharmony_ci#define DS2780_IMIN_REG			0x65
6462306a36Sopenharmony_ci#define DS2780_VAE_REG			0x66
6562306a36Sopenharmony_ci#define DS2780_IAE_REG			0x67
6662306a36Sopenharmony_ci#define DS2780_AE_40_REG		0x68
6762306a36Sopenharmony_ci#define DS2780_RSNSP_REG		0x69
6862306a36Sopenharmony_ci#define DS2780_FULL_40_MSB_REG		0x6A
6962306a36Sopenharmony_ci#define DS2780_FULL_40_LSB_REG		0x6B
7062306a36Sopenharmony_ci#define DS2780_FULL_3040_SLOPE_REG	0x6C
7162306a36Sopenharmony_ci#define DS2780_FULL_2030_SLOPE_REG	0x6D
7262306a36Sopenharmony_ci#define DS2780_FULL_1020_SLOPE_REG	0x6E
7362306a36Sopenharmony_ci#define DS2780_FULL_0010_SLOPE_REG	0x6F
7462306a36Sopenharmony_ci#define DS2780_AE_3040_SLOPE_REG	0x70
7562306a36Sopenharmony_ci#define DS2780_AE_2030_SLOPE_REG	0x71
7662306a36Sopenharmony_ci#define DS2780_AE_1020_SLOPE_REG	0x72
7762306a36Sopenharmony_ci#define DS2780_AE_0010_SLOPE_REG	0x73
7862306a36Sopenharmony_ci#define DS2780_SE_3040_SLOPE_REG	0x74
7962306a36Sopenharmony_ci#define DS2780_SE_2030_SLOPE_REG	0x75
8062306a36Sopenharmony_ci#define DS2780_SE_1020_SLOPE_REG	0x76
8162306a36Sopenharmony_ci#define DS2780_SE_0010_SLOPE_REG	0x77
8262306a36Sopenharmony_ci#define DS2780_RSGAIN_MSB_REG		0x78
8362306a36Sopenharmony_ci#define DS2780_RSGAIN_LSB_REG		0x79
8462306a36Sopenharmony_ci#define DS2780_RSTC_REG			0x7A
8562306a36Sopenharmony_ci#define DS2780_FRSGAIN_MSB_REG		0x7B
8662306a36Sopenharmony_ci#define DS2780_FRSGAIN_LSB_REG		0x7C
8762306a36Sopenharmony_ci#define DS2780_EEPROM_BLOCK1_END	0x7C
8862306a36Sopenharmony_ci/* Register 0x7D - 0xFF Reserved */
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci/* Number of valid register addresses */
9162306a36Sopenharmony_ci#define DS2780_DATA_SIZE		0x80
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci/* Status register bits */
9462306a36Sopenharmony_ci#define DS2780_STATUS_REG_CHGTF		(1 << 7)
9562306a36Sopenharmony_ci#define DS2780_STATUS_REG_AEF		(1 << 6)
9662306a36Sopenharmony_ci#define DS2780_STATUS_REG_SEF		(1 << 5)
9762306a36Sopenharmony_ci#define DS2780_STATUS_REG_LEARNF	(1 << 4)
9862306a36Sopenharmony_ci/* Bit 3 Reserved */
9962306a36Sopenharmony_ci#define DS2780_STATUS_REG_UVF		(1 << 2)
10062306a36Sopenharmony_ci#define DS2780_STATUS_REG_PORF		(1 << 1)
10162306a36Sopenharmony_ci/* Bit 0 Reserved */
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci/* Control register bits */
10462306a36Sopenharmony_ci/* Bit 7 Reserved */
10562306a36Sopenharmony_ci#define DS2780_CONTROL_REG_UVEN		(1 << 6)
10662306a36Sopenharmony_ci#define DS2780_CONTROL_REG_PMOD		(1 << 5)
10762306a36Sopenharmony_ci#define DS2780_CONTROL_REG_RNAOP	(1 << 4)
10862306a36Sopenharmony_ci/* Bit 0 - 3 Reserved */
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci/* Special feature register bits */
11162306a36Sopenharmony_ci/* Bit 1 - 7 Reserved */
11262306a36Sopenharmony_ci#define DS2780_SFR_REG_PIOSC		(1 << 0)
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci/* EEPROM register bits */
11562306a36Sopenharmony_ci#define DS2780_EEPROM_REG_EEC		(1 << 7)
11662306a36Sopenharmony_ci#define DS2780_EEPROM_REG_LOCK		(1 << 6)
11762306a36Sopenharmony_ci/* Bit 2 - 6 Reserved */
11862306a36Sopenharmony_ci#define DS2780_EEPROM_REG_BL1		(1 << 1)
11962306a36Sopenharmony_ci#define DS2780_EEPROM_REG_BL0		(1 << 0)
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ciextern int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count,
12262306a36Sopenharmony_ci			int io);
12362306a36Sopenharmony_ciextern int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd);
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci#endif /* !_W1_DS2780_H */
126