(Kyösti) : Via driver and related documentation moved under

lm_sensors2 source tree. Improvements in VIA driver,
            now checks revision code and refuses to load the
            module if bit_test (in algo-bit) fails.
            (Also fixes previous unsuccessfull CVS commit)


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@187 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Kyosti Malkki committed 1999-01-31 22:55:35 +00:00
1 parent e2f85d427e
commit 4928c0d7bc
5 files changed
+275 -254

No files matched your search

-20
View File
@@ -1,20 +0,0 @@
(From a recent mailing of Kyösti Mälkki)
Read i2c/README.bitmb.
Your /proc/pci or lspci must show VT82C586B (note the last B)
to make it work. This is an upgraded version of VT82C586/A with USB and
ACPI support. The i2c-lines are accessed through the ACPI part.
This is my PCI bus data:
00:07.3 Bridge: VIA Technologies, Inc. VT82C586B ACPI (rev 10)
Flags: medium devsel
South bridge VT82C586B is in these chipsets: MVP3, VP3, VP2/97, VPX/97
I don't see the last two PCI devices if USB is not enabled in BIOS setup.
BTW, my motherboard is FIC VA-503+.
Hope this helps for now, I will write better documentation some day.
+34
View File
@@ -0,0 +1,34 @@
i2c-via is an i2c bus driver for motherboards with VIA chipset.
The following VIA pci chipsets are supported:
- MVP3, VP3, VP2/97, VPX/97
- others with South bridge VT82C586B
Your /proc/pci or lspci listing must show this :
Bridge: VIA Technologies, Inc. VT82C586B ACPI (rev 10)
To install this driver, simply do
# modprobe i2c-via
Problems?
Q: You have VT82C586B on the motherboard, but not in the listing.
A: Go to your BIOS setup, section PCI devices or similar.
Turn USB support on, and try again.
Q: The module wont load. The error message is:
1.
2.
3.
4.
Q: No error messages, but still can't find any devices.
A: This can happen. This driver uses the pins VIA recommends in their
datasheets, but there are several ways the motherboard manufacturer
can actually wire the lines.
-36
View File
@@ -1,36 +0,0 @@
README for bit-mb.c and hw-monitor.c
September 23, 1998. Kyösti Mälkki
The questions you would probably want to ask
about bit-mb and hw-monitor, here are the answers.
What are bit-mb.c and hw-monitor.c?
Both are new modules for Simon G. Vogl's i2c-driver for Linux:
Bit-mb gives you access to motherboard's SMBus (or i2c -bus).
You should have VIA VT82C586B South Bridge, and this is verified on
module-load. On some motherboards, you must enable USB -support in BIOS-setup
to make it active, check this with pciutils or in /proc/pci.
NOTE: Accessing wrong registers on PCI-chipset is likely to lock your
computer. If your hardware goes BOOOMMM, don't blame me.
Hw-monitor is an i2c-driver for GL518SM (by Genesys Logic) chip, used in my
cpu fan (FAN78, EISCA-compatible). This gives you /proc/temperature to show
your cpu temperature. It is not tested with FAN79 (GL520SM), I will get the
datasheet for that in a few days.
Problems?
This is not near alpha-level, but it works with my FIC-VA503+.
There is no quarantee your motherboard manufacturer has used the VIA
recommended pins for i2c-lines... With my FIC, they have.
For error reports, turn i2c-debugging on. Check Simon's sourcecode
files for how to do that.
Please report any success or failure with possible logfiles to me:
Kyösti Mälkki kmalkki@cc.hut.fi
-198
View File
@@ -1,198 +0,0 @@
/*
Motherboard SMBus (or i2c) Support for VIA VT82C586B South Bridge
Based on bit-lp.c by Simon Vogl
Copyright (c) 1998 Kyösti Mälkki
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/kernel.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <asm/io.h>
#include <linux/types.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < 0x020136 /* 2.1.54 */
#include <linux/bios32.h>
#endif
#include "i2c.h"
#include "algo-bit.h"
/* Power management registers */
#define PM_IO_BASE pm_io_base
#define PM_IO_BASE_REGISTER 0x48
#define I2C_DIR (PM_IO_BASE+0x40)
#define I2C_OUT (PM_IO_BASE+0x42)
#define I2C_IN (PM_IO_BASE+0x44)
#define I2C_SCL 0x02
#define I2C_SDA 0x04
/* io-region reservation */
#define IOSPACE 0x06
#define IOTEXT "Via VT82C586B i2c"
/* ----- global defines ----------------------------------------------- */
#define DEB(x) /* should be reasonable open, close &c. */
#define DEB2(x) /* low level debugging - very slow */
#define DEBE(x) x /* error messages */
/* ----- local functions ---------------------------------------------- */
u32 pm_io_base;
static void bit_mb_setscl(void *data, int state)
{
outb(state ? inb(I2C_OUT)|I2C_SCL : inb(I2C_OUT)&~I2C_SCL, I2C_OUT);
}
static void bit_mb_setsda(void *data, int state)
{
outb(state ? inb(I2C_OUT)|I2C_SDA : inb(I2C_OUT)&~I2C_SDA, I2C_OUT);
}
static int bit_mb_getscl(void *data)
{
return (0 != (inb(I2C_IN) & I2C_SCL) );
}
static int bit_mb_getsda(void *data)
{
return (0 != (inb(I2C_IN) & I2C_SDA) );
}
static int bit_mb_reg(struct i2c_client *client)
{
MOD_INC_USE_COUNT;
return 0;
}
static int bit_mb_unreg(struct i2c_client *client)
{
MOD_DEC_USE_COUNT;
return 0;
}
/* ------------------------------------------------------------------------ */
struct bit_adapter bit_mb_ops = {
"VT82C586B i2c",
HW_B_MB,
NULL,
bit_mb_setsda,
bit_mb_setscl,
bit_mb_getsda,
bit_mb_getscl,
bit_mb_reg,
bit_mb_unreg,
10, 10, 100, /*waits, timeout */
};
u32 pm_io_base=0;
static int bit_mb_init(void)
{
if (check_region(I2C_DIR, IOSPACE) < 0 ) {
return -ENODEV;
} else {
request_region(I2C_DIR, IOSPACE, IOTEXT);
/* Set lines to output and make them high */
outb(inb(I2C_DIR) | I2C_SCL | I2C_SDA, I2C_DIR);
bit_mb_setsda(NULL, 1);
bit_mb_setscl(NULL, 1);
}
return 0;
}
static void bit_mb_exit(void)
{
release_region(I2C_DIR, IOSPACE);
}
/* When exactly was the new pci interface introduced? */
#if LINUX_VERSION_CODE >= 0x020136 /* 2.1.54 */
static u32 find_i2c(void)
{
struct pci_dev *s_bridge;
u32 val;
if (! pci_present())
return(0);
s_bridge = pci_find_device(
PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, NULL);
if (! s_bridge) return 0;
if ( PCIBIOS_SUCCESSFUL !=
pci_read_config_dword(s_bridge, PM_IO_BASE_REGISTER, &val) )
return 0;
return (val & (0xff<<8));
}
#else
static u32 find_i2c(void)
{
unsigned char VIA_bus, VIA_devfn;
u32 val;
if (! pcibios_present())
return(0);
if(pcibios_find_device(
PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, 0, &VIA_bus,
&VIA_devfn))
return 0;
if ( PCIBIOS_SUCCESSFUL !=
pcibios_read_config_dword(VIA_bus, VIA_devfn,
PM_IO_BASE_REGISTER, &val))
return 0;
return (val & (0xff<<8));
}
#endif
#ifdef MODULE
MODULE_AUTHOR("Kyosti Malkki <kmalkki@cc.hut.fi>");
MODULE_DESCRIPTION("SMBus for VT82C586");
int init_module(void)
{
pm_io_base = find_i2c();
if (pm_io_base == 0) return -ENODEV;
if (bit_mb_init()==0) {
i2c_bit_add_bus(&bit_mb_ops);
} else {
return -ENODEV;
}
printk("Using i2c bus on motherboard\n");
return 0;
}
void cleanup_module(void)
{
i2c_bit_del_bus(&bit_mb_ops);
bit_mb_exit();
}
#endif
+241
View File
@@ -0,0 +1,241 @@
/*
i2c-via.c - Part of lm_sensors, Linux kernel modules
for hardware monitoring
i2c Support for Via Technologies 82C586B South Bridge
Copyright (c) 1998 Kyösti Mälkki <kmalkki@cc.hut.fi>
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/kernel.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <asm/io.h>
#include <linux/types.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < 0x020136 /* 2.1.54 */
#include <linux/bios32.h>
#endif
#include "i2c.h"
#include "algo-bit.h"
/* Power management registers */
#define PM_CFG_REVID 0x08 /* silicon revision code */
#define PM_CFG_IOBASE0 0x20
#define PM_CFG_IOBASE1 0x48
#define I2C_DIR (pm_io_base+0x40)
#define I2C_OUT (pm_io_base+0x42)
#define I2C_IN (pm_io_base+0x44)
#define I2C_SCL 0x02
#define I2C_SDA 0x04
/* io-region reservation */
#define IOSPACE 0x06
#define IOTEXT "VIA i2c"
/* ----- global defines ----------------------------------------------- */
#define DEB(x) x /* silicon revision, io addresses */
#define DEB2(x) x /* line status */
#define DEBE(x) /* */
/* ----- local functions ---------------------------------------------- */
u32 pm_io_base;
static void bit_via_setscl(void *data, int state)
{
outb(state ? inb(I2C_OUT)|I2C_SCL : inb(I2C_OUT)&~I2C_SCL, I2C_OUT);
}
static void bit_via_setsda(void *data, int state)
{
outb(state ? inb(I2C_OUT)|I2C_SDA : inb(I2C_OUT)&~I2C_SDA, I2C_OUT);
}
static int bit_via_getscl(void *data)
{
return (0 != (inb(I2C_IN) & I2C_SCL) );
}
static int bit_via_getsda(void *data)
{
return (0 != (inb(I2C_IN) & I2C_SDA) );
}
static int bit_via_reg(struct i2c_client *client)
{
MOD_INC_USE_COUNT;
return 0;
}
static int bit_via_unreg(struct i2c_client *client)
{
MOD_DEC_USE_COUNT;
return 0;
}
/* ------------------------------------------------------------------------ */
struct bit_adapter bit_via_ops = {
"VIA i2c",
HW_B_VIA,
NULL,
bit_via_setsda,
bit_via_setscl,
bit_via_getsda,
bit_via_getscl,
bit_via_reg,
bit_via_unreg,
5, 5, 100, /*waits, timeout */
};
u32 pm_io_base=0;
/* When exactly was the new pci interface introduced? */
#if LINUX_VERSION_CODE >= 0x020136 /* 2.1.54 */
static int find_via(void)
{
struct pci_dev *s_bridge;
u32 val, base;
u8 rev;
if (! pci_present())
return -ENODEV;
s_bridge = pci_find_device(
PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, NULL);
if (! s_bridge) {
printk("vt82c586b not found\n");
return -ENODEV;
}
if ( PCIBIOS_SUCCESSFUL !=
pci_read_config_byte(s_bridge, PM_CFG_REVID, &rev))
return -ENODEV;
switch(rev)
{
case 0x00: base = PM_CFG_IOBASE0;
break;
case 0x01:
case 0x10: base = PM_CFG_IOBASE1;
break;
default : base = PM_CFG_IOBASE1;
/* later revision */
}
if ( PCIBIOS_SUCCESSFUL !=
pci_read_config_dword(s_bridge, base, &val))
return -ENODEV;
pm_io_base = (val & (0xff<<8));
return 0;
}
#else
static int find_via(void)
{
unsigned char VIA_bus, VIA_devfn;
u32 val, base;
u8 rev;
if (! pcibios_present())
return -ENODEV;
if(pcibios_find_device(
PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, 0, &VIA_bus,
&VIA_devfn))
{
printk("vt82c586b not found\n");
return -ENODEV;
}
if ( PCIBIOS_SUCCESSFUL !=
pcibios_read_config_byte(VIA_bus, VIA_devfn,
PM_CFG_REVID, &rev))
return -ENODEV;
switch(rev)
{
case 0x00: base = PM_CFG_IOBASE0;
break;
case 0x01:
case 0x10: base = PM_CFG_IOBASE1;
break;
default : base = PM_CFG_IOBASE1;
/* later revision */
}
if ( PCIBIOS_SUCCESSFUL !=
pcibios_read_config_dword(VIA_bus, VIA_devfn,
base, &val))
return -ENODEV;
pm_io_base = (val & (0xff<<8));
return 0;
}
#endif
#ifdef MODULE
MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>");
MODULE_DESCRIPTION("i2c for Via vt82c586b southbridge");
int init_module(void)
{
if (find_via() < 0) {
printk("Error while reading PCI configuration\n");
return -ENODEV;
}
if ( check_region(I2C_DIR, IOSPACE) < 0) {
printk("IO 0x%x-0x%x already in use\n",
I2C_DIR, I2C_DIR+IOSPACE);
return -EBUSY;
} else {
request_region(I2C_DIR, IOSPACE, IOTEXT);
outb(inb(I2C_DIR) | I2C_SDA | I2C_SCL, I2C_DIR);
outb(inb(I2C_OUT) | I2C_SDA | I2C_SCL, I2C_OUT);
}
if (i2c_bit_add_bus(&bit_via_ops) == 0) {
printk("Via i2c: Module succesfully loaded\n");
return 0;
} else {
outb(inb(I2C_DIR)&~(I2C_SDA|I2C_SCL), I2C_DIR);
release_region(I2C_DIR, IOSPACE);
printk("Via i2c: Algo-bit error, couldn't register bus\n");
return -ENODEV;
}
}
void cleanup_module(void)
{
i2c_bit_del_bus(&bit_via_ops);
release_region(I2C_DIR, IOSPACE);
}
#endif