From: Sascha Hauer <sha@pengutronix.de>
To: John Watts <contact@jookia.org>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] I2C: i.MX: early: Use internal udelay
Date: Mon, 30 Jan 2023 13:17:52 +0100 [thread overview]
Message-ID: <20230130121752.GR13319@pengutronix.de> (raw)
In-Reply-To: <Y9efLdQi++e/ZFOn@novena-choice-citizen>
On Mon, Jan 30, 2023 at 09:42:53PM +1100, John Watts wrote:
> On Mon, Jan 30, 2023 at 11:27:27AM +0100, Sascha Hauer wrote:
> > This takes around 5 times too long on a i.MX8MM and around 50 times too
> > long on a i.MX6Q. This was measured under a regular barebox on the
> > shell. In an early environment with MMU disabled it takes 730 times too
> > long.
>
> Yikes! I'm glad I broke this in to its own patch then. :)
>
> I did copy this code from these boards:
>
> arch/arm/boards/cm-fx6/lowlevel.c
> arch/arm/boards/skov-imx6/lowlevel.c
> arch/arm/boards/technexion-wandboard/lowlevel.c
> arch/arm/mach-imx/xload-gpmi-nand.c
> arch/arm/mach-imx/imx6-mmdc.c (uses 1000 loops)
>
> Maybe it's time for an i.MX6-wide early udelay?
i.MX6 is not enough, the code could run on other i.MX SoCs as well.
> Though this code might break if its timing is already wrong.
>
> > Maybe we could do this:
> >
> > static void __udelay(void *base, int us)
> > {
> > int i;
> >
> > for (i = 0; i < us * 4; i++)
> > readb(base);
> > }
> >
> > The time spent for a register read depends on the bus clock which
> > doesn't change that much between the different SoCs.
>
> This seems like a better solution if you've tested it, I'm not too sure
> how to check this. Would I just then specify the controller as the base?
Yes, the I2C controller base should be passed here.
I tested this with a call to this udelay function with a sufficiently
great number of microseconds surrounded by a printf.
>
> Though the actual goal of the code is to wait for the controller to bestable.
> Maybe there's a better way than a delay?
I briefly looked into this, but the commit history of both barebox or
Linux do not give a real conclusion what we are waiting here for.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2023-01-30 18:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 18:56 John Watts
2023-01-30 10:27 ` Sascha Hauer
2023-01-30 10:42 ` John Watts
2023-01-30 12:17 ` Sascha Hauer [this message]
2023-01-30 12:24 ` John Watts
2023-01-30 12:31 ` Sascha Hauer
2023-01-30 12:56 ` John Watts
2023-01-30 16:36 ` Sascha Hauer
2023-01-30 18:42 ` John Watts
2023-01-31 6:14 ` Sascha Hauer
2023-01-31 6:33 ` John Watts
2023-02-02 14:21 ` Jules Maselbas
2023-02-02 14:27 ` Ahmad Fatoum
2023-02-01 17:50 ` Alexander Shiyan
2023-02-01 18:12 ` Jookia
2023-02-01 19:44 ` Ahmad Fatoum
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=20230130121752.GR13319@pengutronix.de \
--to=sha@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=contact@jookia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox