linux/drivers/hwmon/amc6821.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * amc6821.c - Part of lm_sensors, Linux kernel modules for hardware
 *	       monitoring
 * Copyright (C) 2009 T. Mertelj <[email protected]>
 *
 * Based on max6650.c:
 * Copyright (C) 2007 Hans J. Koch <[email protected]>
 *
 * Conversion to regmap and with_info API:
 * Copyright (C) 2024 Guenter Roeck <[email protected]>
 */

#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/bits.h>
#include <linux/err.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/minmax.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/regmap.h>
#include <linux/slab.h>

/*
 * Addresses to scan.
 */

static const unsigned short normal_i2c[] =;

/*
 * Insmod parameters
 */

static int pwminv;	/*Inverted PWM output. */
module_param(pwminv, int, 0444);

static int init =; /*Power-on initialization.*/
module_param(init, int, 0444);

#define AMC6821_REG_DEV_ID
#define AMC6821_REG_COMP_ID
#define AMC6821_REG_CONF1
#define AMC6821_REG_CONF2
#define AMC6821_REG_CONF3
#define AMC6821_REG_CONF4
#define AMC6821_REG_STAT1
#define AMC6821_REG_STAT2
#define AMC6821_REG_TEMP_LO
#define AMC6821_REG_TDATA_LOW
#define AMC6821_REG_TDATA_HI
#define AMC6821_REG_LTEMP_HI
#define AMC6821_REG_RTEMP_HI
#define AMC6821_REG_LTEMP_LIMIT_MIN
#define AMC6821_REG_LTEMP_LIMIT_MAX
#define AMC6821_REG_RTEMP_LIMIT_MIN
#define AMC6821_REG_RTEMP_LIMIT_MAX
#define AMC6821_REG_LTEMP_CRIT
#define AMC6821_REG_RTEMP_CRIT
#define AMC6821_REG_PSV_TEMP
#define AMC6821_REG_DCY
#define AMC6821_REG_LTEMP_FAN_CTRL
#define AMC6821_REG_RTEMP_FAN_CTRL
#define AMC6821_REG_DCY_LOW_TEMP

#define AMC6821_REG_TACH_LLIMITL
#define AMC6821_REG_TACH_HLIMITL
#define AMC6821_REG_TACH_SETTINGL

#define AMC6821_CONF1_START
#define AMC6821_CONF1_FAN_INT_EN
#define AMC6821_CONF1_FANIE
#define AMC6821_CONF1_PWMINV
#define AMC6821_CONF1_FAN_FAULT_EN
#define AMC6821_CONF1_FDRC0
#define AMC6821_CONF1_FDRC1
#define AMC6821_CONF1_THERMOVIE

#define AMC6821_CONF2_PWM_EN
#define AMC6821_CONF2_TACH_MODE
#define AMC6821_CONF2_TACH_EN
#define AMC6821_CONF2_RTFIE
#define AMC6821_CONF2_LTOIE
#define AMC6821_CONF2_RTOIE
#define AMC6821_CONF2_PSVIE
#define AMC6821_CONF2_RST

#define AMC6821_CONF3_THERM_FAN_EN
#define AMC6821_CONF3_REV_MASK

#define AMC6821_CONF4_OVREN
#define AMC6821_CONF4_TACH_FAST
#define AMC6821_CONF4_PSPR
#define AMC6821_CONF4_MODE

#define AMC6821_STAT1_RPM_ALARM
#define AMC6821_STAT1_FANS
#define AMC6821_STAT1_RTH
#define AMC6821_STAT1_RTL
#define AMC6821_STAT1_R_THERM
#define AMC6821_STAT1_RTF
#define AMC6821_STAT1_LTH
#define AMC6821_STAT1_LTL

#define AMC6821_STAT2_RTC
#define AMC6821_STAT2_LTC
#define AMC6821_STAT2_LPSV
#define AMC6821_STAT2_L_THERM
#define AMC6821_STAT2_THERM_IN

#define AMC6821_TEMP_SLOPE_MASK
#define AMC6821_TEMP_LIMIT_MASK

/*
 * Client data (each client gets its own)
 */

struct amc6821_data {};

