Power & Source of Big Ideas

Use SPI1 on nanopi neo core 2

Moderators: chensy, FATechsupport

I'm trying to enable and use SPI1 on a Nanopi neo core 2, using the Friendlyarm kernel.

I understand that SPI1 is multiplexed with UART3, and is disabled by default. But simply enabling SPI1 in the device tree while disabling UART3 didn't do the trick (there was no attempt to bring up spi1 during boot). Extending the DT with my device as follows (fragment of a DT overlay file):

Code: Select all

fragment@6 {
        target = <&spi1>;
        __overlay__ {
                #address-cells = <1>;
                #size-cells = <0>;
                pinctrl-names = "default";
                pinctrl-0 = <&spi1_pins>;
                status = "okay";
                eth1: spidev1@0 {
                        status = "okay";
                        compatible = "micrel,ks8851";
                        reg = <0>;

                        spi-max-frequency = <40000000>; /* 40 MHz */
                       
                        reset-gpios = <&pio 6 9 1>; /* PG9 GPIO_ACTIVE_LOW */

                        interrupt-controller;
                        #interrupt-cells=<2>;
                        interrupt-parent = <&pio>;
                        interrupts = <11 11 8>; /* PL11 IRQ_TYPE_LEVEL_LOW */
                };
        };
};


Produces the following errors during boot:

Code: Select all

pi@NanoPi-NEO-Core2:~$ dmesg | grep spi
[    1.278364] sun6i-spi 1c69000.spi: chipselect 0 already in use
[    1.284211] spi_master spi1: spi_device register error /soc/spi@1c69000/spi@1
[    1.291350] spi_master spi1: Failed to create SPI device for /soc/spi@1c69000/spi@1
[   10.806866] ks8851 spi1.0: spi1.0 supply vdd-io not found, using dummy regulator
[   10.806983] ks8851 spi1.0: spi1.0 supply vdd not found, using dummy regulator
[   10.817998] ks8851 spi1.0: message enable is 0
[   10.820343] ks8851 spi1.0: failed to get irq
[   10.820462] ks8851: probe of spi1.0 failed with error -22


Why does it complain that chipselect 0 is already in use? Am I missing something from SPI1 configuration?
ptz wrote:
I'm trying to enable and use SPI1 on a Nanopi neo core 2, using the Friendlyarm kernel.

I understand that SPI1 is multiplexed with UART3, and is disabled by default. But simply enabling SPI1 in the device tree while disabling UART3 didn't do the trick (there was no attempt to bring up spi1 during boot). Extending the DT with my device as follows (fragment of a DT overlay file):

Code: Select all

fragment@6 {
        target = <&spi1>;
        __overlay__ {
                #address-cells = <1>;
                #size-cells = <0>;
                pinctrl-names = "default";
                pinctrl-0 = <&spi1_pins>;
                status = "okay";
                eth1: spidev1@0 {
                        status = "okay";
                        compatible = "micrel,ks8851";
                        reg = <0>;

                        spi-max-frequency = <40000000>; /* 40 MHz */
                       
                        reset-gpios = <&pio 6 9 1>; /* PG9 GPIO_ACTIVE_LOW */

                        interrupt-controller;
                        #interrupt-cells=<2>;
                        interrupt-parent = <&pio>;
                        interrupts = <11 11 8>; /* PL11 IRQ_TYPE_LEVEL_LOW */
                };
        };
};


Produces the following errors during boot:

Code: Select all

pi@NanoPi-NEO-Core2:~$ dmesg | grep spi
[    1.278364] sun6i-spi 1c69000.spi: chipselect 0 already in use
[    1.284211] spi_master spi1: spi_device register error /soc/spi@1c69000/spi@1
[    1.291350] spi_master spi1: Failed to create SPI device for /soc/spi@1c69000/spi@1
[   10.806866] ks8851 spi1.0: spi1.0 supply vdd-io not found, using dummy regulator
[   10.806983] ks8851 spi1.0: spi1.0 supply vdd not found, using dummy regulator
[   10.817998] ks8851 spi1.0: message enable is 0
[   10.820343] ks8851 spi1.0: failed to get irq
[   10.820462] ks8851: probe of spi1.0 failed with error -22


Why does it complain that chipselect 0 is already in use? Am I missing something from SPI1 configuration?


We have working overlays on few years more recent kernel which is supported.
This is, I believe, the second time I ask a question here and get a response from you advertising Armbian, Igor. I did toy with it the last time, but I don't see how it can help me here - I would still need to write and debug a custom overlay. Not sure how adding an OS switch to my work will help.
When I brutally comment-out all mention of UART3 from the DT, it seems to help. The "chipselect 0 already in use" error disappears. The others remain for now.
ptz wrote:
This is, I believe, the second time I ask a question here and get a response from you advertising Armbian, Igor. I did toy with it the last time, but I don't see how it can help me here - I would still need to write and debug a custom overlay. Not sure how adding an OS switch to my work will help.


It will help you everywhere. Not just here.

Armbian is community backed non-profit project. It doesn't need advertisements, contrary. I only try to help you since you are failing and there are not many people that will jump into this code.

We use 4.19, 5.4.y and understand how those chips works very well. No other Linux distro does. We use several hundreds of fixes on top of mainline kernel.

You choose to stick to vendor ... well, convincing convinced is pointless, I am aware, I will not do any more, I promise. I wish you good luck fixing this problem. And another, and another, ...
igorp wrote:
It will help you everywhere. Not just here.

Armbian is community backed non-profit project. It doesn't need advertisements, contrary. I only try to help you since you are failing and there are not many people that will jump into this code.

We use 4.19, 5.4.y and understand how those chips works very well. No other Linux distro does. We use several hundreds of fixes on top of mainline kernel.

You choose to stick to vendor ... well, convincing convinced is pointless, I am aware, I will not do any more, I promise. I wish you good luck fixing this problem. And another, and another, ...


I think that if I were starting a new development-board project I'd definitely look into Armbian. But when I was starting support for my board was still not as stable as I would have liked, so I went with FriendlyArm's image, which I then customized. The future of my project is to move away from the development board entirely, so I expect this to be the last time I mess with anything other than userspace. Hence my unwillingness to switch to Armbian at this point.

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 2 guests