summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/smbus/smbconf.c55
-rw-r--r--sys/dev/smbus/smbconf.h10
-rw-r--r--sys/dev/smbus/smbus.c33
-rw-r--r--sys/dev/smbus/smbus_if.m13
4 files changed, 79 insertions, 32 deletions
diff --git a/sys/dev/smbus/smbconf.c b/sys/dev/smbus/smbconf.c
index 60798f5..8fe67db 100644
--- a/sys/dev/smbus/smbconf.c
+++ b/sys/dev/smbus/smbconf.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: smbconf.c,v 1.1.1.2 1998/08/13 15:16:57 son Exp $
+ * $Id: smbconf.c,v 1.1.1.1 1998/09/03 20:52:54 nsouch Exp $
*
*/
#include <sys/param.h>
@@ -71,6 +71,28 @@ smbus_alloc_bus(device_t parent)
return (child);
}
+static int
+smbus_poll(struct smbus_softc *sc, int how)
+{
+ int error;
+
+ switch (how) {
+ case (SMB_WAIT | SMB_INTR):
+ error = tsleep(sc, SMBPRI|PCATCH, "smbreq", 0);
+ break;
+
+ case (SMB_WAIT | SMB_NOINTR):
+ error = tsleep(sc, SMBPRI, "smbreq", 0);
+ break;
+
+ default:
+ return (EWOULDBLOCK);
+ break;
+ }
+
+ return (error);
+}
+
/*
* smbus_request_bus()
*
@@ -84,25 +106,20 @@ smbus_request_bus(device_t bus, device_t dev, int how)
struct smbus_softc *sc = (struct smbus_softc *)device_get_softc(bus);
int s, error = 0;
+ /* first, ask the underlying layers if the request is ok */
+ do {
+ error = SMBUS_CALLBACK(device_get_parent(bus),
+ SMB_REQUEST_BUS, (caddr_t)&how);
+ if (error)
+ error = smbus_poll(sc, how);
+ } while (error);
+
while (!error) {
s = splhigh();
if (sc->owner) {
splx(s);
- switch (how) {
- case (SMB_WAIT | SMB_INTR):
- error = tsleep(sc, SMBPRI|PCATCH, "smbreq", 0);
- break;
-
- case (SMB_WAIT | SMB_NOINTR):
- error = tsleep(sc, SMBPRI, "smbreq", 0);
- break;
-
- default:
- return (EWOULDBLOCK);
- break;
- }
-
+ error = smbus_poll(sc, how);
} else {
sc->owner = dev;
@@ -123,7 +140,13 @@ int
smbus_release_bus(device_t bus, device_t dev)
{
struct smbus_softc *sc = (struct smbus_softc *)device_get_softc(bus);
- int s;
+ int s, error;
+
+ /* first, ask the underlying layers if the release is ok */
+ error = SMBUS_CALLBACK(device_get_parent(bus), SMB_RELEASE_BUS, NULL);
+
+ if (error)
+ return (error);
s = splhigh();
if (sc->owner != dev) {
diff --git a/sys/dev/smbus/smbconf.h b/sys/dev/smbus/smbconf.h
index 10fc3bc..0a442ec 100644
--- a/sys/dev/smbus/smbconf.h
+++ b/sys/dev/smbus/smbconf.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: smbconf.h,v 1.1.1.2 1998/08/13 15:16:58 son Exp $
+ * $Id: smbconf.h,v 1.1.1.1 1998/09/03 20:52:54 nsouch Exp $
*/
#ifndef __SMBONF_H
#define __SMBONF_H
@@ -43,10 +43,18 @@
#define SMB_INTR 0x2
/*
+ * callback index
+ */
+#define SMB_REQUEST_BUS 0x1
+#define SMB_RELEASE_BUS 0x2
+
+/*
* SMB bus errors
*/
#define SMB_ENOERR 0x0
#define SMB_EBUSERR 0x1
+#define SMB_ENOTSUPP 0x2
+#define SMB_ENOACK 0x3
/*
* How Quick command is executed
diff --git a/sys/dev/smbus/smbus.c b/sys/dev/smbus/smbus.c
index f9f787d..af8ddc3 100644
--- a/sys/dev/smbus/smbus.c
+++ b/sys/dev/smbus/smbus.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: smbus.c,v 1.1.1.2 1998/08/13 15:16:58 son Exp $
+ * $Id: smbus.c,v 1.1.1.1 1998/09/03 20:52:54 nsouch Exp $
*
*/
#include <sys/param.h>
@@ -54,7 +54,9 @@ struct smbus_device {
* list of known devices
*/
struct smbus_device smbus_children[] = {
+#if 0
{ "smb", 0, "General Call" },
+#endif
{ NULL, 0 }
};
@@ -100,26 +102,30 @@ static driver_t smbus_driver = {
static int
smbus_probe(device_t dev)
{
- struct smbus_device *smbdev;
- device_t child;
-
- for (smbdev = smbus_children; smbdev->smbd_name; smbdev++) {
-
- child = device_add_child(dev, smbdev->smbd_name, -1, smbdev);
- device_set_desc(child, smbdev->smbd_desc);
- }
-
+ device_set_desc(dev, "System Management Bus");
return (0);
}
static int
smbus_attach(device_t dev)
{
- struct smbus_softc *sc = device_get_softc(dev);
- device_t parent = device_get_parent(dev);
+ struct smbus_device *smbdev;
+ device_t child;
+ char byte;
+ u_short addr;
- printf("Probing for devices on the SMB bus:\n");
bus_generic_attach(dev);
+
+#if 0
+ printf("Probing for devices on smbus%d:\n", device_get_unit(dev));
+
+ /* probe known devices */
+ for (smbdev = smbus_children; smbdev->smbd_name; smbdev++) {
+
+ child = device_add_child(dev, smbdev->smbd_name, -1, smbdev);
+ device_set_desc(child, smbdev->smbd_desc);
+ }
+#endif
return (0);
}
@@ -155,3 +161,4 @@ smbus_read_ivar(device_t bus, device_t dev, int index, u_long* result)
}
DRIVER_MODULE(smbus, iicsmb, smbus_driver, smbus_devclass, 0, 0);
+DRIVER_MODULE(smbus, bti2c, smbus_driver, smbus_devclass, 0, 0);
diff --git a/sys/dev/smbus/smbus_if.m b/sys/dev/smbus/smbus_if.m
index 3c9ee5a..c5cef2b 100644
--- a/sys/dev/smbus/smbus_if.m
+++ b/sys/dev/smbus/smbus_if.m
@@ -23,13 +23,13 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $Id: smbus_if.m,v 1.1.1.2 1998/08/13 15:16:58 son Exp $
+# $Id: smbus_if.m,v 1.1.1.1 1998/09/03 20:52:54 nsouch Exp $
#
INTERFACE smbus
#
-# Interprete interrupt
+# Interpret interrupt
#
METHOD void intr {
device_t dev;
@@ -40,6 +40,15 @@ METHOD void intr {
};
#
+# smbus callback
+#
+METHOD int callback {
+ device_t dev;
+ int index;
+ caddr_t data;
+};
+
+#
# Quick command
#
METHOD int quick {
OpenPOWER on IntegriCloud