From owner-freebsd-arm@freebsd.org Mon Dec 2 13:04:27 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 11AD11A93FB for ; Mon, 2 Dec 2019 13:04:27 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.blih.net", Issuer "mail.blih.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 47RQLK6WQBz3L2M; Mon, 2 Dec 2019 13:04:25 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) by mail.blih.net (OpenSMTPD) with ESMTP id d5cfb9f6; Mon, 2 Dec 2019 14:04:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bidouilliste.com; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mail; bh=PXzajdEW1kZEoy4F9+NwN2yq64E=; b=dUba3/BF74VddAdxPv/r9P6VT/cY p9WJ3s+br9Lm1VqXTyUx77Y8noHoBXrpy+S2bJGFow12Ru5wQmZWTucbpuhP23FS gNT1E2gWDlK47ScFdIF1/bwc6b8sRTBgToOMiEqRjINyY6z6HzpU+VFpfTSvgbWC RtA8DVROqUMKVF0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=bidouilliste.com; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= mail; b=rzpxz2wmGBKimmINXJ6vU6XoYygIns6pN2gObADoyuxwKMK9b+kQC1Ej SXP4q3ZoKbgBqLUpFKmFZNfGHrV1y4XrknuezJY6F1E+htnBTeSMsK9+bFOuzEYI nDBRw+rCnnQLcXQ4MF84klQCEwI8kxxLLitKBKYsofEYfdHVhKQ= Received: from skull.home.blih.net (lfbn-1-12172-130.w90-92.abo.wanadoo.fr [90.92.223.130]) by mail.blih.net (OpenSMTPD) with ESMTPSA id a47957ca TLS version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO; Mon, 2 Dec 2019 14:04:17 +0100 (CET) Date: Mon, 2 Dec 2019 14:04:16 +0100 From: Emmanuel Vadot To: Peter Jeremy Cc: Michal Meloun , freebsd-arm@freebsd.org Subject: Re: rk_tsadc breaks (my) Rock64 Message-Id: <20191202140416.936a457adebce6fca1341b18@bidouilliste.com> In-Reply-To: <20191202111322.GF37113@server.rulingia.com> References: <20191201110716.GA41224@server.rulingia.com> <20191202111322.GF37113@server.rulingia.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; amd64-portbld-freebsd13.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 47RQLK6WQBz3L2M X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bidouilliste.com header.s=mail header.b=dUba3/BF; dmarc=none; spf=pass (mx1.freebsd.org: domain of manu@bidouilliste.com designates 212.83.177.182 as permitted sender) smtp.mailfrom=manu@bidouilliste.com X-Spamd-Result: default: False [-0.54 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[bidouilliste.com:s=mail]; NEURAL_HAM_MEDIUM(-0.63)[-0.626,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+ip4:212.83.177.182/32]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[bidouilliste.com]; NEURAL_HAM_LONG(-0.39)[-0.389,0]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[bidouilliste.com:+]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; IP_SCORE(0.38)[ip: (-0.58), ipnet: 212.83.160.0/19(2.42), asn: 12876(0.06), country: FR(-0.00)]; ASN(0.00)[asn:12876, ipnet:212.83.160.0/19, country:FR]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2] 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 13:04:27 -0000 On Mon, 2 Dec 2019 22:13:22 +1100 Peter Jeremy wrote: > On 2019-Dec-01 22:07:16 +1100, Peter Jeremy wrote: > >r355173 added code to read the Rockchip temperature sensors. Unfortunately, > >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 configuration > >missing from syscon that tsadc needs but I'm not sure what (and I don't really > >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 ofwbus0 > (via compatible = "rockchip,rk3328-grf") > simple_mfd0: mem 0xff450000-0xff45ffff on ofwbus0 > (via compatible = "simple-mfd") ??? those aren't the same devices. > 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 = <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. > > -- > Peter Jeremy root@rock64:~ # uname -a FreeBSD rock64.home.blih.net 13.0-CURRENT FreeBSD 13.0-CURRENT #13 r355188:355190M: Thu Nov 28 21:43:00 CET 2019 manu@skull.home.blih.net:/usr/home/manu/Work/freebsd/obj/usr/home/manu/Work/freebsd/freebsd-svn/base/head/arm64.aarch64/sys/GENERIC arm64 root@rock64:~ # sysctl hw.temperature hw.temperature.CPU: 50.7C Everything is working for me after I've added the clocks, so I don't know what's happening for you. But after looking again at the docs it seems that rk3328 is a mix between v2 and v3 so the GRF write are wrong. I'll have a look today or tomorow and fix this. -- Emmanuel Vadot