From 6be9cf002d391d19b66ae2e206f6009ada092ffa Mon Sep 17 00:00:00 2001 From: jdc Date: Sun, 3 Feb 2013 17:41:02 +0000 Subject: [PATCH] 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). --- sys/dev/ofw/ofw_subr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/dev/ofw/ofw_subr.c b/sys/dev/ofw/ofw_subr.c index ed0c94c520d5..e5c105112ba5 100644 --- a/sys/dev/ofw/ofw_subr.c +++ b/sys/dev/ofw/ofw_subr.c @@ -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 -__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 #include @@ -353,6 +353,13 @@ of_enter_i2c_devs(prop_dictionary_t props, int ofnode, size_t cell_size) < 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", ®32, sizeof(reg32)) < sizeof(reg32))