Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1303547yba; Tue, 2 Apr 2019 06:31:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQeOBv9G7KdTXitaKXBPmMOs6qn50nPPVm0pX+10Rq1eeSDuTJpD46a0GN0rh83PdDHWj5 X-Received: by 2002:a62:1c13:: with SMTP id c19mr29816041pfc.11.1554211894095; Tue, 02 Apr 2019 06:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554211894; cv=none; d=google.com; s=arc-20160816; b=cO5Tdb1DDdbkzKynttR/oRReTuSvh+BAzlSYDkLFiVdLSm9dSY9ES4P/JfYdphXRSn 3Ya5aXWznFdFl4JNS1dkrpCfiOIkQvUwGkhal5j5LBEQWffKsGKOfMzsGITqxr+zTeEz F92lViNifPJcasDrPd4DmZfx4wVvsC3PPmz9nBHmBC2p44Mv7TCL2Z9jbHbYK980nEn/ Khoq3J61Gmg202zfNGcvS7YbFDwjvg8i2ntn/dtS3RqJmH2y5gD58KfxXneMfGhxjOZD EL2vHAJzP3XdIpc6PqJzP9fYSY//38SBnSdTYTuMplcvnbIWtGcfUVfdGbFHd5GzAQ9f gTwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=j/toM77mK/6Wzq2SxGdTcqJ8jKAyQ4AGbuBlKOaTIDA=; b=b9GYuHkrM3LzasdC7Vm0hdgBebLfyWc4FugD+3obJxllT0T15bsT9L/Pjpx5BFqzY1 FHEDrluN+iTO7HbgP8UiOf05gVuaoFqTpjPw+laJZuGehLAfVTnh3NBnil4LwrAzDLCr qyqgNV0Qy/XYPJ4ZgiHca/86ggL3U1s4GxYT9POJlubEUeRCQIJPI0Y31nqIv2L0WRtR UA1Jxv4mYPMefoGbm7Ix+qjogVBnd2SkIrLwyZaFEBUdYtyMBRKJI38dGZBryYuNUw4n HHJ24g8X2yli/b+gZ2P+/bkxm5VvhKRCGrAEYH+qwtiZUJZX0Dt5euqJDFA/s0Ougnzp 4O9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si11211366pgq.486.2019.04.02.06.31.15; Tue, 02 Apr 2019 06:31:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731105AbfDBMg1 (ORCPT + 99 others); Tue, 2 Apr 2019 08:36:27 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:24657 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727065AbfDBMgZ (ORCPT ); Tue, 2 Apr 2019 08:36:25 -0400 X-UUID: ec5e9f2b2771459d949803cbe852a7da-20190402 X-UUID: ec5e9f2b2771459d949803cbe852a7da-20190402 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1418319423; Tue, 02 Apr 2019 20:36:11 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 2 Apr 2019 20:36:10 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 2 Apr 2019 20:36:10 +0800 From: Qii Wang To: CC: , , , , , , , , , , Subject: [PATCH RESEND v6 4/6] i2c: mediatek: Add i2c and apdma sync in i2c driver Date: Tue, 2 Apr 2019 20:35:58 +0800 Message-ID: <1554208560-14817-5-git-send-email-qii.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1554208560-14817-1-git-send-email-qii.wang@mediatek.com> References: <1554208560-14817-1-git-send-email-qii.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When i2c and apdma use different source clocks, we should enable synchronization between them. Signed-off-by: Qii Wang Reviewed-by: Nicolas Boichat --- drivers/i2c/busses/i2c-mt65xx.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c index 1a7235e..6137ad7 100644 --- a/drivers/i2c/busses/i2c-mt65xx.c +++ b/drivers/i2c/busses/i2c-mt65xx.c @@ -77,6 +77,8 @@ #define I2C_CONTROL_DIR_CHANGE (0x1 << 4) #define I2C_CONTROL_ACKERR_DET_EN (0x1 << 5) #define I2C_CONTROL_TRANSFER_LEN_CHANGE (0x1 << 6) +#define I2C_CONTROL_DMAACK_EN (0x1 << 8) +#define I2C_CONTROL_ASYNC_MODE (0x1 << 9) #define I2C_CONTROL_WRAPPER (0x1 << 0) #define I2C_DRV_NAME "i2c-mt65xx" @@ -169,6 +171,7 @@ struct mtk_i2c_compatible { unsigned char aux_len_reg: 1; unsigned char support_33bits: 1; unsigned char timing_adjust: 1; + unsigned char dma_sync: 1; }; struct mtk_i2c { @@ -218,6 +221,7 @@ struct mtk_i2c { .aux_len_reg = 1, .support_33bits = 1, .timing_adjust = 1, + .dma_sync = 0, }; static const struct mtk_i2c_compatible mt6577_compat = { @@ -229,6 +233,7 @@ struct mtk_i2c { .aux_len_reg = 0, .support_33bits = 0, .timing_adjust = 0, + .dma_sync = 0, }; static const struct mtk_i2c_compatible mt6589_compat = { @@ -240,6 +245,7 @@ struct mtk_i2c { .aux_len_reg = 0, .support_33bits = 0, .timing_adjust = 0, + .dma_sync = 0, }; static const struct mtk_i2c_compatible mt7622_compat = { @@ -251,6 +257,7 @@ struct mtk_i2c { .aux_len_reg = 1, .support_33bits = 0, .timing_adjust = 0, + .dma_sync = 0, }; static const struct mtk_i2c_compatible mt8173_compat = { @@ -261,6 +268,7 @@ struct mtk_i2c { .aux_len_reg = 1, .support_33bits = 1, .timing_adjust = 0, + .dma_sync = 0, }; static const struct of_device_id mtk_i2c_of_match[] = { @@ -360,6 +368,9 @@ static void mtk_i2c_init_hw(struct mtk_i2c *i2c) control_reg = I2C_CONTROL_ACKERR_DET_EN | I2C_CONTROL_CLK_EXT_EN | I2C_CONTROL_DMA_EN; + if (i2c->dev_comp->dma_sync) + control_reg |= I2C_CONTROL_DMAACK_EN | I2C_CONTROL_ASYNC_MODE; + mtk_i2c_writew(i2c, control_reg, OFFSET_CONTROL); mtk_i2c_writew(i2c, I2C_DELAY_LEN, OFFSET_DELAY_LEN); -- 1.7.9.5