Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2072383pxv; Sat, 17 Jul 2021 03:19:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKC3pW8p7RMM5QU4vLYMnsNJH7PlqpxD5vDCSOWarwzvuDqbczXTHncRek9tNaTSEwNI73 X-Received: by 2002:a05:6638:2195:: with SMTP id s21mr12862970jaj.15.1626517174275; Sat, 17 Jul 2021 03:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626517174; cv=none; d=google.com; s=arc-20160816; b=xxzm54Qi7vkBUNUyl21q+wkAD4GA7V3/rRmD3BTsiRX5lP+lHL90FL6UCtFpFRawjp lxs+V7vGHSim5eSetkQXXye4kpcUujQZYN3YKtogudLIPgng4Co0Dr3qgEDfHfQsNQCy +JB707diPHrHRvnJqcEWMin2RNWRLVZsP3JRd2O+rL8WM5uVgqb9We6mGkhkXyYlJt89 6WmOfKBUkYgt+k6KrC+W2QzZmgcMNLISlzXq6N3+dTqduLQQBzxz2lVV6RnrqI/cuIqY wXPtj05wJvFD+vTtU1GPAm3pklxduRL9W4ZwyLVI23xfxzlBKci5zKYm9vHdR+WOXbh3 sfPQ== 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=5f5ufdfed4ymcoLahX9bQn06lG2x25/ER4NE78DTjXA=; b=oNEibSPgKUu6lXdVnvGwQa8FJQUc49oswn9EJr+ILTSDdXO8R5ch38/AtExCukLeKB vkR+fluj1Kotn09stvJThl+2gSE+l7NlpsnI9cy943QJ91sQwCts5iVIIxi0krQdaU1C k2BG8nDTNTRIEiIJD6YkOzGPo7FntGCOs+/EIHD08DeA22MJo3g8tf2J4R3BRKnGCMc4 cCs2YnoG0SxSo8nDuUWFNIiCa/pSddocvDi3cL70bRwB2ncN523DwqAj6kqK/ZBK5y7V b+oYN5ClRwWcEiqYt9y3MWPRrVbmEFB46yyp+bUTyhqmxt4HTqax8XvUsZ+wHAKwe0Oh 2edg== 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 l15si14159991jad.101.2021.07.17.03.19.22; Sat, 17 Jul 2021 03:19:34 -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 S233882AbhGQKVb (ORCPT + 99 others); Sat, 17 Jul 2021 06:21:31 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:35822 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S233284AbhGQKVH (ORCPT ); Sat, 17 Jul 2021 06:21:07 -0400 X-UUID: 3bdf12ecf04e41c6bd94830fcb9adc9b-20210717 X-UUID: 3bdf12ecf04e41c6bd94830fcb9adc9b-20210717 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 810267710; Sat, 17 Jul 2021 18:18:07 +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 Jul 2021 18:18:05 +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 Jul 2021 18:18:04 +0800 From: Kewei Xu To: CC: , , , , , , , , , , , , , Subject: [PATCH v4 3/8] i2c: mediatek: Reset the handshake signal between i2c and dma Date: Sat, 17 Jul 2021 18:17:54 +0800 Message-ID: <1626517079-9057-4-git-send-email-kewei.xu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1626517079-9057-1-git-send-email-kewei.xu@mediatek.com> References: <1626517079-9057-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 222ff765e55d..c0108387f34b 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 @@ -850,6 +853,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)) -- 2.18.0