linux/drivers/hwmon/max16065.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Driver for
 *  Maxim MAX16065/MAX16066 12-Channel/8-Channel, Flash-Configurable
 *  System Managers with Nonvolatile Fault Registers
 *  Maxim MAX16067/MAX16068 6-Channel, Flash-Configurable System Managers
 *  with Nonvolatile Fault Registers
 *  Maxim MAX16070/MAX16071 12-Channel/8-Channel, Flash-Configurable System
 *  Monitors with Nonvolatile Fault Registers
 *
 * Copyright (C) 2011 Ericsson AB.
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/jiffies.h>

enum chips {};

/*
 * Registers
 */
#define MAX16065_ADC(x)

#define MAX16065_CURR_SENSE
#define MAX16065_CSP_ADC
#define MAX16065_FAULT(x)
#define MAX16065_SCALE(x)
#define MAX16065_CURR_CONTROL
#define MAX16065_LIMIT(l, x)

#define MAX16065_SW_ENABLE

#define MAX16065_WARNING_OV

#define MAX16065_CURR_ENABLE

#define MAX16065_NUM_LIMIT
#define MAX16065_NUM_ADC

static const int max16065_num_adc[] =;

static const bool max16065_have_secondary[] =;

static const bool max16065_have_current[] =;

struct max16065_data {};

static const int max16065_adc_range[] =;
static const int max16065_csp_adc_range[] =;

/* ADC registers have 10 bit resolution. */
static inline int ADC_TO_MV(int adc, int range)
{}

/*
 * Limit registers have 8 bit resolution and match upper 8 bits of ADC
 * registers.
 */
static inline int LIMIT_TO_MV(int limit, int range)
{}

static inline int MV_TO_LIMIT(int mv, int range)
{}

static inline int ADC_TO_CURR(int adc, int gain)
{}

/*
 * max16065_read_adc()
 *
 * Read 16 bit value from <reg>, <reg+1>.
 * Upper 8 bits are in <reg>, lower 2 bits are in bits 7:6 of <reg+1>.
 */
static int max16065_read_adc(struct i2c_client *client, int reg)
{}

static struct max16065_data *max16065_update_device(struct device *dev)
{}

static ssize_t max16065_alarm_show(struct device *dev,
				   struct device_attribute *da, char *buf)
{}

static ssize_t max16065_input_show(struct device *dev,
				   struct device_attribute *da, char *buf)
{}

static ssize_t max16065_current_show(struct device *dev,
				     struct device_attribute *da, char *buf)
{}

static ssize_t max16065_limit_store(struct device *dev,
				    struct device_attribute *da,
				    const char *buf, size_t count)
{}

static ssize_t max16065_limit_show(struct device *dev,
				   struct device_attribute *da, char *buf)
{}

/* Construct a sensor_device_attribute structure for each register */

/* Input voltages */
static SENSOR_DEVICE_ATTR_RO(in0_input, max16065_input, 0);
static SENSOR_DEVICE_ATTR_RO(in1_input, max16065_input, 1);
static SENSOR_DEVICE_ATTR_RO(in2_input, max16065_input, 2);
static SENSOR_DEVICE_ATTR_RO(in3_input, max16065_input, 3);
static SENSOR_DEVICE_ATTR_RO(in4_input, max16065_input, 4);
static SENSOR_DEVICE_ATTR_RO(in5_input, max16065_input, 5);
static SENSOR_DEVICE_ATTR_RO(in6_input, max16065_input, 6);
static SENSOR_DEVICE_ATTR_RO(in7_input, max16065_input, 7);
static SENSOR_DEVICE_ATTR_RO(in8_input, max16065_input, 8);
static SENSOR_DEVICE_ATTR_RO(in9_input, max16065_input, 9);
static SENSOR_DEVICE_ATTR_RO(in10_input, max16065_input, 10);
static SENSOR_DEVICE_ATTR_RO(in11_input, max16065_input, 11);
static SENSOR_DEVICE_ATTR_RO(in12_input, max16065_input, 12);

