public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/5] i2c: omap24xx: Fix high speed trimming calculation
Date: Mon, 18 Jan 2016 07:02:25 +0100	[thread overview]
Message-ID: <569C7FF1.6040203@denx.de> (raw)
In-Reply-To: <1453028992-14220-5-git-send-email-christophe-h.ricard@st.com>

Hello Christophe,

Am 17.01.2016 um 12:09 schrieb Christophe Ricard:
> Work based on i2c-omap.c from linux kernel.
>
> fsscll/fssclh and hsscll/hssclh was always negative in high speed.
>
> i2c high speed frequency start after 400Khz.
>
> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
> ---
>
>   drivers/i2c/omap24xx_i2c.c | 17 +++++++++--------
>   1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c
> index 48ca446..774edaf 100644
> --- a/drivers/i2c/omap24xx_i2c.c
> +++ b/drivers/i2c/omap24xx_i2c.c
> @@ -129,7 +129,9 @@ static int omap24_i2c_setspeed(struct udevice *adap, unsigned int speed)
>   	i2c_base = i2c_bus->i2c_base;
>   #endif
>
> -	if (speed >= OMAP_I2C_HIGH_SPEED) {
> +	if (speed > 400000) {

Why you remove the define?

> +		unsigned long scl;
> +
>   		/* High speed */
>   		psc = I2C_IP_CLK / I2C_INTERNAL_SAMPLING_CLK;
>   		psc -= 1;
> @@ -139,12 +141,11 @@ static int omap24_i2c_setspeed(struct udevice *adap, unsigned int speed)
>   		}
>
>   		/* For first phase of HS mode */
> -		fsscll = I2C_INTERNAL_SAMPLING_CLK / (2 * speed);
> +		scl = I2C_INTERNAL_SAMPLING_CLK / 400000;
>
> -		fssclh = fsscll;
> +		fsscll = scl - (scl / 3) - 7;
> +		fssclh = (scl / 3)  - 5;
>
> -		fsscll -= I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM;
> -		fssclh -= I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM;
>   		if (((fsscll < 0) || (fssclh < 0)) ||
>   		    ((fsscll > 255) || (fssclh > 255))) {
>   			puts("Error : I2C initializing first phase clock\n");
> @@ -152,10 +153,10 @@ static int omap24_i2c_setspeed(struct udevice *adap, unsigned int speed)
>   		}
>
>   		/* For second phase of HS mode */
> -		hsscll = hssclh = I2C_INTERNAL_SAMPLING_CLK / (2 * speed);
> +		scl = I2C_IP_CLK / speed;
> +		hsscll = scl - (scl / 3) - 7;
> +		hssclh = (scl / 3) - 5;
>
> -		hsscll -= I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM;
> -		hssclh -= I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM;
>   		if (((fsscll < 0) || (fssclh < 0)) ||
>   		    ((fsscll > 255) || (fssclh > 255))) {
>   			puts("Error : I2C initializing second phase clock\n");
>

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  reply	other threads:[~2016-01-18  6:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-17 11:09 [U-Boot] [PATCH 0/5] Convert omap24xx-i2c driver to Driver Model Christophe Ricard
2016-01-17 11:09 ` [U-Boot] [PATCH 1/5] i2c: omap24xx: Convert to DM Christophe Ricard
2016-01-18  5:49   ` Heiko Schocher
2016-01-21  2:46   ` Simon Glass
2016-01-17 11:09 ` [U-Boot] [PATCH 2/5] i2c: omap24xx: Fix waitdelay value for I2C HS Christophe Ricard
2016-01-18  5:59   ` Heiko Schocher
2016-01-17 11:09 ` [U-Boot] [PATCH 3/5] i2c: omap24xx: Remove unused I2C_WAIT macro Christophe Ricard
2016-01-18  6:00   ` Heiko Schocher
2016-01-17 11:09 ` [U-Boot] [PATCH 4/5] i2c: omap24xx: Fix high speed trimming calculation Christophe Ricard
2016-01-18  6:02   ` Heiko Schocher [this message]
2016-01-17 11:09 ` [U-Boot] [PATCH 5/5] i2c: omap24xx: Convert fully to DM_I2C Christophe Ricard
2016-01-18  6:04   ` Heiko Schocher
2016-01-18 21:22     ` Christophe Ricard
2016-01-20  4:50       ` Heiko Schocher
2016-12-05 12:19 ` [U-Boot] [PATCH 0/5] Convert omap24xx-i2c driver to Driver Model Heiko Schocher

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=569C7FF1.6040203@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.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