Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp173332pxb; Wed, 3 Feb 2021 02:40:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAL7rZ7kMbz8TP7hnA6zcz9NysMvbOvPSX5OtS4vUUtzePpk0B9sVBedUg4F6C56x+NCTq X-Received: by 2002:a17:906:40ca:: with SMTP id a10mr2570803ejk.295.1612348811984; Wed, 03 Feb 2021 02:40:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612348811; cv=none; d=google.com; s=arc-20160816; b=BuuxW2WYf8jjoUb9VJ9Q650DrwH6HPhHVcTcRoudeAVBbJd4y/ltaCvGoeGskvlaca CMdRJmnj5dxN9Hbv9ofkwZ7qXjYCHL+kiW9Uk83jC/4rHYzGM2Ult3WIKbmCw/PbCpKY cft7WkGMnLYabBNW+RTezmqnUNb89KMOZjkrlfOHSTOUPgGVBLfGtmHE+SNWeyIPCUc8 Z0LEeRUngZVR+BURTgRvhuzOaH+1kLZyGxxbIjgZI0Rh/b5ZDv8xiVQBasC6bK1XvkhK 4r6Tj2LA+QUUqHHi0i4gKSfVO/s/SFjQBge+dz17YMvMOp0pIO9W3+NfHNITjQYxwLA7 xnRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=BmEom18VGkKKIoM9sHP40mTY+/eS0NEIc434DwUBvhE=; b=sgvOfKa7xLbjlfoKsjTv6h8QeDzqk0A2rmwkIh+vZLrQvjYlZiGBiOwEkkw22di3EP DyZfXchNf6mdJ4Bvnq91v9Jj2PlejRh8OxTg1uKRWmgfe6dMmPup6ZFdF3A/bENIXGo9 MDCU+MSTO2zkOdxJjQ/RtieydH4j9YAMYh16h5r79CcVRAer8Pkftti5NVhuiOUC4gjJ yrriP3yz8TPuUxn8rPOFEZnXCH7t+asvDgX5HxexXf5qPBMR+QWveb1WR1Ulics3DzXr rvKisZZlbqFJx59LMcFV8/nOG717n5e8HuLETpiNzFL9v+4HICr0Zojw0iA4or3ljXu5 KT7g== 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 b13si1007041ejc.561.2021.02.03.02.39.47; Wed, 03 Feb 2021 02:40:11 -0800 (PST) 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 S233913AbhBCKgZ (ORCPT + 99 others); Wed, 3 Feb 2021 05:36:25 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:49796 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S233825AbhBCKgQ (ORCPT ); Wed, 3 Feb 2021 05:36:16 -0500 X-UUID: 5a4cfd566a3b4d3fab00057c9881199f-20210203 X-UUID: 5a4cfd566a3b4d3fab00057c9881199f-20210203 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 615688265; Wed, 03 Feb 2021 18:35:30 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 3 Feb 2021 18:35:28 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 3 Feb 2021 18:35:28 +0800 From: To: CC: , , , , , , , Subject: [PATCH] i2c: mediatek: Get device clock-stretch time via dts Date: Wed, 3 Feb 2021 18:35:25 +0800 Message-ID: <1612348525-13364-1-git-send-email-qii.wang@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qii Wang tSU,STA/tHD,STA/tSU,STOP maybe out of spec due to device clock-stretching or circuit loss, we could get device clock-stretch time from dts to adjust 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 2ffd2f3..47c7255 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -245,6 +245,7 @@ struct mtk_i2c { u16 irq_stat; /* interrupt status */ unsigned int clk_src_div; unsigned int speed_hz; /* The speed in transfer */ + unsigned int clock_stretch_ns; enum mtk_trans_op op; u16 timing_reg; u16 high_speed_reg; @@ -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->clock_stretch_ns, + clk_ns); if (su_sta_cnt > max_sta_cnt) return -1; @@ -1171,6 +1173,8 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c) if (i2c->clk_src_div == 0) return -EINVAL; + of_property_read_u32(np, "clock-stretch-ns", &i2c->clock_stretch_ns); + i2c->have_pmic = of_property_read_bool(np, "mediatek,have-pmic"); i2c->use_push_pull = of_property_read_bool(np, "mediatek,use-push-pull"); -- 1.9.1