From owner-freebsd-arm@FreeBSD.ORG Tue Nov 18 02:02:15 2014 Return-Path: Delivered-To: freebsd-arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 35D096C4 for ; Tue, 18 Nov 2014 02:02:15 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1DEAE977 for ; Tue, 18 Nov 2014 02:02:15 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id sAI22EBC083606 for ; Tue, 18 Nov 2014 02:02:14 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-arm@FreeBSD.org Subject: [Bug 195009] [patch]: [arm] Use 400 kHz as the default OMAP4 I2C bus speed Date: Tue, 18 Nov 2014 02:02:15 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 11.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: ian@FreeBSD.org X-Bugzilla-Status: In Discussion X-Bugzilla-Priority: Normal X-Bugzilla-Assigned-To: freebsd-arm@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Nov 2014 02:02:15 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=195009 --- Comment #4 from Ian Lepore --- (In reply to Luiz Otavio O Souza from comment #2) > (In reply to Scott Ellis from comment #0) > > The I2C bus speed for OMAP4 boards defaults to 842 kHz. > > > > The formula for calculating this comes from the TRM table 23-8 > > > > scl = i2c_fclk / ( ( psc + 1) * ( (scll + 7) + (sclh + 5) ) ) > > > > The code says it's attempting 1 MHz, but it's using the wrong values. > > Yes, that is right. > > These values comes from TRM table 23-9 in "Fast Mode+". > > The TRM doesn't take into account the '+ 1' for the prescaler value (psc), > but only for Fast Mode+, all the other values seems correct. > > For a internal clock frequency of 19.2 MHz we need to set the prescaler to 4: > > 96 MHz / (4 + 1) = 19.2 MHz > > And then the bus frequency is: > > 19.2 MHz / (3 + 7) + (4 + 5) = 1.010 MHz > > Good catch! Thanks! I'm thinking of fixing this a different way... { 1000000, 5, 1, 3, 0, 0}, That gives 96 / 6 = 16 MHz then 16 / (1 + 7 + 3 + 5) = 1 MHz exactly. I've got another commit coming that fixes this and the fact that we've been running the i2c bus at half speed on beaglebone/am335x systems (root clock is 48mhz not 96). -- You are receiving this mail because: You are the assignee for the bug.