Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/macppc/dev bus_space-ify
details: https://anonhg.NetBSD.org/src/rev/acdaea681db4
branches: trunk
changeset: 356298:acdaea681db4
user: macallan <macallan%NetBSD.org@localhost>
date: Fri Sep 15 21:34:42 2017 +0000
description:
bus_space-ify
diffstat:
sys/arch/macppc/dev/ki2c.c | 26 ++++++++++++++------------
sys/arch/macppc/dev/ki2cvar.h | 6 ++++--
2 files changed, 18 insertions(+), 14 deletions(-)
diffs (95 lines):
diff -r 476a6bb0f3ff -r acdaea681db4 sys/arch/macppc/dev/ki2c.c
--- a/sys/arch/macppc/dev/ki2c.c Fri Sep 15 21:33:52 2017 +0000
+++ b/sys/arch/macppc/dev/ki2c.c Fri Sep 15 21:34:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ki2c.c,v 1.20 2017/09/05 17:21:09 macallan Exp $ */
+/* $NetBSD: ki2c.c,v 1.21 2017/09/15 21:34:42 macallan Exp $ */
/* Id: ki2c.c,v 1.7 2002/10/05 09:56:05 tsubai Exp */
/*-
@@ -45,8 +45,8 @@
int ki2c_match(device_t, cfdata_t, void *);
void ki2c_attach(device_t, device_t, void *);
-inline u_int ki2c_readreg(struct ki2c_softc *, int);
-inline void ki2c_writereg(struct ki2c_softc *, int, u_int);
+inline uint8_t ki2c_readreg(struct ki2c_softc *, int);
+inline void ki2c_writereg(struct ki2c_softc *, int, uint8_t);
u_int ki2c_getmode(struct ki2c_softc *);
void ki2c_setmode(struct ki2c_softc *, u_int);
u_int ki2c_getspeed(struct ki2c_softc *);
@@ -95,6 +95,7 @@
u_int reg[20];
sc->sc_dev = self;
+ sc->sc_tag = ca->ca_tag;
ca->ca_reg[0] += ca->ca_baseaddr;
if (OF_getprop(node, "AAPL,i2c-rate", &rate, 4) != 4) {
@@ -105,7 +106,11 @@
aprint_error(": unable to find i2c address\n");
return;
}
- sc->sc_reg = mapiodev(addr, PAGE_SIZE, false);
+ if (bus_space_map(sc->sc_tag, addr, PAGE_SIZE, 0, &sc->sc_bh) != 0) {
+ aprint_error_dev(sc->sc_dev, "failed to map registers\n");
+ return;
+ }
+
if (OF_getprop(node, "AAPL,address-step", &sc->sc_regstep, 4) != 4) {
aprint_error(": unable to find i2c address step\n");
return;
@@ -200,21 +205,18 @@
return UNCONF;
}
-u_int
+uint8_t
ki2c_readreg(struct ki2c_softc *sc, int reg)
{
- u_char *addr = sc->sc_reg + sc->sc_regstep * reg;
- return *addr;
+ return bus_space_read_1(sc->sc_tag, sc->sc_bh, sc->sc_regstep * reg);
}
void
-ki2c_writereg(struct ki2c_softc *sc, int reg, u_int val)
+ki2c_writereg(struct ki2c_softc *sc, int reg, uint8_t val)
{
- u_char *addr = sc->sc_reg + sc->sc_regstep * reg;
-
- *addr = val;
- __asm volatile ("eieio");
+
+ bus_space_write_1(sc->sc_tag, sc->sc_bh, reg * sc->sc_regstep, val);
delay(10);
}
diff -r 476a6bb0f3ff -r acdaea681db4 sys/arch/macppc/dev/ki2cvar.h
--- a/sys/arch/macppc/dev/ki2cvar.h Fri Sep 15 21:33:52 2017 +0000
+++ b/sys/arch/macppc/dev/ki2cvar.h Fri Sep 15 21:34:42 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ki2cvar.h,v 1.4 2011/07/26 08:36:02 macallan Exp $ */
+/* $NetBSD: ki2cvar.h,v 1.5 2017/09/15 21:34:42 macallan Exp $ */
/* Id: ki2c.c,v 1.7 2002/10/05 09:56:05 tsubai Exp */
/*-
@@ -33,6 +33,7 @@
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
+#include <machine/autoconf.h>
#include <dev/i2c/i2cvar.h>
@@ -84,7 +85,8 @@
struct ki2c_softc {
device_t sc_dev;
- u_char *sc_reg;
+ bus_space_tag_t sc_tag;
+ bus_space_handle_t sc_bh;
int sc_regstep;
struct i2c_controller sc_i2c;
Home |
Main Index |
Thread Index |
Old Index