From c8812077bf640ee5073598870bb03eb307a866c1 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Fri, 18 Jun 2010 14:28:57 +0000 Subject: [PATCH] Add support for the Keywest I2C controller in Apple uninorth northbridges. Although the Keywest registers have only 1 byte of content, they are secretly 4-byte registers, which became apparent from them moving on the big-endian Uninorth version of the controller. --- sys/powerpc/powermac/kiic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/powerpc/powermac/kiic.c b/sys/powerpc/powermac/kiic.c index 459d20e649d7..c01987a79817 100644 --- a/sys/powerpc/powermac/kiic.c +++ b/sys/powerpc/powermac/kiic.c @@ -57,6 +57,7 @@ #define ADDR 5 #define SUBADDR 6 #define DATA 7 +#define REV 8 /* MODE */ #define I2C_SPEED 0x03 /* Speed mask */ @@ -146,6 +147,7 @@ static driver_t kiic_driver = { static devclass_t kiic_devclass; DRIVER_MODULE(kiic, macio, kiic_driver, kiic_devclass, 0, 0); +DRIVER_MODULE(kiic, unin, kiic_driver, kiic_devclass, 0, 0); static int kiic_probe(device_t self) @@ -235,6 +237,9 @@ kiic_attach(device_t self) kiic_writereg(sc, IER, I2C_INT_DATA | I2C_INT_ADDR | I2C_INT_STOP); + if (bootverbose) + device_printf(self, "Revision: %02X\n", kiic_readreg(sc, REV)); + /* Add the IIC bus layer */ sc->sc_iicbus = device_add_child(self, "iicbus", -1); @@ -244,14 +249,14 @@ kiic_attach(device_t self) static void kiic_writereg(struct kiic_softc *sc, u_int reg, u_int val) { - bus_write_1(sc->sc_reg, sc->sc_regstep * reg, val); + bus_write_4(sc->sc_reg, sc->sc_regstep * reg, val); DELAY(10); /* register access delay */ } static u_int kiic_readreg(struct kiic_softc *sc, u_int reg) { - return bus_read_1(sc->sc_reg, sc->sc_regstep * reg); + return bus_read_4(sc->sc_reg, sc->sc_regstep * reg) & 0xff; } static void