diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-11-14 22:29:36 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-11-14 22:29:36 +0000 |
commit | b8ec6149d15a6dee8d27b4e23be2f5c46ccdca43 (patch) | |
tree | e3e39c7559f9343a85a37262e710da1f1e3cde3d /sys/arch | |
parent | a17e073af6c0184a6a265fb39cc79462eee6a6af (diff) |
there are actually two ports on the ki2c unit. if the OF address has
the 0x80 bit set, the device is on the 2nd port. ok kettenis
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/macppc/dev/ki2c.c | 14 | ||||
-rw-r--r-- | sys/arch/macppc/dev/ki2cvar.h | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/sys/arch/macppc/dev/ki2c.c b/sys/arch/macppc/dev/ki2c.c index 2540f0f558a..a8d5b57e8e8 100644 --- a/sys/arch/macppc/dev/ki2c.c +++ b/sys/arch/macppc/dev/ki2c.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ki2c.c,v 1.5 2005/11/13 19:26:30 kettenis Exp $ */ +/* $OpenBSD: ki2c.c,v 1.6 2005/11/14 22:29:35 deraadt Exp $ */ /* $NetBSD: ki2c.c,v 1.1 2003/12/27 02:19:34 grant Exp $ */ /*- @@ -43,7 +43,7 @@ void ki2c_attach(struct device *, struct device *, void *); inline u_int ki2c_readreg(struct ki2c_softc *, int); inline void ki2c_writereg(struct ki2c_softc *, int, u_int); u_int ki2c_getmode(struct ki2c_softc *); -void ki2c_setmode(struct ki2c_softc *, u_int); +void ki2c_setmode(struct ki2c_softc *, u_int, u_int); u_int ki2c_getspeed(struct ki2c_softc *); void ki2c_setspeed(struct ki2c_softc *, u_int); int ki2c_intr(struct ki2c_softc *); @@ -117,7 +117,7 @@ ki2c_attach(parent, self, aux) ki2c_writereg(sc, ISR, 0); ki2c_writereg(sc, IER, 0); - ki2c_setmode(sc, I2C_STDSUBMODE); + ki2c_setmode(sc, I2C_STDSUBMODE, 0); ki2c_setspeed(sc, I2C_100kHz); /* XXX rate */ lockinit(&sc->sc_buslock, PZERO, sc->sc_dev.dv_xname, 0, 0); @@ -164,15 +164,18 @@ ki2c_getmode(sc) } void -ki2c_setmode(sc, mode) +ki2c_setmode(sc, mode, bus) struct ki2c_softc *sc; u_int mode; + u_int bus; { u_int x; KASSERT((mode & ~I2C_MODE) == 0); x = ki2c_readreg(sc, MODE); x &= ~I2C_MODE; + if (bus) + x |= I2C_BUS1; x |= mode; ki2c_writereg(sc, MODE, x); } @@ -365,7 +368,8 @@ ki2c_i2c_exec(void *cookie, i2c_op_t op, i2c_addr_t addr, return (EINVAL); /* We handle the subaddress stuff ourselves. */ - ki2c_setmode(sc, I2C_STDMODE); + ki2c_setmode(sc, I2C_STDMODE, addr >> 7); + addr &= 0x7f; if (ki2c_write(sc, (addr << 1), 0, cmdbuf, cmdlen) != 0) return (EIO); diff --git a/sys/arch/macppc/dev/ki2cvar.h b/sys/arch/macppc/dev/ki2cvar.h index e6174dfe33c..378bac8cc91 100644 --- a/sys/arch/macppc/dev/ki2cvar.h +++ b/sys/arch/macppc/dev/ki2cvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ki2cvar.h,v 1.2 2005/11/13 19:26:30 kettenis Exp $ */ +/* $OpenBSD: ki2cvar.h,v 1.3 2005/11/14 22:29:35 deraadt Exp $ */ /*- * Copyright (c) 2001 Tsubai Masanari. All rights reserved. @@ -56,6 +56,7 @@ #define I2C_STDSUBMODE 0x08 /* Standard mode + sub address */ #define I2C_COMBMODE 0x0c /* Combined mode */ #define I2C_PORT 0xf0 /* Port mask */ +#define I2C_BUS1 0x10 /* choose Bus 1 */ /* CONTROL */ #define I2C_CT_AAK 0x01 /* Send AAK */ |