Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp798957imc; Sun, 10 Mar 2019 22:42:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeTe/oMUJl8/fm9ridQa7hzjXYeLNajhH6TI42QXh8MIKfXVoQ96wLSZAi7MpTSpQOfXHS X-Received: by 2002:a17:902:b492:: with SMTP id y18mr31838797plr.175.1552282942230; Sun, 10 Mar 2019 22:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552282942; cv=none; d=google.com; s=arc-20160816; b=f9K5+r5VUUlPwrxK+ICseusYrPZjGjC5M4yf2kP662/GWu/aGZksQHz4YW6/n2s2us l1a7XwqOegJfDNx5fdN7M1KG5us7oYESq91/BR6f27XcZg200+Ou+nTKNfRLTTbJzBLe Q86y8Mjyhz/lgJ3apvlWkbcnV9qa6nkk/bRMAfYjWhfbPudLhgdvJFZbDYYjsk6kr0Nj yD7yNKoEPfXn0WN9FXp9ksiymNlG9WfxmC6jtCxWMoFmgVmdlbUQuEZkQ2v9yDdvpu1Q wNdaBX/Xzm5EFTrMf5aBAxOig1GfxtVnj2QOcQdswan8n6Cv06zrp11zDZLY8oNSzGem 2IkA== 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=g5bZpdmw3I3EUwC58KWr6RSeVbFYo9idNLd03wBAcBksfhKQrS78l2FcFqYyT67Goh lRzsgbITPGN+VrRZeRvsR1VNGBlxqVEW4Po1Ihlb3JQrbrWYpiPa94eXNK9z8HFn+f/9 dHxz4A795wMEFZCPlntYso53jFOcqGVss0VU9lCQm/U/cREo6P2p5WIyVY2PcwtI6iuY 5ik0HyVVlof876dA9rGGUNnlbhai58Ox9/FwJIyp5ld9PSd9PgM6p5rXGd1NOOv5NRpy QOnvjBKeQSpvYdB/qQDrZjee1cY4LvaZ0iwQSw196jdFfxzBxT6Fy6/3siS7L52qPGIO zFaA== 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 23si4292116pgc.220.2019.03.10.22.42.06; Sun, 10 Mar 2019 22:42:22 -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 S1726655AbfCKFlY (ORCPT + 99 others); Mon, 11 Mar 2019 01:41:24 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:24782 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726567AbfCKFlX (ORCPT ); Mon, 11 Mar 2019 01:41:23 -0400 X-UUID: 68ffc28792fe44c69066f10b7a1c3793-20190311 X-UUID: 68ffc28792fe44c69066f10b7a1c3793-20190311 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 157929164; Mon, 11 Mar 2019 13:41:16 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 11 Mar 2019 13:41: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; Mon, 11 Mar 2019 13:41:10 +0800 From: Qii Wang To: CC: , , , , , , , , , , Subject: [PATCH v6 4/6] i2c: mediatek: Add i2c and apdma sync in i2c driver Date: Mon, 11 Mar 2019 13:40:38 +0800 Message-ID: <1552282840-12778-5-git-send-email-qii.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1552282840-12778-1-git-send-email-qii.wang@mediatek.com> References: <1552282840-12778-1-git-send-email-qii.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 59F907CC2C80A94B60F21362E48223A79055842444E5E5838767CF9DFCEB56B72000:8 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