Welcome, Guest

Author Topic: adding spi device  (Read 408 times)

vinczo

  • Newbie
  • *
  • Posts: 16
  • Karma: +1/-0
adding spi device
« on: August 06, 2018, 07:40:55 PM »
Hi,

I already have two spi devices used (m25p80@0 and mac@1) and I'm trying to add two more spi devices (mac@2 and mac@3) to the dts.

So I modified the code as follows :
Code: [Select]

        palmbus@10000000 {
                spi@b00 {
                        // I comment these two lines
                        //pinctrl-names = "default";
            //pinctrl-0 = <&spi_pins &spi_cs1>;

                        // I specify the GPIO used as CS for the four devices
                        // two of them belong to the spi group and the two others to the jtag group
            #address-cells = <2>;
                        #size-cells = <0>;
                        cs-gpios = <&gpio0 3 1>, <&gpio1 5 1>, <&gpio0 19 1>, <&gpio0 21 1>;

                        status = "okay";

                        m25p80@0 {
                                #address-cells = <1>;
                                #size-cells = <1>;
                                compatible = "s25fl064k";
                                reg = <0 0>;
                                linux,modalias = "m25p80", "s25fl064k";
                                spi-max-frequency = <10000000>;

                                partition@0 {
                                        label = "u-boot";
                                        reg = <0x0 0x30000>;
                                        read-only;
                                };

                                partition@30000 {
                                        label = "u-boot-env";
                                        reg = <0x30000 0x10000>;
                                        read-only;
                                };

                                factory: partition@40000 {
                                        label = "factory";
                                        reg = <0x40000 0x10000>;
                                        read-only;
                                };

                                partition@50000 {
                                        label = "firmware";
                                        reg = <0x50000 0x7b0000>;
                                };
                        };
                       
                        mac@1 {
                            status = "okay";
                            compatible = "at25";
                            spi-max-frequency = <1000000>;
                            reg = <1>;

                            at25,byte-len = <0x100>;
                            at25,addr-mode = <1>;
                            at25,page-size = <16>;
                        };

                        mac@2 {
                            status = "okay";
                            compatible = "at25";
                            spi-max-frequency = <1000000>;
                            reg = <2>;

                            at25,byte-len = <0x100>;
                            at25,addr-mode = <1>;
                            at25,page-size = <16>;
                        };

                        mac@3 {
                            status = "okay";
                            compatible = "at25";
                            spi-max-frequency = <1000000>;
                            reg = <3>;

                            at25,byte-len = <0x100>;
                            at25,addr-mode = <1>;
                            at25,page-size = <16>;
                        };
                };
                [...];
        };

I can see all four spi devices declared :
Code: [Select]
root@OpenWrt:~# ls /sys/bus/spi/devices/spi32766.
spi32766.0/  spi32766.1/  spi32766.2/  spi32766.3/

However, only the spi devices with CS from the spi group have data. The two others from the jtag group have no data to be read.

Does anyone have an idea, an advice ?
That would be much appreciated.

If impossible through dts, how can I do that ? spidev ? How ?

Thank you.

Vince
« Last Edit: August 07, 2018, 01:07:27 PM by vinczo »

vinczo

  • Newbie
  • *
  • Posts: 16
  • Karma: +1/-0
Re: adding spi device
« Reply #1 on: August 08, 2018, 05:28:39 PM »
Trying to expose the problem in a clearer manner and presenting the progress...

The context
We have a working board which has 2 spi devices : a flash memory & an eeprom that contains a MAC address. We need to add 2 more spi devices containing two other MAC addresses.

These two SPI devices have their CS in the JTAG group.

The issue
AFAIK since the JTAG group doesn't support ralink,function="spi", I can't use the same driver as for the first MAC addr ( compatible="at25" ), right ?

The incomplete solution?
The only solution that I have would be to use spidev ? How ?
I tried something but I don't know if it worked : I managed to declare them as spidev but I don't know how to extract the MAC addr from /dev/spidevxxx.
If I try to hexdump /dev/spidevxxx, this is what I get :

Code: [Select]
root@OpenWrt:~# ls /sys/bus/spi/devices/spi32766.2/
driver/     modalias    spidev/     subsystem/  uevent
root@OpenWrt:~# ls /sys/bus/spi/devices/spi32766.2/spidev/spidev32766.2/
dev         device/     subsystem/  uevent
root@OpenWrt:~# cat /sys/bus/spi/devices/spi32766.2/spidev/spidev32766.2/dev
153:1
root@OpenWrt:~# hexdump /dev/spidev32766.2
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
^C

Thank you in advance for your help.

Vince
« Last Edit: August 08, 2018, 05:32:40 PM by vinczo »