Home | History | Annotate | Line # | Download | only in pci
piixpm.c revision 1.2.8.2
      1  1.2.8.2  tron /* $NetBSD: piixpm.c,v 1.2.8.2 2006/05/24 15:50:28 tron Exp $ */
      2  1.2.8.2  tron /*	$OpenBSD: piixpm.c,v 1.20 2006/02/27 08:25:02 grange Exp $	*/
      3  1.2.8.2  tron 
      4  1.2.8.2  tron /*
      5  1.2.8.2  tron  * Copyright (c) 2005, 2006 Alexander Yurchenko <grange (at) openbsd.org>
      6  1.2.8.2  tron  *
      7  1.2.8.2  tron  * Permission to use, copy, modify, and distribute this software for any
      8  1.2.8.2  tron  * purpose with or without fee is hereby granted, provided that the above
      9  1.2.8.2  tron  * copyright notice and this permission notice appear in all copies.
     10  1.2.8.2  tron  *
     11  1.2.8.2  tron  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12  1.2.8.2  tron  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     13  1.2.8.2  tron  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     14  1.2.8.2  tron  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     15  1.2.8.2  tron  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     16  1.2.8.2  tron  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     17  1.2.8.2  tron  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     18  1.2.8.2  tron  */
     19  1.2.8.2  tron 
     20  1.2.8.2  tron /*
     21  1.2.8.2  tron  * Intel PIIX and compatible Power Management controller driver.
     22  1.2.8.2  tron  */
     23  1.2.8.2  tron 
     24  1.2.8.2  tron #include <sys/cdefs.h>
     25  1.2.8.2  tron __KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.2.8.2 2006/05/24 15:50:28 tron Exp $");
     26  1.2.8.2  tron 
     27  1.2.8.2  tron #include <sys/param.h>
     28  1.2.8.2  tron #include <sys/systm.h>
     29  1.2.8.2  tron #include <sys/device.h>
     30  1.2.8.2  tron #include <sys/kernel.h>
     31  1.2.8.2  tron #include <sys/lock.h>
     32  1.2.8.2  tron #include <sys/proc.h>
     33  1.2.8.2  tron 
     34  1.2.8.2  tron #include <machine/bus.h>
     35  1.2.8.2  tron 
     36  1.2.8.2  tron #include <dev/pci/pcidevs.h>
     37  1.2.8.2  tron #include <dev/pci/pcireg.h>
     38  1.2.8.2  tron #include <dev/pci/pcivar.h>
     39  1.2.8.2  tron 
     40  1.2.8.2  tron #include <dev/pci/piixpmreg.h>
     41  1.2.8.2  tron 
     42  1.2.8.2  tron #include <dev/i2c/i2cvar.h>
     43  1.2.8.2  tron 
     44  1.2.8.2  tron #ifdef PIIXPM_DEBUG
     45  1.2.8.2  tron #define DPRINTF(x) printf x
     46  1.2.8.2  tron #else
     47  1.2.8.2  tron #define DPRINTF(x)
     48  1.2.8.2  tron #endif
     49  1.2.8.2  tron 
     50  1.2.8.2  tron #define PIIXPM_DELAY	200
     51  1.2.8.2  tron #define PIIXPM_TIMEOUT	1
     52  1.2.8.2  tron 
     53  1.2.8.2  tron struct piixpm_softc {
     54  1.2.8.2  tron 	struct device		sc_dev;
     55  1.2.8.2  tron 
     56  1.2.8.2  tron 	bus_space_tag_t		sc_iot;
     57  1.2.8.2  tron 	bus_space_handle_t	sc_ioh;
     58  1.2.8.2  tron 	void *			sc_ih;
     59  1.2.8.2  tron 	int			sc_poll;
     60  1.2.8.2  tron 
     61  1.2.8.2  tron 	struct i2c_controller	sc_i2c_tag;
     62  1.2.8.2  tron 	struct lock		sc_i2c_lock;
     63  1.2.8.2  tron 	struct {
     64  1.2.8.2  tron 		i2c_op_t     op;
     65  1.2.8.2  tron 		void *       buf;
     66  1.2.8.2  tron 		size_t       len;
     67  1.2.8.2  tron 		int          flags;
     68  1.2.8.2  tron 		volatile int error;
     69  1.2.8.2  tron 	}			sc_i2c_xfer;
     70  1.2.8.2  tron };
     71  1.2.8.2  tron 
     72  1.2.8.2  tron int	piixpm_match(struct device *, struct cfdata *, void *);
     73  1.2.8.2  tron void	piixpm_attach(struct device *, struct device *, void *);
     74  1.2.8.2  tron 
     75  1.2.8.2  tron int	piixpm_i2c_acquire_bus(void *, int);
     76  1.2.8.2  tron void	piixpm_i2c_release_bus(void *, int);
     77  1.2.8.2  tron int	piixpm_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *, size_t,
     78  1.2.8.2  tron 	    void *, size_t, int);
     79  1.2.8.2  tron 
     80  1.2.8.2  tron int	piixpm_intr(void *);
     81  1.2.8.2  tron 
     82  1.2.8.2  tron CFATTACH_DECL(piixpm, sizeof(struct piixpm_softc),
     83  1.2.8.2  tron     piixpm_match, piixpm_attach, NULL, NULL);
     84  1.2.8.2  tron 
     85  1.2.8.2  tron int
     86  1.2.8.2  tron piixpm_match(struct device *parent, struct cfdata *match, void *aux)
     87  1.2.8.2  tron {
     88  1.2.8.2  tron 	struct pci_attach_args *pa;
     89  1.2.8.2  tron 
     90  1.2.8.2  tron 	pa = (struct pci_attach_args *)aux;
     91  1.2.8.2  tron 	switch (PCI_VENDOR(pa->pa_id)) {
     92  1.2.8.2  tron 	case PCI_VENDOR_INTEL:
     93  1.2.8.2  tron 		switch (PCI_PRODUCT(pa->pa_id)) {
     94  1.2.8.2  tron 		case PCI_PRODUCT_INTEL_82371AB_PMC:
     95  1.2.8.2  tron 		case PCI_PRODUCT_INTEL_82440MX_PMC:
     96  1.2.8.2  tron 			return 1;
     97  1.2.8.2  tron 		}
     98  1.2.8.2  tron 		break;
     99  1.2.8.2  tron 	case PCI_VENDOR_ATI:
    100  1.2.8.2  tron 		switch (PCI_PRODUCT(pa->pa_id)) {
    101  1.2.8.2  tron 		case PCI_PRODUCT_ATI_SB200_SMB:
    102  1.2.8.2  tron 			return 1;
    103  1.2.8.2  tron 		}
    104  1.2.8.2  tron 		break;
    105  1.2.8.2  tron 	}
    106  1.2.8.2  tron 
    107  1.2.8.2  tron 	return 0;
    108  1.2.8.2  tron }
    109  1.2.8.2  tron 
    110  1.2.8.2  tron void
    111  1.2.8.2  tron piixpm_attach(struct device *parent, struct device *self, void *aux)
    112  1.2.8.2  tron {
    113  1.2.8.2  tron 	struct piixpm_softc *sc = (struct piixpm_softc *)self;
    114  1.2.8.2  tron 	struct pci_attach_args *pa = aux;
    115  1.2.8.2  tron 	struct i2cbus_attach_args iba;
    116  1.2.8.2  tron 	pcireg_t base, conf;
    117  1.2.8.2  tron 	pci_intr_handle_t ih;
    118  1.2.8.2  tron 	const char *intrstr = NULL;
    119  1.2.8.2  tron 
    120  1.2.8.2  tron 	/* Read configuration */
    121  1.2.8.2  tron 	conf = pci_conf_read(pa->pa_pc, pa->pa_tag, PIIX_SMB_HOSTC);
    122  1.2.8.2  tron 	DPRINTF((": conf 0x%x", conf));
    123  1.2.8.2  tron 
    124  1.2.8.2  tron 	if ((conf & PIIX_SMB_HOSTC_HSTEN) == 0) {
    125  1.2.8.2  tron 		printf(": SMBus disabled\n");
    126  1.2.8.2  tron 		return;
    127  1.2.8.2  tron 	}
    128  1.2.8.2  tron 
    129  1.2.8.2  tron 	/* Map I/O space */
    130  1.2.8.2  tron 	sc->sc_iot = pa->pa_iot;
    131  1.2.8.2  tron 	base = pci_conf_read(pa->pa_pc, pa->pa_tag, PIIX_SMB_BASE) & 0xffff;
    132  1.2.8.2  tron 	if (bus_space_map(sc->sc_iot, PCI_MAPREG_IO_ADDR(base),
    133  1.2.8.2  tron 	    PIIX_SMB_SIZE, 0, &sc->sc_ioh)) {
    134  1.2.8.2  tron 		printf(": can't map I/O space\n");
    135  1.2.8.2  tron 		return;
    136  1.2.8.2  tron 	}
    137  1.2.8.2  tron 
    138  1.2.8.2  tron 	sc->sc_poll = 1;
    139  1.2.8.2  tron 	if ((conf & PIIX_SMB_HOSTC_INTMASK) == PIIX_SMB_HOSTC_SMI) {
    140  1.2.8.2  tron 		/* No PCI IRQ */
    141  1.2.8.2  tron 		printf(": SMI");
    142  1.2.8.2  tron 	} else if ((conf & PIIX_SMB_HOSTC_INTMASK) == PIIX_SMB_HOSTC_IRQ) {
    143  1.2.8.2  tron 		/* Install interrupt handler */
    144  1.2.8.2  tron 		if (pci_intr_map(pa, &ih) == 0) {
    145  1.2.8.2  tron 			intrstr = pci_intr_string(pa->pa_pc, ih);
    146  1.2.8.2  tron 			sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO,
    147  1.2.8.2  tron 			    piixpm_intr, sc);
    148  1.2.8.2  tron 			if (sc->sc_ih != NULL) {
    149  1.2.8.2  tron 				printf(": %s", intrstr);
    150  1.2.8.2  tron 				sc->sc_poll = 0;
    151  1.2.8.2  tron 			}
    152  1.2.8.2  tron 		}
    153  1.2.8.2  tron 		if (sc->sc_poll)
    154  1.2.8.2  tron 			printf(": polling");
    155  1.2.8.2  tron 	}
    156  1.2.8.2  tron 
    157  1.2.8.2  tron 	printf("\n");
    158  1.2.8.2  tron 
    159  1.2.8.2  tron 	/* Attach I2C bus */
    160  1.2.8.2  tron 	lockinit(&sc->sc_i2c_lock, PRIBIO | PCATCH, "iiclk", 0, 0);
    161  1.2.8.2  tron 	sc->sc_i2c_tag.ic_cookie = sc;
    162  1.2.8.2  tron 	sc->sc_i2c_tag.ic_acquire_bus = piixpm_i2c_acquire_bus;
    163  1.2.8.2  tron 	sc->sc_i2c_tag.ic_release_bus = piixpm_i2c_release_bus;
    164  1.2.8.2  tron 	sc->sc_i2c_tag.ic_exec = piixpm_i2c_exec;
    165  1.2.8.2  tron 
    166  1.2.8.2  tron 	bzero(&iba, sizeof(iba));
    167  1.2.8.2  tron 	iba.iba_name = "iic";
    168  1.2.8.2  tron 	iba.iba_tag = &sc->sc_i2c_tag;
    169  1.2.8.2  tron 	config_found(self, &iba, iicbus_print);
    170  1.2.8.2  tron 
    171  1.2.8.2  tron 	return;
    172  1.2.8.2  tron }
    173  1.2.8.2  tron 
    174  1.2.8.2  tron int
    175  1.2.8.2  tron piixpm_i2c_acquire_bus(void *cookie, int flags)
    176  1.2.8.2  tron {
    177  1.2.8.2  tron 	struct piixpm_softc *sc = cookie;
    178  1.2.8.2  tron 
    179  1.2.8.2  tron 	if (cold || sc->sc_poll || (flags & I2C_F_POLL))
    180  1.2.8.2  tron 		return (0);
    181  1.2.8.2  tron 
    182  1.2.8.2  tron 	return (lockmgr(&sc->sc_i2c_lock, LK_EXCLUSIVE, NULL));
    183  1.2.8.2  tron }
    184  1.2.8.2  tron 
    185  1.2.8.2  tron void
    186  1.2.8.2  tron piixpm_i2c_release_bus(void *cookie, int flags)
    187  1.2.8.2  tron {
    188  1.2.8.2  tron 	struct piixpm_softc *sc = cookie;
    189  1.2.8.2  tron 
    190  1.2.8.2  tron 	if (cold || sc->sc_poll || (flags & I2C_F_POLL))
    191  1.2.8.2  tron 		return;
    192  1.2.8.2  tron 
    193  1.2.8.2  tron 	lockmgr(&sc->sc_i2c_lock, LK_RELEASE, NULL);
    194  1.2.8.2  tron }
    195  1.2.8.2  tron 
    196  1.2.8.2  tron int
    197  1.2.8.2  tron piixpm_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr,
    198  1.2.8.2  tron     const void *cmdbuf, size_t cmdlen, void *buf, size_t len, int flags)
    199  1.2.8.2  tron {
    200  1.2.8.2  tron 	struct piixpm_softc *sc = cookie;
    201  1.2.8.2  tron 	const u_int8_t *b;
    202  1.2.8.2  tron 	u_int8_t ctl = 0, st;
    203  1.2.8.2  tron 	int retries;
    204  1.2.8.2  tron 
    205  1.2.8.2  tron 	DPRINTF(("%s: exec: op %d, addr 0x%x, cmdlen %d, len %d, flags 0x%x\n",
    206  1.2.8.2  tron 	    sc->sc_dev.dv_xname, op, addr, cmdlen, len, flags));
    207  1.2.8.2  tron 
    208  1.2.8.2  tron 	/* Wait for bus to be idle */
    209  1.2.8.2  tron 	for (retries = 100; retries > 0; retries--) {
    210  1.2.8.2  tron 		st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_HS);
    211  1.2.8.2  tron 		if (!(st & PIIX_SMB_HS_BUSY))
    212  1.2.8.2  tron 			break;
    213  1.2.8.2  tron 		DELAY(PIIXPM_DELAY);
    214  1.2.8.2  tron 	}
    215  1.2.8.2  tron 	DPRINTF(("%s: exec: st 0x%b\n", sc->sc_dev.dv_xname, st,
    216  1.2.8.2  tron 	    PIIX_SMB_HS_BITS));
    217  1.2.8.2  tron 	if (st & PIIX_SMB_HS_BUSY)
    218  1.2.8.2  tron 		return (1);
    219  1.2.8.2  tron 
    220  1.2.8.2  tron 	if (cold || sc->sc_poll)
    221  1.2.8.2  tron 		flags |= I2C_F_POLL;
    222  1.2.8.2  tron 
    223  1.2.8.2  tron 	if (!I2C_OP_STOP_P(op) || cmdlen > 1 || len > 2)
    224  1.2.8.2  tron 		return (1);
    225  1.2.8.2  tron 
    226  1.2.8.2  tron 	/* Setup transfer */
    227  1.2.8.2  tron 	sc->sc_i2c_xfer.op = op;
    228  1.2.8.2  tron 	sc->sc_i2c_xfer.buf = buf;
    229  1.2.8.2  tron 	sc->sc_i2c_xfer.len = len;
    230  1.2.8.2  tron 	sc->sc_i2c_xfer.flags = flags;
    231  1.2.8.2  tron 	sc->sc_i2c_xfer.error = 0;
    232  1.2.8.2  tron 
    233  1.2.8.2  tron 	/* Set slave address and transfer direction */
    234  1.2.8.2  tron 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_TXSLVA,
    235  1.2.8.2  tron 	    PIIX_SMB_TXSLVA_ADDR(addr) |
    236  1.2.8.2  tron 	    (I2C_OP_READ_P(op) ? PIIX_SMB_TXSLVA_READ : 0));
    237  1.2.8.2  tron 
    238  1.2.8.2  tron 	b = cmdbuf;
    239  1.2.8.2  tron 	if (cmdlen > 0)
    240  1.2.8.2  tron 		/* Set command byte */
    241  1.2.8.2  tron 		bus_space_write_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_HCMD, b[0]);
    242  1.2.8.2  tron 
    243  1.2.8.2  tron 	if (I2C_OP_WRITE_P(op)) {
    244  1.2.8.2  tron 		/* Write data */
    245  1.2.8.2  tron 		b = buf;
    246  1.2.8.2  tron 		if (len > 0)
    247  1.2.8.2  tron 			bus_space_write_1(sc->sc_iot, sc->sc_ioh,
    248  1.2.8.2  tron 			    PIIX_SMB_HD0, b[0]);
    249  1.2.8.2  tron 		if (len > 1)
    250  1.2.8.2  tron 			bus_space_write_1(sc->sc_iot, sc->sc_ioh,
    251  1.2.8.2  tron 			    PIIX_SMB_HD1, b[1]);
    252  1.2.8.2  tron 	}
    253  1.2.8.2  tron 
    254  1.2.8.2  tron 	/* Set SMBus command */
    255  1.2.8.2  tron 	if (len == 0)
    256  1.2.8.2  tron 		ctl = PIIX_SMB_HC_CMD_BYTE;
    257  1.2.8.2  tron 	else if (len == 1)
    258  1.2.8.2  tron 		ctl = PIIX_SMB_HC_CMD_BDATA;
    259  1.2.8.2  tron 	else if (len == 2)
    260  1.2.8.2  tron 		ctl = PIIX_SMB_HC_CMD_WDATA;
    261  1.2.8.2  tron 
    262  1.2.8.2  tron 	if ((flags & I2C_F_POLL) == 0)
    263  1.2.8.2  tron 		ctl |= PIIX_SMB_HC_INTREN;
    264  1.2.8.2  tron 
    265  1.2.8.2  tron 	/* Start transaction */
    266  1.2.8.2  tron 	ctl |= PIIX_SMB_HC_START;
    267  1.2.8.2  tron 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_HC, ctl);
    268  1.2.8.2  tron 
    269  1.2.8.2  tron 	if (flags & I2C_F_POLL) {
    270  1.2.8.2  tron 		/* Poll for completion */
    271  1.2.8.2  tron 		DELAY(PIIXPM_DELAY);
    272  1.2.8.2  tron 		for (retries = 1000; retries > 0; retries--) {
    273  1.2.8.2  tron 			st = bus_space_read_1(sc->sc_iot, sc->sc_ioh,
    274  1.2.8.2  tron 			    PIIX_SMB_HS);
    275  1.2.8.2  tron 			if ((st & PIIX_SMB_HS_BUSY) == 0)
    276  1.2.8.2  tron 				break;
    277  1.2.8.2  tron 			DELAY(PIIXPM_DELAY);
    278  1.2.8.2  tron 		}
    279  1.2.8.2  tron 		if (st & PIIX_SMB_HS_BUSY)
    280  1.2.8.2  tron 			goto timeout;
    281  1.2.8.2  tron 		piixpm_intr(sc);
    282  1.2.8.2  tron 	} else {
    283  1.2.8.2  tron 		/* Wait for interrupt */
    284  1.2.8.2  tron 		if (tsleep(sc, PRIBIO, "iicexec", PIIXPM_TIMEOUT * hz))
    285  1.2.8.2  tron 			goto timeout;
    286  1.2.8.2  tron 	}
    287  1.2.8.2  tron 
    288  1.2.8.2  tron 	if (sc->sc_i2c_xfer.error)
    289  1.2.8.2  tron 		return (1);
    290  1.2.8.2  tron 
    291  1.2.8.2  tron 	return (0);
    292  1.2.8.2  tron 
    293  1.2.8.2  tron timeout:
    294  1.2.8.2  tron 	/*
    295  1.2.8.2  tron 	 * Transfer timeout. Kill the transaction and clear status bits.
    296  1.2.8.2  tron 	 */
    297  1.2.8.2  tron 	printf("%s: timeout, status 0x%x\n", sc->sc_dev.dv_xname, st);
    298  1.2.8.2  tron 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_HC,
    299  1.2.8.2  tron 	    PIIX_SMB_HC_KILL);
    300  1.2.8.2  tron 	DELAY(PIIXPM_DELAY);
    301  1.2.8.2  tron 	st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_HS);
    302  1.2.8.2  tron 	if ((st & PIIX_SMB_HS_FAILED) == 0)
    303  1.2.8.2  tron 		printf("%s: transaction abort failed, status 0x%x\n",
    304  1.2.8.2  tron 		    sc->sc_dev.dv_xname, st);
    305  1.2.8.2  tron 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_HS, st);
    306  1.2.8.2  tron 	return (1);
    307  1.2.8.2  tron }
    308  1.2.8.2  tron 
    309  1.2.8.2  tron int
    310  1.2.8.2  tron piixpm_intr(void *arg)
    311  1.2.8.2  tron {
    312  1.2.8.2  tron 	struct piixpm_softc *sc = arg;
    313  1.2.8.2  tron 	u_int8_t st;
    314  1.2.8.2  tron 	u_int8_t *b;
    315  1.2.8.2  tron 	size_t len;
    316  1.2.8.2  tron 
    317  1.2.8.2  tron 	/* Read status */
    318  1.2.8.2  tron 	st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_HS);
    319  1.2.8.2  tron 	if ((st & PIIX_SMB_HS_BUSY) != 0 || (st & (PIIX_SMB_HS_INTR |
    320  1.2.8.2  tron 	    PIIX_SMB_HS_DEVERR | PIIX_SMB_HS_BUSERR |
    321  1.2.8.2  tron 	    PIIX_SMB_HS_FAILED)) == 0)
    322  1.2.8.2  tron 		/* Interrupt was not for us */
    323  1.2.8.2  tron 		return (0);
    324  1.2.8.2  tron 
    325  1.2.8.2  tron 	DPRINTF(("%s: intr st 0x%b\n", sc->sc_dev.dv_xname, st,
    326  1.2.8.2  tron 	    PIIX_SMB_HS_BITS));
    327  1.2.8.2  tron 
    328  1.2.8.2  tron 	/* Clear status bits */
    329  1.2.8.2  tron 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, PIIX_SMB_HS, st);
    330  1.2.8.2  tron 
    331  1.2.8.2  tron 	/* Check for errors */
    332  1.2.8.2  tron 	if (st & (PIIX_SMB_HS_DEVERR | PIIX_SMB_HS_BUSERR |
    333  1.2.8.2  tron 	    PIIX_SMB_HS_FAILED)) {
    334  1.2.8.2  tron 		sc->sc_i2c_xfer.error = 1;
    335  1.2.8.2  tron 		goto done;
    336  1.2.8.2  tron 	}
    337  1.2.8.2  tron 
    338  1.2.8.2  tron 	if (st & PIIX_SMB_HS_INTR) {
    339  1.2.8.2  tron 		if (I2C_OP_WRITE_P(sc->sc_i2c_xfer.op))
    340  1.2.8.2  tron 			goto done;
    341  1.2.8.2  tron 
    342  1.2.8.2  tron 		/* Read data */
    343  1.2.8.2  tron 		b = sc->sc_i2c_xfer.buf;
    344  1.2.8.2  tron 		len = sc->sc_i2c_xfer.len;
    345  1.2.8.2  tron 		if (len > 0)
    346  1.2.8.2  tron 			b[0] = bus_space_read_1(sc->sc_iot, sc->sc_ioh,
    347  1.2.8.2  tron 			    PIIX_SMB_HD0);
    348  1.2.8.2  tron 		if (len > 1)
    349  1.2.8.2  tron 			b[1] = bus_space_read_1(sc->sc_iot, sc->sc_ioh,
    350  1.2.8.2  tron 			    PIIX_SMB_HD1);
    351  1.2.8.2  tron 	}
    352  1.2.8.2  tron 
    353  1.2.8.2  tron done:
    354  1.2.8.2  tron 	if ((sc->sc_i2c_xfer.flags & I2C_F_POLL) == 0)
    355  1.2.8.2  tron 		wakeup(sc);
    356  1.2.8.2  tron 	return (1);
    357  1.2.8.2  tron }
    358