Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3758049pxj; Mon, 7 Jun 2021 20:22:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyNxXTyU70sv/m/lm5AxDG9C2jGe0iguzuPRLhWoI41VpkfP6/h4oulcqui9pWSnDtgjKb X-Received: by 2002:a17:906:757:: with SMTP id z23mr20332261ejb.537.1623122538864; Mon, 07 Jun 2021 20:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623122538; cv=none; d=google.com; s=arc-20160816; b=x+Yvb2czjsA5M05guGNzEDQCi+GiQ0XxIbrRkkJ4YdGseNs6Mx6dEdXWXcDaxc0ZG7 6Hc4SrcdZMtgJTbxXna6J9Emdy1ysTxCtYZQHs8hchDaQgKFp5OJBD4m/PAf5jVtGQEd 23vLlsXhgoONsXH0Mk9088nCHQaD4B8vWL4+DZ8aDFDeTilyGnVY/XhbFNiRonx/EZx6 t1ePOTuZy7EDvaXfQLJ9yoLe0lVNM8KVJ+QF9s7mFN/U3mnNgEpYpgbeWprqKzLht9bd UOvGwUXOUWYpBFfM/KkDuhq793W5T3SC4yz8VGSuWc7U03VoY4yU8T31QOQ5YJiDCjrN 8Fmw== 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=m7n1BqHNO9hlIbsWYgo9nmkKjmg6vdCY+qfH5OCRmgI=; b=R8TeTJKWJTNY59E3Lfg2yfHqdnKQ4K5rRZ5Ax06K6LTTdxy3Ed7AWZDbIVab8csH5r wIQ232YgOid2pKYzcabaDlH/BUIZfpABxe4SpvFLAh0RfiPWfdlBkjWHVmFDyM8Gsw46 W7ioIMUM74HqWIoISl1JWvO49ZaRa7UCK4amEZ2IxMm6MNFcEKv4kF/eyHlJD63N0Ahl aholYBPAhv0M+B42YwFuklQq0KHfgFUtcKRAOE/C1ZmX/b5+K+iQQGTc3ya4jFYuyxCT b5GogQy3npfdI6gpUEbsPgaS9bP7wo1F3UH09Xk4TaUgS4f8c5OVNgk4Z3zD2e8mWZY4 biDg== 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 hq22si14133876ejc.454.2021.06.07.20.21.55; Mon, 07 Jun 2021 20:22:18 -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 S231517AbhFHDTm (ORCPT + 99 others); Mon, 7 Jun 2021 23:19:42 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:58354 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230514AbhFHDTi (ORCPT ); Mon, 7 Jun 2021 23:19:38 -0400 X-UUID: 81c28be49c4645179291f550c2d8cf71-20210608 X-UUID: 81c28be49c4645179291f550c2d8cf71-20210608 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1593744583; Tue, 08 Jun 2021 11:17:43 +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; Tue, 8 Jun 2021 11:17:41 +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; Tue, 8 Jun 2021 11:17:40 +0800 From: Kewei Xu To: CC: , , , , , , , , , , , Subject: [PATCH 3/3] i2c: mediatek: Reset the handshake signal between i2c and dma Date: Tue, 8 Jun 2021 11:16:40 +0800 Message-ID: <1623122200-1896-4-git-send-email-kewei.xu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1623122200-1896-1-git-send-email-kewei.xu@mediatek.com> References: <1623122200-1896-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 From: "Kewei.Xu" 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