kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* the difference between /drivers/spi and /drivers/mtd
@ 2019-12-10 15:01 Tomek Domek
  2019-12-19 10:15 ` Luca Ceresoli
  0 siblings, 1 reply; 2+ messages in thread
From: Tomek Domek @ 2019-12-10 15:01 UTC (permalink / raw)
  To: kernelnewbies


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

Hi
I have in device tree node:

qspi: somename@0 {
    compatible = "nameOfDriverFrom/drivers/spi";
    reg = <someAddr size>;
    clocks = <reference to clock>;
    clock-names = "some names";
    #address-cells = <1>;
    #size-cells = <0>;
    status = "disabled";
};

and then I have such thing:
&qspi {
    pinctrl-names="default";
    pinctrl-0 = <&reference to some pin controller>;
    status = "okay";
    spi-max-frequency = <11000000>;

    flash@0 {
        compatible = "spi-flash (this is driver from /drivers/mtd/)";
        #address-cells = <1>;
        #size-cells = <1>;
        reg = <0x0>;
        spi-max-frequency = <22000000>;
     };
};

Why just one node isn't enough? And what frequency driver have at all -
11MHz or 22MHz?
What is the difference between drivers defined in /drivers/spi and
/drivers/mtd?
Does it mean that driver in /drivers/mtd can use somehow driver or the code
from /drivers/spi?
Or maybe it works in opposite direction?

[-- Attachment #1.2: Type: text/html, Size: 1363 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] 2+ messages in thread

* Re: the difference between /drivers/spi and /drivers/mtd
  2019-12-10 15:01 the difference between /drivers/spi and /drivers/mtd Tomek Domek
@ 2019-12-19 10:15 ` Luca Ceresoli
  0 siblings, 0 replies; 2+ messages in thread
From: Luca Ceresoli @ 2019-12-19 10:15 UTC (permalink / raw)
  To: Tomek Domek, kernelnewbies

Hi Tomek,

On 10/12/19 16:01, Tomek Domek wrote:
> Hi
> I have in device tree node:
> 
> qspi: somename@0 {
>     compatible = "nameOfDriverFrom/drivers/spi";
>     reg = <someAddr size>;
>     clocks = <reference to clock>;
>     clock-names = "some names";
>     #address-cells = <1>;
>     #size-cells = <0>;
>     status = "disabled";
> };
> 
> and then I have such thing:
> &qspi {
>     pinctrl-names="default";
>     pinctrl-0 = <&reference to some pin controller>;
>     status = "okay";
>     spi-max-frequency = <11000000>;
> 
>     flash@0 {
>         compatible = "spi-flash (this is driver from /drivers/mtd/)";
>         #address-cells = <1>;
>         #size-cells = <1>;
>         reg = <0x0>;
>         spi-max-frequency = <22000000>;
>      };
> };
> 
> Why just one node isn't enough? And what frequency driver have at all -
> 11MHz or 22MHz?
> What is the difference between drivers defined in /drivers/spi and
> /drivers/mtd?

The qspi node is the Quad SPI master (=controller), i.e. the piece of
hardware, usually in the the SoC, that drives the (Quad) SPI bus.

The flash@0 node is the flash chip, external to the SoC, it's a SPI
slave that is driven by the SPI master.

Device tree describes the hardware. It is possible that the flash chip
supports up to 22 MHz but the SPI master supports up to 11 MHz. Using
the highest possible speed, 11 MHz in this case, is up to the driver
implementation.

> Does it mean that driver in /drivers/mtd can use somehow driver or the
> code from /drivers/spi?

Yes, absolutely. MTD is a kernel layer to drive memory chips. In order
to reach the memory chip it uses a communication bus. Typical
communication busses for MTD chips include [Quad] SPI, I2C and parallel.

Layering in Linux drivers is absolutely normal. E.g. when you connect a
pendrive to your PC you probably have the mass storage driver use the
USB controller driver, because the pendrive uses USB to connect. And the
USB controller driver uses the PCIe controller driver because the USB
controller is connected to the CPU via PCI express.

-- 
Luca

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

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

end of thread, other threads:[~2019-12-19 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 15:01 the difference between /drivers/spi and /drivers/mtd Tomek Domek
2019-12-19 10:15 ` Luca Ceresoli

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