linux/drivers/hwmon/abituguru3.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * abituguru3.c
 *
 * Copyright (c) 2006-2008 Hans de Goede <[email protected]>
 * Copyright (c) 2008 Alistair John Strachan <[email protected]>
 */
/*
 * This driver supports the sensor part of revision 3 of the custom Abit uGuru
 * chip found on newer Abit uGuru motherboards. Note: because of lack of specs
 * only reading the sensors and their settings is supported.
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/mutex.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/dmi.h>
#include <linux/io.h>

/* uGuru3 bank addresses */
#define ABIT_UGURU3_SETTINGS_BANK
#define ABIT_UGURU3_SENSORS_BANK
#define ABIT_UGURU3_MISC_BANK
#define ABIT_UGURU3_ALARMS_START
#define ABIT_UGURU3_SETTINGS_START
#define ABIT_UGURU3_VALUES_START
#define ABIT_UGURU3_BOARD_ID
/* uGuru3 sensor bank flags */			     /* Alarm if: */
#define ABIT_UGURU3_TEMP_HIGH_ALARM_ENABLE
#define ABIT_UGURU3_VOLT_HIGH_ALARM_ENABLE
#define ABIT_UGURU3_VOLT_LOW_ALARM_ENABLE
#define ABIT_UGURU3_TEMP_HIGH_ALARM_FLAG
#define ABIT_UGURU3_VOLT_HIGH_ALARM_FLAG
#define ABIT_UGURU3_VOLT_LOW_ALARM_FLAG
#define ABIT_UGURU3_FAN_LOW_ALARM_ENABLE
#define ABIT_UGURU3_BEEP_ENABLE
#define ABIT_UGURU3_SHUTDOWN_ENABLE
/* sensor types */
#define ABIT_UGURU3_IN_SENSOR
#define ABIT_UGURU3_TEMP_SENSOR
#define ABIT_UGURU3_FAN_SENSOR

/*
 * Timeouts / Retries, if these turn out to need a lot of fiddling we could
 * convert them to params. Determined by trial and error. I assume this is
 * cpu-speed independent, since the ISA-bus and not the CPU should be the
 * bottleneck.
 */
#define ABIT_UGURU3_WAIT_TIMEOUT
/*
 * Normally the 0xAC at the end of synchronize() is reported after the
 * first read, but sometimes not and we need to poll
 */
#define ABIT_UGURU3_SYNCHRONIZE_TIMEOUT
/* utility macros */
#define ABIT_UGURU3_NAME
#define ABIT_UGURU3_DEBUG(format, arg...)

/* Macros to help calculate the sysfs_names array length */
#define ABIT_UGURU3_MAX_NO_SENSORS
/*
 * sum of strlen +1 of: in??_input\0, in??_{min,max}\0, in??_{min,max}_alarm\0,
 * in??_{min,max}_alarm_enable\0, in??_beep\0, in??_shutdown\0, in??_label\0
 */
#define ABIT_UGURU3_IN_NAMES_LENGTH
/*
 * sum of strlen +1 of: temp??_input\0, temp??_max\0, temp??_crit\0,
 * temp??_alarm\0, temp??_alarm_enable\0, temp??_beep\0, temp??_shutdown\0,
 * temp??_label\0
 */
#define ABIT_UGURU3_TEMP_NAMES_LENGTH
/*
 * sum of strlen +1 of: fan??_input\0, fan??_min\0, fan??_alarm\0,
 * fan??_alarm_enable\0, fan??_beep\0, fan??_shutdown\0, fan??_label\0
 */
#define ABIT_UGURU3_FAN_NAMES_LENGTH
/*
 * Worst case scenario 16 in sensors (longest names_length) and the rest
 * temp sensors (second longest names_length).
 */
#define ABIT_UGURU3_SYSFS_NAMES_LENGTH

