From nobody Thu Nov 14 08:05:24 2024 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xpt4z3jw0z5cJL5 for ; Thu, 14 Nov 2024 08:05:55 +0000 (UTC) (envelope-from darius@dons.net.au) Received: from midget.dons.net.au (midget.dons.net.au [61.245.145.238]) by mx1.freebsd.org (Postfix) with ESMTP id 4Xpt4w5MSXz4jvs for ; Thu, 14 Nov 2024 08:05:52 +0000 (UTC) (envelope-from darius@dons.net.au) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=dons.net.au header.s=default header.b=Vl+Ei5ga; spf=pass (mx1.freebsd.org: domain of darius@dons.net.au designates 61.245.145.238 as permitted sender) smtp.mailfrom=darius@dons.net.au; dmarc=pass (policy=quarantine) header.from=dons.net.au Received: from smtpclient.apple (unknown [IPv6:2001:44b8:1d2:8900:1c4e:b7a9:c47b:bfda]) by midget.dons.net.au (Postfix) with ESMTPSA id 5D1157429BF; Thu, 14 Nov 2024 18:35:41 +1030 (ACDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dons.net.au; s=default; t=1731571543; bh=rDP+it7S6JfbpOOOsrq/NWX8bLJWhZrr+vDZbc8ysas=; h=Subject:From:In-Reply-To:Date:References:To; b=Vl+Ei5ga6ypxkexgoy1nO9/XhMVoHBIXC8wvDA1d61BNMU/mPXrER9Z1udp/hDnIS 6C/20lXoAt5kigCwayyhJjYpdFVPnk5wtnEAE5XGRORdkSUsH2EgoPSip9LnQhDvXW 0TpHJiihfPqjfdWMNOmHjaf3xFHMiFOUzcNcau2hCKRMrD00kbvVtfs8pQ6676kB4x KZKZ4k5AV0IVUX/VDls+xflFcvnhykSGL4Mqvzzk659O6w7yQC1Pq1IRI1q1/LKY+v 2vhV6mXJ6g77QfEz9+tAO8+mckuBNzJBJpiM7x0bXrGCllrqZZlkA6vhLs0t4I5J4x IPDZ+i82vJ71g== Content-Type: text/plain; charset=us-ascii List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@FreeBSD.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: Re: I2C on Raspberry Pi 4B has wrong clock rate? From: Daniel O'Connor In-Reply-To: Date: Thu, 14 Nov 2024 18:35:24 +1030 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: freebsd-arm@freebsd.org X-Mailer: Apple Mail (2.3776.700.51) X-Rspamd-Action: no action X-Rspamd-Server: midget.dons.net.au X-Spam-Status: No, score=0.07 X-Spamd-Result: default: False [-2.80 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_SHORT(-1.00)[-0.998]; DMARC_POLICY_ALLOW(-0.50)[dons.net.au,quarantine]; R_DKIM_ALLOW(-0.20)[dons.net.au:s=default]; R_SPF_ALLOW(-0.20)[+mx]; ONCE_RECEIVED(0.10)[]; RCVD_NO_TLS_LAST(0.10)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[dons.net.au:+]; RCPT_COUNT_ONE(0.00)[1]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ASN(0.00)[asn:4764, ipnet:61.245.144.0/22, country:AU]; TO_DN_NONE(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; MLMMJ_DEST(0.00)[freebsd-arm@freebsd.org]; APPLE_MAILER_COMMON(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+] X-Rspamd-Queue-Id: 4Xpt4w5MSXz4jvs X-Spamd-Bar: -- > On 13 Nov 2024, at 14:27, Daniel O'Connor wrote: > I tried setting the frequency but it does not 'stick': > [rpi13 3:56] ~ >sudo sysctl dev.iichb.0.frequency=3D10000 > dev.iichb.0.frequency: 100000 -> 100000 I tried lowering the clock frequency to 600MHz (from 1.5GHz) and it = seems 100% reliable now.. I then tried increasing the clock divisor programmed in = bcm_bsc_iicbus_reset by 3x and it works fine at 1.5GHz (and 600MHz). I suppose in practise most users have devices which can run at 400kHz so = running at 250kHz is no problem but the pijuice I2C is handled by a = microcontroller so it is pickier. Obviously fixing the code so it properly handles clock speeds changes = would be good but I am not sure where to start with that. The code uses IICBUS_GET_FREQUENCY() to find which rate to use for I2C - = is there some tunable or hint that can set this? Or DTS? Thanks. -- Daniel O'Connor "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum