Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1219744ybi; Wed, 19 Jun 2019 16:06:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxL0d4a9mJGTMm2RIjKj+R+RCBn5rhCgb8u7Qg/ZETjkgVn+xqEvc6VcYBnDHhnx+Uarbdt X-Received: by 2002:a17:902:b487:: with SMTP id y7mr61029562plr.219.1560985597853; Wed, 19 Jun 2019 16:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560985597; cv=none; d=google.com; s=arc-20160816; b=jrQ3bTbQCVAYmhXeVZg84edzryRVHvUWDZt7GoA0SQWsBmB7b/K+fs7xYepzCJFitV OAMN7Vlrh4cji2jRkK94nqv+bIQVdzvvnQxJZ/f20mlCWGbycYsr2RBfVo+KKbyWrYiD DGMMUoQ4d91crLf4NNmYa7yb/qxRVr/IiMBspcGXqz1tzx1d13+iAJN3WnMbPBZqYZip 0vHVhsw92hNvQDRD1c51So80sJHy23bMQyxj3R5cyL4eRMYsMIAlxfkgU47k2LqZn6Q1 s3nDTTRAWhgy6V/QQRtLTOTX2KM58IRLfvBJkmZMvTeWR5sGYzxTHA9zDhpS+2l9M5CO IgRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=52J9aj2YxHWLBDh6ZX1NNjvEmgLQcPPFg/PK3VBGmF0=; b=qYg4EECCWbOc28D5L8xs8RofsZLkvwN1rFKEhOUoK/aQOJ3jAoCZzX3Ym5xHljc+HB G6xKf62X/dFJAxQLAAJ9I3l8wz31E6lH8A0AEIE9wfIr2R96aa2ZeoSzIr0jYsnUwYoe kupqD+4id3CBIdH472Vvl97Oz0Qd6YWc/kNnePILMnjKkH4inASXrlRdW7e4kfXlquxF 83GXTUVOttV0VoSdyW0boTtD5YekDAWC7yj+jKJSX82nOjZTCCRTbPEfYOjTzhRxG/of DIoY81CRa77YI9t/pKSHK+Y+RdV350WrDREMfobvQVH+JpH8zsjPlmZnc+zqj5IMgvNR weGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a36si2448081pje.14.2019.06.19.16.06.09; Wed, 19 Jun 2019 16:06:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729971AbfFSXDQ (ORCPT + 99 others); Wed, 19 Jun 2019 19:03:16 -0400 Received: from gate.crashing.org ([63.228.1.57]:48234 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726251AbfFSXDP (ORCPT ); Wed, 19 Jun 2019 19:03:15 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x5JN2NFs022741; Wed, 19 Jun 2019 18:02:25 -0500 Message-ID: <4c8b9ca5e84db7db67ad552d8fdbaa17d11b6432.camel@kernel.crashing.org> Subject: Re: [PATCH 1/2] i2c: aspeed: allow to customize base clock divisor From: Benjamin Herrenschmidt To: Tao Ren , Brendan Higgins Cc: Mark Rutland , devicetree , "linux-aspeed@lists.ozlabs.org" , Andrew Jeffery , OpenBMC Maillist , Linux Kernel Mailing List , Rob Herring , Joel Stanley , Linux ARM , "linux-i2c@vger.kernel.org" , "ryan_chen@aspeedtech.com" Date: Thu, 20 Jun 2019 09:02:23 +1000 In-Reply-To: <18565fcf-3dc1-b671-f826-e4417e4ad284@fb.com> References: <20190619205009.4176588-1-taoren@fb.com> <18565fcf-3dc1-b671-f826-e4417e4ad284@fb.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-06-19 at 22:32 +0000, Tao Ren wrote: > Thank you for the quick response, Brendan. > > Aspeed I2C bus frequency is defined by 3 parameters > (base_clk_divisor, clk_high_width, clk_low_width), and I choose > base_clk_divisor because it controls all the Aspeed I2C timings (such > as setup time and hold time). Once base_clk_divisor is decided > (either by the current logic in i2c-aspeed driver or manually set in > device tree), clk_high_width and clk_low_width will be calculated by > i2c-aspeed driver to meet the specified I2C bus speed. > > For example, by setting I2C bus frequency to 100KHz on AST2500 > platform, (base_clock_divisor, clk_high_width, clk_low_width) is set > to (3, 15, 14) by our driver. But some slave devices (on CMM i2c-8 > and Minipack i2c-0) NACK byte transactions with the default timing > setting: the issue can be resolved by setting base_clk_divisor to 4, > and (clk_high_width, clk_low_width) will be set to (7, 7) by our i2c- > aspeed driver to achieve similar I2C bus speed. > > Not sure if my answer helps to address your concerns, but kindly let > me know if you have further questions/suggestions. Did you look at the resulting output on a scope ? I'm curious what might be wrong.... CCing Ryan from Aspeed, he might have some idea. Could it be that with some specific dividers you have more jitter ? Still, i2c devices tend to be rather robust vs crappy clocks unless you are massively out of bounds, which makes me wonder whether something else might be wrong in your setup. Cheers, Ben.