/*
* vt1211.c - driver for the VIA VT1211 Super-I/O chip integrated hardware
* monitoring features
* Copyright (C) 2006 Juerg Haefliger <juergh@gmail.com>
*
* This driver is based on the driver for kernel 2.4 by Mark D. Studebaker
* and its port to kernel 2.6 by Lars Ekman.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/platform_device.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/ioport.h>
#include <linux/acpi.h>
#include <linux/io.h>
static int uch_config = -1;
module_param(uch_config, int, 0);
MODULE_PARM_DESC(uch_config, "Initialize the universal channel configuration");
static int int_mode = -1;
module_param(int_mode, int, 0);
MODULE_PARM_DESC(int_mode, "Force the temperature interrupt mode");
static unsigned short force_id;
module_param(force_id, ushort, 0);
MODULE_PARM_DESC(force_id, "Override the detected device ID");
static struct platform_device *pdev;
#define DRVNAME "vt1211"
/* ---------------------------------------------------------------------
* Registers
*
* The sensors are defined as follows.
*
* Sensor Voltage Mode Temp Mode Notes (from the datasheet)
* -------- ------------ --------- --------------------------
* Reading 1 temp1 Intel thermal diode
* Reading 3 temp2 Internal thermal diode
* UCH1/Reading2 in0 temp3 NTC type thermistor
* UCH2 in1 temp4 +2.5V
* UCH3 in2 temp5 VccP
* UCH4 in3 temp6 +5V
* UCH5 in4 temp7 +12V
* 3.3V in5 Internal VDD (+3.3V)
*
* --------------------------------------------------------------------- */
/* Voltages (in) numbered 0-5 (ix) */
#define VT1211_REG_IN(ix) (0x21 + (ix))
#define VT1211_REG_IN_MIN(ix) ((ix) == 0 ? 0x3e : 0x2a + 2 * (ix))
#define VT1211_REG_IN_MAX(ix) ((ix) == 0 ? 0x3d : 0x29 + 2 * (ix))
/* Temperatures (temp) numbered 0-6 (ix) */
static u8 regtemp[] = {0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25};
static u8 regtempmax[] = {0x39, 0x1d, 0x3d, 0x2b, 0x2d, 0x2f, 0x31};
static u8 regtemphyst[] = {0x3a, 0x1e, 0x3e, 0x2c