Module Name: src Committed By: jmcneill Date: Sun Nov 23 13:37:27 UTC 2014
Modified Files: src/sys/dev/i2c: gttwsi_core.c gttwsivar.h Log Message: On Allwinner A31 you need to set the CONTROL_IFLG bit to clear it. Add a "iflg-rwc" property to enable this behaviour. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/gttwsi_core.c \ src/sys/dev/i2c/gttwsivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/i2c/gttwsi_core.c diff -u src/sys/dev/i2c/gttwsi_core.c:1.1 src/sys/dev/i2c/gttwsi_core.c:1.2 --- src/sys/dev/i2c/gttwsi_core.c:1.1 Fri Sep 6 00:56:12 2013 +++ src/sys/dev/i2c/gttwsi_core.c Sun Nov 23 13:37:27 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: gttwsi_core.c,v 1.1 2013/09/06 00:56:12 matt Exp $ */ +/* $NetBSD: gttwsi_core.c,v 1.2 2014/11/23 13:37:27 jmcneill Exp $ */ /* * Copyright (c) 2008 Eiji Kawauchi. * All rights reserved. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: gttwsi_core.c,v 1.1 2013/09/06 00:56:12 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gttwsi_core.c,v 1.2 2014/11/23 13:37:27 jmcneill Exp $"); #include "locators.h" #include <sys/param.h> @@ -124,6 +124,7 @@ void gttwsi_attach_subr(device_t self, bus_space_tag_t iot, bus_space_handle_t ioh) { struct gttwsi_softc * const sc = device_private(self); + prop_dictionary_t cfg = device_properties(self); aprint_naive("\n"); aprint_normal(": Marvell TWSI controller\n"); @@ -136,6 +137,8 @@ gttwsi_attach_subr(device_t self, bus_sp mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_BIO); cv_init(&sc->sc_cv, device_xname(self)); + prop_dictionary_get_bool(cfg, "iflg-rwc", &sc->sc_iflg_rwc); + sc->sc_started = false; sc->sc_i2c.ic_cookie = sc; sc->sc_i2c.ic_acquire_bus = gttwsi_acquire_bus; @@ -223,11 +226,15 @@ gttwsi_send_stop(void *v, int flags) { struct gttwsi_softc *sc = v; int retry = TWSI_RETRY_COUNT; + uint32_t control; sc->sc_started = false; /* Interrupt is not generated for STAT_NRS. */ - gttwsi_write_4(sc, TWSI_CONTROL, CONTROL_STOP | CONTROL_TWSIEN); + control = CONTROL_STOP | CONTROL_TWSIEN; + if (sc->sc_iflg_rwc) + control |= CONTROL_IFLG; + gttwsi_write_4(sc, TWSI_CONTROL, control); while (retry > 0) { if (gttwsi_read_4(sc, TWSI_STATUS) == STAT_NRS) return 0; @@ -324,6 +331,8 @@ gttwsi_wait(struct gttwsi_softc *sc, uin DELAY(5); if (!(flags & I2C_F_POLL)) control |= CONTROL_INTEN; + if (sc->sc_iflg_rwc) + control |= CONTROL_IFLG; gttwsi_write_4(sc, TWSI_CONTROL, control | CONTROL_TWSIEN); timo = 0; Index: src/sys/dev/i2c/gttwsivar.h diff -u src/sys/dev/i2c/gttwsivar.h:1.1 src/sys/dev/i2c/gttwsivar.h:1.2 --- src/sys/dev/i2c/gttwsivar.h:1.1 Fri Sep 6 00:56:12 2013 +++ src/sys/dev/i2c/gttwsivar.h Sun Nov 23 13:37:27 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: gttwsivar.h,v 1.1 2013/09/06 00:56:12 matt Exp $ */ +/* $NetBSD: gttwsivar.h,v 1.2 2014/11/23 13:37:27 jmcneill Exp $ */ /* * Copyright (c) 2008 Eiji Kawauchi. * All rights reserved. @@ -87,6 +87,8 @@ struct gttwsi_softc { kmutex_t sc_buslock; kmutex_t sc_mtx; kcondvar_t sc_cv; + + bool sc_iflg_rwc; }; void gttwsi_attach_subr(device_t, bus_space_tag_t, bus_space_handle_t);