Kernel Newbies archive on lore.kernel.org
 help / color / 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 --]

<div dir="ltr">Hi<div>I have in device tree node:</div><div><br></div><div>qspi: somename@0 {<br>    compatible = &quot;nameOfDriverFrom/drivers/spi&quot;;<br>    reg = &lt;someAddr size&gt;;<br>    clocks = &lt;reference to clock&gt;;<br>    clock-names = &quot;some names&quot;;<br>    #address-cells = &lt;1&gt;;<br>    #size-cells = &lt;0&gt;;<br>    status = &quot;disabled&quot;;<br>		};<br></div><div><br></div><div>and then I have such thing:</div><div>&amp;qspi {<br>    pinctrl-names=&quot;default&quot;;<br>    pinctrl-0 = &lt;&amp;reference to some pin controller&gt;;<br>    status = &quot;okay&quot;;<br>    spi-max-frequency = &lt;11000000&gt;;<br><br>    flash@0 {<br>        compatible = &quot;spi-flash (this is driver from /drivers/mtd/)&quot;;<br>        #address-cells = &lt;1&gt;;<br>        #size-cells = &lt;1&gt;;<br>        reg = &lt;0x0&gt;;<br>        spi-max-frequency = &lt;22000000&gt;;<br>     };<br>};<br></div><div><br></div><div>Why just one node isn&#39;t enough? And what frequency driver have at all - 11MHz or 22MHz?</div><div>What is the difference between drivers defined in /drivers/spi and /drivers/mtd?</div><div>Does it mean that driver in /drivers/mtd can use somehow driver or the code from /drivers/spi?</div><div>Or maybe it works in opposite direction?</div></div>

[-- 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, back to index

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

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org
	public-inbox-index kernelnewbies

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git