From owner-freebsd-hackers@freebsd.org Mon Aug 20 09:36:40 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 5562E108A238; Mon, 20 Aug 2018 09:36:40 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A95D283BD9; Mon, 20 Aug 2018 09:36:39 +0000 (UTC) (envelope-from rajfbsd@gmail.com) Received: by mail-wr1-x432.google.com with SMTP id w11-v6so9827202wrc.5; Mon, 20 Aug 2018 02:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zJ9dgvfPjlgToL3w7dMe1B+r0GyzSNSc6AasKP49K9M=; b=tSCdRKYr4FujycVqYGmM8Xq7xDquGKwnxfMP2z58c9UBIpTSQg159h2w2s8Zg8D35h kUY2c+kfOra4KA+WqUi773BGZEXF6K1Fgv7dlzv1yRCJvt+hrcAzimt88xCZuXoYSchh AsdrC/8HWWXblLQfeY3SwYfZ1wNWP2iDNSU2ot/6U+yo/wTgSWhQh3RyQxd80FeVJGFA qZAE4u2p+bYbOsZqhthgIIfvUC2AUs4cQ+LXVsLcYGWmxDVdiWWifBTYFaouem9Fjiky jhtfV2rTuyOqZ1zc/P7pvljaY146raaJshOXyBV2yt+bXT0+L2J0g9sg5/3/0ophAXGj 3Q9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zJ9dgvfPjlgToL3w7dMe1B+r0GyzSNSc6AasKP49K9M=; b=RTd3iq8+SuKmu1yrvDq79pwW3IZIbicmw/CbJMjWdVWcvAteT1e8RXlzAzkJl+eG9V 7xlSGFW6nGtHISkmuJnS5oLKq2tznx4IuN0KtcJXKRWU3yZExQ9JzpQvw+dyc2zgtLjM nSYuory5UbXgf2TZSoTqkBSFrpsqbyOjJIG0AJyKtJTjE+rZb9KXTahYYB1wA0e/rTg1 5FGv86eXUg+PI4Nt7BUsyVFiopXiBZi+0NRLhvEj1QdSpJWjVNZHaijP9GZ3Qt7oHlfI pAZ74jspnqFHN/JL8vqBoeLTwZj2cDhC196+LwZHU/gxJS1q1qc+Z+tTVZzc/3rlQtVx 2bqw== X-Gm-Message-State: AOUpUlGEV3u2eNS6dcdNp8doPYBd5ud4LE9zrg7nxKEPrfiwkxd+WKd8 36zfgzHzuCY54U6+j/ZmQ0ISzsutDaZb6uxNZwLYU7dlttk= X-Google-Smtp-Source: AA+uWPzvzByWn93L0gHXE5ADN1KhxIsv9oxLAYDo1iuau/cBrDWDN0jk6t5tw4fP2ug3BJOC2BLG1o/OmZ3z1Eu1alU= X-Received: by 2002:adf:cc83:: with SMTP id p3-v6mr10754968wrj.226.1534757798586; Mon, 20 Aug 2018 02:36:38 -0700 (PDT) MIME-Version: 1.0 References: <1534523216.27158.17.camel@freebsd.org> <1534702861.27158.36.camel@freebsd.org> In-Reply-To: From: Rajesh Kumar Date: Mon, 20 Aug 2018 15:06:26 +0530 Message-ID: Subject: Re: Need a clarification regarding I2C bus frequency in FreeBSD To: danny@cs.huji.ac.il Cc: ian@freebsd.org, freebsd-hackers@freebsd.org, freebsd-drivers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 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: Mon, 20 Aug 2018 09:36:40 -0000 Hi Ian/Daniel, Sorry about the mixed-posting. By "i2c clock frequency", I mean the internal base frequency only, which drives the chip. I thought data will be transferred on bus based on the base frequency. So, thought both bus and base frequency are same. But from what you said, seems both are different. So, based on the setting in *_HCNT/LCNT register, the bus frequency (which is the rate at which data is transferred) will change for a particular base frequency. Is that right? So, few questions here 1) As you said, we need to have a base frequency of 150 Mhz in our case. So, do we need to program that IG4_REG_CLK_PARMS to 150 Mhz (0x8F0D180)? And can this be done at the same time when programming the HCNT/LNCT registers? 2) Not sure how that 111Hz value is arrived. Can you please explain this calculation. So, that I can derive the appropriate values for HCNT/LCNT for different speeds at 150Mhz base clock. 3) "Default HCNT/LCNT register values would be consistent with an internal base clock speed of 1GHz", Does it mean with those values, all speeds can be achieved until 1GHz clock? 4) I am quite unfamiliar with the oscilloscope outputs. So, it would be good if you give some idea about what is shown in that pic? On Mon, Aug 20, 2018 at 1:43 PM Daniel Braniss wrote: > > > On 20 Aug 2018, at 09:49, Daniel Braniss wrote: > > > > On 19 Aug 2018, at 21:21, Ian Lepore wrote: > > On Sun, 2018-08-19 at 19:23 +0530, Rajesh Kumar wrote: > > Hi Ian, > > Basically, I want to set the I2C clock frequency for Designware IP in our > board to 150Mhz. So, I was looking for the way in FreeBSD. > > So, Is this the frequency which is configured through the clock high/low > registers? I see the those register are coded to 100 and 125 currently, I > am not sure how that value is arrived. If it needs to be configured for > 150Mhz, how to derive the appropriate values? I looked at the DW_apb_i2c > databook section 3.11 to understand about it. I am still unclear. I see a > comment saying "Program based on 25000 Hz clock". In my case, should they > be programmed based on 150Mhz clock? > > > Rajesh, > > Please bottom-post when replying on freebsd mailing lists, mixed top- > and bottom-posting is too confusing. > > What exactly do you mean when you say "the i2c clock frequency"? > > The datasheet appears to use a term like that to refer to the internal > clock used to drive the IP block in the chip. That base clock is then > divided down to create the i2c bus frequency on the I2C_SCL line. > > The IG4_REG_SS_SCL_HCNT and IG4_REG_SS_SCL_LCNT registers are the > duration in base clock ticks that the SCL line is held high and low for > standard speed. The registers with FS in the name are for high speed > mode. > > The comment block and the values our driver programs into those > registers appear to be wildly wrong. There is no way a base clock > running at 25KHz can be divided down to create i2c bus speeds of 100KHz > and 400KHz for standard and fast modes. If the base clock really is > 25KHz then the driver currently sets the i2c bus to run at 111Hz. > > The hardware default values for the HCNT/LCNT registers, as given in > the datasheet referenced by the driver [1], would be consistant with an > internal base clock speed of 1GHz. The fact that the header file > defines a IG4_REG_CLK_PARMS register, but the datasheet doesn't mention > it, makes me think that on some versions of the hardware the speed is > fixed and the driver has to know what that is based on the version, or > vendor, or something. Other versions of the hardware may have > information about the base clock speed in that IG4_REG_CLK_PARMS > register. > > What we need is for someone who has this hardware to put an > oscilliscope on the SCL line and get us some real-world truth. > > [1] > http://www.intel.com/content/www/us/en/processors/core/4th-gen-core-family-mobile-i-o-datasheet.html?wapkw=datasheets+4th+generation > < > http://www.intel.com/content/www/us/en/processors/core/4th-gen-core-family-mobile-i-o-datasheet.html?wapkw=datasheets+4th+generation > > > > -- Ian > > > > hi, > I have similar issues with the allwinner/twsi but I do have a Saleae Logic > and here is a nice picture: > > > ah, maybe this is better: > https://cs.huji.ac.il/~danny/Screen%20Shot%202018-08-20%20at%2011.06.43.png > > > > > danny > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > >