Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp130469pxv; Wed, 14 Jul 2021 20:39:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJWnu1Cx28Fwbl0GJK+f7+ZpkNtlosubC7Nk2ivRMBVlBtLYKdzk6l09mmqUJcwte1Xd+w X-Received: by 2002:a05:6402:51:: with SMTP id f17mr3046360edu.359.1626320353393; Wed, 14 Jul 2021 20:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626320353; cv=none; d=google.com; s=arc-20160816; b=Prux4WcYQ/uf/Ju3RppH9WKwFNl26c9EScd7r7pI+pER3ejl0CHBhNJHDdC7fwWtRp Ou1egcMbS9EvWn8cqYuxU0PbQrvag4V4BCqK3hopvnZx7W27NYyKfbfyP6CvFMMya9hV wMhozzl1DFDscAIILzVbcAtcbfwqmnhF6Ea/bN5gPYWQQ7UkqA8MmbToIWGc4EZkLUM2 GaLSLZpwNij9aK70w9sJMLGleOpdRuK5T3X9C1FOJ3JwRyeibALlIM47WWq+gezGezF3 Et2ogztBecJxGfYr0i+iw/UbXP4JKpk44h6m6hGygx9NLEkJsoudgNX6eXJAqMbn0NK5 aMvg== 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=0t9AnjtUsfugEv+vcDEdqzZudH4JAQg9VfM3Xph/dwM=; b=szsTvMrJsZn5r/brCMRQOf2ubPgvweVeV1LOqqkV4objxbYXZW4pRxyeZnCtaqJvV4 IMPmZGg9kNS+xM5GXn5huCywvvr6XqF+lJ0qhqrEXQEQknBvWZ6IEk9T+YuPCaKDd1R2 mGT6lWt6YkQzxt09gkTjTeHcE6D/CsbweTweWCC0WQIQoSgq5dRpSbQuv5Ty5Zg6hYwB 3kh4NgjOMTgPkEskYQP4XMu0EUwUNZuIiKG2zeRITVXCl0l+J3qDdTtLXe9HkaxCyQe5 89cqjThqiMmnCn5MmPJDpqPw64u2OjGGTF1HoSE4WAouwdO2w3+RkBzDtHdH3yp853tV MP8w== 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 p13si5277377edx.221.2021.07.14.20.38.35; Wed, 14 Jul 2021 20:39:13 -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 S235650AbhGOCdQ (ORCPT + 99 others); Wed, 14 Jul 2021 22:33:16 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:54070 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S232740AbhGOCdK (ORCPT ); Wed, 14 Jul 2021 22:33:10 -0400 X-UUID: 586b3013e21e49649fa3a5f1f7b2f648-20210715 X-UUID: 586b3013e21e49649fa3a5f1f7b2f648-20210715 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2032874960; Thu, 15 Jul 2021 10:30:13 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 15 Jul 2021 10:30:12 +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; Thu, 15 Jul 2021 10:30:11 +0800 From: Kewei Xu To: CC: , , , , , , , , , , , , Subject: [PATCH 4/8] i2c: mediatek: Reset the handshake signal between i2c and dma Date: Thu, 15 Jul 2021 10:29:13 +0800 Message-ID: <1626316157-24935-5-git-send-email-kewei.xu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1626316157-24935-1-git-send-email-kewei.xu@mediatek.com> References: <1626316157-24935-1-git-send-email-kewei.xu@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 Due to changes in the hardware design of the handshaking signal between i2c and dma, it is necessary to reset the handshaking signal before each transfer to ensure that the multi-msgs can be transferred correctly. Signed-off-by: Kewei Xu --- drivers/i2c/busses/i2c-mt65xx.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index e65a41e..ded94f9 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -47,6 +47,9 @@ #define I2C_RD_TRANAC_VALUE 0x0001 #define I2C_SCL_MIS_COMP_VALUE 0x0000 #define I2C_CHN_CLR_FLAG 0x0000 +#define I2C_CLR_DEBUGCTR 0x0000 +#define I2C_RELIABILITY 0x0010 +#define I2C_DMAACK_ENABLE 0x0008 #define I2C_DMA_CON_TX 0x0000 #define I2C_DMA_CON_RX 0x0001 @@ -942,6 +945,17 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, reinit_completion(&i2c->msg_complete); + if (i2c->dev_comp->apdma_sync) { + mtk_i2c_writew(i2c, I2C_CLR_DEBUGCTR, OFFSET_DEBUGCTRL); + writel(I2C_DMA_HANDSHAKE_RST | I2C_DMA_WARM_RST, + i2c->pdmabase + OFFSET_RST); + writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_RST); + mtk_i2c_writew(i2c, I2C_HANDSHAKE_RST, OFFSET_SOFTRESET); + mtk_i2c_writew(i2c, I2C_CHN_CLR_FLAG, OFFSET_SOFTRESET); + mtk_i2c_writew(i2c, I2C_RELIABILITY | I2C_DMAACK_ENABLE, + OFFSET_DEBUGCTRL); + } + control_reg = mtk_i2c_readw(i2c, OFFSET_CONTROL) & ~(I2C_CONTROL_DIR_CHANGE | I2C_CONTROL_RS); if ((i2c->speed_hz > I2C_MAX_FAST_MODE_PLUS_FREQ) || (left_num >= 1)) -- 1.9.1