summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2014-11-23 13:37:27 +0000
committerjmcneill <jmcneill@NetBSD.org>2014-11-23 13:37:27 +0000
commitbd063a49a4e7e285782f78d0aeeb9715ef97eda2 (patch)
tree7d4be81fd68bf8a605d54d56ee619afc67871dbb /sys/dev
parentcb932ad256fb3a4911d6eb3666bb4c4028573884 (diff)
On Allwinner A31 you need to set the CONTROL_IFLG bit to clear it. Add
a "iflg-rwc" property to enable this behaviour.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/i2c/gttwsi_core.c15
-rw-r--r--sys/dev/i2c/gttwsivar.h4
2 files changed, 15 insertions, 4 deletions
diff --git a/sys/dev/i2c/gttwsi_core.c b/sys/dev/i2c/gttwsi_core.c
index 415f5e0090e..af955b6679b 100644
--- a/sys/dev/i2c/gttwsi_core.c
+++ b/sys/dev/i2c/gttwsi_core.c
@@ -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_space_tag_t iot, bus_space_handle_t ioh)
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, uint32_t control, uint32_t expect,
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;
diff --git a/sys/dev/i2c/gttwsivar.h b/sys/dev/i2c/gttwsivar.h
index 5bedcc1edf5..5ef270053af 100644
--- a/sys/dev/i2c/gttwsivar.h
+++ b/sys/dev/i2c/gttwsivar.h
@@ -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);