diff options
author | imp <imp@FreeBSD.org> | 2007-03-23 23:02:33 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2007-03-23 23:02:33 +0000 |
commit | 75d8168eb3aade1613cfc76d01cd8c638efbc02c (patch) | |
tree | ec1d8e516c9f57881ff72d209aff7e3925490ab3 /sys/dev/iicbus/iicbus.h | |
parent | b63dd57bc9322f91623a8fe5b81b29183127b013 (diff) | |
download | FreeBSD-src-75d8168eb3aade1613cfc76d01cd8c638efbc02c.zip FreeBSD-src-75d8168eb3aade1613cfc76d01cd8c638efbc02c.tar.gz |
MFp4: Create an ivar for each iic device on the iicbus. This ivar
holds the device's address.
Diffstat (limited to 'sys/dev/iicbus/iicbus.h')
-rw-r--r-- | sys/dev/iicbus/iicbus.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/sys/dev/iicbus/iicbus.h b/sys/dev/iicbus/iicbus.h index f0c061c..55f3b93 100644 --- a/sys/dev/iicbus/iicbus.h +++ b/sys/dev/iicbus/iicbus.h @@ -29,13 +29,36 @@ #ifndef __IICBUS_H #define __IICBUS_H -struct iicbus_softc { +#define IICBUS_IVAR(d) (struct iicbus_ivar *) device_get_ivars(d) +#define IICBUS_SOFTC(d) (struct iicbus_softc *) device_get_softc(d) +struct iicbus_softc +{ + device_t dev; /* Myself */ device_t owner; /* iicbus owner device structure */ u_char started; /* address of the 'started' slave * 0 if no start condition succeeded */ }; +struct iicbus_ivar +{ + uint32_t addr; +}; + +enum { + IICBUS_IVAR_ADDR /* Address or base address */ +}; + +#define IICBUS_ACCESSOR(A, B, T) \ +__inline static int \ +iicbus_get_ ## A(device_t dev, T *t) \ +{ \ + return BUS_READ_IVAR(device_get_parent(dev), dev, \ + IICBUS_IVAR_ ## B, (uintptr_t *) t); \ +} + +IICBUS_ACCESSOR(addr, ADDR, uint32_t) + extern int iicbus_generic_intr(device_t dev, int event, char *buf); extern driver_t iicbus_driver; |