BBB:如何在linux 3.14上打开编码器和PWM设备

时间:2015-05-03 15:30:30

标签: embedded ubuntu-14.04 beagleboneblack pwm

我在 BeagleBone Black 主板上安装了Ubuntu(14.04.2 LTS)的新图像。我发现不再支持开普敦经理了,所以

echo bone_eqep2b > /sys/devices/bone_capemgr.*/slots

不起作用。 据我所知加载设备树覆盖,我需要以下内容:

  1. 安装RSCM
  2. 修复am335x-boneblack.dts档案
  3. 运行build.sh
  4. 重新启动主板
  5. 所以,我怀疑第2项。如何正确合并bone_eqep2b.dtsam335x-boneblack.dts

    我想,要启用eqep2b,我只需要更改这段代码:

    epwmss@48304000 {
            compatible = "ti,am33xx-pwmss";
            reg = <0x48304000 0x10>;
            ti,hwmods = "epwmss2";
            #address-cells = <0x1>;
            #size-cells = <0x1>;
            status = "disabled";
            ranges = <0x48304100 0x48304100 0x80 0x48304180 0x48304180 0x80 0x48304200 0x4
    8304200 0x80>;
    
            ecap@48304100 {
                    compatible = "ti,am33xx-ecap";
                    #pwm-cells = <0x3>;
                    reg = <0x48304100 0x80>;
                    ti,hwmods = "ecap2";
                    status = "disabled";
            };
    
            ehrpwm@48304200 {
                    compatible = "ti,am33xx-ehrpwm";
                    #pwm-cells = <0x3>;
                    reg = <0x48304200 0x80>;
                    ti,hwmods = "ehrpwm2";
                    status = "disabled";
            };
    };
    

    类似

    epwmss@48304000 {
            compatible = "ti,am33xx-pwmss";
            reg = <0x48304000 0x10>;
            ti,hwmods = "epwmss2";
            #address-cells = <0x1>;
            #size-cells = <0x1>;
            status = "okay";
    
            count_mode = <0>;  /* 0 - Quadrature mode, normal 90 phase offset cha & chb.  1 - Direction mode.  cha input = clock, chb input = direction */
            swap_inputs = <0>; /* Are channel A and channel B swapped? (0 - no, 1 - yes) */
            invert_qa = <1>;   /* Should we invert the channel A input?  */
            invert_qb = <1>;   /* Should we invert the channel B input? I invert these because my encoder outputs drive transistors that pull down the pins */
            invert_qi = <0>;   /* Should we invert the index input? */
            invert_qs = <0>;   /* Should we invert the strobe input? */
    
            status = "okay";
    
    
            ranges = <0x48304100 0x48304100 0x80 0x48304180 0x48304180 0x80 0x48304200 0x4
    8304200 0x80>;
    
            ecap@48304100 {
                    compatible = "ti,am33xx-ecap";
                    #pwm-cells = <0x3>;
                    reg = <0x48304100 0x80>;
                    ti,hwmods = "ecap2";
                    status = "okay";
            };
    
            ehrpwm@48304200 {
                    compatible = "ti,am33xx-ehrpwm";
                    #pwm-cells = <0x3>;
                    reg = <0x48304200 0x80>;
                    ti,hwmods = "ehrpwm2";
                    status = "okay";
            };
    };
    

    正确?

    我找不到一个现成的版本,如果有人已经修复并且可以分享它,那将会很棒。

2 个答案:

答案 0 :(得分:1)

在内核v3.14中,您可以通过将epwmssx,ecapx和&amp;的状态设置为“okay”来启用PWM。 ehrpwmx,在Robert C Nelson的dtb-rebuilder项目中的am33xx.dtsi下。但是,这只会启用子系统而不是多路复用引脚或启用PWMXTBCLK寄存器。

要复用PWM的引脚,请在GitHub上使用cdsteinkuehler的Universal IO项目中的“config-pin”

要启用PWMXTBCLK寄存器,您需要编写一个简单的内核模块。 (我不知道如何在设备树中执行此操作)

编辑:更新过时的参考文献: 在内核模块中,您需要写入以下寄存器:0x44E10664 该寄存器也称为CONTROL_MODULE.pwmss_ctrl

SPRUH73H- 2011年10月 - 2013年4月修订的版AM335X技术参考手册第796页所述,写入0x01启用pwm子系统1,子系统2为0x02,子系统3为0x04,三者的任意组合(例如0x07启用所有这些组合:0x01 | 0x02 | 0x04 = 0x07)。

