From owner-freebsd-hackers@freebsd.org Fri Aug 17 16:27:03 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E8A5E1074865 for ; Fri, 17 Aug 2018 16:27:02 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (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 76083873AA for ; Fri, 17 Aug 2018 16:27:02 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-RoutePath: aGlwcGll X-MHO-User: 5bbe0730-a23a-11e8-aff6-0b9b8210da61 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id 5bbe0730-a23a-11e8-aff6-0b9b8210da61; Fri, 17 Aug 2018 16:26:57 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w7HGQu8a081010; Fri, 17 Aug 2018 10:26:56 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1534523216.27158.17.camel@freebsd.org> Subject: Re: Need a clarification regarding I2C bus frequency in FreeBSD From: Ian Lepore To: Rajesh Kumar , freebsd-drivers@freebsd.org, freebsd-hackers@freebsd.org Date: Fri, 17 Aug 2018 10:26:56 -0600 In-Reply-To: References: Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2018 16:27:03 -0000 On Fri, 2018-08-17 at 11:48 +0530, Rajesh Kumar wrote: > Hi, > > I am trying to use the I2C designware controller driver available in > FreeBSD (ig4_iic.c) in our boards. > > Is there a clean way, I can set the I2C bus frequency from the controller > driver itself, rather than using device hints, FDT, tunables etc., > Something like, if the driver is loaded for our boards (identified using > the PCI or ACPI ID's), then the frequency of the I2C bus needs to be > hardcoded from driver itself. This is to avoid additional configs from the > config file. > > I tried adding a new interface "iicbus_set_frequency" (in line with > iicbus_get_frequency) and tried calling that from the ig4 driver after the > "iicbus" child is added.  But, iicbus instance is created only after ig4 > driver is loaded. So, calling iicbus_set_frequency after child addition > leads to system panic (as there is no iicbus softc at this point). > > Let me know if you need any details. > > Thanks, > Rajesh. I don't really understand what you're asking for. The ig4_iic controller driver doesn't appear to support bus frequency settings at all, it just loads hard-coded values into the clock high/low registers and never changes them. If you want to locally modify the driver to run at a different hard-coded speed for your application, just change lines 589-592 in ig4_iic.c and continue to ignore the speed set by the bus driver when handling iicbus_reset. -- Ian