All of lore.kernel.org
 help / color / mirror / Atom feed
From: atull <atull@opensource.altera.com>
To: Romain Baeriswyl <Romain.Baeriswyl@abilis.com>
Cc: Wolfram Sang <wsa@the-dreams.de>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Christian Ruppert <christian.ruppert@abilis.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	<linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Mark Rutland <mark.rutland@arm.com>, <baruch@tkos.co.il>,
	<grant.likely@linaro.org>, <robh+dt@kernel.org>,
	<skuribay@pobox.com>, <alan@linux.intel.com>,
	<devicetree@vger.kernel.org>, <delicious.quinoa@gmail.com>,
	<dinguyen@opensource.altera.com>,
	<yvanderv@opensource.altera.com>,
	Romain Baeriswyl <romainba@abilis.com>
Subject: Re: [PATCH] i2c designware add support of I2C standard mode
Date: Wed, 20 Aug 2014 10:25:40 -0500	[thread overview]
Message-ID: <alpine.DEB.2.02.1408201021440.11079@atx-linux-37> (raw)
In-Reply-To: <alpine.DEB.2.02.1408200928130.11079@atx-linux-37>

On Wed, 20 Aug 2014, atull wrote:

> 
> 
> On Wed, 20 Aug 2014, Romain Baeriswyl wrote:
> 
> > From: Romain Baeriswyl <Romain.Baeriswyl@abilis.com>
> > 
> > Some legacy devices support ony I2C standard mode at 100kHz.
> > This patch allows to select the standard mode through the DTS
> > with the use of the existing clock-frequency parameter.
> > 
> > When clock-frequency parameter is not set, the fast mode is selected.
> > Only when the parameter is set at 100000, the standard mode is selected.
> > 
> > Signed-off-by: Romain Baeriswyl <romainba@abilis.com>
> > Reviewed-by: Christian Ruppert <christian.ruppert@abilis.com>
> > ---
> >  drivers/i2c/busses/i2c-designware-platdrv.c |   23 +++++++++++++++++++++--
> >  1 files changed, 21 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> > index 402ec39..b543fe1 100644
> > --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> > +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> > @@ -122,6 +122,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
> >  	struct i2c_adapter *adap;
> >  	struct resource *mem;
> >  	int irq, r;
> > +	u32 clk_freq;
> >  
> >  	irq = platform_get_irq(pdev, 0);
> >  	if (irq < 0) {
> > @@ -151,6 +152,9 @@ static int dw_i2c_probe(struct platform_device *pdev)
> >  		return PTR_ERR(dev->clk);
> >  	clk_prepare_enable(dev->clk);
> >  
> > +	/* fast mode by default because of legacy reasons */
> > +	clk_freq = 400000;
> > +
> >  	if (pdev->dev.of_node) {
> >  		u32 ht = 0;
> >  		u32 ic_clk = dev->get_clk_rate_khz(dev);
> > @@ -166,6 +170,17 @@ static int dw_i2c_probe(struct platform_device *pdev)
> >  		of_property_read_u32(pdev->dev.of_node,
> >  				     "i2c-scl-falling-time-ns",
> >  				     &dev->scl_falling_time);
> > +
> > +		of_property_read_u32(pdev->dev.of_node, "clock-frequency",
> > +				     &clk_freq);
> > +
> > +		/* Only standard mode at 100kHz and fast mode at 400kHz
> > +		 * are supported.
> > +		 */
> > +		if (clk_freq != 100000 && clk_freq != 400000) {
> > +			dev_err(&pdev->dev, "Only 100kHz and 400kHz supported");
> > +			return -EINVAL;
> > +		}
> 
> Hi Romain,
> 
> It is common to operate i2c at <100KHz on boards that have i2c 
> issues.  I am using this driver at 50KHz because I have a LCD module 
> that just doesn't work at a full 100KHz.  Please remove the check for 
> these two frequency points.
> 
> >  	}
> >  
> >  	dev->functionality =
> > @@ -175,8 +190,12 @@ static int dw_i2c_probe(struct platform_device *pdev)
> >  		I2C_FUNC_SMBUS_BYTE_DATA |
> >  		I2C_FUNC_SMBUS_WORD_DATA |
> >  		I2C_FUNC_SMBUS_I2C_BLOCK;
> > -	dev->master_cfg =  DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
> > -		DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST;
> > +	if (clk_freq == 100000)
> 
> Please change to <=
> 

Hi Romain,

This looks fine to me, my "<= issues" are not important as this isn't 
really setting a frequency, but just setting a bit that controls speed.

Acked-by: Alan Tull <atull@opensource.altera.com>


> > +		dev->master_cfg =  DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
> > +			DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_STD;
> > +	else
> > +		dev->master_cfg =  DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
> > +			DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST;
> >  
> >  	/* Try first if we can configure the device from ACPI */
> >  	r = dw_i2c_acpi_configure(pdev);
> > -- 
> > 1.7.1
> > 
> > 
> 

WARNING: multiple messages have this Message-ID (diff)
From: atull <atull-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>
To: Romain Baeriswyl
	<Romain.Baeriswyl-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	Mika Westerberg
	<mika.westerberg-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Christian Ruppert
	<christian.ruppert-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>,
	"Rafael J. Wysocki"
	<rafael.j.wysocki-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	skuribay-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org,
	alan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	delicious.quinoa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	dinguyen-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org,
	yvanderv-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org,
	Romain Baeriswyl
	<romainba-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] i2c designware add support of I2C standard mode
