Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp574607img; Tue, 26 Feb 2019 05:12:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IYo6QqCeWEy+wMcTGLaufP6QvTrdPVkxXFPeaEld3ifMapY9C244aIVf+TUeCN++J/HekmA X-Received: by 2002:a17:902:6804:: with SMTP id h4mr26021594plk.115.1551186745757; Tue, 26 Feb 2019 05:12:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551186745; cv=none; d=google.com; s=arc-20160816; b=VkYGsApJiLKkveLaNOIeIY5bWRMWIX0oh9P5qHEwSOSknzWXctFNZZP7VeuxO8G4xO wgo/3YUILogQQXaD8k+8I8VqNnXZvMgPQz0qkerCX0J5cgSrb1gr0doueELrQl8d9zjZ 3OZB+NDMCh0omwEec2Sz2VOD0I7dY5mVFMnMuKnySiQUmjevjU3RjihnumfoJflcm+ls Ap981J6MNLL2N+TsmBcppn5N5X08S3D3D9+gaGMzIaYLyjM+iLosKXgRWk0J4qNXfvKq iKo2KeTUR7jmAVnnluQXPtCg7Us0afYu842mI9DNj2Ksrsd9Jzodqg8A1jEl09sfjbOp v4jA== 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=pXXehR0aLRI7qzXuXhLrUnzwgfVYacAwEgVBS0dhK18=; b=fhlwQXtY2IU3do6oqsVzTd8YWaS8pmgrSy3Ph0HDIyG0e+bprDbG2NjZmfNj9/wihv We++7Xeos3E0nG9nqTQ+scXvwP0is43Bk+TmTqPMgxKjrv409bimVG2lZVakxwMENZli 2Zh7KLXazR/TvZiXsV1Y6uPB+BuOwuYB/v5M1jlA3x1BI5KuwFjMIvS6eSdzbpMc8Lw2 1mG2sOiYZg3zRtSt1hRzkdFG5pN5615eBGiIw8ie+aWSUTevvmp5ctwOuEREhAmcWRJk SNwfUOOu7ZWME5CAt7klo4gPNBKL0kRC3bmOr+sk5xlqz8K13boeMTmfY6P7owPf79Ot ogIA== 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 c21si12002198pfd.55.2019.02.26.05.12.10; Tue, 26 Feb 2019 05:12:25 -0800 (PST) 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 S1727271AbfBZNLl (ORCPT + 99 others); Tue, 26 Feb 2019 08:11:41 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:52833 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726524AbfBZNLi (ORCPT ); Tue, 26 Feb 2019 08:11:38 -0500 X-UUID: 4338a9c5b58e487b8b17127128b6d43b-20190226 X-UUID: 4338a9c5b58e487b8b17127128b6d43b-20190226 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1589511929; Tue, 26 Feb 2019 21:11:32 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 26 Feb 2019 21:11:31 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 26 Feb 2019 21:11:31 +0800 From: Qii Wang To: CC: , , , , , , , , , , Subject: [PATCH v5 4/5] i2c: mediatek: Add i2c and apdma sync in i2c driver Date: Tue, 26 Feb 2019 21:10:59 +0800 Message-ID: <1551186660-16902-5-git-send-email-qii.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1551186660-16902-1-git-send-email-qii.wang@mediatek.com> References: <1551186660-16902-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 --- 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 14d6b38..75d88e1 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