Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4685496imb; Wed, 6 Mar 2019 21:00:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyVWUuqdUiOd04kqDvWFjjXFlOmgvrnZCWFddLdx4EZ1VjhSouZlOlV592WP3DPZNNhNFil X-Received: by 2002:a17:902:900a:: with SMTP id a10mr11065619plp.183.1551934810940; Wed, 06 Mar 2019 21:00:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551934810; cv=none; d=google.com; s=arc-20160816; b=xNaZnaDP53U15M0sR7543wmuSt5AozYE3AqwW335Z6yZJLEbrACVCIPeuPkD/7SZ09 9KSDKeYoXnoNcLfDxi47JD9NrI3rxwh7TAa2tPmi6viBw2O7ComUrymwgaBIOEM4GoGE QVuZpmAGKfN4oojJ1Z8WrRY8l0VDt66kfmvTIwFVLFwHFK6AKQx8WK55eH6Ijnhi7Ja/ zt1Nghsp1GfG/7AnkexKoDltvruxXRrffxItZcFP6gBTuo8O2pgWTND1SVjOvLdPpcek KAFtDHz4lKbWTCI0M1DP/37l/4a/Yg3e6tUjK78FCMsfjJhMmRUE0Lp/ClPnhDQ6qxSV Auew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=X4MPEFHn+rYk8WzOoJdK0/UXiNi/lW1p5oAEGiPqDNs=; b=k19BK6ZLDibwKKFAMBjB5Ft05OqBRRmZ+vlO5DzdFFIQzQop7frZucwg8TyGsIk5UA 6GFr+JzHuMgiGjQDzWWcxjRtvBa90SRk/xqaxrkOa+vE0fLKwK0FASJvFTF+Bb8n6egp bf0ag7ScG65FDHFsD9UzZWSUKD3t78tv9j0rhOnUkMRp8HA8RGDO+lAEN32pBAbesyEh MMci+U/TMM70i+qj2zSX5zFFCaw9WyMPoBewy4nOP4wJKxWcRa9+JzCIEalim66BvE6G r5XYjWOpNTCvMlz356iUG5PvEyt4OSgYGS6KMLfFPqhXm3qo+PJPJOJEMUV5S7Th6spP iiBA== 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 22si3068690pgs.336.2019.03.06.20.59.55; Wed, 06 Mar 2019 21:00:10 -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 S1726597AbfCGE6I (ORCPT + 99 others); Wed, 6 Mar 2019 23:58:08 -0500 Received: from mailgw02.mediatek.com ([1.203.163.81]:8522 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726127AbfCGE6I (ORCPT ); Wed, 6 Mar 2019 23:58:08 -0500 X-UUID: 53ec318dcbf743ab9b199bfe5cd5c022-20190307 X-UUID: 53ec318dcbf743ab9b199bfe5cd5c022-20190307 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 828892857; Thu, 07 Mar 2019 12:57:59 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 7 Mar 2019 12:57:58 +0800 Received: from [10.17.3.153] (172.27.4.253) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 7 Mar 2019 12:57:57 +0800 Message-ID: <1551934677.30363.55.camel@mhfsdcap03> Subject: Re: [PATCH v5 3/5] i2c: mediatek: Add arb clock in i2c driver From: Qii Wang To: Nicolas Boichat CC: , , , linux-arm Mailing List , lkml , "moderated list:ARM/Mediatek SoC support" , srv_heupstream , Leilk Liu , , , Rob Herring Date: Thu, 7 Mar 2019 12:57:57 +0800 In-Reply-To: References: <1551186660-16902-1-git-send-email-qii.wang@mediatek.com> <1551186660-16902-4-git-send-email-qii.wang@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-03-06 at 18:49 +0800, Nicolas Boichat wrote: > One thing I missed from Matthias' comment on v4: > https://patchwork.kernel.org/patch/10822083/ > > On Wed, Mar 6, 2019 at 6:44 PM Nicolas Boichat wrote: > > > > On Tue, Feb 26, 2019 at 9:11 PM Qii Wang wrote: > > > > > > When two i2c controllers are internally connected to the same > > > GPIO pins, the arb clock is needed to ensure that the waveforms > > > do not interfere with each other. > > > > > > Signed-off-by: Qii Wang > > > > Reviewed-by: Nicolas Boichat > > > > > --- > > > drivers/i2c/busses/i2c-mt65xx.c | 25 ++++++++++++++++++++++--- > > > 1 file changed, 22 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c > > > index 428ac99..14d6b38 100644 > > > --- a/drivers/i2c/busses/i2c-mt65xx.c > > > +++ b/drivers/i2c/busses/i2c-mt65xx.c > > > @@ -35,6 +35,7 @@ > > > #include > > > > > > #define I2C_RS_TRANSFER (1 << 4) > > > +#define I2C_ARB_LOST (1 << 3) > > > #define I2C_HS_NACKERR (1 << 2) > > > #define I2C_ACKERR (1 << 1) > > > #define I2C_TRANSAC_COMP (1 << 0) > > > @@ -181,6 +182,7 @@ struct mtk_i2c { > > > struct clk *clk_main; /* main clock for i2c bus */ > > > struct clk *clk_dma; /* DMA clock for i2c via DMA */ > > > struct clk *clk_pmic; /* PMIC clock for i2c from PMIC */ > > > + struct clk *clk_arb; /* Arbitrator clock for i2c */ > > > bool have_pmic; /* can use i2c pins from PMIC */ > > > bool use_push_pull; /* IO config push-pull mode */ > > > > > > @@ -299,8 +301,18 @@ static int mtk_i2c_clock_enable(struct mtk_i2c *i2c) > > > if (ret) > > > goto err_pmic; > > > } > > > + > > > + if (i2c->clk_arb) { > > > + ret = clk_prepare_enable(i2c->clk_arb); > > > + if (ret) > > > + goto err_arb; > > > + } > > > + > > > return 0; > > > > > > +err_arb: > > > + if (i2c->have_pmic) > > > + clk_disable_unprepare(i2c->clk_pmic); > > > err_pmic: > > > clk_disable_unprepare(i2c->clk_main); > > > err_main: > > > @@ -311,6 +323,9 @@ static int mtk_i2c_clock_enable(struct mtk_i2c *i2c) > > > > > > static void mtk_i2c_clock_disable(struct mtk_i2c *i2c) > > > { > > > + if (i2c->clk_arb) > > > + clk_disable_unprepare(i2c->clk_arb); > > > + > > > if (i2c->have_pmic) > > > clk_disable_unprepare(i2c->clk_pmic); > > > > > > @@ -519,13 +534,13 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, > > > > > > /* Clear interrupt status */ > > > mtk_i2c_writew(i2c, restart_flag | I2C_HS_NACKERR | I2C_ACKERR | > > > - I2C_TRANSAC_COMP, OFFSET_INTR_STAT); > > > + I2C_ARB_LOST | I2C_TRANSAC_COMP, OFFSET_INTR_STAT); > > Is it ok to set I2C_ARB_LOST on _all_ SoC that this driver supports? > If so, please at least say so in the commit message. > Yes, old and new SoC have the I2C_ARB_LOST bit, but there was no need for multi-master before, so we didn't set it up specifically, I have test the patch on the old SoCs. I will add a note in the commit message. > > > > > > mtk_i2c_writew(i2c, I2C_FIFO_ADDR_CLR, OFFSET_FIFO_ADDR_CLR); > > > > > > /* Enable interrupt */ > > > mtk_i2c_writew(i2c, restart_flag | I2C_HS_NACKERR | I2C_ACKERR | > > > - I2C_TRANSAC_COMP, OFFSET_INTR_MASK); > > > + I2C_ARB_LOST | I2C_TRANSAC_COMP, OFFSET_INTR_MASK); > > > > > > /* Set transfer and transaction len */ > > > if (i2c->op == I2C_MASTER_WRRD) { > > > @@ -659,7 +674,7 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, > > > > > > /* Clear interrupt mask */ > > > mtk_i2c_writew(i2c, ~(restart_flag | I2C_HS_NACKERR | I2C_ACKERR | > > > - I2C_TRANSAC_COMP), OFFSET_INTR_MASK); > > > + I2C_ARB_LOST | I2C_TRANSAC_COMP), OFFSET_INTR_MASK); > > > > > > if (i2c->op == I2C_MASTER_WR) { > > > dma_unmap_single(i2c->dev, wpaddr, > > > @@ -884,6 +899,10 @@ static int mtk_i2c_probe(struct platform_device *pdev) > > > return PTR_ERR(i2c->clk_dma); > > > } > > > > > > + i2c->clk_arb = devm_clk_get(&pdev->dev, "arb"); > > > + if (IS_ERR(i2c->clk_arb)) > > > + i2c->clk_arb = NULL; > > > + > > > clk = i2c->clk_main; > > > if (i2c->have_pmic) { > > > i2c->clk_pmic = devm_clk_get(&pdev->dev, "pmic"); > > > -- > > > 1.7.9.5 > > >