All of lore.kernel.org
 help / color / mirror / Atom feed
* Uboot SPI uclass - question
@ 2020-11-02 18:14 Moshe, Yaniv
  2020-11-23  1:28 ` Simon Glass
  2020-11-23  7:22 ` Rasmus Villemoes
  0 siblings, 2 replies; 5+ messages in thread
From: Moshe, Yaniv @ 2020-11-02 18:14 UTC (permalink / raw)
  To: u-boot

Hi Simon,
Hope you're doing good.

My name is Yaniv, and I have a question regarding an old commit in U-boot:
commit 60e2809a848bccd3a8090d3f2237964670f2780c
Author: Simon Glass <sjg at chromium.org<mailto:sjg@chromium.org>>
Date:   Tue Feb 17 15:29:35 2015 -0700

    dm: spi: Avoid setting the speed with every transfer

    Only set the speed if it has changed from last time. Since the speed will
    be 0 when the device is probed it will always be changed on the first
    transfer after the device is probed.

    Signed-off-by: Simon Glass sjg at chromium.org<mailto:sjg@chromium.org>


As far as I understand it, each SPI slave has its own struct. So, when we will use the device for the first time, we will set the speed.
But, if we're jumping between different slaves, the slaves structs were already configured at the first time, and since then there won't be any future speed setting.

e.g:
access flash with max-freq = X - > speed set
access TPM with max-freq =Y -> speed set
access flash again, slave struct already configured, no change between speed and slave->speed, -> speed stay the same as for TPM.

Did I got it wrong? I'm trying to understand what am I missing...

Thanks,
-Yaniv Moshe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Uboot SPI uclass - question
  2020-11-02 18:14 Uboot SPI uclass - question Moshe, Yaniv
@ 2020-11-23  1:28 ` Simon Glass
  2020-11-23  7:22 ` Rasmus Villemoes
  1 sibling, 0 replies; 5+ messages in thread
From: Simon Glass @ 2020-11-23  1:28 UTC (permalink / raw)
  To: u-boot

Hi Yaniv,

On Mon, 2 Nov 2020 at 11:14, Moshe, Yaniv <yanivmo@amazon.com> wrote:
>
> Hi Simon,
>
> Hope you?re doing good.
>
>
>
> My name is Yaniv, and I have a question regarding an old commit in U-boot:
>
> commit 60e2809a848bccd3a8090d3f2237964670f2780c
>
> Author: Simon Glass <sjg@chromium.org>
>
> Date:   Tue Feb 17 15:29:35 2015 -0700
>
>
>
>     dm: spi: Avoid setting the speed with every transfer
>
>
>
>     Only set the speed if it has changed from last time. Since the speed will
>
>     be 0 when the device is probed it will always be changed on the first
>
>     transfer after the device is probed.
>
>
>
>     Signed-off-by: Simon Glass sjg at chromium.org
>
>
>
>
>
> As far as I understand it, each SPI slave has its own struct. So, when we will use the device for the first time, we will set the speed.
>
> But, if we?re jumping between different slaves, the slaves structs were already configured at the first time, and since then there won?t be any future speed setting.
>
>
>
> e.g:
>
> access flash with max-freq = X - > speed set
>
> access TPM with max-freq =Y -> speed set
>
> access flash again, slave struct already configured, no change between speed and slave->speed, -> speed stay the same as for TPM.
>
>
>
> Did I got it wrong? I?m trying to understand what am I missing?

Yes I think you are right. I think we need to have a single speed for
the SPI bus and check against that instead. It could be stored in
dm_spi_bus perhaps?

Regards,
Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Uboot SPI uclass - question
  2020-11-02 18:14 Uboot SPI uclass - question Moshe, Yaniv
  2020-11-23  1:28 ` Simon Glass
@ 2020-11-23  7:22 ` Rasmus Villemoes
  2020-11-23 17:33   ` Moshe, Yaniv
  2020-11-23 19:08   ` Simon Glass
  1 sibling, 2 replies; 5+ messages in thread
From: Rasmus Villemoes @ 2020-11-23  7:22 UTC (permalink / raw)
  To: u-boot

On 02/11/2020 19.14, Moshe, Yaniv wrote:
> Hi Simon,
> Hope you're doing good.
> 
> My name is Yaniv, and I have a question regarding an old commit in U-boot:
> commit 60e2809a848bccd3a8090d3f2237964670f2780c
> Author: Simon Glass <sjg at chromium.org<mailto:sjg@chromium.org>>
> Date:   Tue Feb 17 15:29:35 2015 -0700
> 
>     dm: spi: Avoid setting the speed with every transfer
> 
>     Only set the speed if it has changed from last time. Since the speed will
>     be 0 when the device is probed it will always be changed on the first
>     transfer after the device is probed.
> 
>     Signed-off-by: Simon Glass sjg at chromium.org<mailto:sjg@chromium.org>
> 
> 
> As far as I understand it, each SPI slave has its own struct. So, when we will use the device for the first time, we will set the speed.
> But, if we're jumping between different slaves, the slaves structs were already configured at the first time, and since then there won't be any future speed setting.
> 
> e.g:
> access flash with max-freq = X - > speed set
> access TPM with max-freq =Y -> speed set
> access flash again, slave struct already configured, no change between speed and slave->speed, -> speed stay the same as for TPM.
> 
> Did I got it wrong? I'm trying to understand what am I missing...

No, you're reading it the same way I did:

https://lists.denx.de/pipermail/u-boot/2019-December/393854.html