/*
 * All the macros below are named identical to the openguru2 program
 * reverse engineered by Louis Kruger, hence the names might not be 100%
 * logical. I could come up with better names, but I prefer keeping the names
 * identical so that this driver can be compared with his work more easily.
 */
/* Two i/o-ports are used by uGuru */
#define ABIT_UGURU3_BASE
#define ABIT_UGURU3_CMD
#define ABIT_UGURU3_DATA
#define ABIT_UGURU3_REGION_LENGTH
/*
 * The wait_xxx functions return this on success and the last contents
 * of the DATA register (0-255) on failure.
 */
#define ABIT_UGURU3_SUCCESS
/* uGuru status flags */
#define ABIT_UGURU3_STATUS_READY_FOR_READ
#define ABIT_UGURU3_STATUS_BUSY


/* Structures */
struct abituguru3_sensor_info {};

/* Avoid use of flexible array members */
#define ABIT_UGURU3_MAX_DMI_NAMES

struct abituguru3_motherboard_info {};

/*
 * For the Abit uGuru, we need to keep some data in memory.
 * The structure is dynamically allocated, at the same time when a new
 * abituguru3 device is allocated.
 */
struct abituguru3_data {};


/* Constants */
static const struct abituguru3_motherboard_info abituguru3_motherboards[] =;


/* Insmod parameters */
static bool force;
module_param(force, bool, 0);
MODULE_PARM_DESC();
/* Default verbose is 1, since this driver is still in the testing phase */
static bool verbose =;
module_param(verbose, bool, 0644);
MODULE_PARM_DESC();

static const char *never_happen =;
static const char *report_this =;

/* wait while the uguru is busy (usually after a write) */
static int abituguru3_wait_while_busy(struct abituguru3_data *data)
{}

/* wait till uguru is ready to be read */
static int abituguru3_wait_for_read(struct abituguru3_data *data)
{}

/*
 * This synchronizes us with the uGuru3's protocol state machine, this
 * must be done before each command.
 */
static int abituguru3_synchronize(struct abituguru3_data *data)
{}

/*
 * Read count bytes from sensor sensor_addr in bank bank_addr and store the
 * result in buf
 */
static int abituguru3_read(struct abituguru3_data *data, u8 bank, u8 offset,
	u8 count, u8 *buf)
{}

/*
 * Sensor settings are stored 1 byte per offset with the bytes
 * placed add consecutive offsets.
 */
static int abituguru3_read_increment_offset(struct abituguru3_data *data,
					    u8 bank, u8 offset, u8 count,
					    u8 *buf, int offset_count)
{}

/*
 * Following are the sysfs callback functions. These functions expect:
 * sensor_device_attribute_2->index:   index into the data->sensors array
 * sensor_device_attribute_2->nr:      register offset, bitmask or NA.
 */
static struct abituguru3_data *abituguru3_update_device(struct device *dev);

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

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

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

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

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

/* Sysfs attr templates, the real entries are generated automatically. */
static const
struct sensor_device_attribute_2 abituguru3_sysfs_templ[3][10] =;

static struct sensor_device_attribute_2 abituguru3_sysfs_attr[] =;

static int abituguru3_probe(struct platform_device *pdev)
{}

static void abituguru3_remove(struct platform_device *pdev)
{}

static struct abituguru3_data *abituguru3_update_device(struct device *dev)
{}

static int abituguru3_suspend(struct device *dev)
{}

static int abituguru3_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(abituguru3_pm, abituguru3_suspend, abituguru3_resume);

static struct platform_driver abituguru3_driver =;

static int __init abituguru3_dmi_detect(void)
{}

/*
 * FIXME: Manual detection should die eventually; we need to collect stable
 *        DMI model names first before we can rely entirely on CONFIG_DMI.
 */

static int __init abituguru3_detect(void)
{}

static struct platform_device *abituguru3_pdev;

static int __init abituguru3_init(void)
{}

static void __exit abituguru3_exit(void)
{}

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

module_init();
module_exit(abituguru3_exit);