kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Sharing the same SPI between two devices.
@ 2023-11-02  9:14 Patryk
  2023-11-02  9:19 ` Lucas Tanure
  2023-11-02 16:04 ` Billie Alsup (balsup)
  0 siblings, 2 replies; 3+ messages in thread
From: Patryk @ 2023-11-02  9:14 UTC (permalink / raw)
  To: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 726 bytes --]

Hi, I want to have two devices on the same SPI bus.

These devices are:

- SPI nor flash (QSPI compatible)

- my custom device (SPI compatible).

For SPI NOR flash I have the driver in the kernel, for my custom device I
do not have such a driver.

My question is - how the access to this particular SPI peripheral can be
serialized between these two drivers in order to prevent simultaneous
access that would result in a mess on the SPI? Do I have to modify the
existing driver for SPI NOR flash or not?

How about different configurations for these devices - as I mentioned one
is QSPI compatible whereas the other one is SPI compatible. Can I
reconfigure the SPI bus driver before each "transaction"?


Best regards

Patryk

[-- Attachment #1.2: Type: text/html, Size: 1409 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Re: Sharing the same SPI between two devices.
  2023-11-02  9:14 Sharing the same SPI between two devices Patryk
@ 2023-11-02  9:19 ` Lucas Tanure
  2023-11-02 16:04 ` Billie Alsup (balsup)
  1 sibling, 0 replies; 3+ messages in thread
From: Lucas Tanure @ 2023-11-02  9:19 UTC (permalink / raw)
  To: Patryk; +Cc: kernelnewbies

On Thu, Nov 2, 2023 at 9:15 AM Patryk <pbiel7@gmail.com> wrote:
>
> Hi, I want to have two devices on the same SPI bus.
>
> These devices are:
>
> - SPI nor flash (QSPI compatible)
>
> - my custom device (SPI compatible).
>
> For SPI NOR flash I have the driver in the kernel, for my custom device I do not have such a driver.
>
> My question is - how the access to this particular SPI peripheral can be serialized between these two drivers in order to prevent simultaneous access that would result in a mess on the SPI? Do I have to modify the existing driver for SPI NOR flash or not?
>
> How about different configurations for these devices - as I mentioned one is QSPI compatible whereas the other one is SPI compatible. Can I reconfigure the SPI bus driver before each "transaction"?
>
>
> Best regards
>
> Patryk
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

To share the SPI bus between two devices just put them difirent chip
select pins.
Can you use regmap for what you trying to do?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Re: Sharing the same SPI between two devices.
  2023-11-02  9:14 Sharing the same SPI between two devices Patryk
  2023-11-02  9:19 ` Lucas Tanure
@ 2023-11-02 16:04 ` Billie Alsup (balsup)
  1 sibling, 0 replies; 3+ messages in thread
From: Billie Alsup (balsup) @ 2023-11-02 16:04 UTC (permalink / raw)
  To: Patryk, kernelnewbies

> My question is - how the access to this particular SPI peripheral can be serialized between these two drivers in order to prevent simultaneous access that would result in a mess on the SPI? Do I have to modify the existing driver for SPI NOR flash or not? 

Doesn't the serialization happen at the SPI "master" controller driver level, i.e. the device registered via devm_spi_register_master (or equivalent)?  The spi-nor driver is a layer making requests to the underlying controller driver, which come as requests via various callbacks (e.g. transfer_one, prepare_message, mem_ops).  It is that driver that should be serializing requests from higher layers.  Shouldn't your "other" driver be making similar requests of the underlying controller?

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

end of thread, other threads:[~2023-11-02 16:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-02  9:14 Sharing the same SPI between two devices Patryk
2023-11-02  9:19 ` Lucas Tanure
2023-11-02 16:04 ` Billie Alsup (balsup)

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).