#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/of.h>
#include <linux/thermal.h>
static int fan_voltage;
static int prescaler;
static int clock = …;
module_param(fan_voltage, int, 0444);
module_param(prescaler, int, 0444);
module_param(clock, int, 0444);
#define MAX6650_REG_SPEED …
#define MAX6650_REG_CONFIG …
#define MAX6650_REG_GPIO_DEF …
#define MAX6650_REG_DAC …
#define MAX6650_REG_ALARM_EN …
#define MAX6650_REG_ALARM …
#define MAX6650_REG_TACH0 …
#define MAX6650_REG_TACH1 …
#define MAX6650_REG_TACH2 …
#define MAX6650_REG_TACH3 …
#define MAX6650_REG_GPIO_STAT …
#define MAX6650_REG_COUNT …
#define MAX6650_CFG_V12 …
#define MAX6650_CFG_PRESCALER_MASK …
#define MAX6650_CFG_PRESCALER_2 …
#define MAX6650_CFG_PRESCALER_4 …
#define MAX6650_CFG_PRESCALER_8 …
#define MAX6650_CFG_PRESCALER_16 …
#define MAX6650_CFG_MODE_MASK …
#define MAX6650_CFG_MODE_ON …
#define MAX6650_CFG_MODE_OFF …
#define MAX6650_CFG_MODE_CLOSED_LOOP …
#define MAX6650_CFG_MODE_OPEN_LOOP …
#define MAX6650_COUNT_MASK …
#define MAX6650_ALRM_MAX …
#define MAX6650_ALRM_MIN …
#define MAX6650_ALRM_TACH …
#define MAX6650_ALRM_GPIO1 …
#define MAX6650_ALRM_GPIO2 …
#define FAN_RPM_MIN …
#define FAN_RPM_MAX …
#define DIV_FROM_REG(reg) …
#define DAC_LIMIT(v12) …
struct max6650_data { … };
static const u8 tach_reg[] = …;
static const struct of_device_id __maybe_unused max6650_dt_match[] = …;
MODULE_DEVICE_TABLE(of, max6650_dt_match);
static int dac_to_pwm(int dac, bool v12)
{ … }
static u8 pwm_to_dac(unsigned int pwm, bool v12)
{ … }
static struct max6650_data *max6650_update_device(struct device *dev)
{ … }
static int max6650_set_operating_mode(struct max6650_data *data, u8 mode)
{ … }
static int max6650_set_target(struct max6650_data *data, unsigned long rpm)
{ … }
static ssize_t alarm_show(struct device *dev,
struct device_attribute *devattr, char *buf)
{ … }
static SENSOR_DEVICE_ATTR_RO(gpio1_alarm, alarm, MAX6650_ALRM_GPIO1);
static SENSOR_DEVICE_ATTR_RO(gpio2_alarm, alarm, MAX6650_ALRM_GPIO2);
static umode_t max6650_attrs_visible(struct kobject *kobj, struct attribute *a,
int n)
{ … }
static struct attribute *max6650_attrs[] = …;
static const struct attribute_group max6650_group = …;
static const struct attribute_group *max6650_groups[] = …;
static int max6650_init_client(struct max6650_data *data,
struct i2c_client *client)
{ … }
static int max6650_get_max_state(struct thermal_cooling_device *cdev,
unsigned long *state)
{ … }
static int max6650_get_cur_state(struct thermal_cooling_device *cdev,
unsigned long *state)
{ … }
static int max6650_set_cur_state(struct thermal_cooling_device *cdev,
unsigned long state)
{ … }
static const struct thermal_cooling_device_ops max6650_cooling_ops = …;
static int max6650_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{ … }
static const u8 max6650_pwm_modes[] = …;
static int max6650_write(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long val)
{ … }
static umode_t max6650_is_visible(const void *_data,
enum hwmon_sensor_types type, u32 attr,
int channel)
{ … }
static const struct hwmon_channel_info * const max6650_info[] = …;
static const struct hwmon_ops max6650_hwmon_ops = …;
static const struct hwmon_chip_info max6650_chip_info = …;
static const struct i2c_device_id max6650_id[];
static int max6650_probe(struct i2c_client *client)
{ … }
static const struct i2c_device_id max6650_id[] = …;
MODULE_DEVICE_TABLE(i2c, max6650_id);
static struct i2c_driver max6650_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;