Products > Embedded Computing

Device Tree, "ata-generic", any example?

(1/2) > >>

legacy:

--- Code: ---                localbus@0xfe000000
                {
                        #address-cells = <2>;
                        #size-cells = <1>;
                        compatible = "fsl,localbus","fsl,pq2-localbus","simple-bus";
                        reg    = <0x0xfe0001f0 0x100>;
                        ranges = <0x0 0x0 0xfe000000 0x100000
                                  0x3 0x0 0xe8000000 0x10000 >; /* the CF-PATA controller is mapped here */

                        pata@3,0 /* wrong code, here only as example */
                        {
                                 compatible = "ata-generic";
                                 reg = <0x3 0x0 0x10 0x4 0xC 0x2>; /* what is the meaning of this??? */
                                 reg-shift = <1>; /* what is the meaining of this??? */
                                 pio-mode = <0>;
                                 // interrupts = <0x19 0x8>;
                                 // interrupt-parent = <&PIC>;
                        };
                };

--- End code ---

I have a PCI-PATA controller set into "legacy" mode, hence it works attached to a local bus and responds to a fixed addresses mapped in CPU RAM (beyond the first 2Gbyte, hence it doesn't conflict with the RAM).

The Linux Kernel has a SATA driver called OF_ATA, which uses the DeviceTree to initialize its internal strucutre. Unfortunately I cannot find any good doc about this, neither an example.

The above is it should look like. Anyone has ever implemented it?

It was/is usually used to map and handle a Compact Flash in embedded machines, typically routers  :-//



--- Code: ---0xfe0001f0, size=8
0xfe0003f4, size=1
0xfe000170, size=8
0xfe000374, size=1
0xfe000800, size=64

--- End code ---

Registers are physically mapped here


--- Code: ---                                 reg = <0x3 0x0 0x10 0x4 0xC 0x2>; /* what is the meaning of this??? */

--- End code ---

This line looks wrong (and for sure it is), it was found in a chunk of semi example found on the internet and it still needs to be analyzed, understood, and fixed.

thinkfat:
That doesn't look like valid devicetree lingo. The "reg" property of the localbus node seems to be invalid for sure. The "reg" property in the pata node seems invalid, too.

Apart from that, this is the driver that handles "ata-generic". The probe function tells you which attributes it reads from the devicetree:

https://elixir.bootlin.com/linux/v4.20.17/source/drivers/ata/pata_of_platform.c#L25

Explanation for the "ranges" property in "simple-bus" nodes: https://elinux.org/Device_Tree_Usage#Ranges_.28Address_Translation.29

legacy:

--- Quote from: thinkfat on November 08, 2019, 01:49:58 pm ---The probe function tells you which attributes it reads from the devicetree:

https://elixir.bootlin.com/linux/v4.20.17/source/drivers/ata/pata_of_platform.c#L25

--- End quote ---

I know, but it's not clear

thinkfat:

--- Quote from: legacy on November 08, 2019, 01:54:24 pm ---
--- Quote from: thinkfat on November 08, 2019, 01:49:58 pm ---The probe function tells you which attributes it reads from the devicetree:

https://elixir.bootlin.com/linux/v4.20.17/source/drivers/ata/pata_of_platform.c#L25

--- End quote ---

I know, but it's not clear

--- End quote ---

I'm not sure what you mean with that. The probe function says you need to declare two IO resources in the "reg" property and optionally an additional IRQ resource. You need to set "reg_shift" to the correct value, depending on the alignment of the controller registers and define which PIO mode you want to use. That's all.

The link I posted to the devicetree documentation explains how the content of the properties needs to look like.

legacy:
are reg relative or absolute values?


--- Code: ---        external-bus
        {
                #address-cells = <2>;
                #size-cells = <1>;
                ranges = <0 0  0xfe000100   0x1000 // not yet defined
                          2 0  0xfe000000   0x1000>; // Chipselect 2, PATA controller

                        pata@0,2
                        {
                                compatible = "ata-generic";
                                /*
                                 *  reg #address-cells #size-cells
                                 */
                                reg = < 0x1f0 0x08
                                        0x3f4 0x01
                                        0x170 0x08
                                        0x374 0x01
                                        0x800 0x64 >;
                                reg-shift = <0>; /* no offset */
                                pio-mode = <0>;
                                // interrupts = <0x19 0x8>;
                                // interrupt-parent = <&PIC>;
                        };
        };

--- End code ---

something like that?

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version