xref: /openbmc/linux/drivers/w1/slaves/w1_ds2780.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2275ac746SClifton Barnes /*
3275ac746SClifton Barnes  * 1-Wire implementation for the ds2780 chip
4275ac746SClifton Barnes  *
5275ac746SClifton Barnes  * Copyright (C) 2010 Indesign, LLC
6275ac746SClifton Barnes  *
7275ac746SClifton Barnes  * Author: Clifton Barnes <cabarnes@indesign-llc.com>
8275ac746SClifton Barnes  *
9275ac746SClifton Barnes  * Based on w1-ds2760 driver
10275ac746SClifton Barnes  */
11275ac746SClifton Barnes 
12275ac746SClifton Barnes #ifndef _W1_DS2780_H
13275ac746SClifton Barnes #define _W1_DS2780_H
14275ac746SClifton Barnes 
15275ac746SClifton Barnes /* Function commands */
16275ac746SClifton Barnes #define W1_DS2780_READ_DATA		0x69
17275ac746SClifton Barnes #define W1_DS2780_WRITE_DATA		0x6C
18275ac746SClifton Barnes #define W1_DS2780_COPY_DATA		0x48
19275ac746SClifton Barnes #define W1_DS2780_RECALL_DATA		0xB8
20275ac746SClifton Barnes #define W1_DS2780_LOCK			0x6A
21275ac746SClifton Barnes 
22275ac746SClifton Barnes /* Register map */
23275ac746SClifton Barnes /* Register 0x00 Reserved */
24275ac746SClifton Barnes #define DS2780_STATUS_REG		0x01
25275ac746SClifton Barnes #define DS2780_RAAC_MSB_REG		0x02
26275ac746SClifton Barnes #define DS2780_RAAC_LSB_REG		0x03
27275ac746SClifton Barnes #define DS2780_RSAC_MSB_REG		0x04
28275ac746SClifton Barnes #define DS2780_RSAC_LSB_REG		0x05
29275ac746SClifton Barnes #define DS2780_RARC_REG			0x06
30275ac746SClifton Barnes #define DS2780_RSRC_REG			0x07
31275ac746SClifton Barnes #define DS2780_IAVG_MSB_REG		0x08
32275ac746SClifton Barnes #define DS2780_IAVG_LSB_REG		0x09
33275ac746SClifton Barnes #define DS2780_TEMP_MSB_REG		0x0A
34275ac746SClifton Barnes #define DS2780_TEMP_LSB_REG		0x0B
35275ac746SClifton Barnes #define DS2780_VOLT_MSB_REG		0x0C
36275ac746SClifton Barnes #define DS2780_VOLT_LSB_REG		0x0D
37275ac746SClifton Barnes #define DS2780_CURRENT_MSB_REG		0x0E
38275ac746SClifton Barnes #define DS2780_CURRENT_LSB_REG		0x0F
39275ac746SClifton Barnes #define DS2780_ACR_MSB_REG		0x10
40275ac746SClifton Barnes #define DS2780_ACR_LSB_REG		0x11
41275ac746SClifton Barnes #define DS2780_ACRL_MSB_REG		0x12
42275ac746SClifton Barnes #define DS2780_ACRL_LSB_REG		0x13
43275ac746SClifton Barnes #define DS2780_AS_REG			0x14
44275ac746SClifton Barnes #define DS2780_SFR_REG			0x15
45275ac746SClifton Barnes #define DS2780_FULL_MSB_REG		0x16
46275ac746SClifton Barnes #define DS2780_FULL_LSB_REG		0x17
47275ac746SClifton Barnes #define DS2780_AE_MSB_REG		0x18
48275ac746SClifton Barnes #define DS2780_AE_LSB_REG		0x19
49275ac746SClifton Barnes #define DS2780_SE_MSB_REG		0x1A
50275ac746SClifton Barnes #define DS2780_SE_LSB_REG		0x1B
51275ac746SClifton Barnes /* Register 0x1C - 0x1E Reserved */
52275ac746SClifton Barnes #define DS2780_EEPROM_REG		0x1F
53275ac746SClifton Barnes #define DS2780_EEPROM_BLOCK0_START	0x20
54275ac746SClifton Barnes /* Register 0x20 - 0x2F User EEPROM */
55275ac746SClifton Barnes #define DS2780_EEPROM_BLOCK0_END	0x2F
56275ac746SClifton Barnes /* Register 0x30 - 0x5F Reserved */
57275ac746SClifton Barnes #define DS2780_EEPROM_BLOCK1_START	0x60
58275ac746SClifton Barnes #define DS2780_CONTROL_REG		0x60
59275ac746SClifton Barnes #define DS2780_AB_REG			0x61
60275ac746SClifton Barnes #define DS2780_AC_MSB_REG		0x62
61275ac746SClifton Barnes #define DS2780_AC_LSB_REG		0x63
62275ac746SClifton Barnes #define DS2780_VCHG_REG			0x64
63275ac746SClifton Barnes #define DS2780_IMIN_REG			0x65
64275ac746SClifton Barnes #define DS2780_VAE_REG			0x66
65275ac746SClifton Barnes #define DS2780_IAE_REG			0x67
66275ac746SClifton Barnes #define DS2780_AE_40_REG		0x68
67275ac746SClifton Barnes #define DS2780_RSNSP_REG		0x69
68275ac746SClifton Barnes #define DS2780_FULL_40_MSB_REG		0x6A
69275ac746SClifton Barnes #define DS2780_FULL_40_LSB_REG		0x6B
70275ac746SClifton Barnes #define DS2780_FULL_3040_SLOPE_REG	0x6C
71275ac746SClifton Barnes #define DS2780_FULL_2030_SLOPE_REG	0x6D
72275ac746SClifton Barnes #define DS2780_FULL_1020_SLOPE_REG	0x6E
73275ac746SClifton Barnes #define DS2780_FULL_0010_SLOPE_REG	0x6F
74275ac746SClifton Barnes #define DS2780_AE_3040_SLOPE_REG	0x70
75275ac746SClifton Barnes #define DS2780_AE_2030_SLOPE_REG	0x71
76275ac746SClifton Barnes #define DS2780_AE_1020_SLOPE_REG	0x72
77275ac746SClifton Barnes #define DS2780_AE_0010_SLOPE_REG	0x73
78275ac746SClifton Barnes #define DS2780_SE_3040_SLOPE_REG	0x74
79275ac746SClifton Barnes #define DS2780_SE_2030_SLOPE_REG	0x75
80275ac746SClifton Barnes #define DS2780_SE_1020_SLOPE_REG	0x76
81275ac746SClifton Barnes #define DS2780_SE_0010_SLOPE_REG	0x77
82275ac746SClifton Barnes #define DS2780_RSGAIN_MSB_REG		0x78
83275ac746SClifton Barnes #define DS2780_RSGAIN_LSB_REG		0x79
84275ac746SClifton Barnes #define DS2780_RSTC_REG			0x7A
85275ac746SClifton Barnes #define DS2780_FRSGAIN_MSB_REG		0x7B
86275ac746SClifton Barnes #define DS2780_FRSGAIN_LSB_REG		0x7C
87275ac746SClifton Barnes #define DS2780_EEPROM_BLOCK1_END	0x7C
88275ac746SClifton Barnes /* Register 0x7D - 0xFF Reserved */
89275ac746SClifton Barnes 
90275ac746SClifton Barnes /* Number of valid register addresses */
91275ac746SClifton Barnes #define DS2780_DATA_SIZE		0x80
92275ac746SClifton Barnes 
93275ac746SClifton Barnes /* Status register bits */
94275ac746SClifton Barnes #define DS2780_STATUS_REG_CHGTF		(1 << 7)
95275ac746SClifton Barnes #define DS2780_STATUS_REG_AEF		(1 << 6)
96275ac746SClifton Barnes #define DS2780_STATUS_REG_SEF		(1 << 5)
97275ac746SClifton Barnes #define DS2780_STATUS_REG_LEARNF	(1 << 4)
98275ac746SClifton Barnes /* Bit 3 Reserved */
99275ac746SClifton Barnes #define DS2780_STATUS_REG_UVF		(1 << 2)
100275ac746SClifton Barnes #define DS2780_STATUS_REG_PORF		(1 << 1)
101275ac746SClifton Barnes /* Bit 0 Reserved */
102275ac746SClifton Barnes 
103275ac746SClifton Barnes /* Control register bits */
104275ac746SClifton Barnes /* Bit 7 Reserved */
105275ac746SClifton Barnes #define DS2780_CONTROL_REG_UVEN		(1 << 6)
106275ac746SClifton Barnes #define DS2780_CONTROL_REG_PMOD		(1 << 5)
107275ac746SClifton Barnes #define DS2780_CONTROL_REG_RNAOP	(1 << 4)
108275ac746SClifton Barnes /* Bit 0 - 3 Reserved */
109275ac746SClifton Barnes 
110275ac746SClifton Barnes /* Special feature register bits */
111275ac746SClifton Barnes /* Bit 1 - 7 Reserved */
112275ac746SClifton Barnes #define DS2780_SFR_REG_PIOSC		(1 << 0)
113275ac746SClifton Barnes 
114275ac746SClifton Barnes /* EEPROM register bits */
115275ac746SClifton Barnes #define DS2780_EEPROM_REG_EEC		(1 << 7)
116275ac746SClifton Barnes #define DS2780_EEPROM_REG_LOCK		(1 << 6)
117275ac746SClifton Barnes /* Bit 2 - 6 Reserved */
118275ac746SClifton Barnes #define DS2780_EEPROM_REG_BL1		(1 << 1)
119275ac746SClifton Barnes #define DS2780_EEPROM_REG_BL0		(1 << 0)
120275ac746SClifton Barnes 
121275ac746SClifton Barnes extern int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count,
122275ac746SClifton Barnes 			int io);
123275ac746SClifton Barnes extern int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd);
124275ac746SClifton Barnes 
125275ac746SClifton Barnes #endif /* !_W1_DS2780_H */
126