Date: Wed, 20 Aug 2014 10:25:40 -0500	[thread overview]
Message-ID: <alpine.DEB.2.02.1408201021440.11079@atx-linux-37> (raw)
In-Reply-To: <alpine.DEB.2.02.1408200928130.11079@atx-linux-37>

On Wed, 20 Aug 2014, atull wrote:

> 
> 
> On Wed, 20 Aug 2014, Romain Baeriswyl wrote:
> 
> > From: Romain Baeriswyl <Romain.Baeriswyl-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>
> > 
> > Some legacy devices support ony I2C standard mode at 100kHz.
> > This patch allows to select the standard mode through the DTS
> > with the use of the existing clock-frequency parameter.
> > 
> > When clock-frequency parameter is not set, the fast mode is selected.
> > Only when the parameter is set at 100000, the standard mode is selected.
> > 
> > Signed-off-by: Romain Baeriswyl <romainba-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>
> > Reviewed-by: Christian Ruppert <christian.ruppert-ux6zf3SgZrrQT0dZR+AlfA@public.gmane.org>
> > ---
> >  drivers/i2c/busses/i2c-designware-platdrv.c |   23 +++++++++++++++++++++--
> >  1 files changed, 21 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> > index 402ec39..b543fe1 100644
> > --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> > +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> > @@ -122,6 +122,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
> >  	struct i2c_adapter *adap;
> >  	struct resource *mem;
> >  	int irq, r;
> > +	u32 clk_freq;
> >  
> >  	irq = platform_get_irq(pdev, 0);
> >  	if (irq < 0) {
> > @@ -151,6 +152,9 @@ static int dw_i2c_probe(struct platform_device *pdev)
> >  		return PTR_ERR(dev->clk);
> >  	clk_prepare_enable(dev->clk);
> >  
> > +	/* fast mode by default because of legacy reasons */
> > +	clk_freq = 400000;
> > +
> >  	if (pdev->dev.of_node) {
> >  		u32 ht = 0;
> >  		u32 ic_clk = dev->get_clk_rate_khz(dev);
> > @@ -166,6 +170,17 @@ static int dw_i2c_probe(struct platform_device *pdev)
> >  		of_property_read_u32(pdev->dev.of_node,
> >  				     "i2c-scl-falling-time-ns",
> >  				     &dev->scl_falling_time);
> > +
> > +		of_property_read_u32(pdev->dev.of_node, "clock-frequency",
> > +				     &clk_freq);
> > +
> > +		/* Only standard mode at 100kHz and fast mode at 400kHz
> > +		 * are supported.
> > +		 */
> > +		if (clk_freq != 100000 && clk_freq != 400000) {
> > +			dev_err(&pdev->dev, "Only 100kHz and 400kHz supported");
> > +			return -EINVAL;
> > +		}
> 
> Hi Romain,
> 
> It is common to operate i2c at <100KHz on boards that have i2c 
> issues.  I am using this driver at 50KHz because I have a LCD module 
> that just doesn't work at a full 100KHz.  Please remove the check for 
> these two frequency points.
> 
> >  	}
> >  
> >  	dev->functionality =
> > @@ -175,8 +190,12 @@ static int dw_i2c_probe(struct platform_device *pdev)
> >  		I2C_FUNC_SMBUS_BYTE_DATA |
> >  		I2C_FUNC_SMBUS_WORD_DATA |
> >  		I2C_FUNC_SMBUS_I2C_BLOCK;
> > -	dev->master_cfg =  DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
> > -		DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST;
> > +	if (clk_freq == 100000)
> 
> Please change to <=
> 

Hi Romain,

This looks fine to me, my "<= issues" are not important as this isn't 
really setting a frequency, but just setting a bit that controls speed.

Acked-by: Alan Tull <atull-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx@public.gmane.org>


> > +		dev->master_cfg =  DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
> > +			DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_STD;
> > +	else
> > +		dev->master_cfg =  DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
> > +			DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST;
> >  
> >  	/* Try first if we can configure the device from ACPI */
> >  	r = dw_i2c_acpi_configure(pdev);
> > -- 
> > 1.7.1
> > 
> > 
> 

  reply	other threads:[~2014-08-20 15:31 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-19 20:18 [PATCH] i2c: designware: deduce speed mode from device tree setting atull
2014-08-19 20:18 ` atull-yzvPICuk2ABMcg4IHK0kFoH6Mc4MB0Vx
2014-08-20  7:52 ` Mika Westerberg
2014-08-20  7:52   ` Mika Westerberg
2014-08-20  9:22 ` Mark Rutland
2014-08-20  9:22   ` Mark Rutland
2014-08-20  9:49   ` Romain Baeriswyl
2014-08-20  9:49     ` Romain Baeriswyl
2014-08-20 12:07     ` Romain Baeriswyl
2014-08-20 12:32     ` Wolfram Sang
2014-08-20 12:32       ` Wolfram Sang
2014-08-20 14:24     ` atull
2014-08-20 14:24       ` atull
2014-08-20 14:38       ` Romain Baeriswyl
2014-08-20 14:38         ` Romain Baeriswyl
2014-08-20 15:12         ` atull
2014-08-20 15:12           ` atull
2014-08-20 12:36   ` Wolfram Sang
2014-08-20 12:42     ` Mark Rutland
2014-08-20 14:29       ` [PATCH] i2c designware add support of I2C standard mode Romain Baeriswyl
2014-08-20 14:29         ` Romain Baeriswyl
2014-08-20 14:32         ` atull
2014-08-20 14:32           ` atull
2014-08-20 15:25           ` atull [this message]
2014-08-20 15:25             ` atull
2014-09-18 15:52         ` atull
2014-09-18 15:52           ` atull
2014-09-20  9:24         ` Wolfram Sang
2014-09-20  9:24           ` Wolfram Sang
2014-09-28  3:40           ` atull
2014-09-28  3:40             ` atull

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=alpine.DEB.2.02.1408201021440.11079@atx-linux-37 \
    --to=atull@opensource.altera.com \
    --cc=Romain.Baeriswyl@abilis.com \
    --cc=alan@linux.intel.com \
    --cc=baruch@tkos.co.il \
    --cc=christian.ruppert@abilis.com \
    --cc=delicious.quinoa@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dinguyen@opensource.altera.com \
    --cc=grant.likely@linaro.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robh+dt@kernel.org \
    --cc=romainba@abilis.com \
    --cc=skuribay@pobox.com \
    --cc=wsa@the-dreams.de \
    --cc=yvanderv@opensource.altera.com \
    /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.