Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp899619pxb; Fri, 16 Apr 2021 23:51:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztxkum3ZZLboyAFvI4y4wFzZLzqu8P63eOacxwXBBavhw85kHT4pAUdCovGdEHnKblUGtu X-Received: by 2002:a17:906:1e49:: with SMTP id i9mr5784592ejj.536.1618642293256; Fri, 16 Apr 2021 23:51:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618642293; cv=none; d=google.com; s=arc-20160816; b=tRDu1vaj4G3bQo8tS3DPS5n1ubAgcsMUnPW7WksGbJfsQmtfHXvp10Hly/0SE1pM4n 4yNwyPIH1Z3AECehDkJhBsRBQMHJRyj/89DvQu5BEOsKjNYZVWf8LvyhSLCZemnEOLcM ezEpcOerAVk9BFPacdbJo29S31gIXIwhvz5gFKjJHuRsc2B9oxviJUYRH7Q+k0Yv+ICd 3CX6un16h21q6JHqIS+CnKxMUM0ukvfr7sF2wusY5pr5D7Xya/t6/f7b1Dt6fMZp/ZyH h3Q+JPKMO5jJc8cEY6pfAnkZdixV0cJSwdll1G7X3/A1AjgBmE71/1gZs4VwGfpcr40s nJGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=m3+ZJFLrcB71eKuSWdxvZt+ocoQpImV7U2Q1dCEwu9M=; b=teNoWSEyAEXFAiiw90H4QugNtSR2NA2WtzQktCyKJiOskzFLmjP+KDhsZe0DA8E8ey JxoYdkxjP8ZH5/iYjaAeo+AqPqs76ngfSH10oFaWwC+Myt5/0NMBEIg5N7iGjzzTwNEk KSYiHoq37eHkOshvVN6C+IB61UTKKqcbqGk3K/489VZtXK3z1gIFWrltAommZ+g2uGn5 T6Zi08oLbzy+cK5quma17NIrucLwGleTy0N+Ty8HkPobAmZFFC5D2oTyWR+zHj1mXhaJ h2rjaqWaZylQMYHORg2mACPOQa9KGBJJn9JdhpAc/myf/z4jLArH4gWw9lWWWM2RoxfX 2axg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si4159296edl.24.2021.04.16.23.51.10; Fri, 16 Apr 2021 23:51:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbhDQGrn (ORCPT + 99 others); Sat, 17 Apr 2021 02:47:43 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:57907 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229629AbhDQGrl (ORCPT ); Sat, 17 Apr 2021 02:47:41 -0400 X-UUID: 0fce159f55274c4a9aa26a64f79cc043-20210417 X-UUID: 0fce159f55274c4a9aa26a64f79cc043-20210417 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 378527476; Sat, 17 Apr 2021 14:47:12 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 17 Apr 2021 14:47:10 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 17 Apr 2021 14:47:10 +0800 From: Qii Wang To: CC: , , , , , , , Subject: [PATCH 3/3] i2c: mediatek: Use scl_int_delay_ns to compensate clock-stretching Date: Sat, 17 Apr 2021 14:46:52 +0800 Message-ID: <1618642012-10444-4-git-send-email-qii.wang@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1618642012-10444-1-git-send-email-qii.wang@mediatek.com> References: <1618642012-10444-1-git-send-email-qii.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The parameters of tSU,STA/tHD,STA/tSU,STOP maybe out of spec due to device clock-stretch or circuit loss, we could get a suitable scl_int_delay_ns from i2c_timings to compensate these parameters to meet the spec via EXT_CONF register. Signed-off-by: Qii Wang --- drivers/i2c/busses/i2c-mt65xx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index bf25acb..5ddfa4e 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -231,6 +231,7 @@ struct mtk_i2c { struct i2c_adapter adap; /* i2c host adapter */ struct device *dev; struct completion msg_complete; + struct i2c_timings timing_info; /* set in i2c probe */ void __iomem *base; /* i2c base addr */ @@ -607,7 +608,8 @@ static int mtk_i2c_check_ac_timing(struct mtk_i2c *i2c, else clk_ns = sample_ns / 2; - su_sta_cnt = DIV_ROUND_UP(spec->min_su_sta_ns, clk_ns); + su_sta_cnt = DIV_ROUND_UP(spec->min_su_sta_ns + + i2c->timing_info.scl_int_delay_ns, clk_ns); if (su_sta_cnt > max_sta_cnt) return -1; @@ -1176,6 +1178,8 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c) i2c->use_push_pull = of_property_read_bool(np, "mediatek,use-push-pull"); + i2c_parse_fw_timings(i2c->dev, &i2c->timing_info, true); + return 0; } -- 1.9.1