Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys New generic I2C framework. Supports bit-bang and "intel...
details: https://anonhg.NetBSD.org/src/rev/e0d333b7c8e8
branches: trunk
changeset: 552673:e0d333b7c8e8
user: thorpej <thorpej%NetBSD.org@localhost>
date: Tue Sep 30 00:35:30 2003 +0000
description:
New generic I2C framework. Supports bit-bang and "intelligent" I2C
interface controllers (of varying intelligence levels).
Contributed by Wasabi Systems, Inc. Primarily written by Steve Woodford,
with some modification by me.
diffstat:
sys/arch/acorn26/acorn26/machdep.c | 33 ++-
sys/arch/acorn26/acorn26/start.c | 16 +-
sys/arch/acorn26/acorn26/stubs.c | 11 +-
sys/arch/acorn26/conf/FOURMEG | 8 +-
sys/arch/acorn26/conf/GENERIC | 8 +-
sys/arch/acorn26/conf/INSTALL | 8 +-
sys/arch/acorn26/conf/files.acorn26 | 16 +-
sys/arch/acorn26/ioc/iic.c | 349 ----------------------
sys/arch/acorn26/ioc/iic.h | 64 ----
sys/arch/acorn26/ioc/iociicvar.h | 44 ++
sys/arch/acorn26/ioc/pcf8583reg.h | 81 -----
sys/arch/acorn26/ioc/rtc.c | 289 +-----------------
sys/arch/acorn32/acorn32/rpc_machdep.c | 50 +++-
sys/arch/acorn32/conf/GENERIC | 12 +-
sys/arch/acorn32/conf/INSTALL | 12 +-
sys/arch/acorn32/conf/LOWMEM_WSCONS | 10 +-
sys/arch/acorn32/conf/NC | 10 +-
sys/arch/acorn32/conf/NC_WSCONS | 10 +-
sys/arch/acorn32/conf/RPC_WSCONS | 12 +-
sys/arch/acorn32/conf/majors.acorn32 | 5 +-
sys/arch/acorn32/include/machdep.h | 39 ++
sys/arch/arm/conf/majors.arm32 | 5 +-
sys/conf/files | 13 +-
sys/dev/i2c/at24cxx.c | 379 ++++++++++++++++++++++++
sys/dev/i2c/at24cxxvar.h | 43 ++
sys/dev/i2c/ds1307.c | 389 +++++++++++++++++++++++++
sys/dev/i2c/ds1307reg.h | 81 +++++
sys/dev/i2c/files.i2c | 54 +++
sys/dev/i2c/i2c.c | 118 +++++++
sys/dev/i2c/i2c_bitbang.c | 178 +++++++++++
sys/dev/i2c/i2c_bitbang.h | 62 ++++
sys/dev/i2c/i2c_bus.c | 105 ------
sys/dev/i2c/i2c_bus.h | 54 ---
sys/dev/i2c/i2c_eeprom.c | 78 -----
sys/dev/i2c/i2c_eeprom.h | 34 --
sys/dev/i2c/i2c_exec.c | 156 ++++++++++
sys/dev/i2c/i2c_io.h | 98 ++++++
sys/dev/i2c/i2cvar.h | 143 +++++++++
sys/dev/i2c/lm75.c | 242 +++++++++++++++
sys/dev/i2c/lm75reg.h | 78 +++++
sys/dev/i2c/m41st84.c | 380 +++++++++++++++++++++++++
sys/dev/i2c/m41st84reg.h | 92 ++++++
sys/dev/i2c/m41t00.c | 428 ++++++++++++++++++++++++++++
sys/dev/i2c/m41t00reg.h | 62 ++++
sys/dev/i2c/max6900.c | 483 +++++++++++++++++++++++++++++++
sys/dev/i2c/max6900reg.h | 100 ++++++
sys/dev/i2c/pcf8583.c | 501 +++++++++++++++++++++++++++++++++
sys/dev/i2c/pcf8583reg.h | 89 +++++
sys/dev/i2c/pcf8583var.h | 44 ++
sys/dev/pci/files.pci | 5 +-
sys/dev/pci/if_tl.c | 191 +++++++----
sys/dev/pci/if_tlvar.h | 6 +-
52 files changed, 4573 insertions(+), 1205 deletions(-)
diffs (truncated from 6420 to 300 lines):
diff -r 74621efaa11d -r e0d333b7c8e8 sys/arch/acorn26/acorn26/machdep.c
--- a/sys/arch/acorn26/acorn26/machdep.c Tue Sep 30 00:23:23 2003 +0000
+++ b/sys/arch/acorn26/acorn26/machdep.c Tue Sep 30 00:35:30 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.9 2003/09/21 06:52:42 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.10 2003/09/30 00:35:30 thorpej Exp $ */
/*-
* Copyright (c) 1998 Ben Harris
@@ -32,7 +32,7 @@
#include <sys/param.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.9 2003/09/21 06:52:42 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.10 2003/09/30 00:35:30 thorpej Exp $");
#include <sys/buf.h>
#include <sys/kernel.h>
@@ -42,8 +42,12 @@
#include <sys/sysctl.h>
#include <sys/systm.h>
+#include <dev/i2c/i2cvar.h>
+#include <dev/i2c/pcf8583var.h>
+
#include <uvm/uvm_extern.h>
+#include <machine/machdep.h>
#include <machine/memcreg.h>
int physmem;
@@ -54,6 +58,9 @@
/* Our exported CPU info; we can have only one. */
struct cpu_info cpu_info_store;
+/* For reading NVRAM during bootstrap. */
+i2c_tag_t acorn26_i2c_tag;
+
struct vm_map *exec_map = NULL;
struct vm_map *phys_map = NULL;
struct vm_map *mb_map = NULL; /* and ever more shall be so */
@@ -252,3 +259,25 @@
return (EOPNOTSUPP);
}
+
+/* Read a byte from CMOS RAM. */
+int
+cmos_read(int location)
+{
+ uint8_t val;
+
+ if (pcfrtc_bootstrap_read(acorn26_i2c_tag, 0x50,
+ location, &val, 1) != 0)
+ return (-1);
+ return (val);
+}
+
+/* Write a byte to CMOS RAM. */
+int
+cmos_write(int location, int value)
+{
+ uint8_t val = value;
+
+ return (pcfrtc_bootstrap_write(acorn26_i2c_tag, 0x50,
+ location, &val, 1));
+}
diff -r 74621efaa11d -r e0d333b7c8e8 sys/arch/acorn26/acorn26/start.c
--- a/sys/arch/acorn26/acorn26/start.c Tue Sep 30 00:23:23 2003 +0000
+++ b/sys/arch/acorn26/acorn26/start.c Tue Sep 30 00:35:30 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: start.c,v 1.3 2003/04/27 10:42:48 ragge Exp $ */
+/* $NetBSD: start.c,v 1.4 2003/09/30 00:35:30 thorpej Exp $ */
/*-
* Copyright (c) 1998, 2000 Ben Harris
* All rights reserved.
@@ -31,13 +31,16 @@
#include <sys/param.h>
-__KERNEL_RCSID(0, "$NetBSD: start.c,v 1.3 2003/04/27 10:42:48 ragge Exp $");
+__KERNEL_RCSID(0, "$NetBSD: start.c,v 1.4 2003/09/30 00:35:30 thorpej Exp $");
#include <sys/msgbuf.h>
#include <sys/user.h>
#include <sys/syslog.h>
#include <sys/systm.h>
+#include <dev/i2c/i2cvar.h>
+#include <acorn26/ioc/iociicvar.h>
+
#include <arm/armreg.h>
#include <arm/undefined.h>
#include <machine/boot.h>
@@ -62,6 +65,9 @@
struct user *proc0paddr;
+/* in machdep.h */
+extern i2c_tag_t acorn26_i2c_tag;
+
/* We don't pass a command line yet. */
char *boot_args = "";
char *boot_file = "";
@@ -206,6 +212,12 @@
proc0paddr = (struct user *)(round_page((vaddr_t)&onstack) - USPACE);
bzero(proc0paddr, sizeof(*proc0paddr));
+ /*
+ * Get a handle on the IOC's I2C interface in the event we need
+ * it during bootstrap.
+ */
+ acorn26_i2c_tag = iociic_bootstrap_cookie();
+
/* TODO: anything else? */
main();
diff -r 74621efaa11d -r e0d333b7c8e8 sys/arch/acorn26/acorn26/stubs.c
--- a/sys/arch/acorn26/acorn26/stubs.c Tue Sep 30 00:23:23 2003 +0000
+++ b/sys/arch/acorn26/acorn26/stubs.c Tue Sep 30 00:35:30 2003 +0000
@@ -1,10 +1,10 @@
-/* $NetBSD: stubs.c,v 1.4 2003/07/14 22:48:20 lukem Exp $ */
+/* $NetBSD: stubs.c,v 1.5 2003/09/30 00:35:30 thorpej Exp $ */
/*
* stubs.c -- functions I haven't written yet
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: stubs.c,v 1.4 2003/07/14 22:48:20 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: stubs.c,v 1.5 2003/09/30 00:35:30 thorpej Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -13,13 +13,6 @@
#include <uvm/uvm_extern.h>
-void
-resettodr()
-{
-
- printf("resettodr: not doing anything\n");
-}
-
int
suibyte(base, c)
void *base;
diff -r 74621efaa11d -r e0d333b7c8e8 sys/arch/acorn26/conf/FOURMEG
--- a/sys/arch/acorn26/conf/FOURMEG Tue Sep 30 00:23:23 2003 +0000
+++ b/sys/arch/acorn26/conf/FOURMEG Tue Sep 30 00:35:30 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: FOURMEG,v 1.11 2003/09/13 13:30:08 chris Exp $
+# $NetBSD: FOURMEG,v 1.12 2003/09/30 00:35:30 thorpej Exp $
# FOURMEG arm26 configuration -- something small
@@ -130,8 +130,10 @@
ioc0 at iobus0 base 0x200000 # I/O controller
-iic0 at ioc0 # I^2C serial bus
-rtc0 at iic0 addr 0xa0 # Real-time clock
+iociic0 at ioc0 # I^2C serial bus
+iic0 at iociic0
+
+pcfrtc0 at iic0 addr 0x50 # Real-time clock
arckbd0 at ioc0 bank 0 offset 0x04 # System keyboard
arcwskbd0 at arckbd0 # Logical devices...
diff -r 74621efaa11d -r e0d333b7c8e8 sys/arch/acorn26/conf/GENERIC
--- a/sys/arch/acorn26/conf/GENERIC Tue Sep 30 00:23:23 2003 +0000
+++ b/sys/arch/acorn26/conf/GENERIC Tue Sep 30 00:35:30 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.14 2003/09/13 13:30:08 chris Exp $
+# $NetBSD: GENERIC,v 1.15 2003/09/30 00:35:30 thorpej Exp $
#
# GENERIC machine description file
#
@@ -147,8 +147,10 @@
ioc0 at iobus0 base 0x200000 # I/O controller
-iic0 at ioc0 # I^2C serial bus
-rtc0 at iic0 addr 0xa0 # Real-time clock
+iociic0 at ioc0 # I^2C serial bus
+iic0 at iociic0
+
+pcfrtc0 at iic0 addr 0x50 # Real-time clock
arckbd0 at ioc0 bank 0 offset 0x04 # System keyboard
arcwskbd0 at arckbd0 # Logical devices...
diff -r 74621efaa11d -r e0d333b7c8e8 sys/arch/acorn26/conf/INSTALL
--- a/sys/arch/acorn26/conf/INSTALL Tue Sep 30 00:23:23 2003 +0000
+++ b/sys/arch/acorn26/conf/INSTALL Tue Sep 30 00:35:30 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.4 2002/09/18 02:43:53 lukem Exp $
+# $NetBSD: INSTALL,v 1.5 2003/09/30 00:35:30 thorpej Exp $
# INSTALL configuration, used to generate installation media
@@ -134,8 +134,10 @@
ioc0 at iobus0 base 0x200000 # I/O controller
-iic0 at ioc0 # I^2C serial bus
-rtc0 at iic0 addr 0xa0 # Real-time clock
+iociic0 at ioc0 # I^2C serial bus
+iic0 at iociic0
+
+pcfrtc0 at iic0 addr 0x50 # Real-time clock
arckbd0 at ioc0 bank 0 offset 0x04 # System keyboard
arcwskbd0 at arckbd0 # Logical devices...
diff -r 74621efaa11d -r e0d333b7c8e8 sys/arch/acorn26/conf/files.acorn26
--- a/sys/arch/acorn26/conf/files.acorn26 Tue Sep 30 00:23:23 2003 +0000
+++ b/sys/arch/acorn26/conf/files.acorn26 Tue Sep 30 00:35:30 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.acorn26,v 1.5 2003/07/27 01:17:38 thorpej Exp $
+# $NetBSD: files.acorn26,v 1.6 2003/09/30 00:35:30 thorpej Exp $
# Copyright (c) 1997, 1998, 2000 Ben Harris
# All rights reserved.
@@ -54,6 +54,9 @@
file arch/acorn26/acorn26/fpu.c fpu needs-flag
file arch/acorn26/acorn26/fpu_asm.S fpu
+# Real-time clock support
+file arch/acorn26/ioc/rtc.c
+
# I/O bus (on the far side of the address and data latches)
device iobus { base = -1 }
attach iobus at root
@@ -68,14 +71,9 @@
file arch/acorn26/ioc/ioc_fiq_util.S fiq needs-flag
# I^2C bus (bit-banged through IOC control register)
-device iic { addr = -1 }
-attach iic at ioc
-file arch/acorn26/ioc/iic.c iic
-
-# PCF8583 I^2C Clock/calendar/RAM
-device rtc
-attach rtc at iic
-file arch/acorn26/ioc/rtc.c rtc
+device iociic: i2cbus, i2c_bitbang
+attach iociic at ioc
+file arch/acorn26/ioc/iociic.c iociic
# DS2401 Silicon Serial Number
device ssn
diff -r 74621efaa11d -r e0d333b7c8e8 sys/arch/acorn26/ioc/iic.c
--- a/sys/arch/acorn26/ioc/iic.c Tue Sep 30 00:23:23 2003 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,349 +0,0 @@
-/* $NetBSD: iic.c,v 1.8 2003/07/14 22:48:22 lukem Exp $ */
-
-/*
- * Copyright (c) 1994-1996 Mark Brinicombe.
- * Copyright (c) 1994 Brini.
- * All rights reserved.
- *
- * This code is derived from software written for Brini by Mark Brinicombe
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Mark Brinicombe.
- * 4. The name of the company nor the name of the author may be used to
- * endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * RiscBSD kernel project
- *
- * iic.c
- *
- * Routines to communicate with IIC devices
- *
- * Created : 13/10/94
- *
- * Based of kate/display/iiccontrol.c
- */
Home |
Main Index |
Thread Index |
Old Index