From owner-freebsd-arm@freebsd.org Mon Dec 2 11:13:48 2019 Return-Path: Delivered-To: freebsd-arm@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3D9941CE0E3 for ; Mon, 2 Dec 2019 11:13:48 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from vtr.rulingia.com (vtr.rulingia.com [IPv6:2001:19f0:5801:ebe:5400:1ff:fe53:30fd]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vtr.rulingia.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47RMtf1kKTz3DqT; Mon, 2 Dec 2019 11:13:45 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from server.rulingia.com (ppp239-208.static.internode.on.net [59.167.239.208]) by vtr.rulingia.com (8.15.2/8.15.2) with ESMTPS id xB2BDSku053893 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Dec 2019 22:13:34 +1100 (AEDT) (envelope-from peter@rulingia.com) X-Bogosity: Ham, spamicity=0.000000 Received: from server.rulingia.com (localhost.rulingia.com [127.0.0.1]) by server.rulingia.com (8.15.2/8.15.2) with ESMTPS id xB2BDMYK065631 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 2 Dec 2019 22:13:22 +1100 (AEDT) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.15.2/8.15.2/Submit) id xB2BDMI6065630; Mon, 2 Dec 2019 22:13:22 +1100 (AEDT) (envelope-from peter) Date: Mon, 2 Dec 2019 22:13:22 +1100 From: Peter Jeremy To: Michal Meloun Cc: freebsd-arm@freebsd.org Subject: Re: rk_tsadc breaks (my) Rock64 Message-ID: <20191202111322.GF37113@server.rulingia.com> References: <20191201110716.GA41224@server.rulingia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="oj4kGyHlBMXGt3Le" Content-Disposition: inline In-Reply-To: <20191201110716.GA41224@server.rulingia.com> X-PGP-Key: http://www.rulingia.com/keys/peter.pgp User-Agent: Mutt/1.12.2 (2019-09-21) X-Rspamd-Queue-Id: 47RMtf1kKTz3DqT X-Spamd-Bar: ------- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of peter@rulingia.com designates 2001:19f0:5801:ebe:5400:1ff:fe53:30fd as permitted sender) smtp.mailfrom=peter@rulingia.com X-Spamd-Result: default: False [-7.67 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; DMARC_NA(0.00)[rulingia.com]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(-3.27)[ip: (-9.63), ipnet: 2001:19f0:5800::/38(-4.82), asn: 20473(-1.87), country: US(-0.05)]; RCPT_COUNT_TWO(0.00)[2]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:20473, ipnet:2001:19f0:5800::/38, country:US]; RCVD_TLS_ALL(0.00)[] X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Dec 2019 11:13:48 -0000 --oj4kGyHlBMXGt3Le Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2019-Dec-01 22:07:16 +1100, Peter Jeremy wrote: >r355173 added code to read the Rockchip temperature sensors. Unfortunatel= y, >this breaks on my Rock64. I've tried to understand what's going wrong but >haven't managed to make much headway. It looks like there some configurat= ion >missing from syscon that tsadc needs but I'm not sure what (and I don't re= ally >understand what syscon is doing). I'd appreciate any insights. I've added a pile of printf's and done some more digging and have made some progress. Firstly, I've found that the syscon@ff100000 FDT entry attaches as two distinct devices: rk_grf0: mem 0xff100000-0xff100fff on ofw= bus0 (via compatible =3D "rockchip,rk3328-grf") simple_mfd0: mem 0xff450000-0xff45fff= f on ofwbus0 (via compatible =3D "simple-mfd") Based on the traceback going via simple_mfd_syscon_write_4(), I had assumed that tsadc_attach() was using the latter device but when I added code to print structure addresses, I discovered it was the former. This makes the problem clearer: rk_grf0 requests and is allocated 4KiB memory ("reg =3D <0x0 0xff100000 0x0 0x1000>;" in the FDT and "mem 0xff100000-0xff100fff" in the device attach message above) but the tsadc_init() code is doing: SYSCON_WRITE_4(sc->grf, GRF_TSADC_TESTBIT_L, GRF_TSADC_VCM_EN_L); with #define GRF_TSADC_TESTBIT_L 0x0e648 and that offset is well outside the 4KiB allocated to the device. (On the positive side, a panic makes the problem a lot clearer than writing to a random device location would have been). Ganbold's followup shows that the RK3399 allocates 64KiB to the syscon device so the equivalent write is valid on a RK3399. I suspect the problem is that the following defines are only valid for the RK3399 since I can't find any matches to either the names or offsets in the following: #define GRF_SARADC_TESTBIT 0x0e644 #define GRF_TSADC_TESTBIT_L 0x0e648 #define GRF_TSADC_TESTBIT_H 0x0e64c Unfortunately, that also means I currently have no idea what the RK3328 equivalents to those offsets are. --=20 Peter Jeremy --oj4kGyHlBMXGt3Le Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEE7rKYbDBnHnTmXCJ+FqWXoOSiCzQFAl3k8cJfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEVF QjI5ODZDMzA2NzFFNzRFNjVDMjI3RTE2QTU5N0EwRTRBMjBCMzQACgkQFqWXoOSi CzRkwg/+IxI/vMksjqSgWDSJ8jXNd6H7ftRcBsy0e4K4TAhuKg5kglFR1SBFOQyW VgcvZQtLr6uAUEGYGQhmDpEaRacKPoS3ltCqDkqCuVUKqsp0v2b1k7njSlxYr9k+ jTz1WNLHozmOLHks1/oPJ3bE4RE3Q1yVnK+9dcmW5EnS1i5SPw0JbBQAOB7jdQzs 9Wo6sEdewvQhRuPExX5aOrd92vA8AzJL5fJM4v4MkPztvEj3pusOXA6vysAGJd5m yxsGH4FnP5laxCkV/DFsBmVnE1UEBvjqNTfoGo8p73t0GOXcFwf8FyEWDf4J+mMh nEaI6mN4cA0Ez8kq6fW/Rf7s7cXwX/8XgaMVAb+EGDLXyAGCdyWC1m0CJ9BLyETV Wpva6f7FWI8NOYweCcGsqKI1fBAU7J9G2M+8piPlBs0peLT6/KibjcG5bXxCg/NJ TRYFxNFpf6m7RXKM1n1qdtNoYoA8HMkbq9Ogk38PKbLqn/YLdDs75mxZY63yK7dN IPkvGgV3P9xPpzSeU5Ck5dhGOh1qrFDkvKugKY7tUTlq9Sb0EQnEhKaYW4jHtLoz 2aMJVA7UMQX5MpIUDCsxuN0pIISYfKXFCB0iQ/4LS2nhekZanD3Ucq/wyjxnbhH6 B3lDRRVzsSSUSI0w9ZM37NF63a+zpb6cF27+0r6bT4h1tpg6PmU= =uKjc -----END PGP SIGNATURE----- --oj4kGyHlBMXGt3Le--