summaryrefslogtreecommitdiffstats
path: root/sys/dev/iicbus/iicbus.c
diff options
context:
space:
mode:
authornsouch <nsouch@FreeBSD.org>1999-01-09 18:08:24 +0000
committernsouch <nsouch@FreeBSD.org>1999-01-09 18:08:24 +0000
commite670443158fa0f8567cc666000f1cf5819c156ca (patch)
treedc9371aa53218a6e6b09f54a5dd8c837e4342de9 /sys/dev/iicbus/iicbus.c
parent674988520c88d8bdd31977e29964f169a47a72b1 (diff)
downloadFreeBSD-src-e670443158fa0f8567cc666000f1cf5819c156ca.zip
FreeBSD-src-e670443158fa0f8567cc666000f1cf5819c156ca.tar.gz
Change /dev/smb and /dev/iic interface to allow user programs to interact with
devices dynamically. That means, + only one /dev/iic or /dev/smb device for each smb/iic bus to access + I2C/SMB device address must be given to any ioctl + new devices may be plugged and accessed after boot, which was impossible previously (device addresses were hardcoded into the kernel)
Diffstat (limited to 'sys/dev/iicbus/iicbus.c')
-rw-r--r--sys/dev/iicbus/iicbus.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/sys/dev/iicbus/iicbus.c b/sys/dev/iicbus/iicbus.c
index fd982ce..cf9f6ba 100644
--- a/sys/dev/iicbus/iicbus.c
+++ b/sys/dev/iicbus/iicbus.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: iicbus.c,v 1.5 1998/11/22 22:01:42 nsouch Exp $
+ * $Id: iicbus.c,v 1.6 1998/12/07 21:58:16 archie Exp $
*
*/
@@ -73,14 +73,14 @@ struct iicbus_device {
/*
* list of known devices
+ *
+ * XXX only one smb driver should exist for each I2C interface
*/
struct iicbus_device iicbus_children[] = {
{ "iicsmb", IICBUS_DRIVER_CLASS, "I2C to SMB bridge" },
- { "iic", IICBUS_DEVICE_CLASS, "PCF8574 I2C to 8 bits parallel i/o", 64},
- { "iic", IICBUS_DEVICE_CLASS, "PCF8584 as slave", PCF_MASTER_ADDRESS },
- { "ic", IICBUS_DEVICE_CLASS, "network interface", PCF_MASTER_ADDRESS },
+ { "iic", IICBUS_DRIVER_CLASS, "I2C general purpose I/O" },
#if 0
- { "iic", IICBUS_DRIVER_CLASS, "General Call", I2C_GENERAL_CALL },
+ { "ic", IICBUS_DEVICE_CLASS, "network interface", PCF_MASTER_ADDRESS },
#endif
{ NULL, 0 }
};
@@ -121,10 +121,12 @@ static driver_t iicbus_driver = {
static int
iicbus_probe(device_t dev)
{
- /* always present if probed */
+ device_set_desc(dev, "Philips I2C bus");
+
return (0);
}
+#if 0
static int
iic_probe_device(device_t dev, u_char addr)
{
@@ -145,6 +147,7 @@ iic_probe_device(device_t dev, u_char addr)
return (0);
}
+#endif
/*
* We add all the devices which we know about.
@@ -155,10 +158,15 @@ iicbus_attach(device_t dev)
{
struct iicbus_device *iicdev;
device_t child;
- int addr;
iicbus_reset(dev, IIC_FASTEST, 0, NULL);
+ /* device probing is meaningless since the bus is supposed to be
+ * hot-plug. Moreover, some I2C chips do not appreciate random
+ * accesses like stop after start to fast, reads for less than
+ * x bytes...
+ */
+#if 0
printf("Probing for devices on iicbus%d:", device_get_unit(dev));
/* probe any devices */
@@ -168,21 +176,27 @@ iicbus_attach(device_t dev)
}
}
printf("\n");
+#endif
/* attach known devices */
for (iicdev = iicbus_children; iicdev->iicd_name; iicdev++) {
switch (iicdev->iicd_class) {
case IICBUS_DEVICE_CLASS:
/* check if the devclass exists */
- if (devclass_find(iicdev->iicd_name) &&
- iic_probe_device(dev, iicdev->iicd_addr))
+ if (devclass_find(iicdev->iicd_name))
iicdev->iicd_alive = 1;
+ else if (bootverbose)
+ printf("iicbus: %s devclass not found\n",
+ iicdev->iicd_name);
break;
case IICBUS_DRIVER_CLASS:
/* check if the devclass exists */
- if (!devclass_find(iicdev->iicd_name))
+ if (devclass_find(iicdev->iicd_name))
iicdev->iicd_alive = 1;
+ else if (bootverbose)
+ printf("iicbus: %s devclass not found\n",
+ iicdev->iicd_name);
break;
default:
@@ -272,4 +286,3 @@ iicbus_write_ivar(device_t bus, device_t dev, int index, u_long val)
DRIVER_MODULE(iicbus, pcf, iicbus_driver, iicbus_devclass, 0, 0);
DRIVER_MODULE(iicbus, iicbb, iicbus_driver, iicbus_devclass, 0, 0);
DRIVER_MODULE(iicbus, bti2c, iicbus_driver, iicbus_devclass, 0, 0);
-DRIVER_MODULE(iicbus, smbtx, iicbus_driver, iicbus_devclass, 0, 0);
OpenPOWER on IntegriCloud