2

I have the following device tree overlay fragment, and when it's loaded, spidev is added twice:

fragment@0 {
    target = <&fpga>;
    __overlay__ {
        #address-cells = <1>;
        #size-cells = <1>;

        spi2@600 {
            status = "okay";
            compatible = "opencores,spiocv2";
            #address-cells = <1>;
            #size-cells = <0>;
            reg = <0 0x800>;
            cell-index = <2>; // bus number

            spidev0 {
                 spi-max-frequency = <25000000>;
                 reg = <0>;
                 compatible = "spidev";
            };
        };
    };
};
  1. first via of_overlay_create -> ... -> notifier_call_chain -> of_platform_notify -> ... -> device_attach -> ... -> spioc_driver_probe -> spi_register_master -> of_register_spi_devices -> of_register_spi_device -> spi_add_device
  2. then again via of_overlay_create -> ... -> notifier_call_chain -> of_spi_notify -> of_register_spi_device -> spi_add_device

Because it is first loaded correctly, /dev/spidev2.0 is available and works fine, but the second call leads to ugly errors:

[    1.814623] opencores_spi 13e0000f3300000.spi2: chipselect 0 already in use
[    1.836491] spi_master spi2: spi_device register error /fpga/spi2@600/spidev0
[    1.857652] of_spi_notify: failed to create for '/fpga/spi2@600/spidev0'
[    1.877495] __of_changeset_entry_notify: notifier error @/fpga/spi2@600/spidev0

What is a clean and proper way to prevent it from being loaded twice? Or how can I prevent the notifier from notifying the platform and SPI?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.