/*
 * Return 0 on success or negative error code.
 *
 * temps returns set of three temperatures, in °C:
 * temps[0]: Passive cooling temperature, applies to both channels
 * temps[1]: Low temperature, start slope calculations
 * temps[2]: High temperature
 *
 * Channel 0: local, channel 1: remote.
 */
static int amc6821_get_auto_point_temps(struct regmap *regmap, int channel, u8 *temps)
{}

static int amc6821_temp_read_values(struct regmap *regmap, u32 attr, int channel, long *val)
{}

static int amc6821_read_alarms(struct regmap *regmap, enum hwmon_sensor_types type,
			       u32 attr, int channel, long *val)
{}

static int amc6821_temp_read(struct device *dev, u32 attr, int channel, long *val)
{}

static int amc6821_temp_write(struct device *dev, u32 attr, int channel, long val)
{}

static int amc6821_pwm_read(struct device *dev, u32 attr, long *val)
{}

static int amc6821_pwm_write(struct device *dev, u32 attr, long val)
{}

static int amc6821_fan_read_rpm(struct regmap *regmap, u32 attr, long *val)
{}

static int amc6821_fan_read(struct device *dev, u32 attr, long *val)
{}

static int amc6821_fan_write(struct device *dev, u32 attr, long val)
{}

static ssize_t temp_auto_point_temp_show(struct device *dev,
					 struct device_attribute *devattr,
					 char *buf)
{}

static ssize_t pwm1_auto_point_pwm_show(struct device *dev,
					struct device_attribute *devattr,
					char *buf)
{}

/*
 * Set TEMP[0-4] (low temperature) and SLP[0-2] (slope) of local or remote
 * TEMP-FAN control register.
 *
 * Return 0 on success or negative error code.
 *
 * Channel 0: local, channel 1: remote
 */
static inline int set_slope_register(struct regmap *regmap, int channel, u8 *temps)
{}

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

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

static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point1_pwm, pwm1_auto_point_pwm, 0);
static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point2_pwm, pwm1_auto_point_pwm, 1);
static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point3_pwm, pwm1_auto_point_pwm, 2);
static SENSOR_DEVICE_ATTR_2_RO(temp1_auto_point1_temp, temp_auto_point_temp,
			       0, 0);
static SENSOR_DEVICE_ATTR_2_RW(temp1_auto_point2_temp, temp_auto_point_temp,
			       0, 1);
static SENSOR_DEVICE_ATTR_2_RW(temp1_auto_point3_temp, temp_auto_point_temp,
			       0, 2);

static SENSOR_DEVICE_ATTR_2_RW(temp2_auto_point1_temp, temp_auto_point_temp,
			       1, 0);
static SENSOR_DEVICE_ATTR_2_RW(temp2_auto_point2_temp, temp_auto_point_temp,
			       1, 1);
static SENSOR_DEVICE_ATTR_2_RW(temp2_auto_point3_temp, temp_auto_point_temp,
			       1, 2);

static struct attribute *amc6821_attrs[] =;
ATTRIBUTE_GROUPS();

static int amc6821_read(struct device *dev, enum hwmon_sensor_types type,
			u32 attr, int channel, long *val)
{}

static int amc6821_write(struct device *dev, enum hwmon_sensor_types type,
			 u32 attr, int channel, long val)
{}

static umode_t amc6821_is_visible(const void *data,
				  enum hwmon_sensor_types type,
				  u32 attr, int channel)
{}

static const struct hwmon_channel_info * const amc6821_info[] =;

static const struct hwmon_ops amc6821_hwmon_ops =;

static const struct hwmon_chip_info amc6821_chip_info =;

/* Return 0 if detection is successful, -ENODEV otherwise */
static int amc6821_detect(struct i2c_client *client, struct i2c_board_info *info)
{}

static int amc6821_init_client(struct amc6821_data *data)
{}

static bool amc6821_volatile_reg(struct device *dev, unsigned int reg)
{}

static const struct regmap_config amc6821_regmap_config =;

static int amc6821_probe(struct i2c_client *client)
{}

static const struct i2c_device_id amc6821_id[] =;

MODULE_DEVICE_TABLE(i2c, amc6821_id);

static const struct of_device_id __maybe_unused amc6821_of_match[] =;

MODULE_DEVICE_TABLE(of, amc6821_of_match);

static struct i2c_driver amc6821_driver =;

module_i2c_driver();

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