/* Input voltages lcrit */
static SENSOR_DEVICE_ATTR_2_RW(in0_lcrit, max16065_limit, 2, 0);
static SENSOR_DEVICE_ATTR_2_RW(in1_lcrit, max16065_limit, 2, 1);
static SENSOR_DEVICE_ATTR_2_RW(in2_lcrit, max16065_limit, 2, 2);
static SENSOR_DEVICE_ATTR_2_RW(in3_lcrit, max16065_limit, 2, 3);
static SENSOR_DEVICE_ATTR_2_RW(in4_lcrit, max16065_limit, 2, 4);
static SENSOR_DEVICE_ATTR_2_RW(in5_lcrit, max16065_limit, 2, 5);
static SENSOR_DEVICE_ATTR_2_RW(in6_lcrit, max16065_limit, 2, 6);
static SENSOR_DEVICE_ATTR_2_RW(in7_lcrit, max16065_limit, 2, 7);
static SENSOR_DEVICE_ATTR_2_RW(in8_lcrit, max16065_limit, 2, 8);
static SENSOR_DEVICE_ATTR_2_RW(in9_lcrit, max16065_limit, 2, 9);
static SENSOR_DEVICE_ATTR_2_RW(in10_lcrit, max16065_limit, 2, 10);
static SENSOR_DEVICE_ATTR_2_RW(in11_lcrit, max16065_limit, 2, 11);

/* Input voltages crit */
static SENSOR_DEVICE_ATTR_2_RW(in0_crit, max16065_limit, 1, 0);
static SENSOR_DEVICE_ATTR_2_RW(in1_crit, max16065_limit, 1, 1);
static SENSOR_DEVICE_ATTR_2_RW(in2_crit, max16065_limit, 1, 2);
static SENSOR_DEVICE_ATTR_2_RW(in3_crit, max16065_limit, 1, 3);
static SENSOR_DEVICE_ATTR_2_RW(in4_crit, max16065_limit, 1, 4);
static SENSOR_DEVICE_ATTR_2_RW(in5_crit, max16065_limit, 1, 5);
static SENSOR_DEVICE_ATTR_2_RW(in6_crit, max16065_limit, 1, 6);
static SENSOR_DEVICE_ATTR_2_RW(in7_crit, max16065_limit, 1, 7);
static SENSOR_DEVICE_ATTR_2_RW(in8_crit, max16065_limit, 1, 8);
static SENSOR_DEVICE_ATTR_2_RW(in9_crit, max16065_limit, 1, 9);
static SENSOR_DEVICE_ATTR_2_RW(in10_crit, max16065_limit, 1, 10);
static SENSOR_DEVICE_ATTR_2_RW(in11_crit, max16065_limit, 1, 11);

/* Input voltages min */
static SENSOR_DEVICE_ATTR_2_RW(in0_min, max16065_limit, 0, 0);
static SENSOR_DEVICE_ATTR_2_RW(in1_min, max16065_limit, 0, 1);
static SENSOR_DEVICE_ATTR_2_RW(in2_min, max16065_limit, 0, 2);
static SENSOR_DEVICE_ATTR_2_RW(in3_min, max16065_limit, 0, 3);
static SENSOR_DEVICE_ATTR_2_RW(in4_min, max16065_limit, 0, 4);
static SENSOR_DEVICE_ATTR_2_RW(in5_min, max16065_limit, 0, 5);
static SENSOR_DEVICE_ATTR_2_RW(in6_min, max16065_limit, 0, 6);
static SENSOR_DEVICE_ATTR_2_RW(in7_min, max16065_limit, 0, 7);
static SENSOR_DEVICE_ATTR_2_RW(in8_min, max16065_limit, 0, 8);
static SENSOR_DEVICE_ATTR_2_RW(in9_min, max16065_limit, 0, 9);
static SENSOR_DEVICE_ATTR_2_RW(in10_min, max16065_limit, 0, 10);
static SENSOR_DEVICE_ATTR_2_RW(in11_min, max16065_limit, 0, 11);

/* Input voltages max */
static SENSOR_DEVICE_ATTR_2_RW(in0_max, max16065_limit, 0, 0);
static SENSOR_DEVICE_ATTR_2_RW(in1_max, max16065_limit, 0, 1);
static SENSOR_DEVICE_ATTR_2_RW(in2_max, max16065_limit, 0, 2);
static SENSOR_DEVICE_ATTR_2_RW(in3_max, max16065_limit, 0, 3);
static SENSOR_DEVICE_ATTR_2_RW(in4_max, max16065_limit, 0, 4);
static SENSOR_DEVICE_ATTR_2_RW(in5_max, max16065_limit, 0, 5);
static SENSOR_DEVICE_ATTR_2_RW(in6_max, max16065_limit, 0, 6);
static SENSOR_DEVICE_ATTR_2_RW(in7_max, max16065_limit, 0, 7);
static SENSOR_DEVICE_ATTR_2_RW(in8_max, max16065_limit, 0, 8);
static SENSOR_DEVICE_ATTR_2_RW(in9_max, max16065_limit, 0, 9);
static SENSOR_DEVICE_ATTR_2_RW(in10_max, max16065_limit, 0, 10);
static SENSOR_DEVICE_ATTR_2_RW(in11_max, max16065_limit, 0, 11);

/* alarms */
static SENSOR_DEVICE_ATTR_2_RO(in0_alarm, max16065_alarm, 0, 0);
static SENSOR_DEVICE_ATTR_2_RO(in1_alarm, max16065_alarm, 0, 1);
static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, max16065_alarm, 0, 2);
static SENSOR_DEVICE_ATTR_2_RO(in3_alarm, max16065_alarm, 0, 3);
static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, max16065_alarm, 0, 4);
static SENSOR_DEVICE_ATTR_2_RO(in5_alarm, max16065_alarm, 0, 5);
static SENSOR_DEVICE_ATTR_2_RO(in6_alarm, max16065_alarm, 0, 6);
static SENSOR_DEVICE_ATTR_2_RO(in7_alarm, max16065_alarm, 0, 7);
static SENSOR_DEVICE_ATTR_2_RO(in8_alarm, max16065_alarm, 1, 0);
static SENSOR_DEVICE_ATTR_2_RO(in9_alarm, max16065_alarm, 1, 1);
static SENSOR_DEVICE_ATTR_2_RO(in10_alarm, max16065_alarm, 1, 2);
static SENSOR_DEVICE_ATTR_2_RO(in11_alarm, max16065_alarm, 1, 3);

/* Current and alarm */
static SENSOR_DEVICE_ATTR_RO(curr1_input, max16065_current, 0);
static SENSOR_DEVICE_ATTR_2_RO(curr1_alarm, max16065_alarm, 1, 4);

/*
 * Finally, construct an array of pointers to members of the above objects,
 * as required for sysfs_create_group()
 */
static struct attribute *max16065_basic_attributes[] =;

static struct attribute *max16065_current_attributes[] =;

static struct attribute *max16065_min_attributes[] =;

static struct attribute *max16065_max_attributes[] =;

static umode_t max16065_basic_is_visible(struct kobject *kobj,
					 struct attribute *a, int n)
{}

static umode_t max16065_secondary_is_visible(struct kobject *kobj,
					     struct attribute *a, int index)
{}

static const struct attribute_group max16065_basic_group =;

static const struct attribute_group max16065_current_group =;

static const struct attribute_group max16065_min_group =;

static const struct attribute_group max16065_max_group =;

static int max16065_probe(struct i2c_client *client)
{}

static const struct i2c_device_id max16065_id[] =;

MODULE_DEVICE_TABLE(i2c, max16065_id);

/* This is the driver that will be inserted */
static struct i2c_driver max16065_driver =;

module_i2c_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();