All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: AngeloGioacchino Del Regno  <angelogioacchino.delregno@somainline.org>
Cc: agross@kernel.org, linux-kernel@vger.kernel.org,
	konrad.dybcio@somainline.org, marijn.suijten@somainline.org,
	martin.botka@somainline.org, robh+dt@kernel.org,
	devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-i2c@vger.kernel.org, phone-devel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] i2c: qup: Introduce SCL/SDA noise rejection
Date: Thu, 14 Jan 2021 11:57:26 -0600	[thread overview]
Message-ID: <YACGBnAbHllCdGNw@builder.lan> (raw)
In-Reply-To: <20210114174909.399284-3-angelogioacchino.delregno@somainline.org>

On Thu 14 Jan 11:49 CST 2021, AngeloGioacchino Del Regno wrote:

> Some I2C devices may be glitchy due to electrical noise coming
> from the device itself or because of possible board design issues.
> To overcome this issue, the QUP's I2C in Qualcomm SoCs supports
> a noise rejection setting for both SCL and SDA lines.
> 
> Introduce a setting for noise rejection through device properties,
> "qcom,noise-reject-sda" and "qcom,noise-reject-scl", which will
> be used to set the level of noise rejection sensitivity.
> If the properties are not specified, noise rejection will not be
> enabled.
> 

This looks reasonable, just some small nits below.

> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
> ---
>  drivers/i2c/busses/i2c-qup.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
> index 5a47915869ae..af51234a60ba 100644
> --- a/drivers/i2c/busses/i2c-qup.c
> +++ b/drivers/i2c/busses/i2c-qup.c
> @@ -8,6 +8,7 @@
>  #include <linux/acpi.h>
>  #include <linux/atomic.h>
>  #include <linux/clk.h>
> +#include <linux/bitfield.h>

If you move this one step up you'll maintain the sort order.

>  #include <linux/delay.h>
>  #include <linux/dmaengine.h>
>  #include <linux/dmapool.h>
> @@ -39,6 +40,8 @@
>  #define QUP_MX_READ_CNT		0x208
>  #define QUP_IN_FIFO_BASE	0x218
>  #define QUP_I2C_CLK_CTL		0x400
> +#define  QUP_I2C_CLK_CTL_SDA_NR	GENMASK(27, 26)
> +#define  QUP_I2C_CLK_CTL_SCL_NR	GENMASK(25, 24)
>  #define QUP_I2C_STATUS		0x404
>  #define QUP_I2C_MASTER_GEN	0x408
>  
> @@ -1663,6 +1666,7 @@ static int qup_i2c_probe(struct platform_device *pdev)
>  	int ret, fs_div, hs_div;
>  	u32 src_clk_freq = DEFAULT_SRC_CLK;
>  	u32 clk_freq = DEFAULT_CLK_FREQ;
> +	u32 noise_reject_scl = 0, noise_reject_sda = 0;

You shouldn't need to initialize these, device_property_read_u32() won't
return 0 without updating them.

>  	int blocks;
>  	bool is_qup_v1;
>  
> @@ -1860,6 +1864,19 @@ static int qup_i2c_probe(struct platform_device *pdev)
>  		qup->clk_ctl = ((fs_div / 2) << 16) | (hs_div << 8) | (fs_div & 0xff);
>  	}
>  
> +	/* SCL/SDA Noise rejection (optional) */
> +	ret = device_property_read_u32(qup->dev, "qcom,noise-reject-scl",
> +				      &noise_reject_scl);
> +	if (ret == 0)
> +		qup->clk_ctl |= FIELD_PREP(QUP_I2C_CLK_CTL_SCL_NR,
> +					   noise_reject_scl);

I would prefer if you didn't break this line.

> +
> +	ret = device_property_read_u32(qup->dev, "qcom,noise-reject-sda",
> +				      &noise_reject_sda);
> +	if (ret == 0)
> +		qup->clk_ctl |= FIELD_PREP(QUP_I2C_CLK_CTL_SDA_NR,
> +					   noise_reject_sda);

Ditto.

Regards,
Bjorn

> +
>  	/*
>  	 * Time it takes for a byte to be clocked out on the bus.
>  	 * Each byte takes 9 clock cycles (8 bits + 1 ack).
> -- 
> 2.29.2
> 

  reply	other threads:[~2021-01-14 17:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 17:49 [PATCH v2 0/3] QCOM QUP I2C - Add noise rejection, convert to YAML AngeloGioacchino Del Regno
2021-01-14 17:49 ` [PATCH v2 1/3] dt-bindings: i2c: qcom,i2c-qup: Convert txt to YAML schema AngeloGioacchino Del Regno
2021-01-14 17:49 ` [PATCH v2 2/3] i2c: qup: Introduce SCL/SDA noise rejection AngeloGioacchino Del Regno
2021-01-14 17:57   ` Bjorn Andersson [this message]
2021-01-14 17:49 ` [PATCH v2 3/3] dt-bindings: i2c: qcom,i2c-qup: Document noise rejection properties AngeloGioacchino Del Regno
2021-01-14 17:58   ` Bjorn Andersson
2021-01-14 18:05     ` AngeloGioacchino Del Regno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YACGBnAbHllCdGNw@builder.lan \
    --to=bjorn.andersson@linaro.org \
    --cc=agross@kernel.org \
    --cc=angelogioacchino.delregno@somainline.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konrad.dybcio@somainline.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=martin.botka@somainline.org \
    --cc=phone-devel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.