Difference between revisions of "BeagleBone Black Enable SPIDEV"

From eLinux.org
Jump to: navigation, search
(SPI0)
Line 108: Line 108:
 
Start nano
 
Start nano
 
<pre>
 
<pre>
nano BB-SPI1-01-00A0.dts
+
nano BB-SPI0-01-00A0.dts
 
</pre>
 
</pre>
 
<br>
 
<br>
Line 120: Line 120:
  
 
     /* identification */
 
     /* identification */
     part-number = "BB-SPI1-01";
+
     part-number = "spi0pinmux";
 
 
    /* version */
 
    version = "00A0";
 
 
 
    /* state the resources this cape uses */
 
    exclusive-use =
 
        /* the pin header uses */
 
        "P9.31",
 
        "P9.29",
 
        "P9.30",
 
        "P9.28",
 
        "P9.13",
 
        "P9.12",
 
        "spi1";
 
  
 
     fragment@0 {
 
     fragment@0 {
 
         target = <&am33xx_pinmux>;
 
         target = <&am33xx_pinmux>;
 
         __overlay__ {
 
         __overlay__ {
             pinctrl_spi1: pinctrl_spi1_pins {
+
             spi0_pins_s0: spi0_pins_s0 {
                 pinctrl-single,pins = <                                      
+
                 pinctrl-single,pins = <
                    0x190 0x13    /* P9_31 = mcasp0_aclkx.spi1_sclk                , OUTPUT_PULLUP | MODE3 */
+
                  0x150 0x30  /* spi0_sclk, INPUT_PULLUP | MODE0 */
                    0x194 0x33    /* P9_29 = mcasp0_fsx.spi1_d0                    , INPUT_PULLUP | MODE3 */
+
                  0x154 0x30  /* spi0_d0, INPUT_PULLUP | MODE0 */
                    0x198 0x13    /* P9_30 = mcasp0_axr0.spi1_d1                    , OUTPUT_PULLUP | MODE3 */
+
                  0x158 0x10  /* spi0_d1, OUTPUT_PULLUP | MODE0 */
                    0x19c 0x13    /* P9_28 = mcasp0_ahclkr.spi1_cs0                , OUTPUT_PULLUP | MODE3 */                   
+
                  0x15c 0x10 /* spi0_cs0, OUTPUT_PULLUP | MODE0 */
                    0x164 0x12 /* P9_42 = GPIO0_7 =  eCAP0_in_PWM0_out.gpio0[7] , OUTPUT_PULLUP | MODE2 */
 
 
                 >;
 
                 >;
 
             };
 
             };
Line 152: Line 137:
  
 
     fragment@1 {
 
     fragment@1 {
         target = <&spi1>;
+
         target = <&spi0>;
 
         __overlay__ {
 
         __overlay__ {
            #address-cells     = <1>;
+
            #address-cells = <1>;
            #size-cells     = <0>;
+
            #size-cells = <0>;
            status           = "okay";
+
 
            pinctrl-names   = "default";
+
            status = "okay";
            pinctrl-0       = <&pinctrl_spi1>;   
+
            pinctrl-names = "default";
            cs-gpios        = <&gpio4 17 0>, <&gpio1 7 0>;
+
            pinctrl-0 = <&spi0_pins_s0>;
  
            spi1_0{
+
            spidev@0 {
                #address-cells      = <1>;
+
                spi-max-frequency = <24000000>;
                #size-cells      = <0>;
+
                reg = <0>;
                compatible          = "spidev";
+
                compatible = "linux,spidev";
                reg              = <0>;
 
                spi-max-frequency = <16000000>;
 
                spi-cpha;         
 
            };
 
            spi1_1{
 
                #address-cells      = <1>;
 
                #size-cells      = <0>;
 
                compatible           = "spidev";
 
                reg              = <1>;
 
                spi-max-frequency = <16000000>;
 
                // Mode 0 (CPOL = 0, CPHA = 0)
 
 
             };
 
             };
 
         };
 
         };
Line 183: Line 157:
 
Close the file (Ctrl-o, Ctrl-x) and compile using dtc:
 
Close the file (Ctrl-o, Ctrl-x) and compile using dtc:
 
<pre>
 
<pre>
dtc -O dtb -o BB-SPI1-01-00A0.dtbo -b 0 -@ BB-SPI1-01-00A0.dts
+
dtc -O dtb -o BB-SPI0-01-00A0.dtbo -b 0 -@ BB-SPI0-01-00A0.dts
 
</pre>
 
</pre>
 
Then, copy the file into /lib/firmware/:
 
Then, copy the file into /lib/firmware/:
 
<pre>
 
<pre>
  cp BB-SPI1-01-00A0.dtbo /lib/firmware/
+
  cp BB-SPI0-01-00A0.dtbo /lib/firmware/
 
</pre>
 
</pre>
 
Then enable the device tree overlay:
 
Then enable the device tree overlay:
 
<pre>
 
<pre>
  echo BB-SPI1-01 > /sys/devices/bone_capemgr.*/slots
+
  echo BB-SPI0-01 > /sys/devices/bone_capemgr.*/slots
 
</pre>
 
</pre>
  
Line 197: Line 171:
 
You should now have two spidev-files in the folder /dev/
 
You should now have two spidev-files in the folder /dev/
 
<pre>
 
<pre>
ls -al /dev/spidev1.*
+
ls -al /dev/spidev0.*
 
</pre>
 
</pre>
 
You should also be able to see the pingroups:
 
You should also be able to see the pingroups:

Revision as of 19:41, 15 July 2013

For SPI1

Start nano

nano BB-SPI1-01-00A0.dts


Copy-paste this into the file:

/dts-v1/;
/plugin/;

/ {
    compatible = "ti,beaglebone", "ti,beaglebone-black";

    /* identification */
    part-number = "BB-SPI1-01";

    /* version */
    version = "00A0";

    /* state the resources this cape uses */
    exclusive-use =
        /* the pin header uses */
        "P9.31",
        "P9.29",
        "P9.30",
        "P9.28",
        "P9.13",
        "P9.12", 
        "spi1";

    fragment@0 {
        target = <&am33xx_pinmux>;
        __overlay__ {
            pinctrl_spi1: pinctrl_spi1_pins {
                pinctrl-single,pins = <                                        
                    0x190 0x13    /* P9_31 = mcasp0_aclkx.spi1_sclk                 , OUTPUT_PULLUP | MODE3 */
                    0x194 0x33    /* P9_29 = mcasp0_fsx.spi1_d0                     , INPUT_PULLUP  | MODE3 */
                    0x198 0x13    /* P9_30 = mcasp0_axr0.spi1_d1                     , OUTPUT_PULLUP | MODE3 */
                    0x19c 0x13    /* P9_28 = mcasp0_ahclkr.spi1_cs0                 , OUTPUT_PULLUP | MODE3 */                    
                    0x164 0x12  /* P9_42 = GPIO0_7 =  eCAP0_in_PWM0_out.gpio0[7] , OUTPUT_PULLUP | MODE2 */
                >;
            };
        };
    };

    fragment@1 {
        target = <&spi1>;
        __overlay__ {
            #address-cells     = <1>;
            #size-cells     = <0>;
            status            = "okay";
            pinctrl-names    = "default";
            pinctrl-0        = <&pinctrl_spi1>;    
            cs-gpios         = <&gpio4 17 0>, <&gpio1 7 0>;

            spi1_0{
                #address-cells       = <1>;
                #size-cells       = <0>;
                compatible           = "spidev";
                reg               = <0>;
                spi-max-frequency = <16000000>;
                spi-cpha;          
            };
            spi1_1{
                #address-cells       = <1>;
                #size-cells       = <0>;
                compatible           = "spidev";
                reg               = <1>;
                spi-max-frequency = <16000000>;
                // Mode 0 (CPOL = 0, CPHA = 0)
            };
        };
    };
};

Close the file (Ctrl-o, Ctrl-x) and compile using dtc:

dtc -O dtb -o BB-SPI1-01-00A0.dtbo -b 0 -@ BB-SPI1-01-00A0.dts

Then, copy the file into /lib/firmware/:

 cp BB-SPI1-01-00A0.dtbo /lib/firmware/

Then enable the device tree overlay:

 echo BB-SPI1-01 > /sys/devices/bone_capemgr.*/slots

Make sure it is enabled You should now have two spidev-files in the folder /dev/

ls -al /dev/spidev1.*

You should also be able to see the pingroups:

cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups

SPI0

Start nano

nano BB-SPI0-01-00A0.dts


Copy-paste this into the file:

/dts-v1/;
/plugin/;

/ {
    compatible = "ti,beaglebone", "ti,beaglebone-black";

    /* identification */
    part-number = "spi0pinmux";

    fragment@0 {
        target = <&am33xx_pinmux>;
        __overlay__ {
            spi0_pins_s0: spi0_pins_s0 {
                pinctrl-single,pins = <
                  0x150 0x30  /* spi0_sclk, INPUT_PULLUP | MODE0 */
                  0x154 0x30  /* spi0_d0, INPUT_PULLUP | MODE0 */
                  0x158 0x10  /* spi0_d1, OUTPUT_PULLUP | MODE0 */
                  0x15c 0x10  /* spi0_cs0, OUTPUT_PULLUP | MODE0 */
                >;
            };
        };
    };

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

             status = "okay";
             pinctrl-names = "default";
             pinctrl-0 = <&spi0_pins_s0>;

             spidev@0 {
                 spi-max-frequency = <24000000>;
                 reg = <0>;
                 compatible = "linux,spidev";
            };
        };
    };
};

Close the file (Ctrl-o, Ctrl-x) and compile using dtc:

dtc -O dtb -o BB-SPI0-01-00A0.dtbo -b 0 -@ BB-SPI0-01-00A0.dts

Then, copy the file into /lib/firmware/:

 cp BB-SPI0-01-00A0.dtbo /lib/firmware/

Then enable the device tree overlay:

 echo BB-SPI0-01 > /sys/devices/bone_capemgr.*/slots

Make sure it is enabled You should now have two spidev-files in the folder /dev/

ls -al /dev/spidev0.*

You should also be able to see the pingroups:

cat /sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups