adjust to dbcool_chipset.

This commit is contained in:
christos 2009-11-02 21:38:07 +00:00
parent 2365d83de9
commit e641795b86

View File

@ -1,4 +1,4 @@
/* $NetBSD: dbcool_ki2c.c,v 1.4 2009/01/14 03:16:57 ahoka Exp $ */
/* $NetBSD: dbcool_ki2c.c,v 1.5 2009/11/02 21:38:07 christos Exp $ */
/*-
* Copyright (C) 2005 Michael Lorenz
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dbcool_ki2c.c,v 1.4 2009/01/14 03:16:57 ahoka Exp $");
__KERNEL_RCSID(0, "$NetBSD: dbcool_ki2c.c,v 1.5 2009/11/02 21:38:07 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -50,8 +50,8 @@ __KERNEL_RCSID(0, "$NetBSD: dbcool_ki2c.c,v 1.4 2009/01/14 03:16:57 ahoka Exp $"
static void dbcool_ki2c_attach(device_t, device_t, void *);
static int dbcool_ki2c_match(device_t, cfdata_t, void *);
static uint8_t dbcool_ki2c_readreg(struct dbcool_softc *, uint8_t);
static void dbcool_ki2c_writereg(struct dbcool_softc *, uint8_t, uint8_t);
static uint8_t dbcool_ki2c_readreg(struct dbcool_chipset *, uint8_t);
static void dbcool_ki2c_writereg(struct dbcool_chipset *, uint8_t, uint8_t);
CFATTACH_DECL_NEW(dbcool_ki2c, sizeof(struct dbcool_softc),
dbcool_ki2c_match, dbcool_ki2c_attach, NULL, NULL);
@ -83,18 +83,18 @@ dbcool_ki2c_attach(device_t parent, device_t self, void *aux)
aprint_normal("\n");
aprint_naive("\n");
sc->sc_tag = ka->ka_tag;
sc->sc_addr = ka->ka_addr & 0xfe;
sc->sc_readreg = dbcool_ki2c_readreg;
sc->sc_writereg = dbcool_ki2c_writereg;
sc->sc_dc.dc_tag = ka->ka_tag;
sc->sc_dc.dc_addr = ka->ka_addr & 0xfe;
sc->sc_dc.dc_readreg = dbcool_ki2c_readreg;
sc->sc_dc.dc_writereg = dbcool_ki2c_writereg;
if (dbcool_chip_ident(sc) < 0) {
if (dbcool_chip_ident(&sc->sc_dc) < 0) {
aprint_error_dev(self, "Unrecognized dbCool chip - "
"set-up aborted\n");
return;
}
ver = sc->sc_readreg(sc, DBCOOL_REVISION_REG);
ver = sc->sc_dc.dc_readreg(&sc->sc_dc, DBCOOL_REVISION_REG);
if (sc->sc_chip->flags & DBCFLAG_4BIT_VER)
aprint_normal_dev(self, "%s dBCool(tm) Controller "
@ -111,23 +111,22 @@ dbcool_ki2c_attach(device_t parent, device_t self, void *aux)
}
static uint8_t
dbcool_ki2c_readreg(struct dbcool_softc *sc, uint8_t reg)
dbcool_ki2c_readreg(struct dbcool_chipset *dc, uint8_t reg)
{
uint8_t data = 0;
iic_acquire_bus(sc->sc_tag, 0);
iic_exec(sc->sc_tag, I2C_OP_READ, sc->sc_addr, &reg, 1,
&data, 1, 0);
iic_release_bus(sc->sc_tag, 0);
iic_acquire_bus(dc->dc_tag, 0);
iic_exec(dc->dc_tag, I2C_OP_READ, dc->dc_addr, &reg, 1, &data, 1, 0);
iic_release_bus(dc->dc_tag, 0);
return data;
}
static void
dbcool_ki2c_writereg(struct dbcool_softc *sc, uint8_t reg, uint8_t data)
dbcool_ki2c_writereg(struct dbcool_chipset *dc, uint8_t reg, uint8_t data)
{
uint8_t mdata[2] = {reg, data};
iic_acquire_bus(sc->sc_tag, 0);
iic_exec(sc->sc_tag, I2C_OP_WRITE, sc->sc_addr, &mdata, 2, NULL, 0, 0);
iic_release_bus(sc->sc_tag, 0);
iic_acquire_bus(dc->dc_tag, 0);
iic_exec(dc->dc_tag, I2C_OP_WRITE, dc->dc_addr, &mdata, 2, NULL, 0, 0);
iic_release_bus(dc->dc_tag, 0);
}