linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jarkko Nikula <jarkko.nikula@linux.intel.com>, linux-i2c@vger.kernel.org
Cc: Wolfram Sang <wsa@the-dreams.de>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Subject: Re: [PATCH] i2c: designware: Fix false warning from i2c_dw_clk_rate()
Date: Thu, 11 May 2017 17:00:49 +0300	[thread overview]
Message-ID: <1494511249.6967.11.camel@linux.intel.com> (raw)
In-Reply-To: <20170511124949.26650-1-jarkko.nikula@linux.intel.com>

On Thu, 2017-05-11 at 15:49 +0300, Jarkko Nikula wrote:
> Commit bd698d24b1b5 ("i2c: designware: Get selected speed mode
> sda-hold-time via ACPI") causes a false warning from i2c_dw_clk_rate()
> in case platform doesn't provide explicit input clock but provides
> valid
> SCL timing parameters via ACPI.
> 
> After above commit timing parameters only for the selected speed is
> get
> but code in i2c_dw_init() tries to calculate missing parameters using
> the input clock which leads to a warning when there is no input clock
> defined.
> 
> Fix this by reordering the code such a way that timing parameters
> validation/calculation and setting is done for the selected speed
> only.
> While at it do the calculation only once during the first call.

> +static void i2c_dw_set_timings(struct dw_i2c_dev *dev)
> +{
> +	u32 reg;
> +
> +	/* set standard and fast speed deviders for high/low periods
> */
> +	dev->sda_falling_time = dev->sda_falling_time ?: 300; /* ns
> */
> +	dev->scl_falling_time = dev->scl_falling_time ?: 300; /* ns
> */
> +
> +	switch (dev->master_cfg & DW_IC_CON_SPEED_MASK) {
> +	case DW_IC_CON_SPEED_STD:
> +		i2c_dw_set_timings_sm(dev);
> +		break;
> +	case DW_IC_CON_SPEED_FAST:
> +		i2c_dw_set_timings_fm(dev);
> +		break;
> +	case DW_IC_CON_SPEED_HIGH:
> +		i2c_dw_set_timings_hsm(dev);
> +		break;
>  	}

I would put same suffixes to the helper functions, i.e.
_sm -> _std
_fm -> _fast
_hsm-> _high

> +}

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

  reply	other threads:[~2017-05-11 14:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-11 12:49 [PATCH] i2c: designware: Fix false warning from i2c_dw_clk_rate() Jarkko Nikula
2017-05-11 14:00 ` Andy Shevchenko [this message]
2017-05-16 21:29   ` Wolfram Sang
2017-05-17  6:12     ` Jarkko Nikula
2017-05-19  7:12 ` Jarkko Nikula

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=1494511249.6967.11.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=wsa@the-dreams.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).