I never followed up because I didn't actually have two different spi
devices in play on the board I was working on at the time. But it's
something that really should be fixed.

Rasmus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Uboot SPI uclass - question
  2020-11-23  7:22 ` Rasmus Villemoes
@ 2020-11-23 17:33   ` Moshe, Yaniv
  2020-11-23 19:08   ` Simon Glass
  1 sibling, 0 replies; 5+ messages in thread
From: Moshe, Yaniv @ 2020-11-23 17:33 UTC (permalink / raw)
  To: u-boot

Hi,

So, I was thinking about the same solution of working with one frequency for the SPI, but then I saw this
comment in the "include/spi.h":

/* TODO(sjg at chromium.org): Remove this and use max_hz from struct spi_slave */
struct dm_spi_bus {
	uint max_hz;
};

So, I thought that maybe someone already has some progress about this problem...
In my case, the easy W/A was to just ignore the if that check if frequency is the same in the slave struct, and instead, I'm updating the speed for every change in slave.

I do think that working with one speed variable for the SPI is the right solution.

-Yaniv



-----Original Message-----
From: Rasmus Villemoes <rasmus.villemoes@prevas.dk> 
Sent: Sunday, November 22, 2020 11:22 PM
To: Moshe, Yaniv <yanivmo@amazon.com>; u-boot at lists.denx.de
Cc: sjg at chromium.org
Subject: RE: [EXTERNAL] Uboot SPI uclass - question

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.



On 02/11/2020 19.14, Moshe, Yaniv wrote:
> Hi Simon,
> Hope you're doing good.
>
> My name is Yaniv, and I have a question regarding an old commit in U-boot:
> commit 60e2809a848bccd3a8090d3f2237964670f2780c
> Author: Simon Glass <sjg at chromium.org<mailto:sjg@chromium.org>>
> Date:   Tue Feb 17 15:29:35 2015 -0700
>
>     dm: spi: Avoid setting the speed with every transfer
>
>     Only set the speed if it has changed from last time. Since the speed will
>     be 0 when the device is probed it will always be changed on the first
>     transfer after the device is probed.
>
>     Signed-off-by: Simon Glass 
> sjg at chromium.org<mailto:sjg@chromium.org>
>
>
> As far as I understand it, each SPI slave has its own struct. So, when we will use the device for the first time, we will set the speed.
> But, if we're jumping between different slaves, the slaves structs were already configured at the first time, and since then there won't be any future speed setting.
>
> e.g:
> access flash with max-freq = X - > speed set access TPM with max-freq 
> =Y -> speed set access flash again, slave struct already configured, 
> no change between speed and slave->speed, -> speed stay the same as for TPM.
>
> Did I got it wrong? I'm trying to understand what am I missing...

No, you're reading it the same way I did:

https://lists.denx.de/pipermail/u-boot/2019-December/393854.html

I never followed up because I didn't actually have two different spi devices in play on the board I was working on at the time. But it's something that really should be fixed.

Rasmus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Uboot SPI uclass - question
  2020-11-23  7:22 ` Rasmus Villemoes
  2020-11-23 17:33   ` Moshe, Yaniv
@ 2020-11-23 19:08   ` Simon Glass
  1 sibling, 0 replies; 5+ messages in thread
From: Simon Glass @ 2020-11-23 19:08 UTC (permalink / raw)
  To: u-boot

Hi,

On Mon, 23 Nov 2020 at 00:22, Rasmus Villemoes
<rasmus.villemoes@prevas.dk> wrote:
>
> On 02/11/2020 19.14, Moshe, Yaniv wrote:
> > Hi Simon,
> > Hope you're doing good.
> >
> > My name is Yaniv, and I have a question regarding an old commit in U-boot:
> > commit 60e2809a848bccd3a8090d3f2237964670f2780c
> > Author: Simon Glass <sjg at chromium.org<mailto:sjg@chromium.org>>
> > Date:   Tue Feb 17 15:29:35 2015 -0700
> >
> >     dm: spi: Avoid setting the speed with every transfer
> >
> >     Only set the speed if it has changed from last time. Since the speed will
> >     be 0 when the device is probed it will always be changed on the first
> >     transfer after the device is probed.
> >
> >     Signed-off-by: Simon Glass sjg at chromium.org<mailto:sjg@chromium.org>
> >
> >
> > As far as I understand it, each SPI slave has its own struct. So, when we will use the device for the first time, we will set the speed.
> > But, if we're jumping between different slaves, the slaves structs were already configured at the first time, and since then there won't be any future speed setting.
> >
> > e.g:
> > access flash with max-freq = X - > speed set
> > access TPM with max-freq =Y -> speed set
> > access flash again, slave struct already configured, no change between speed and slave->speed, -> speed stay the same as for TPM.
> >
> > Did I got it wrong? I'm trying to understand what am I missing...
>
> No, you're reading it the same way I did:
>
> https://lists.denx.de/pipermail/u-boot/2019-December/393854.html
>
> I never followed up because I didn't actually have two different spi
> devices in play on the board I was working on at the time. But it's
> something that really should be fixed.

It is easy enough to add a sandbox test for this I think.

Regards,
Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-23 19:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-02 18:14 Uboot SPI uclass - question Moshe, Yaniv
2020-11-23  1:28 ` Simon Glass
2020-11-23  7:22 ` Rasmus Villemoes
2020-11-23 17:33   ` Moshe, Yaniv
2020-11-23 19:08   ` Simon Glass

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.