Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4018923imb; Wed, 6 Mar 2019 03:18:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwp9bP6FWouwvVMEm/qAqLBNm5Nx/SbU+i12dSYnWA70IcmsqinZMcy0xWOHAIl9lxP6tu2 X-Received: by 2002:a17:902:b609:: with SMTP id b9mr6495758pls.134.1551871109875; Wed, 06 Mar 2019 03:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551871109; cv=none; d=google.com; s=arc-20160816; b=xcKuJqNKWXBrJh2pIK8EIHCSFneM2YgAvIzpF37SfJRbs9t6xcr5lyHHs5fyAT16UE Dxy9ouzQC80eJtuskggUIumG90V/varb6YalWMG14zLTq/CO9n018mY1nIrkqceESyE0 MWsFi0F+anTXwcbHl/nHBTLe24oYtrOntIPROf2MhuqyLH862CL9XIR2hqbjRzG9HPK4 QRh490zTXwy8FXllRlvDm4PJ9W04V1m9XwW8E69Q56JFk3VBnqfMyF5mUJN0rIH4dKDn K59exHQ5cfxm5ahSz4aEud0ByNi8LUTr+w2ocUZI6lOqfbcaWcPTeBMNbn2au+fQKAxl 6JWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Q0LFmcE09YMfyBgiDrvHfDxJYLJ9mk0yY5XqqNC/7Rk=; b=PDHcU1Rd3IPyZuz1rXeE3dJxVEo0xyUqdUpLAnU8k4L2DD/B0+fVOjywvE6aIEppZB ah1odtRqZPH+IAj7ch96qiEunlC9mYYuJHCaINaVH41et+NqI6ygTwqCtxyPh+MK0jsy 3JwTUNT4PbBZoCXDLgXM1glazuAHpe06BQx0ctwyj9zOn6oRwfCfhz0h/tceaYYIOL53 QvgX5+atbRk+q6PnrSJhMfQxOmGhYiYFiAcD5dUjPhUIhXdp4Zc6uXx2BO1FqPVGGemY EcTHJ6wqS6WFKpbCgm/huQwNiowi4ZcGohjxUj5ZXVZrZmZ/zkLXjSiIhHTqHfIJOXOs LCaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VSVmBtDK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i7si1189893pgs.147.2019.03.06.03.18.14; Wed, 06 Mar 2019 03:18:29 -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; dkim=pass header.i=@chromium.org header.s=google header.b=VSVmBtDK; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729665AbfCFKoS (ORCPT + 99 others); Wed, 6 Mar 2019 05:44:18 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:43786 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729605AbfCFKoS (ORCPT ); Wed, 6 Mar 2019 05:44:18 -0500 Received: by mail-qt1-f196.google.com with SMTP id y4so12244549qtc.10 for ; Wed, 06 Mar 2019 02:44:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q0LFmcE09YMfyBgiDrvHfDxJYLJ9mk0yY5XqqNC/7Rk=; b=VSVmBtDK1/RF6bBKBKgH0aPbl1P1tcT+MWbwEWKFgbWHluboVvOJcLCPhLqQTtfJGE bauS4jza4hx1+CjAOCJHBX/R4TYDV3ckG6Dy8Jot4Jf7458MDMXVw6Ubk08iiDLiYYU8 vSWPgNS9u7+AobwW4D2v3SA0iuzJvStdYvdc8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q0LFmcE09YMfyBgiDrvHfDxJYLJ9mk0yY5XqqNC/7Rk=; b=VlOUXCtPTn84yz93mo6xPL9+SHSQnAk8fhitgz7gWbHp1jnfsSZ4Xkc3bpp+30VRK4 JrICAJtaQAAHRbytngOuXIchBPxZvDgXjCZYrEwnf6bbf0E9HchUVPricLK/PygM9D/V OAowkv4qOR64su4U9CLdYVMJlgjeyg66PsPgPZmNrbW9gH6kW9FNlt1vLY9RFCVoEIFj OsJpD8JuEKdoZsdUV3+pUz9oSeoBvAXrHYIsnHpOglzxpF8Ys8IFlZUqketzDW3/aDHo pH0MV9M0Y6gSKbap40rUZQK3DelTwrS5u9HaM044RLo4wGkZiLVzLc/tQGnEgHYqXdB+ UfIg== X-Gm-Message-State: APjAAAUf2m69iWSqvWeK8SEBMb2uCYeDPDqHCBoz+5BdVs3i9k1mQETB Z6LXb5V0QnmPLrxk5Y7e7L/3efjRLSqR7pY9lcg5aw== X-Received: by 2002:aed:253a:: with SMTP id v55mr5219606qtc.339.1551869056544; Wed, 06 Mar 2019 02:44:16 -0800 (PST) MIME-Version: 1.0 References: <1551186660-16902-1-git-send-email-qii.wang@mediatek.com> <1551186660-16902-4-git-send-email-qii.wang@mediatek.com> In-Reply-To: <1551186660-16902-4-git-send-email-qii.wang@mediatek.com> From: Nicolas Boichat Date: Wed, 6 Mar 2019 18:44:05 +0800 Message-ID: Subject: Re: [PATCH v5 3/5] i2c: mediatek: Add arb clock in i2c driver To: Qii Wang Cc: wsa@the-dreams.de, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-arm Mailing List , lkml , "moderated list:ARM/Mediatek SoC support" , srv_heupstream , Leilk Liu , xinping.qian@mediatek.com, liguo.zhang@mediatek.com, Rob Herring Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); > > 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 >