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

Embedded BBB:如何在linux 3.14上打开编码器和PWM设备,embedded,ubuntu-14.04,beagleboneblack,pwm,Embedded,Ubuntu 14.04,Beagleboneblack,Pwm,我在我的BeagleBone Black板上安装了一个新的Ubuntu映像(14.04.2 LTS)。我发现cape manager不再受支持,所以 echo bone_eqep2b > /sys/devices/bone_capemgr.*/slots 不起作用。 据我所知,要加载设备树覆盖,我需要以下内容: 安装RSCM 修复am335x boneblack.dts文件 运行build.sh 重新启动电路板 因此,我对第2项表示怀疑。如何正确合并bone\u eqep2b.dts和a

我在我的BeagleBone Black板上安装了一个新的Ubuntu映像(14.04.2 LTS)。我发现cape manager不再受支持,所以

echo bone_eqep2b > /sys/devices/bone_capemgr.*/slots
不起作用。 据我所知,要加载设备树覆盖,我需要以下内容:

  • 安装RSCM
  • 修复am335x boneblack.dts文件
  • 运行build.sh
  • 重新启动电路板
  • 因此,我对第2项表示怀疑。如何正确合并
    bone\u eqep2b.dts
    am335x 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=;
    ti,hwmods=“epwmss2”;
    #地址单元=;
    #大小单元格=;
    status=“disabled”;
    范围=;
    ecap@48304100 {
    compatible=“ti,am33xx ecap”;
    #pwm单元=;
    reg=;
    ti,hwmods=“ecap2”;
    status=“disabled”;
    };
    ehrpwm@48304200 {
    compatible=“ti,am33xx ehrpwm”;
    #pwm单元=;
    reg=;
    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";
            };
    };
    
    epwmss@48304000 {
    compatible=“ti,am33xx pwmss”;
    reg=;
    ti,hwmods=“epwmss2”;
    #地址单元=;
    #大小单元格=;
    status=“好”;
    计数模式=;/*0-正交模式,正常90相位偏移cha和chb.1-方向模式。cha输入=时钟,chb输入=方向*/
    交换_输入=;/*通道A和通道B是否交换?(0-否,1-是)*/
    反转_qa=;/*我们应该反转通道A输入吗*/
    反转_qb=;/*我们应该反转通道B输入吗?我反转这些,因为我的编码器输出驱动晶体管拉下管脚*/
    反转_qi=;/*我们应该反转索引输入吗*/
    反转_qs=;/*我们应该反转选通输入吗*/
    status=“好”;
    范围=;
    ecap@48304100 {
    compatible=“ti,am33xx ecap”;
    #pwm单元=;
    reg=;
    ti,hwmods=“ecap2”;
    status=“好”;
    };
    ehrpwm@48304200 {
    compatible=“ti,am33xx ehrpwm”;
    #pwm单元=;
    reg=;
    ti,hwmods=“ehrpwm2”;
    status=“好”;
    };
    };
    
    对吗


    我找不到一个现成的版本,如果有人已经修复并可以共享它,那就太好了。

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

    要多路复用PWM引脚,请使用GitHub上cdsteinkuehler的Universal IO项目中的“配置引脚”

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

    编辑:更新过期的引用: 在内核模块中,需要写入以下寄存器:
    0x44E10664
    该寄存器也称为
    控制模块.pwmss\u ctrl


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

    我使用的是内核3.18,为了能够使用eqep模块,我已将这些模块添加到am335x-bone-common-pinmux.dtsi文件中,以正确设置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 */
        >;
    };
    ...
    
    。。。
    /*eHRPWM0模块*/
    pinctrl_ehrpwm0:pinctrl_ehrpwm0{
    pinctrl单端,引脚=<
    0x150 0x23/*P9_22=GPIO0_2=eHRPWM0A,模式3*/
    0x190 0x21/*P9_31=GPIO3_14=eHRPWM0A,模式1*/
    0x154 0x23/*P9_21=GPIO0_3=eHRPWM0B,模式3*/
    /*0x0a4 0x23这不正常P8_46=GPIO2_7=eHRPWM0B,模式3*/
    >;
    };
    /*eCAP0模块*/
    pinctrl_ecap0:pinctrl_ecap0{
    pinctrl单端,引脚=<
    0x164 0x20/*P9_42A(?)=GPIO0_7=eCAP0,模式0*/
    >;
    };
    /*eQEP0模块*/
    pinctrl_eqep0:pinctrl_eqep0{
    pinctrl单端,引脚=<
    0x1a8 0x21/*P9_41B=GPIO3_20=eQEP0_索引,模式1*/
    0x1ac 0x21/*P9_25=GPIO3_21=eQEP0_选通,模式1*/
    0x1a4 0x31/*P9_27=GPIO3_19=eQEP0B_in,模式1*/
    0x1a0 0x31/*P9_42B=GPIO3_18=eQEP0A_in,模式1*/
    >;
    };
    /*eHRPWM1模块*/
    pinctrl_ehrpwm1:pinctrl_ehrpwm1{
    pinctrl单端,引脚=<
    0x048 0x26/*P9_14=GPIO1_18=eHRPWM1A,模式6*/
    0x0c8 0x22/*P8_36=GPIO2_16=eHRPWM1A,模式2*/
    0x04c 0x26/*P9_16=GPIO1_19=eHRPWM1B,模式6*/
    0x0cc 0x22/*P8_34=GPIO2_17=eHRPWM1B,模式2*/
    >;
    };
    /*eQEP1模块*/
    pinctrl_eqep1:pinctrl_eqep1{
    pinctrl单端,引脚=<
    /*0x0d8 0x22 P8_31=GPIO0_10=eQEP1_索引,模式2,用于光电池*/
    /*0x0dc 0x22 P8_32=GPIO0_11=eQEP1_选通,用于光电池的模式2*/
    0x0d4 0x32/*P8_33=GPIO0_09=eQEP1B_输入,模式2*/
    0x0d0 0x32/*P8_35=GPIO0_08=eQEP1A_输入,模式2*/
    >;
    };
    /*eHRPWM2模块*/
    pinctrl_ehrpwm2:pinctrl_ehrpwm2{
    pinctrl单端,引脚=<
    0x020 0x24/*P8_19=GPIO0_22=eHRPWM2A,模式4*/
    0x0a0 0x23/*P8_45=GPIO2_6=eHRPWM2A,模式3*/
    0x024 0x24/*P8_13=GPIO0_23=eHRPWM2B,模式4*/
    0x0a4 0x23/*P8_46=GPIO2_7=eHRPWM2B,模式3*/
    >;
    };
    /*eCAP2模块*/
    pinctrl_ecap2:pinctrl_ecap2{
    pinctrl单端,引脚=<
    0x19c 0x24/*P9_28=GPIO3_17=eCAP2,模式4*/
    >;
    };
    /*eQEP2模块*/
    pinctrl_eqep2:pinctrl_eqep2{
    平克特尔
    
        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";
            };
        };