Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ofw The i2c bus number (0 or 1) is encoded in bit 33...



details:   https://anonhg.NetBSD.org/src/rev/2de318fe744c
branches:  trunk
changeset: 784614:2de318fe744c
user:      jdc <jdc%NetBSD.org@localhost>
date:      Sun Feb 03 17:41:02 2013 +0000

description:
The i2c bus number (0 or 1) is encoded in bit 33 of the register for a node,
but we encode it in bit 8 of i2c_addr_t.  If bit 33 is set, unset it and
set bit 9 instead (we later shift by one bit).

diffstat:

 sys/dev/ofw/ofw_subr.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r c1a30de179c9 -r 2de318fe744c sys/dev/ofw/ofw_subr.c
--- a/sys/dev/ofw/ofw_subr.c    Sun Feb 03 16:28:51 2013 +0000
+++ b/sys/dev/ofw/ofw_subr.c    Sun Feb 03 17:41:02 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofw_subr.c,v 1.19 2012/11/02 15:44:07 jdc Exp $        */
+/*     $NetBSD: ofw_subr.c,v 1.20 2013/02/03 17:41:02 jdc Exp $        */
 
 /*
  * Copyright 1998
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.19 2012/11/02 15:44:07 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.20 2013/02/03 17:41:02 jdc Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -353,6 +353,13 @@
                            < sizeof(reg64))
                                continue;
                        addr = reg64;
+                       /*
+                        * The i2c bus number (0 or 1) is encoded in bit 33
+                        * of the register, but we encode it in bit 8 of
+                        * i2c_addr_t.
+                        */
+                       if (addr & 0x100000000)
+                               addr = (addr & 0xff) | 0x100;
                } else if (cell_size == 4 && len >= sizeof(reg32)) {
                        if (OF_getprop(node, "reg", &reg32, sizeof(reg32))
                            < sizeof(reg32))



Home | Main Index | Thread Index | Old Index