Hi!
add smbus support VIA VT82C596A, VT82C596B and VT82C686A in viapm(4)
Tested VIA VT82C596A.
--
Alexandr Shadchin
Index: viapm.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/viapm.c,v
retrieving revision 1.12
diff -u -p -r1.12 viapm.c
--- viapm.c 26 Jun 2009 02:46:27 -0000 1.12
+++ viapm.c 13 Feb 2010 16:54:51 -0000
@@ -36,11 +36,18 @@
#include <dev/i2c/i2cvar.h>
/*
+ * VIA VT82C596 register definitions.
+ */
+
+/* PCI configuration registers */
+#define VIAPM_SMB_BASE1 0x90 /* SMBus base address */
+
+/*
* VIA VT8237 ISA register definitions.
*/
/* PCI configuration registers */
-#define VIAPM_SMB_BASE 0xd0 /* SMBus base address */
+#define VIAPM_SMB_BASE2 0xd0 /* SMBus base address */
#define VIAPM_SMB_HOSTC 0xd2 /* host configuration */
#define VIAPM_SMB_HOSTC_HSTEN (1 << 0) /* enable host controller */
#define VIAPM_SMB_HOSTC_INTEN (1 << 1) /* enable SCI/SMI */
@@ -124,7 +131,13 @@ struct cfdriver viapm_cd = {
NULL, "viapm", DV_DULL
};
-const struct pci_matchid viapm_ids[] = {
+const struct pci_matchid viapm_smb_base1_ids[] = {
+ { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C596 },
+ { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C596B_PM },
+ { PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT82C686A_SMB }
+};
+
+const struct pci_matchid viapm_smb_base2_ids[] = {
{ PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8233_ISA },
{ PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8233A_ISA },
{ PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VT8235_ISA },
@@ -140,8 +153,15 @@ const struct pci_matchid viapm_ids[] = {
int
viapm_match(struct device *parent, void *match, void *aux)
{
- return (pci_matchbyid(aux, viapm_ids,
- sizeof(viapm_ids) / sizeof(viapm_ids[0])));
+ if (pci_matchbyid(aux, viapm_smb_base1_ids,
+ sizeof(viapm_smb_base1_ids) / sizeof(viapm_smb_base1_ids[0])))
+ return 1;
+
+ if (pci_matchbyid(aux, viapm_smb_base2_ids,
+ sizeof(viapm_smb_base2_ids) / sizeof(viapm_smb_base2_ids[0])))
+ return 1;
+
+ return 0;
}
void
@@ -151,14 +171,21 @@ viapm_attach(struct device *parent, stru
struct pci_attach_args *pa = aux;
struct i2cbus_attach_args iba;
pcireg_t conf, iobase;
+ int issmb_base1;
#if 0
pci_intr_handle_t ih;
const char *intrstr = NULL;
#endif
+ issmb_base1 = (pci_matchbyid(pa, viapm_smb_base1_ids,
+ sizeof(viapm_smb_base1_ids) / sizeof(viapm_smb_base1_ids[0])));
+
/* Map I/O space */
sc->sc_iot = pa->pa_iot;
- iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, VIAPM_SMB_BASE);
+ if (issmb_base1)
+ iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, VIAPM_SMB_BASE1);
+ else
+ iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, VIAPM_SMB_BASE2);
if (iobase == 0 ||
bus_space_map(sc->sc_iot, iobase & 0xfffe,
VIAPM_SMB_SIZE, 0, &sc->sc_ioh)) {
@@ -167,6 +194,8 @@ viapm_attach(struct device *parent, stru
}
/* Read configuration */
+ if (issmb_base1)
+ iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, VIAPM_SMB_BASE2);
conf = (iobase >> 16);
DPRINTF((": conf 0x%x", conf));
OpenBSD 4.7-beta (GENERIC) #25: Sat Feb 13 14:37:57 YEKT 2010
[email protected]:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel Pentium III ("GenuineIntel" 686-class) 853 MHz
cpu0:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,SER,MMX,FXSR,SSE
real mem = 670593024 (639MB)
avail mem = 641105920 (611MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 04/12/01, BIOS32 rev. 0 @ 0xfb300, SMBIOS
rev. 2.2 @ 0xf0800 (39 entries)
bios0: vendor Award Software International, Inc. version "4.51 PG" date 04/12/01
bios0: VIA Technologies, Inc. VT82C693/A
apm0 at bios0: Power Management spec V1.2 (slowidle)
apm0: AC on, battery charge unknown
acpi at bios0 function 0x0 not configured
pcibios0 at bios0: rev 2.1 @ 0xf0000/0xb788
pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfdf00/144 (7 entries)
pcibios0: PCI Exclusive IRQs: 5 7 10 11
pcibios0: PCI Interrupt Router at 000:07:0 ("VIA VT82C596A ISA" rev 0x00)
pcibios0: PCI bus #1 is the last bus
bios0: ROM list: 0xc0000/0xc800
cpu0 at mainbus0: (uniprocessor)
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "VIA VT82C691 PCI" rev 0x44
viaagp0 at pchb0: v2
agp0 at viaagp0: aperture at 0xe0000000, size 0x10000000
ppb0 at pci0 dev 1 function 0 "VIA VT82C598 AGP" rev 0x00
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 "NVIDIA GeForce2 MX" rev 0xb2
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
pcib0 at pci0 dev 7 function 0 "VIA VT82C596A ISA" rev 0x23
pciide0 at pci0 dev 7 function 1 "VIA VT82C571 IDE" rev 0x10: ATA66, channel 0
configured to compatibility, channel 1 configured to compatibility
atapiscsi0 at pciide0 channel 0 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <_NEC, DVD_RW ND-3500AG, 2.1B> ATAPI 5/cdrom
removable
cd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
wd0 at pciide0 channel 1 drive 0: <ST340016A>
wd0: 16-sector PIO, LBA, 39097MB, 80070686 sectors
wd1 at pciide0 channel 1 drive 1: <ST340016A>
wd1: 16-sector PIO, LBA, 38166MB, 78165360 sectors
wd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 4
wd1(pciide0:1:1): using PIO mode 4, Ultra-DMA mode 4
uhci0 at pci0 dev 7 function 2 "VIA VT83C572 USB" rev 0x11: irq 10
viapm0 at pci0 dev 7 function 3 "VIA VT82C596 Power" rev 0x30
iic0 at viapm0
spdmem0 at iic0 addr 0x50: 128MB SDRAM non-parity PC133CL2
spdmem1 at iic0 addr 0x51: 256MB SDRAM non-parity PC133CL3
spdmem2 at iic0 addr 0x52: 256MB SDRAM non-parity PC133CL3
skc0 at pci0 dev 8 function 0 "D-Link Systems DGE-530T B1" rev 0x11, Yukon Lite
(0x9): irq 11
sk0 at skc0 port A: address 00:17:9a:06:14:4f
eephy0 at sk0 phy 0: 88E1011 Gigabit PHY, rev. 5
envy0 at pci0 dev 9 function 0 "IC Ensemble Envy24PT/HT Audio" rev 0x01: irq 5
envy0: VIA Tremor 5.1, 2 inputs, 6 outputs
ac97: codec id 0x56494170 (VIA Technologies VT1617A)
ac97: codec features headphone, 18 bit DAC, 18 bit ADC, KS Waves 3D
audio0 at envy0
rl0 at pci0 dev 10 function 0 "Realtek 8139" rev 0x10: irq 7, address
00:50:22:40:2b:23
rlphy0 at rl0 phy 0: RTL internal PHY
rl1 at pci0 dev 12 function 0 "D-Link Systems 530TX+" rev 0x10: irq 11, address
00:55:d0:ca:12:21
rlphy1 at rl1 phy 0: RTL internal PHY
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pmsi0 at pckbc0 (aux slot)
pckbc0: using irq 12 for aux slot
wsmouse0 at pmsi0 mux 0
pcppi0 at isa0 port 0x61
midi0 at pcppi0: <PC speaker>
spkr0 at pcppi0
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
usb0 at uhci0: USB revision 1.0
uhub0 at usb0 "VIA UHCI root hub" rev 1.00/1.00 addr 1
biomask e75d netmask efdd ttymask ffdf
mtrr: Pentium Pro MTRR support
vscsi0 at root
scsibus1 at vscsi0: 256 targets
softraid0 at root
root on wd0a swap on wd0b dump on wd0b
WARNING: / was not properly unmounted
pppoe0: received unexpected PADO