summaryrefslogtreecommitdiffstats
path: root/sys/dev/pcf/pcfvar.h
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-08-04 20:46:15 +0000
committerjhb <jhb@FreeBSD.org>2008-08-04 20:46:15 +0000
commit9b394a3293bfa4397c24c6649034b411994dbb72 (patch)
tree2a244ae80de29ad3e4b277353b095b09dc4a9aba /sys/dev/pcf/pcfvar.h
parent6f12163ca676979b992a474aab9c999d288f57ed (diff)
downloadFreeBSD-src-9b394a3293bfa4397c24c6649034b411994dbb72.zip
FreeBSD-src-9b394a3293bfa4397c24c6649034b411994dbb72.tar.gz
Add locking to the various iicbus(4) bridge drivers:
- Just grab Giant in the ixp425_iic(4) driver since this driver uses a shared address/data register window pair to access the actual I2C registers. None of the other ixp425 drivers lock access to these shared address/data registers yet and that would need to be done before this could use any meaningful locking. - Add locking to the interrupt handler and 'iicbus_reset' methods of the at91_twi(4) driver. - Add locking to the pcf(4) driver. Other pcf(4) fixes include: - Don't needlessly zero the softc. - Use bus_foo rather than bus_space_foo and remove bus space tag and handle from softc. - The lpbb(4) driver just grabs Giant for now. This will be refined later when ppbus(4) is locked. - As was done with smbus earlier, move the DRIVER_MODULE() lines to match the bus driver (either iicbus or iicbb) to the bridge driver into the bridge drivers. Tested by: sam (arm/ixp425)
Diffstat (limited to 'sys/dev/pcf/pcfvar.h')
-rw-r--r--sys/dev/pcf/pcfvar.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/dev/pcf/pcfvar.h b/sys/dev/pcf/pcfvar.h
index ed4d9d8..8e4d5d8 100644
--- a/sys/dev/pcf/pcfvar.h
+++ b/sys/dev/pcf/pcfvar.h
@@ -27,6 +27,9 @@
* $FreeBSD$
*/
+#ifndef __PCFVAR_H__
+#define __PCFVAR_H__
+
#define IO_PCFSIZE 2
#define TIMEOUT 9999 /* XXX */
@@ -63,19 +66,22 @@ struct pcf_softc {
int pcf_slave_mode; /* receiver or transmitter */
int pcf_started; /* 1 if start condition sent */
+ struct mtx pcf_lock;
device_t iicbus; /* the corresponding iicbus */
/* Resource handling stuff. */
struct resource *res_ioport;
int rid_ioport;
- bus_space_tag_t bt_ioport;
- bus_space_handle_t bh_ioport;
struct resource *res_irq;
int rid_irq;
void *intr_cookie;
};
#define DEVTOSOFTC(dev) ((struct pcf_softc *)device_get_softc(dev))
+#define PCF_LOCK(sc) mtx_lock(&(sc)->pcf_lock)
+#define PCF_UNLOCK(sc) mtx_unlock(&(sc)->pcf_lock)
+#define PCF_ASSERT_LOCKED(sc) mtx_assert(&(sc)->pcf_lock, MA_OWNED)
+
/*
* PCF8584 datasheet : when operate at 8 MHz or more, a minimun time of
* 6 clocks cycles must be left between two consecutives access
@@ -92,7 +98,7 @@ static __inline void
pcf_set_S0(struct pcf_softc *sc, int data)
{
- bus_space_write_1(sc->bt_ioport, sc->bh_ioport, 0, data);
+ bus_write_1(sc->res_ioport, 0, data);
pcf_nops();
}
@@ -100,7 +106,7 @@ static __inline void
pcf_set_S1(struct pcf_softc *sc, int data)
{
- bus_space_write_1(sc->bt_ioport, sc->bh_ioport, 1, data);
+ bus_write_1(sc->res_ioport, 1, data);
pcf_nops();
}
@@ -109,7 +115,7 @@ pcf_get_S0(struct pcf_softc *sc)
{
char data;
- data = bus_space_read_1(sc->bt_ioport, sc->bh_ioport, 0);
+ data = bus_read_1(sc->res_ioport, 0);
pcf_nops();
return (data);
@@ -120,7 +126,7 @@ pcf_get_S1(struct pcf_softc *sc)
{
char data;
- data = bus_space_read_1(sc->bt_ioport, sc->bh_ioport, 1);
+ data = bus_read_1(sc->res_ioport, 1);
pcf_nops();
return (data);
@@ -138,3 +144,5 @@ extern driver_intr_t pcf_intr;
#define PCF_MINVER 1
#define PCF_MAXVER 1
#define PCF_PREFVER PCF_MODVER
+
+#endif /* !__PCFVAR_H__ */
OpenPOWER on IntegriCloud