(mds) Add i810 dual-bus (I2C/DDC) driver using algo-bit.

The i801 driver is for the standard I2C bus on an i810 board.
      This driver adds the support for the DDC and TV-out busses.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@729 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Mark D. Studebaker committed 2000-02-07 02:03:33 +00:00
1 parent ac2f78cb0e
commit da8174c4db
8 files changed
+431 -2

No files matched your search

+3
View File
@@ -15,6 +15,9 @@ ask CVS about it:
2.5.0 (200001??)
Dropped all kernel 2.0 and 2.1 compatibility
Module i2c-i810: new
Module i2c-amd756: fixed region request
Module ddcmon: new
2.4.5 (20000116)
Introduced DESTDIR installation prefix
+1 -2
View File
@@ -24,7 +24,7 @@ problems.
Author of the i2c-via and i2c-viapro host drivers. Sis5595 hack.
Extended support for GL518SM and GL520SM sensors.
* Mark D. Studebaker <mdsxyz123@yahoo.com>
Author of the i2c-ali15x3 bus driver and the i2c-i810 bus driver.
Author of the i2c-ali15x3, i2c-i801, and i2c-i810 bus drivers.
Added w83782d, w83783s, w83627hf, and as99127f support to the w83781d driver.
Added max1617, thmc10, gl523sm, and lm84 support to the adm1021 driver.
Added lm81 support to the adm9240 driver.
@@ -41,7 +41,6 @@ problems.
Author of the AMD756 module and sensord.
* Constantine Gavrilov <const-g@xpert.com>
Created and maintains the RPM files
* Simon Vogl <simon@tk.uni-linz.ac.at>
Wrote the new i2c kernel driver. This driver is indispensable for the
workings of lm_sensors version 2.
+3
View File
@@ -40,7 +40,9 @@ At least the following SMBus adapters are supported:
Apple Hydra (used on some PPC machines)
Intel ICH (used in the Intel 810 and 810E chipsets)
Intel PIIX4 (used in most Intel chipsets)
Intel I810 GMCH
SiS 5595 (used in many SiS chipsets)
3Dfx Voodoo 3 and Banshee
VIA Technologies 82C586B (used in most VIA chipsets)
VIA Technologies VT596A/B (used in some more modern VIA chipsets)
@@ -63,6 +65,7 @@ We also support some miscellaneous chips:
Linear Technologies LTC1710
Dimms with EEPROMs
Intel Xeon processor embedded EEPROMs
DDC Monitor embedded EEPROMs
We could use some testers of hardware. If you own a specific monitoring
chip or I2C bus, and are willing to help us out, please contact us - even
+3
View File
@@ -42,6 +42,9 @@ KERNEL MODULES
an lm75. Add support for the two new registers.
* Add MTP006F chip: http://www.myson.com/Pcd/MTP006/Mtp006.pdf
gfiala@s.netic.de (Guido Fiala) has one on his mainboard
* Rewrite i2c-voodoo3 to use i2c-algo-bit
* Add support for Via 686a integrated sensors
* Figure out what chips are appearing at 0x08 and 0x30
LIBRARY
=======
+62
View File
@@ -0,0 +1,62 @@
Kernel driver `i2c-i810.o'
Status: 'Beta', still under development and testing
Supported adapters:
* Intel 82810 and 82810-DC100 (GMCH)
Author: Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock
<phil@netroedge.com>,
Kyösti Mälkki <kmalkki@cc.hut.fi>,
and Mark D. Studebaker <mdsxyz123@yahoo.com>
Main contact: Mark Studebaker <mdsxyz123@yahoo.com>
Module Parameters
-----------------
(none)
Description
-----------
WARNING: If you have an '810' motherboard, your standard I2C
temperature sensors are most likely on the 801's I2C bus.
You want the i2c-i801.o driver for those.
Now for the i2c-i810...
The GMCH chip contains two I2C interfaces.
The first interface is used for DDC (Data Display Channel)
which is a serial channel through the VGA monitor connector
to a DDC-compliant monitor. This interface is defined by the
Video Electronics Standards Association (VESA). The standards
are available for purchase at http://www.vesa.org .
The second interface is a general-purpose I2C bus.
It may be connected to a TV-out chip such as the BT869 or possibly
to a digital flat-panel display.
Stability
---------
Seems to be stable on the test machine, but needs more testing on other
machines.
Supported Devices
-----------------
Specifically, this driver was written and tested on the '3dfx Voodoo3 AGP
3000' which has a tv-out feature (s-video or composite). According to the
docs and discussions, this code should work for any Voodoo3 based cards as
well as Voodoo Banshee based cards. The DDC interface has been tested
on a Voodoo Banshee card.
Features
--------
Both busses use the i2c-algo-bit driver for 'bit banging' and support
for specific transactions is provided by i2c-algo-bit.
Issues
------
If you enable bus testing in i2c-algo-bit (insmod i2c-algo-bit bit_test=1),
the test may fail and the i2c-i810 driver won't be inserted.
+1
View File
@@ -27,6 +27,7 @@ KERNELBUSSESTARGETS := $(MODULE_DIR)/i2c-i801.o \
$(MODULE_DIR)/i2c-viapro.o \
$(MODULE_DIR)/i2c-voodoo3.o \
$(MODULE_DIR)/i2c-amd756.o \
$(MODULE_DIR)/i2c-i810.o \
$(MODULE_DIR)/i2c-sis5595.o
ifneq ($(shell if grep -q '^CONFIG_I2C_ALI15X3=y' $(LINUX)/.config; then echo 1; fi),1)
KERNELBUSSESTARGETS += $(MODULE_DIR)/i2c-ali15x3.o
+342
View File
@@ -0,0 +1,342 @@
/*
i2c-i810.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>,
Philip Edelbrock <phil@netroedge.com>,
Ralph Metzler <rjkm@thp.uni-koeln.de>, and
Mark D. Studebaker <mdsxyz123@yahoo.com>
Based on code written by Ralph Metzler <rjkm@thp.uni-koeln.de> and
Simon Vogl
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.
*/
/* This interfaces to the I2C bus of the I810 to gain access to
the DDC Bus and possibly other I2C devices. */
#include <linux/version.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <asm/io.h>
#include <linux/i2c.h>
#include <linux/i2c-algo-bit.h>
#include "version.h"
#include <linux/init.h>
/* PCI defines */
#ifndef PCI_DEVICE_ID_INTEL_82810
#define PCI_DEVICE_ID_INTEL_82810 0x7121
#endif
#ifndef PCI_DEVICE_ID_INTEL_82810_DC100
#define PCI_DEVICE_ID_INTEL_82810_DC100 0x7123
#endif
/* GPIO register locations */
#define I810_IOCONTROL_OFFSET 0x5000
#define I810_HVSYNC 0x00 /* not used */
#define I810_GPIOA 0x10
#define I810_GPIOB 0x14
/* bit locations in the registers */
#define SCL_DIR_MASK 0x0001
#define SCL_DIR 0x0002
#define SCL_VAL_MASK 0x0004
#define SCL_VAL_OUT 0x0008
#define SCL_VAL_IN 0x0010
#define SDA_DIR_MASK 0x0100
#define SDA_DIR 0x0200
#define SDA_VAL_MASK 0x0400
#define SDA_VAL_OUT 0x0800
#define SDA_VAL_IN 0x1000
/* initialization states */
#define INIT1 0x1
#define INIT2 0x2
#define INIT3 0x4
/* delays */
#define CYCLE_DELAY 10
#define TIMEOUT 50
#ifdef MODULE
static
#else
extern
#endif
int __init i2c_i810i2c_init(void);
static int __init i810i2c_cleanup(void);
static int i810i2c_setup(void);
static void config_i810(struct pci_dev *dev);
static void i810_inc(struct i2c_adapter *adapter);
static void i810_dec(struct i2c_adapter *adapter);
#ifdef MODULE
extern int init_module(void);
extern int cleanup_module(void);
#endif /* MODULE */
static int __initdata i810i2c_initialized;
static unsigned char *mem;
static inline void outlong(unsigned int dat, int off)
{
*((unsigned int *) (mem + off)) = dat;
}
static inline unsigned int readlong(int off)
{
return *((unsigned int *) (mem + off));
}
/* The i810 GPIO registers have individual masks for each bit
so we never have to read before writing. Nice. */
static void bit_i810i2c_setscl(void *data, int val)
{
outlong((val ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK,
I810_GPIOB);
}
static void bit_i810i2c_setsda(void *data, int val)
{
outlong((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK,
I810_GPIOB);
}
/* The GPIO pins are open drain, so the pins always remain outputs.
We rely on the i2c-algo-bit routines to set the pins high before
reading the input from other chips. */
static int bit_i810i2c_getscl(void *data)
{
return (0 != (readlong(I810_GPIOB) & SCL_VAL_IN));
}
static int bit_i810i2c_getsda(void *data)
{
return (0 != (readlong(I810_GPIOB) & SDA_VAL_IN));
}
static void bit_i810ddc_setscl(void *data, int val)
{
outlong((val ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK,
I810_GPIOA);
}
static void bit_i810ddc_setsda(void *data, int val)
{
outlong((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK,
I810_GPIOA);
}
static int bit_i810ddc_getscl(void *data)
{
return (0 != (readlong(I810_GPIOA) & SCL_VAL_IN));
}
static int bit_i810ddc_getsda(void *data)
{
return (0 != (readlong(I810_GPIOA) & SDA_VAL_IN));
}
static struct i2c_algo_bit_data i810_i2c_bit_data = {
NULL,
bit_i810i2c_setsda,
bit_i810i2c_setscl,
bit_i810i2c_getsda,
bit_i810i2c_getscl,
CYCLE_DELAY, CYCLE_DELAY, TIMEOUT
};
static struct i2c_adapter i810_i2c_adapter = {
"I810 I2C Adapter",
I2C_HW_B_I810,
NULL,
&i810_i2c_bit_data,
i810_inc,
i810_dec,
NULL,
NULL,
};
static struct i2c_algo_bit_data i810_ddc_bit_data = {
NULL,
bit_i810ddc_setsda,
bit_i810ddc_setscl,
bit_i810ddc_getsda,
bit_i810ddc_getscl,
CYCLE_DELAY, CYCLE_DELAY, TIMEOUT
};
static struct i2c_adapter i810_ddc_adapter = {
"I810 DDC Adapter",
I2C_HW_B_I810,
NULL,
&i810_ddc_bit_data,
i810_inc,
i810_dec,
NULL,
NULL,
};
/* Configures the chip */
void config_i810(struct pci_dev *dev)
{
unsigned long cadr;
/* map I810 memory */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,13)
cadr = dev->resource[1].start;
#else
cadr = dev->base_address[1];
#endif
cadr += I810_IOCONTROL_OFFSET;
cadr &= PCI_BASE_ADDRESS_MEM_MASK;
mem = ioremap_nocache(cadr, 0x1000);
bit_i810i2c_setscl(NULL, 1);
bit_i810i2c_setsda(NULL, 1);
bit_i810ddc_setscl(NULL, 1);
bit_i810ddc_setsda(NULL, 1);
}
/* Detect whether a I810 or I810_DC100 can be found,
and initialize it */
static int i810i2c_setup(void)
{
struct pci_dev *dev;
int num = 0;
dev = NULL;
do {
if ((dev = pci_find_device(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82810,
dev))) {
if (!num)
config_i810(dev);
num++;
}
} while (dev);
dev = NULL;
do {
if ((dev = pci_find_device(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82810_DC100,
dev))) {
if (!num)
config_i810(dev);
num++;
}
} while (dev);
if (num > 0) {
printk(KERN_INFO
"i2c-i810.o: %d i810 found.\n", num);
if (num > 1)
printk(KERN_INFO
"i2c-i810.o: warning: only 1 supported.\n");
return 0;
} else {
return -ENODEV;
}
}
void i810_inc(struct i2c_adapter *adapter)
{
MOD_INC_USE_COUNT;
}
void i810_dec(struct i2c_adapter *adapter)
{
MOD_DEC_USE_COUNT;
}
int __init i2c_i810i2c_init(void)
{
int res;
printk("i2c-i810.o version %s (%s)\n", LM_VERSION, LM_DATE);
i810i2c_initialized = 0;
if ((res = i810i2c_setup())) {
printk
("i2c-i810.o: i810 not detected, module not inserted.\n");
i810i2c_cleanup();
return res;
}
if ((res = i2c_bit_add_bus(&i810_i2c_adapter))) {
printk("i2c-i810.o: I2C adapter registration failed\n");
} else {
printk("i2c-i810.o: I810 I2C bus initialized\n");
i810i2c_initialized |= INIT2;
}
if ((res = i2c_bit_add_bus(&i810_ddc_adapter))) {
printk("i2c-i810.o: DDC adapter registration failed\n");
} else {
printk("i2c-i810.o: I810 DDC bus initialized\n");
i810i2c_initialized |= INIT3;
}
if(!(i810i2c_initialized & (INIT2 | INIT3))) {
printk("i2c-i810.o: Both registrations failed, module not inserted\n");
i810i2c_cleanup();
return res;
}
return 0;
}
int __init i810i2c_cleanup(void)
{
int res;
iounmap(mem);
if (i810i2c_initialized & INIT3) {
if ((res = i2c_bit_del_bus(&i810_ddc_adapter))) {
printk
("i2c-i810.o: i2c_del_adapter failed, module not removed\n");
return res;
}
}
if (i810i2c_initialized & INIT2) {
if ((res = i2c_bit_del_bus(&i810_i2c_adapter))) {
printk
("i2c-i810.o: i2c_del_adapter failed, module not removed\n");
return res;
}
}
i810i2c_initialized = 0;
return 0;
}
EXPORT_NO_SYMBOLS;
#ifdef MODULE
MODULE_AUTHOR
("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, Ralph Metzler <rjkm@thp.uni-koeln.de>, and Mark D. Studebaker <mdsxyz123@yahoo.com>");
MODULE_DESCRIPTION("I810 I2C/DDC driver");
int init_module(void)
{
return i2c_i810i2c_init();
}
int cleanup_module(void)
{
return i810i2c_cleanup();
}
#endif /* MODULE */
+16
View File
@@ -224,6 +224,22 @@ use vars qw(@pci_adapters @chip_ids @undetectable_adapters);
driver => "i2c-voodoo3",
match => sub { $_[0] =~ /Banshee adapter/ },
},
{
vendid => 0x8086,
devid => 0x7121,
func => 0,
procid => "Intel 82810 GMCH",
driver => "i2c-i810",
match => sub { $_[0] =~ /^I810/ },
} ,
{
vendid => 0x8086,
devid => 0x7123,
func => 0,
procid => "Intel 82810-DC100 GMCH",
driver => "i2c-i810",
match => sub { $_[0] =~ /^I810/ },
} ,
);
use subs qw(lm78_detect lm78_isa_detect lm78_alias_detect lm75_detect