答案 1 :(得分:1)

我正在使用内核3.18,并且能够使用我在am335x-bone-common-pinmux.dtsi文件中添加这些模块的eqep模块来正确设置pinmux。

...
/* eHRPWM0 module */
pinctrl_ehrpwm0: pinctrl_ehrpwm0 {
    pinctrl-single,pins = <
        0x150 0x23  /* P9_22 = GPIO0_2 = eHRPWM0A, MODE3 */
        0x190 0x21  /* P9_31 = GPIO3_14 = eHRPWM0A, MODE1 */
        0x154 0x23  /* P9_21 = GPIO0_3 = eHRPWM0B, MODE3 */
        /*0x0a4 0x23     This is not OK P8_46 = GPIO2_7 = eHRPWM0B, MODE3 */
    >;
};

/* eCAP0 module ?????*/
pinctrl_ecap0: pinctrl_ecap0 {
    pinctrl-single,pins = <
        0x164 0x20  /* P9_42A (?) = GPIO0_7 = eCAP0, MODE0 */
    >;
};

/* eQEP0 module */
pinctrl_eqep0: pinctrl_eqep0 {
    pinctrl-single,pins = <
        0x1a8 0x21  /* P9_41B = GPIO3_20 = eQEP0_index, MODE1 */
        0x1ac 0x21  /* P9_25 = GPIO3_21 = eQEP0_strobe, MODE1 */
        0x1a4 0x31  /* P9_27 = GPIO3_19 = eQEP0B_in, MODE1 */
        0x1a0 0x31  /* P9_42B = GPIO3_18 = eQEP0A_in, MODE1 */
    >;
};


/* eHRPWM1 module */
pinctrl_ehrpwm1: pinctrl_ehrpwm1 {
    pinctrl-single,pins = <
        0x048 0x26  /* P9_14 = GPIO1_18 = eHRPWM1A, MODE6 */
        0x0c8 0x22  /* P8_36 = GPIO2_16 = eHRPWM1A, MODE2 */
        0x04c 0x26  /* P9_16 = GPIO1_19 = eHRPWM1B, MODE6 */
        0x0cc 0x22  /* P8_34 = GPIO2_17 = eHRPWM1B, MODE2 */
    >;
};

/* eQEP1 module */
pinctrl_eqep1: pinctrl_eqep1 {
    pinctrl-single,pins = <
        /*0x0d8 0x22     P8_31 = GPIO0_10 = eQEP1_index, MODE2, USED FOR PHOTOCELLS */
        /*0x0dc 0x22     P8_32 = GPIO0_11 = eQEP1_strobe, MODE2 USED FOR PHOTOCELLS */
        0x0d4 0x32  /* P8_33 = GPIO0_09 = eQEP1B_in, MODE2 */
        0x0d0 0x32  /* P8_35 = GPIO0_08 = eQEP1A_in, MODE2 */
    >;
};


/* eHRPWM2 module */
pinctrl_ehrpwm2: pinctrl_ehrpwm2 {
    pinctrl-single,pins = <
        0x020 0x24  /* P8_19 = GPIO0_22 = eHRPWM2A, MODE4*/
        0x0a0 0x23  /* P8_45 = GPIO2_6 = eHRPWM2A, MODE3 */
        0x024 0x24  /* P8_13 = GPIO0_23 = eHRPWM2B, MODE4 */
        0x0a4 0x23  /* P8_46 = GPIO2_7 = eHRPWM2B, MODE3 */
    >;
};

/* eCAP2 module */
pinctrl_ecap2: pinctrl_ecap2 {
    pinctrl-single,pins = <
        0x19c 0x24  /* P9_28 = GPIO3_17 = eCAP2, MODE4 */
    >;
};

/* eQEP2 module */
pinctrl_eqep2: pinctrl_eqep2 {
    pinctrl-single,pins = <
        0x038 0x0F  /* P8_16 = GPIO1_14 = eQEP2_index, MODE4 --- STOLEN FOR MOTOR DIRECTION, ORIGINAL HEX value was 0x24*/
        0x03c 0x0F  /* P8_15 = GPIO1_15 = eQEP2_strobe, MODE4 --- STOLEN FOR MOTOR DIRECTION, ORIGINAL HEX value was 0x24*/
        0x034 0x34  /* P8_11 = GPIO1_13 = eQEP2B_in, MODE4 */
        0x030 0x34  /* P8_12 = GPIO1_12 = eQEP2A_in, MODE4 */
    >;
};
...

然后也在am33x.dtsi:

    epwmss0: epwmss@48300000 {
        compatible = "ti,am33xx-pwmss";
        reg = <0x48300000 0x10>;
        ti,hwmods = "epwmss0";
        #address-cells = <1>;
        #size-cells = <1>;
        status = "disabled";
        ranges = <0x48300100 0x48300100 0x80   /* ECAP */
              0x48300180 0x48300180 0x80   /* EQEP */
              0x48300200 0x48300200 0x80>; /* EHRPWM */

        ecap0: ecap@48300100 {
            compatible = "ti,am33xx-ecap";
            #pwm-cells = <3>;
            reg = <0x48300100 0x80>;
            interrupts = <31>;
            interrupt-names = "ecap0";
            ti,hwmods = "ecap0";
            status = "disabled";
        };

        eqep0: eqep@48300180 {
            /* pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_eqep0>;*/
            compatible = "ti,am33xx-eqep";
            reg = <0x48300180 0x80>;
            ti,hwmods = "eqep0";
            interrupt-parent = <&intc>;
            interrupts = <79>;
            status = "disabled";
        };


        ehrpwm0: ehrpwm@48300200 {
            compatible = "ti,am33xx-ehrpwm";
            #pwm-cells = <3>;
            reg = <0x48300200 0x80>;
            ti,hwmods = "ehrpwm0";
            status = "disabled";
        };
    };

    epwmss1: epwmss@48302000 {
        compatible = "ti,am33xx-pwmss";
        reg = <0x48302000 0x10>;
        ti,hwmods = "epwmss1";
        #address-cells = <1>;
        #size-cells = <1>;
        status = "okay";
        ranges = <0x48302100 0x48302100 0x80   /* ECAP */
              0x48302180 0x48302180 0x80   /* EQEP */
              0x48302200 0x48302200 0x80>; /* EHRPWM */

        ecap1: ecap@48302100 {
            compatible = "ti,am33xx-ecap";
            #pwm-cells = <3>;
            reg = <0x48302100 0x80>;
            interrupts = <47>;
            interrupt-names = "ecap1";
            ti,hwmods = "ecap1";
            status = "disabled";
        };

        eqep1: eqep@48302180 {
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_eqep1>;
            compatible = "ti,am33xx-eqep";
            reg = <0x48302180 0x80>;
            ti,hwmods = "eqep1";
            interrupt-parent = <&intc>;
            interrupts = <88>;
            status = "okay";
        };


        ehrpwm1: ehrpwm@48302200 {
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_ehrpwm1>;
            compatible = "ti,am33xx-ehrpwm";
            #pwm-cells = <3>;
            reg = <0x48302200 0x80>;
            ti,hwmods = "ehrpwm1";
            status = "okay";
        };
    };

    epwmss2: epwmss@48304000 {
        compatible = "ti,am33xx-pwmss";
        reg = <0x48304000 0x10>;
        ti,hwmods = "epwmss2";
        #address-cells = <1>;
        #size-cells = <1>;
        status = "okay";
        ranges = <0x48304100 0x48304100 0x80   /* ECAP */
              0x48304180 0x48304180 0x80   /* EQEP */
              0x48304200 0x48304200 0x80>; /* EHRPWM */

        ecap2: ecap@48304100 {
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_ecap2>;
            compatible = "ti,am33xx-ecap";
            #pwm-cells = <3>;
            reg = <0x48304100 0x80>;
            interrupts = <61>;
            interrupt-names = "ecap2";
            ti,hwmods = "ecap2";
            status = "okay";
        };

        eqep2: eqep@48304180 {
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_eqep2>;
            compatible = "ti,am33xx-eqep";
            reg = <0x48304180 0x80>;
            ti,hwmods = "eqep2";
            interrupt-parent = <&intc>;
            interrupts = <89>;
            status = "okay";
        };

        ehrpwm2: ehrpwm@48304200 {
            pinctrl-names = "default";
            pinctrl-0 = <&pinctrl_ehrpwm2>;
            compatible = "ti,am33xx-ehrpwm";
            #pwm-cells = <3>;
            reg = <0x48304200 0x80>;
            ti,hwmods = "ehrpwm2";
            status = "okay";
        };
    };

我重建了am335x-boneblack.dtb并复制到了BBB。在此之后我从https://github.com/Teknoman117/beaglebot/tree/master/encoders加载了eqep内核模块  它工作正常。