From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EEACC43381 for ; Thu, 7 Mar 2019 04:58:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E3B720835 for ; Thu, 7 Mar 2019 04:58:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KPEyRT2X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E3B720835 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=b6WV847+8bEI9frO9YwiArB6IowKKSVgzFcmaMWIqEM=; b=KPEyRT2X5stQq8 UndDtnqhLf0MKeOVzPB369Hnn1ArekM1KfHgGUZ82wrHyBps57O0oXgKpQmaSu+QNOCbdlh77CLW1 MijwmTitbHm3kAWy/yDP+7CKPEaZruxagD23bPdVC1dzfWSSMM+AyCnfOvn8UcidMPbQ0XlUbdu80 j5qL0GdI55Nu48tpzqN5LndmovuwKbHnz4sMLQauKRS5I34yBI71RNUHhgNz32Pm2zAPm00sbLdtZ EmDxi5U16VpmIyIV/leZTQzfHPbgb6JW13NheKrHYX3qX8GT79AkeFkAc550JYCYSE+usTsGsZlYG +Her/nmO4FuEzM+oaDzQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1l6p-0006VP-KR; Thu, 07 Mar 2019 04:58:19 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h1l6k-0006UX-FR; Thu, 07 Mar 2019 04:58:16 +0000 X-UUID: e6f7e9994b4c44f4bb9ab76cc8b15ef9-20190306 X-UUID: e6f7e9994b4c44f4bb9ab76cc8b15ef9-20190306 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 2052830618; Wed, 06 Mar 2019 20:58:02 -0800 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 6 Mar 2019 20:58:00 -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 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> X-Mailer: Evolution 3.2.3-0ubuntu6 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190306_205814_523953_FE0AF4C5 X-CRM114-Status: GOOD ( 22.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, srv_heupstream , wsa@the-dreams.de, Leilk Liu , xinping.qian@mediatek.com, lkml , liguo.zhang@mediatek.com, "moderated list:ARM/Mediatek SoC support" , linux-i2c@vger.kernel.org, Rob Herring , linux-arm Mailing List Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel