1

Supposedly, there is a new driver that supports arbitrary GPIOs for SPI0 channel select, that is configurable via the device tree.

Everything I try only half works. The hard works. If I toggle the channel selects via GPIO, I can access the drive.

Below is one such attempt. I'm using physical pins 24,36,7,37 which correspond to GPIO 8, 16, 4, 26

Access to SD1 works

/dts-v1/;
/plugin/;

/ {
   compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";

   fragment@0 {
      target = <&spi0>;
      frag0: __overlay__ {
         status = "okay";
         sd1 {
                reg = <0>;
                status = "okay";
                compatible = "spi,mmc_spi";
                voltage-ranges = <3000 3500>;
                spi-max-frequency = <8000000>;
         };
         sd2 {
                reg = <1>;
                status = "okay";
                compatible = "spi,mmc_spi";
                volatge-ranges = <3000 3500>;
                spi-max-frequency = <8000000>;
         };
      };
   };
};

Devices appear detected, but I get errors on accessing the drives:

/dts-v1/;
/plugin/;

/ {
   compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";

   fragment@0 {
      target = <&spi0>;
      frag0: __overlay__ {
         status = "okay";
         pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
         cs-gpios = <&gpio 8 1>, <&gpio 16 1>, <&gpio 4 1>, <&gpio 26 1>;
         sd1 {
                reg = <0>;
                status = "okay";
                compatible = "spi,mmc_spi";
                voltage-ranges = <3000 3500>;
                spi-max-frequency = <8000000>;
         };
         sd2 {
                reg = <1>;
                status = "okay";
                compatible = "spi,mmc_spi";
                voltage-ranges = <3000 3500>;
                spi-max-frequency = <8000000>;
         };
         sd3 {
                reg = <2>;
                status = "okay";
                compatible = "spi,mmc_spi";
                voltage-ranges = <3000 3500>;
                spi-max-frequency = <8000000>;
         };
      };
   };

   fragment@1 {
      target = <&gpio>;
      frag1: __overlay__ {
          spi0_cs_pins: spi0_cs_pins {
              brcm,pins = <8 16 4 26>;
              brcm,function = <1>;
          };
      };
   };

   __overrides__ {
       cs0_pin = <&frag0>, "cs-gpios:4", <&frag1>, "bcrm,pins:0";
       cs1_pin = <&frag0>, "cs-gpios:16", <&frag1>, "bcrm,pins:4";
       cs2_pin = <&frag0>, "cs-gpios:28", <&frag1>, "bcrm,pins:8";
       cs3_pin = <&frag0>, "cs-gpios:40", <&frag1>, "bcrm,pins:12";
   };
};
  • Why not use the predefined blobs as documented in /boot/overlays/README ? – joan Feb 6 '18 at 19:57
  • I find no predefined blobs for more than 2 slaves on spi 0 – Adam Tegen Feb 6 '18 at 22:17
  • Could you give an example of one of these predefined blobs? – Adam Tegen Feb 6 '18 at 22:18

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.