Thursday, August 25, 2016

MMC2 Linux Device Tree Configuration For SD CARD on ARM PART ii




What has changed since earlier kernel releases?

  • There has been a recent changes (end of last year) to the dt bindings for eDMA3.  Older kernels used DEPRECATED binding for DTS files.  The old bindings were ti,edma3-tpcc/ti,edma3-tptc.  And to get mmc2 (labeled mmc3 in dts files) to work properly you must use the ti,edma-xbar-event-map property for edma:


&mmc3 {
      vmmc-supply = <&vmmcsd_fixed>;
      ti,dual-volt;
      ti,needs-special-reset;
      ti,needs-special-hs-handling;
      pinctrl-names = "default";
      pinctrl-0 = <&mmc3_pins>;
      cd-gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>;
      cd-inverted;
      bus-width = <4>;
      max-frequency = <25000000>;
      dmas = <&edma 12
              &edma 13>;
      dma-names = "tx", "rx";
      status = "okay";
};

&edma {
 ti,edma-xbar-event-map = /bits/ 16 <1 12 
                                     2 13>;

};


What are the new dt bindings for eDMA3?

  • "ti,edma3-tpcc" for the channel controller(s)
  • "ti,edma3-tptc" for the transfer controller(s)
  • "ti,am335x-edma-crossbar" for Crossbar event to channel map
The changes to mmc3 configuration is in bold below:

&mmc3 {
      vmmc-supply = <&vmmcsd_fixed>;
      ti,dual-volt;
      ti,needs-special-reset;
      ti,needs-special-hs-handling;
      pinctrl-names = "default";
      pinctrl-0 = <&mmc3_pins>;
      cd-gpios = <&gpio3 16 GPIO_ACTIVE_LOW>;
      bus-width = <4>;
      max-frequency = <25000000>;

     dmas = <&edma_xbar 12 0 1
             &edma_xbar 13 0 2>;

     #address-cells = <1>;
     #size-cells = <0>;

     dma-names = "tx", "rx";
     status = "okay";
};

  • This is assuming that the pinmux configuration for mmc3 (&mmc3_pins) is:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
mmc3_pins: pinmux_mmc3_pins { 

    pinctrl-single,pins = < 
    
      /* gpmc_a1.mmc2_dat0, INPUT_PULLUP | MODE3 */
       0x44 (PIN_INPUT_PULLUP | MUX_MODE3)
      
      /* gpmc_a2.mmc2_dat1, INPUT_PULLUP | MODE3 */ 
       0x48 (PIN_INPUT_PULLUP | MUX_MODE3) 

      /* gpmc_a3.mmc2_dat2, INPUT_PULLUP | MODE3 */  
       0x4C (PIN_INPUT_PULLUP | MUX_MODE3) 
 
      /* gpmc_ben1.mmc2_dat3, INPUT_PULLUP | MODE3 */
       0x78 (PIN_INPUT_PULLUP | MUX_MODE3)

      /* gpmc_csn3.mmc2_cmd, INPUT_PULLUP | MODE3 */ 
       0x88 (PIN_INPUT_PULLUP | MUX_MODE3)
  
      /* gpmc_clk.mmc2_clk, INPUT_PULLUP | MODE3 */  
      0x8C (PIN_INPUT_PULLUP | MUX_MODE3) 

      /* gpmc_a0.gpio1_16 */ 
      0x40 (PIN_OUTPUT_PULLDOWN | MUX_MODE7)
 
      /* mmc2_sdcd, p9_13, Note: Dont know why but we set card 
         detect pinout to be GPIO */  
      0x74 (PIN_INPUT_PULLDOWN | MUX_MODE7)

      /* mmc2_sdwp, p9_17, Note: Write protect is not configured
         in the device tree settings*/ 
      0x15c (PIN_INPUT_PULLDOWN | MUX_MODE1) 

    >; 

};

Friday, July 1, 2016

MMC2 Linux Device Tree Configuration For SD CARD on ARM PART i

Update: 


  • This blog is useful for ARM microprocessors running Linux Kernel versions 4.1.2-ti-r4 to 4.4.0.
  • It could still be relevant for earlier kernel releases but earlier releases  
have not been tested.
  • If your ARM microprocessor is running kernel's 4.4.16-ti-rt and newer go to part II:

Interfacing a second SD card reader to the Beaglebone Black 


  • I could not find any tutorials or guides in forums on how to interface another SD card to the beaglebone black, so I thought I'd share and show you how I got mine up and running.  I won't explain the device tree bindings in detail but you can use my solution as a reference.




MMC2 PINMUX CONFIGURATION:


Added in file: am335x-bone-common.dtsi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
mmc3_pins: pinmux_mmc3_pins { 

    pinctrl-single,pins = < 

       0x44 (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_a1.mmc2_dat0, INPUT_PULLUP | MODE3 */

         0x48 (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_a2.mmc2_dat1, INPUT_PULLUP | MODE3 */ 

         0x4C (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_a3.mmc2_dat2, INPUT_PULLUP | MODE3 */ 

         0x78 (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_ben1.mmc2_dat3, INPUT_PULLUP | MODE3 */

         0x88 (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_csn3.mmc2_cmd, INPUT_PULLUP | MODE3 */ 

         0x8C (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_clk.mmc2_clk, INPUT_PULLUP | MODE3 */ 

         0x40 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* gpmc_a0.gpio1_16 */ 

         0x74 (PIN_INPUT_PULLDOWN | MUX_MODE7) /* mmc2_sdcd, p9_13, Note: Dont know why but we set card detect pinout to be GPIO */ 

         0x15c (PIN_INPUT_PULLDOWN | MUX_MODE1) /* mmc2_sdwp, p9_17, Note: Write protect is not configured in the device tree settings*/ 

    >; 

};
 

  • Note that the mmc0, mmc1, and mmc2 lines on the beaglebone refer to mmc1, mmc2, and mmc3 in the device tree.




1
2
3
4
         0x88 (PIN_INPUT_PULLUP | MUX_MODE3) /* gpmc_csn3.mmc2_cmd, INPUT_PULLUP | MODE3 */ 
                    ...
                    ...
         0x40 (PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* gpmc_a0.gpio1_16 */ 



  • You can see that the two lines are connected:





MMC2 DEVICE TREE BINDINGS:



Added in file: am335x-bone-common.dtsi


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
&mmc3 {
      vmmc-supply = <&vmmcsd_fixed>;
      ti,dual-volt;
      ti,needs-special-reset;
      ti,needs-special-hs-handling;
      pinctrl-names = "default";
      pinctrl-0 = <&mmc3_pins>;
      cd-gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>;
      cd-inverted;
      bus-width = <4>;
      max-frequency = <25000000>;
      dmas = <&edma 12
              &edma 13>;
      dma-names = "tx", "rx";
      status = "okay";
};

&edma {
 ti,edma-xbar-event-map = /bits/ 16 <1 12 
                                     2 13>;

};