All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael Walle" <mwalle@kernel.org>
To: "Andre Przywara" <andre.przywara@arm.com>
Cc: "Jagan Teki" <jagan@amarulasolutions.com>,
	"Tom Rini" <trini@konsulko.com>, "Simon Glass" <sjg@chromium.org>,
	<u-boot@lists.denx.de>
Subject: Re: [PATCH 2/2] spi: sunxi: fix clock divider calculation for max frequency setting
Date: Tue, 16 Jul 2024 09:18:53 +0200	[thread overview]
Message-ID: <D2QS41FUIHAA.2GWE3AXZFQHBS@kernel.org> (raw)
In-Reply-To: <20240716013921.786059dc@minigeek.lan>

> > -	if ((div / 2) <= (SUN4I_CLK_CTL_CDR2_MASK + 1)) {
> > +	if (div != 1 && ((div / 2) <= (SUN4I_CLK_CTL_CDR2_MASK + 1))) {
> >  		div /= 2;
>
> This is still not fully correct, is it? If I ask for 10 MHz, the
> algorithm should select 8 MHz (24/3) or actually 6 MHz (24/4), but it
> chooses 12 MHz (24/2), which is too much.
> So I think this division here should be either:
> 	div = (div + 1) / 2;
> or:
> 	div = DIV_ROUND_UP(div, 2);
>
> Can someone confirm this?

When I've written this patch, I've looked at how linux does it (and
it's history) and I'm sure you know that linux has two drivers, for
sun4i and sun6i/sun8i. Somehow u-boot conflates them into one with
just one being correct with the SPI_CLK in the CDR2 case (?).

But anyway, this is about CDR1 and it seems you're right. But OTOH
I've tested this briefly with "sf probe 0:0 <hz>" and looked at the
SCK frequency of the readid command with a scope and it was always
less than my requested frequency. At least after the second probe
(there must be another bug which will still keep the frequency of
the probe at the former speed). Soo.. I'm not sure. Mh.

While this might be a bug, it doesn't affect this patch which will
just make sure we can get a 1:1 ratio on SoCs where this is
possible, i.e. not on the sun4i variant.

-michael

  reply	other threads:[~2024-07-16  7:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-12 17:14 [PATCH 0/2] spi: sunxi: Improve the loading speed Michael Walle
2024-07-12 17:14 ` [PATCH 1/2] spi: sunxi: drop max_hz handling Michael Walle
2024-07-16  0:05   ` Andre Przywara
2024-07-16  6:58     ` Michael Walle
2024-07-16 14:20       ` Andre Przywara
2024-07-12 17:14 ` [PATCH 2/2] spi: sunxi: fix clock divider calculation for max frequency setting Michael Walle
2024-07-16  0:39   ` Andre Przywara
2024-07-16  7:18     ` Michael Walle [this message]
2024-07-12 17:28 ` [PATCH 0/2] spi: sunxi: Improve the loading speed Peter Robinson
2024-07-12 18:11   ` Michael Walle
2024-07-16  0:32   ` Andre Przywara

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=D2QS41FUIHAA.2GWE3AXZFQHBS@kernel.org \
    --to=mwalle@kernel.org \
    --cc=andre.przywara@arm.com \
    --cc=jagan@amarulasolutions.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --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 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.