summaryrefslogtreecommitdiff
path: root/include/linux/ina3221.h
blob: d0e0d20878d051c8d363ae71305eb86fc2443c08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * include/linux/ina3221.h
 *
 * Copyright (c) 2013-2014, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef _INA3221_H
#define _INA3221_H

#include <linux/types.h>

#define INA3221_CONFIG			0x00
#define INA3221_SHUNT_VOL_CHAN1		0x01
#define INA3221_BUS_VOL_CHAN1		0x02
#define INA3221_SHUNT_VOL_CHAN2		0x03
#define INA3221_BUS_VOL_CHAN2		0x04
#define INA3221_SHUNT_VOL_CHAN3		0x05
#define INA3221_BUS_VOL_CHAN3		0x06
#define INA3221_CRIT_CHAN1		0x07
#define INA3221_WARN_CHAN1		0x08
#define INA3221_CRIT_CHAN2		0x09
#define INA3221_WARN_CHAN2		0x0A
#define INA3221_CRIT_CHAN3		0x0B
#define INA3221_WARN_CHAN3		0x0C
#define INA3221_MASK_ENABLE		0x0F

#define INA3221_SHUNT_VOL(i)		(INA3221_SHUNT_VOL_CHAN1 + (i) * 2)
#define INA3221_BUS_VOL(i)		(INA3221_BUS_VOL_CHAN1 + (i) * 2)
#define INA3221_CRIT(i)                 (INA3221_CRIT_CHAN1 + (i) * 2)
#define INA3221_WARN(i)                 (INA3221_WARN_CHAN1 + (i) * 2)

#define INA3221_RESET			0x8000
#define INA3221_POWER_DOWN		0
#define INA3221_ENABLE_CHAN		(7 << 12) /* enable all 3 channels */
#define INA3221_AVG			(3 << 9) /* 64 averages */
#define INA3221_VBUS_CT			(4 << 6) /* Vbus 1.1 mS conv time */
#define INA3221_VSHUNT_CT		(4 << 3) /* Vshunt 1.1 mS conv time */
#define INA3221_CONT_MODE		7 /* continuous bus n shunt V measure */
#define INA3221_TRIG_MODE		3 /* triggered bus n shunt V measure */

#define INA3221_CONT_CONFIG_DATA	(INA3221_ENABLE_CHAN | INA3221_AVG | \
					INA3221_VBUS_CT | INA3221_VSHUNT_CT | \
					INA3221_CONT_MODE) /* 0x7727 */

#define INA3221_TRIG_CONFIG_DATA	(INA3221_ENABLE_CHAN | \
					INA3221_TRIG_MODE) /* 0x7723 */

#define INA3221_NUMBER_OF_RAILS		3
#define INA3221_RAIL_NAME_SIZE		32

struct ina3221_platform_data {
	char rail_name[INA3221_NUMBER_OF_RAILS][INA3221_RAIL_NAME_SIZE];
	u32 shunt_resistor[INA3221_NUMBER_OF_RAILS]; /* specify in mOhms */
	u16 cont_conf_data; /* config data for continuous mode */
	u16 trig_conf_data; /* config data for triggered mode */
	u32 warn_conf_limits[INA3221_NUMBER_OF_RAILS]; /* in mAmps */
	u32 crit_conf_limits[INA3221_NUMBER_OF_RAILS]; /* in mAmps */
};

#endif /* _LINUX_INA3221_H */