Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1882058pxf; Sat, 13 Mar 2021 00:15:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzI2JBAOlHVOJtsPHjlr3KQplzY9hzSBxiIW+Z45ed7oTihmBRc1nPYzp9LOHwOaCMBjaaf X-Received: by 2002:aa7:db53:: with SMTP id n19mr19352182edt.330.1615623345092; Sat, 13 Mar 2021 00:15:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615623345; cv=none; d=google.com; s=arc-20160816; b=ym+QyzS00cFqNIAQ2eCRR8PMDsNCYCzVs2fEXTlDtcl2K1DMBtmn63JL7jY7BChaB7 EtVZ/CuxFL+i/ic8iuDArulBlQzwlQw+d9KAP92Rb7gls+olrveL/SyP0+pbIrmTRlGa parHLUgr6CT0+K1f3KrIvQt43S4V3Sx6pHZZblz1kP60/vKtHZ46zYmHd3Lg7QJS2xBY 2a0CVnnwMUqpIYlIzANfo6sXgY9EbABKatDn8Rz2yon/mDE+cHl8N5YacFKkHveEOJDq vxu15deexW0zypslg9L8rFhRxiTuqT3tB+01cKrBh8C9snrx11eKvw44vSKT713AM/O5 MdtA== 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=yhu3WeBu9ySMZvjCyzl5gCvil8ZNPKPglRAvqeST2ICdUniRV3pj27bo440ih3wXV9 FQCoMfAhB22P0d/go7m1Ycz9zGnjIWIp/7JMPNcuruBjweXlqH54DXiXTHQGpH/jxhUl cjoP2vDrsxQWdwutrle3UNi/HNE0VC/f2kiE0vgKw47VLagZ7HcQVn4IJleNZkrolZq/ 11d1Yg/UPwXmEz1jAk7wEgRYtR0azBMfQG9zTB8zQsJi3w5n7QBq1yDRBZT2SniK9sSk NGW3NBgYKO3NmG7YjDMBtjR+vpw4MclsLG2+lbYg8dScZpZUjB5/twfWj+/PpBmXryzP BhhA== 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 t19si5668174ejx.42.2021.03.13.00.15.22; Sat, 13 Mar 2021 00:15:45 -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 S231938AbhCMIE6 (ORCPT + 99 others); Sat, 13 Mar 2021 03:04:58 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:56350 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229968AbhCMIEf (ORCPT ); Sat, 13 Mar 2021 03:04:35 -0500 X-UUID: c35dee2e5f0140da925f17cf18b31b08-20210313 X-UUID: c35dee2e5f0140da925f17cf18b31b08-20210313 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw01.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 1916932198; Sat, 13 Mar 2021 16:04:30 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 13 Mar 2021 16:04: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; Sat, 13 Mar 2021 16:04:28 +0800 From: To: CC: , , , , , , , Subject: [RESEND] i2c: mediatek: Get device clock-stretch time via dts Date: Sat, 13 Mar 2021 16:04:24 +0800 Message-ID: <1615622664-15032-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