Source
x
/*
* Driver for Linear Technology LTC2990 power monitor
*
* Copyright (C) 2014 Topic Embedded Products
* Author: Mike Looijmans <mike.looijmans@topic.nl>
*
* License: GPLv2
*/
/* Enabled measurements for mode bits 2..0 */
static const int ltc2990_attrs_ena_0[] = {
LTC2990_IN1 | LTC2990_IN2 | LTC2990_TEMP3,
LTC2990_CURR1 | LTC2990_TEMP3,
LTC2990_CURR1 | LTC2990_IN3 | LTC2990_IN4,
LTC2990_TEMP2 | LTC2990_IN3 | LTC2990_IN4,
LTC2990_TEMP2 | LTC2990_CURR2,
LTC2990_TEMP2 | LTC2990_TEMP3,
LTC2990_CURR1 | LTC2990_CURR2,
LTC2990_IN1 | LTC2990_IN2 | LTC2990_IN3 | LTC2990_IN4
};
/* Enabled measurements for mode bits 4..3 */
static const int ltc2990_attrs_ena_1[] = {
LTC2990_NONE,
LTC2990_TEMP2 | LTC2990_IN1 | LTC2990_CURR1,
LTC2990_TEMP3 | LTC2990_IN3 | LTC2990_CURR2,
LTC2990_ALL
};
struct ltc2990_data {
struct i2c_client *i2c;
u32 mode[2];
};
/* Return the converted value from the given register in uV or mC */
static int ltc2990_get_value(struct i2c_client *i2c, int index, int *result)
{
int val;
u8 reg;
switch (index) {
case LTC2990_IN0:
reg = LTC2990_VCC_MSB;
break;
case LTC2990_IN1:
case LTC2990_CURR1:
case LTC2990_TEMP2:
reg = LTC2990_V1_MSB;
break;
case LTC2990_IN2:
reg = LTC2990_V2_MSB;
break;
case LTC2990_IN3:
case LTC2990_CURR2:
case LTC2990_TEMP3: