Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Install dev/i2c/i2c_io.h and implement the API in the iic(4)...
details: https://anonhg.NetBSD.org/src/rev/1fc69cfe9c22
branches: trunk
changeset: 770059:1fc69cfe9c22
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun Oct 02 16:39:45 2011 +0000
description:
Install dev/i2c/i2c_io.h and implement the API in the iic(4) driver.
Obsolete the I2C_SCAN option as this can now be done from userland.
diffstat:
distrib/sets/lists/comp/mi | 3 +-
etc/MAKEDEV.tmpl | 12 +++-
share/man/man4/iic.4 | 6 +-
share/man/man4/options.4 | 17 +----
sys/arch/i386/conf/ALL | 5 +-
sys/conf/majors | 3 +-
sys/dev/Makefile | 4 +-
sys/dev/i2c/Makefile | 6 +
sys/dev/i2c/files.i2c | 4 +-
sys/dev/i2c/i2c.c | 160 +++++++++++++++++++++++++-------------------
10 files changed, 122 insertions(+), 98 deletions(-)
diffs (truncated from 392 to 300 lines):
diff -r 69785742a1c6 -r 1fc69cfe9c22 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Sun Oct 02 16:30:58 2011 +0000
+++ b/distrib/sets/lists/comp/mi Sun Oct 02 16:39:45 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1683 2011/09/30 22:08:18 jym Exp $
+# $NetBSD: mi,v 1.1684 2011/10/02 16:39:45 jmcneill Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -282,6 +282,7 @@
./usr/include/dev/hpc/hpcfbio.h comp-c-include
./usr/include/dev/i2c/i2c_bus.h comp-obsolete obsolete
./usr/include/dev/i2c/i2c_eeprom.h comp-obsolete obsolete
+./usr/include/dev/i2c/i2c_io.h comp-c-include
./usr/include/dev/i2o/i2o.h comp-c-include
./usr/include/dev/i2o/iopio.h comp-c-include
./usr/include/dev/i2o/iopvar.h comp-obsolete obsolete
diff -r 69785742a1c6 -r 1fc69cfe9c22 etc/MAKEDEV.tmpl
--- a/etc/MAKEDEV.tmpl Sun Oct 02 16:30:58 2011 +0000
+++ b/etc/MAKEDEV.tmpl Sun Oct 02 16:39:45 2011 +0000
@@ -1,5 +1,5 @@
#!/bin/sh -
-# $NetBSD: MAKEDEV.tmpl,v 1.142 2011/09/06 13:34:44 apb Exp $
+# $NetBSD: MAKEDEV.tmpl,v 1.143 2011/10/02 16:39:46 jmcneill Exp $
#
# Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -811,6 +811,10 @@
makedev dtv0 dtv1 dtv2 dtv3
;;
+iic)
+ makedev iic0 iic1 iic2 iic3
+ ;;
+
altmem)
makedev altmem0 altmem1
;;
@@ -1417,6 +1421,12 @@
mkdev dvb/adapter$unit/dvr0 c %dtv_chr% $(($unit + 32)) 666
;;
+iic[0-9]*)
+ unit=${i#iic}
+ : ${unit:-0}
+ mkdev iic$unit c %iic_chr% $unit 600
+ ;;
+
amr[0-9]*)
unit=${i#amr}
mkdev amr$unit c %amr_chr% $unit
diff -r 69785742a1c6 -r 1fc69cfe9c22 share/man/man4/iic.4
--- a/share/man/man4/iic.4 Sun Oct 02 16:30:58 2011 +0000
+++ b/share/man/man4/iic.4 Sun Oct 02 16:39:45 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: iic.4,v 1.8 2011/08/30 07:44:37 mbalmer Exp $
+.\" $NetBSD: iic.4,v 1.9 2011/10/02 16:39:46 jmcneill Exp $
.\" $OpenBSD: iic.4,v 1.74 2008/09/10 16:13:43 reyk Exp $
.\"
.\" Copyright (c) 2004, 2006 Alexander Yurchenko <grange%openbsd.org@localhost>
@@ -16,7 +16,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd August 30, 2011
+.Dd October 2, 2011
.Dt IIC 4
.Os
.Sh NAME
@@ -50,8 +50,6 @@
.Cd "iic* at piixpm? # amd64 i386 "
.Cd "iic0 at slugiic0 # evbarm "
.Cd "iic* at viapcib? # i386 "
-.Pp
-.Cd "options I2C_SCAN"
.Sh DESCRIPTION
.Tn I2C
is a two-wire bus developed by Philips used for connecting
diff -r 69785742a1c6 -r 1fc69cfe9c22 share/man/man4/options.4
--- a/share/man/man4/options.4 Sun Oct 02 16:30:58 2011 +0000
+++ b/share/man/man4/options.4 Sun Oct 02 16:39:45 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: options.4,v 1.408 2011/06/17 18:13:49 wiz Exp $
+.\" $NetBSD: options.4,v 1.409 2011/10/02 16:39:46 jmcneill Exp $
.\"
.\" Copyright (c) 1996
.\" Perry E. Metzger. All rights reserved.
@@ -30,7 +30,7 @@
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\"
-.Dd June 17, 2011
+.Dd October 2, 2011
.Dt OPTIONS 4
.Os
.Sh NAME
@@ -1494,19 +1494,6 @@
Number of storage slots per file for
.Xr fileassoc 9 .
Default is 4.
-.It Cd options I2C_SCAN
-Scan each i2c bus to determine which addresses respond.
-.Pp
-.Em WARNING !
-Using this option can access some devices in such a
-manner as to leave them in an unstable or unuseable state, and
-can prevent those devices from being properly matched and/or
-attached.
-It can also lock up the entire
-.Xr iic 4
-bus and even prevent a machine from completing the boot process.
-Don't use this option unless you know what you're doing and can
-accept all sorts of unforeseen consequences.
.El
.Ss Networking Options
.Bl -ohang
diff -r 69785742a1c6 -r 1fc69cfe9c22 sys/arch/i386/conf/ALL
--- a/sys/arch/i386/conf/ALL Sun Oct 02 16:30:58 2011 +0000
+++ b/sys/arch/i386/conf/ALL Sun Oct 02 16:39:45 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.321 2011/09/26 18:14:07 jakllsch Exp $
+# $NetBSD: ALL,v 1.322 2011/10/02 16:39:47 jmcneill Exp $
# From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
#
# ALL machine description file
@@ -17,7 +17,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "ALL-$Revision: 1.321 $"
+#ident "ALL-$Revision: 1.322 $"
maxusers 64 # estimated number of users
@@ -254,7 +254,6 @@
options PNPBIOSVERBOSE # verbose PnP BIOS messages
#options PNPBIOSDEBUG # more fulsome PnP BIOS debugging messages
options MCAVERBOSE # verbose MCA device autoconfig messages
-options I2C_SCAN # Scan i2c bus for responses
options NFS_BOOT_DHCP,NFS_BOOT_BOOTPARAM
diff -r 69785742a1c6 -r 1fc69cfe9c22 sys/conf/majors
--- a/sys/conf/majors Sun Oct 02 16:30:58 2011 +0000
+++ b/sys/conf/majors Sun Oct 02 16:39:45 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: majors,v 1.56 2011/07/09 14:47:27 jmcneill Exp $
+# $NetBSD: majors,v 1.57 2011/10/02 16:39:47 jmcneill Exp $
#
# Device majors for Machine-Independent drivers.
#
@@ -46,3 +46,4 @@
device-major npf char 198 npf
device-major flash char 199 block 199 flash
device-major dtv char 200 dtv
+device-major iic char 201 iic
diff -r 69785742a1c6 -r 1fc69cfe9c22 sys/dev/Makefile
--- a/sys/dev/Makefile Sun Oct 02 16:30:58 2011 +0000
+++ b/sys/dev/Makefile Sun Oct 02 16:39:45 2011 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.31 2011/07/09 14:52:03 jmcneill Exp $
+# $NetBSD: Makefile,v 1.32 2011/10/02 16:39:47 jmcneill Exp $
-SUBDIR= apm ata bluetooth dec dm dmover dtv hpc i2o ic ieee1394 ir isa \
+SUBDIR= apm ata bluetooth dec dm dmover dtv hpc i2c i2o ic ieee1394 ir isa \
microcode ofw pci pckbport pcmcia pud putter raidframe sbus scsipi \
sun tc usb vme wscons
diff -r 69785742a1c6 -r 1fc69cfe9c22 sys/dev/i2c/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/i2c/Makefile Sun Oct 02 16:39:45 2011 +0000
@@ -0,0 +1,6 @@
+# $NetBSD: Makefile,v 1.3 2011/10/02 16:39:47 jmcneill Exp $
+
+INCSDIR= /usr/include/dev/i2c
+INCS= i2c_io.h
+
+.include <bsd.kinc.mk>
diff -r 69785742a1c6 -r 1fc69cfe9c22 sys/dev/i2c/files.i2c
--- a/sys/dev/i2c/files.i2c Sun Oct 02 16:30:58 2011 +0000
+++ b/sys/dev/i2c/files.i2c Sun Oct 02 16:39:45 2011 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: files.i2c,v 1.42 2011/08/13 18:31:38 jmcneill Exp $
+# $NetBSD: files.i2c,v 1.43 2011/10/02 16:39:47 jmcneill Exp $
-defflag opt_i2cbus.h I2C_SCAN
+obsolete defflag opt_i2cbus.h I2C_SCAN
define i2cbus { }
define i2cexec
diff -r 69785742a1c6 -r 1fc69cfe9c22 sys/dev/i2c/i2c.c
--- a/sys/dev/i2c/i2c.c Sun Oct 02 16:30:58 2011 +0000
+++ b/sys/dev/i2c/i2c.c Sun Oct 02 16:39:45 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: i2c.c,v 1.30 2011/10/02 12:25:40 mbalmer Exp $ */
+/* $NetBSD: i2c.c,v 1.31 2011/10/02 16:39:47 jmcneill Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.30 2011/10/02 12:25:40 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.31 2011/10/02 16:39:47 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -52,9 +52,6 @@
#include <dev/i2c/i2cvar.h>
#include "locators.h"
-#ifdef KERNEL_OPT
-#include <opt_i2cbus.h>
-#endif
#define I2C_MAX_ADDR 0x3ff /* 10-bit address, max */
@@ -64,6 +61,17 @@
device_t sc_devices[I2C_MAX_ADDR + 1];
};
+static dev_type_open(iic_open);
+static dev_type_close(iic_close);
+static dev_type_ioctl(iic_ioctl);
+
+const struct cdevsw iic_cdevsw = {
+ iic_open, iic_close, noread, nowrite, iic_ioctl,
+ nostop, notty, nopoll, nommap, nokqfilter, D_OTHER
+};
+
+extern struct cfdriver iic_cd;
+
static void iic_smbus_intr_thread(void *);
static void iic_fill_compat(struct i2c_attach_args*, const char*,
size_t, char **);
@@ -182,70 +190,6 @@
if (rv)
aprint_error_dev(self, "unable to create intr thread\n");
-#if I2C_SCAN
- if (sc->sc_type == I2C_TYPE_SMBUS) {
- int err;
- int found = 0;
- i2c_addr_t addr;
- uint8_t val;
-
- for (addr = 0x09; addr < 0x78; addr++) {
- /*
- * Skip certain i2c addresses:
- * 0x00 General Call / START
- * 0x01 CBUS Address
- * 0x02 Different Bus format
- * 0x03 - 0x07 Reserved
- * 0x08 Host Address
- * 0x0c Alert Response Address
- * 0x28 ACCESS.Bus host
- * 0x37 ACCESS.Bus default address
- * 0x48 - 0x4b Prototypes
- * 0x61 Device Default Address
- * 0x78 - 0x7b 10-bit addresses
- * 0x7c - 0x7f Reserved
- *
- * Some of these are skipped by judicious selection
- * of the range of the above for (;;) statement.
- *
- * if (addr <= 0x08 || addr >= 0x78)
- * continue;
- */
- if (addr == 0x0c || addr == 0x28 || addr == 0x37 ||
- addr == 0x61 || (addr & 0x7c) == 0x48)
- continue;
-
- iic_acquire_bus(ic, 0);
- /*
- * Use SMBus quick_write command to detect most
- * addresses; should avoid hanging the bus on
- * some write-only devices (like clocks that show
- * up at address 0x69)
- *
- * XXX The quick_write() is allegedly known to
- * XXX corrupt the Atmel AT24RF08 EEPROM found
- * XXX on some IBM Thinkpads!
- */
- if ((addr & 0xf8) == 0x30 ||
- (addr & 0xf0) == 0x50)
- err = iic_smbus_receive_byte(ic, addr, &val, 0);
- else
- err = iic_smbus_quick_write(ic, addr, 0);
- if (err == 0) {
- if (found == 0)
- aprint_normal("%s: devices at",
- ic->ic_devname);
- found++;
- aprint_normal(" 0x%02x", addr);
- }
- iic_release_bus(ic, 0);
- }
- if (found == 0)
- aprint_normal("%s: no devices found", ic->ic_devname);
Home |
Main Index |
Thread Index |
Old Index