Re: autoconf hack for broken firmware

Michael <[email protected]> Sun, 1 Feb 2026 21:52:19 -0500
Newsgroups gmane.os.netbsd.ports.sparc64
Message-ID <20260201215219.7851a580@bushmills>
Hello,

On Mon, 2 Feb 2026 04:23:29 +0300
Valery Ushakov <[email protected]> wrote:

> On Sun, Feb 01, 2026 at 21:10:38 +0100, Julian Coleman wrote:
>=20
> > My U45 doesn't attach jbus-i2c because the node has:
> >=20
> >   f0096404: /i2c@400,fc62020
> >  =20
> >   #address-cells          00000002 ........ ........ ........     2
> >   #size-cells             00000000 ........ ........ ........     0
> >   compatible              6a627573 2d693263 00...... ........   "jbus-i=
2c"
> >   device_type             69326300 ........ ........ ........   "i2c"
> >   name                    69326300 ........ ........ ........   "i2c"
> >   reg                     00000400 0fc62020 00000010 ........   ...... =
 ....
> >=20
> > and the reg property is 96-bits wide.  We try to read it as 64-bit
> > words, which fails. =20
>=20
> I haven't touched OFW in _ages_, but
>=20
>   "reg" - Standard property name to define the package=E2=80=99s register=
s.
>=20
>   prop-encoded-array:
>     Arbitrary number of (phys-addr size) pairs.
>     phys-addr is a (phys.lo ... phys.hi) list, encoded with encod
>     size is a list of integers, each encoded with encode-int.
>=20
> IIRC what is going on here, then assuming that #address-cells on the
> parent is 2 (which is the default and can be omitted), this
>=20
>    reg 00000400 0fc62020 00000010
>=20
> looks like two words for phys address and one word for size.

Yeah, the problem is that on every other machine it looks like this:
#address-cells          00000002 ........ ........ ........     2
#size-cells             00000000 ........ ........ ........     0
compatible              6a627573 2d693263 00...... ........   "jbus-i2c"
device_type             69326300 ........ ........ ........   "i2c"
name                    69326300 ........ ........ ........   "i2c"
reg                     00000400 0fc64000 00000000 00000010 ......@.........

... with size as a 64bit word. And all of them lie about #size-cells.
mainbus_attach() blindly reads it into a
struct upa_reg {
	int64_t	ur_paddr;
	int64_t	ur_len;
};
I'd just check the property length and patch up ur_len as needed.

have fun
Michael