Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp889307imc; Mon, 11 Mar 2019 01:30:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWxflz41g6ANeXeoHqkZcbRsJdJf0yG5IwnAaqaSp0StfjjwxGBtvQFj38AGyroDO3bQlt X-Received: by 2002:a62:1752:: with SMTP id 79mr31731309pfx.127.1552293047866; Mon, 11 Mar 2019 01:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552293047; cv=none; d=google.com; s=arc-20160816; b=aT575WzBkLJax5u/HrGVJ3NZIX6675uAGf7sxOICY4bgCUazN6JwrF69dPSSFtVB+U G2szSsHHHx+o2hmR4seZTjk80UT/SJ+qCux2ogvvV57Xj0SJmvs8eB5SCwNFz+W3hdLi VrcwDQQfyddE2Uf8ihR2PkAZPbkk+b/YKQwL5xr/3gCSHgShhFDZkvKL6o11ucEIeE0s S+NPPMtvOQWyVJfdp+GCrv1qx86JjujmWjpXzV7flFHaXCC/k5ceFev9EgqCN4L8Dq+C rL0rj2wyoTT5nFTF1VIbLqOboWAKzzv7TVusAqv5fE73aqOcAmGdjNKuNJl4fTUe+SnW 8wiQ== 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=u/g68vjKtnqkumh5ZxD32tljZq9+3YSH18gcmZETy8Q=; b=swKk2ZE965UJx958PP/6tYJ8AyosmvqXKRFUkLpmELPwKWgtE7Z9VONQvmM8MaNrRe 3/cviuvFXGa3sgaZ5RVWn/DBRW604wSik7mxq/Ql8ZVOgnsYo2/X3ZnsW7H07Ncyp9sE y36A2Cc6J2bfzLjyh/ltKnqebJsvKXy93Ye20xsbX1GIlVR8b6TT1IKKzQN4stRxtCJu X1ps24U3o+UTNRzuGrvKMAFYVUAoS6vxinBYQCKaMSoHU5ALuSuD4FZKTcvyIcOv66Eo RQrVX9aLbB39nYwqlypezokpnCCGdyou8RUCsu69aYDslSNSW2XkWKhVv/HXQciVSjL+ MtnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="GTu/XCj8"; 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 a5si4561049pfo.116.2019.03.11.01.30.31; Mon, 11 Mar 2019 01:30:47 -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; dkim=pass header.i=@chromium.org header.s=google header.b="GTu/XCj8"; 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 S1726770AbfCKI2j (ORCPT + 99 others); Mon, 11 Mar 2019 04:28:39 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:46587 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbfCKI2j (ORCPT ); Mon, 11 Mar 2019 04:28:39 -0400 Received: by mail-qt1-f193.google.com with SMTP id z25so4062939qti.13 for ; Mon, 11 Mar 2019 01:28:38 -0700 (PDT) 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=u/g68vjKtnqkumh5ZxD32tljZq9+3YSH18gcmZETy8Q=; b=GTu/XCj8NRFw3YGg/JjiV2JU8xxkHaL36MHcUvn2ZMrxqNX+GVwuUHuBZMIochQCa2 ehG5+GWvW3WfFQDjSC4wjaFRL98/IrZnijO+zD2ofI8kspaDkkc/hM/qTITdjIjSfGxA wltw9Rfx5W9+zhx4fzSe6C65ctSiAz8nYbm0c= 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=u/g68vjKtnqkumh5ZxD32tljZq9+3YSH18gcmZETy8Q=; b=UKOHBA1jHUqLHoVj93MpsdmmUD8PINak3+A1ABBIMydOhND0q6OXip00TlkUgNUgnt qhrl+YyCRCp/E3HHBYbEo2mPlXSrJ3basDxyq9nfIMenmNXRDyew3wknFTeM9EpAIu4G VIfhTczKxW1Xbt4PEg+avkZza/Sa0TrMlIqhYm2tQ1CW6Ky2nW3OyjnPO9inFxeUfsNw 5e8uDetBhrHTcCN7rHMDrPTp1VL2IIGGqbjvHHUhqwop1LFPsH/r5ZXp0YjoSlIRGAKg F3udnssGZsPe4UHRGiG4rMCRZRT/pDCHAUxi0iX1qA0cnhxEBjNYYMZ9BCubGdn9LQ3W C+3A== X-Gm-Message-State: APjAAAX8mk+Ts1N5OvGTzzBrkI5QtJjp52vWI3h3tyjv8LAx7pxBa3mq K/lNj8L4KTvmEKvQcc7qOpz+GTGdlc9zKZGbv1icsA== X-Received: by 2002:ac8:2805:: with SMTP id 5mr24938833qtq.75.1552292917856; Mon, 11 Mar 2019 01:28:37 -0700 (PDT) MIME-Version: 1.0 References: <1552282840-12778-1-git-send-email-qii.wang@mediatek.com> <1552282840-12778-4-git-send-email-qii.wang@mediatek.com> In-Reply-To: <1552282840-12778-4-git-send-email-qii.wang@mediatek.com> From: Nicolas Boichat Date: Mon, 11 Mar 2019 16:28:26 +0800 Message-ID: Subject: Re: [PATCH v6 3/6] 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 , Matthias Brugger 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 Mon, Mar 11, 2019 at 1:41 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. And we also need to enable > the interrupt to find arb lost, old i2c controllers also have > the bit. > > Signed-off-by: Qii Wang I'll let Matthias comment too (I think the comment above is just enough), but otherwise: 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 be36018..1a7235e 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 >