linux/drivers/hwmon/nct7904.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * nct7904.c - driver for Nuvoton NCT7904D.
 *
 * Copyright (c) 2015 Kontron
 * Author: Vadim V. Vlasov <[email protected]>
 *
 * Copyright (c) 2019 Advantech
 * Author: Amy.Shih <[email protected]>
 *
 * Copyright (c) 2020 Advantech
 * Author: Yuechao Zhao <[email protected]>
 *
 * Supports the following chips:
 *
 * Chip        #vin  #fan  #pwm  #temp  #dts  chip ID
 * nct7904d     20    12    4     5      8    0xc5
 */

#include <linux/module.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
#include <linux/hwmon.h>
#include <linux/watchdog.h>

#define VENDOR_ID_REG
#define NUVOTON_ID
#define CHIP_ID_REG
#define NCT7904_ID
#define DEVICE_ID_REG

#define BANK_SEL_REG
#define BANK_0
#define BANK_1
#define BANK_2
#define BANK_3
#define BANK_4
#define BANK_MAX

#define FANIN_MAX
#define VSEN_MAX
#define FANCTL_MAX
#define TCPU_MAX
#define TEMP_MAX
#define SMI_STS_MAX

#define VT_ADC_CTRL0_REG
#define VT_ADC_CTRL1_REG
#define VT_ADC_CTRL2_REG
#define FANIN_CTRL0_REG
#define FANIN_CTRL1_REG
#define DTS_T_CTRL0_REG
#define DTS_T_CTRL1_REG
#define VT_ADC_MD_REG

#define VSEN1_HV_LL_REG
#define VSEN1_LV_LL_REG
#define VSEN1_HV_HL_REG
#define VSEN1_LV_HL_REG
#define SMI_STS1_REG
#define SMI_STS3_REG
#define SMI_STS5_REG
#define SMI_STS7_REG
#define SMI_STS8_REG

#define VSEN1_HV_REG
#define TEMP_CH1_HV_REG
#define LTD_HV_REG
#define LTD_HV_HL_REG
#define LTD_LV_HL_REG
#define LTD_HV_LL_REG
#define LTD_LV_LL_REG
#define TEMP_CH1_CH_REG
#define TEMP_CH1_W_REG
#define TEMP_CH1_WH_REG
#define TEMP_CH1_C_REG
#define DTS_T_CPU1_C_REG
#define DTS_T_CPU1_CH_REG
#define DTS_T_CPU1_W_REG
#define DTS_T_CPU1_WH_REG
#define FANIN1_HV_REG
#define FANIN1_HV_HL_REG
#define FANIN1_LV_HL_REG
#define T_CPU1_HV_REG

#define PRTS_REG
#define PFE_REG
#define TSI_CTRL_REG
#define FANCTL1_FMR_REG
#define FANCTL1_OUT_REG

#define WDT_LOCK_REG
#define WDT_EN_REG
#define WDT_STS_REG
#define WDT_TIMER_REG
#define WDT_SOFT_EN
#define WDT_SOFT_DIS

#define VOLT_MONITOR_MODE
#define THERMAL_DIODE_MODE
#define THERMISTOR_MODE

#define ENABLE_TSI

#define WATCHDOG_TIMEOUT

/*The timeout range is 1-255 minutes*/
#define MIN_TIMEOUT
#define MAX_TIMEOUT

static int timeout;
module_param(timeout, int, 0);
MODULE_PARM_DESC();

static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC();

static const unsigned short normal_i2c[] =;

struct nct7904_data {};

/* Access functions */
static int nct7904_bank_lock(struct nct7904_data *data, unsigned int bank)
{}

static inline void nct7904_bank_release(struct nct7904_data *data)
{}

/* Read 1-byte register. Returns unsigned reg or -ERRNO on error. */
static int nct7904_read_reg(struct nct7904_data *data,
			    unsigned int bank, unsigned int reg)
{}

/*
 * Read 2-byte register. Returns register in big-endian format or
 * -ERRNO on error.
 */
static int nct7904_read_reg16(struct nct7904_data *data,
			      unsigned int bank, unsigned int reg)
{}

/* Write 1-byte register. Returns 0 or -ERRNO on error. */
static int nct7904_write_reg(struct nct7904_data *data,
			     unsigned int bank, unsigned int reg, u8 val)
{}

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

static umode_t nct7904_fan_is_visible(const void *_data, u32 attr, int channel)
{}

static u8 nct7904_chan_to_index[] =;

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

static umode_t nct7904_in_is_visible(const void *_data, u32 attr, int channel)
{}

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

static umode_t nct7904_temp_is_visible(const void *_data, u32 attr, int channel)
{}

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

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

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

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

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

static umode_t nct7904_pwm_is_visible(const void *_data, u32 attr, int channel)
{}

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

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

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

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

static const struct hwmon_channel_info * const nct7904_info[] =;

static const struct hwmon_ops nct7904_hwmon_ops =;

static const struct hwmon_chip_info nct7904_chip_info =;

/*
 * Watchdog Function
 */
static int nct7904_wdt_start(struct watchdog_device *wdt)
{}

static int nct7904_wdt_stop(struct watchdog_device *wdt)
{}

static int nct7904_wdt_set_timeout(struct watchdog_device *wdt,
				   unsigned int timeout)
{}

static int nct7904_wdt_ping(struct watchdog_device *wdt)
{}

static unsigned int nct7904_wdt_get_timeleft(struct watchdog_device *wdt)
{}

static const struct watchdog_info nct7904_wdt_info =;

static const struct watchdog_ops nct7904_wdt_ops =;

static int nct7904_probe(struct i2c_client *client)
{}

static const struct i2c_device_id nct7904_id[] =;
MODULE_DEVICE_TABLE(i2c, nct7904_id);

static struct i2c_driver nct7904_driver =;

module_i2c_driver();

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