我使用的是内核 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 */
>;
};
...
然后也在 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 内核模块
,它工作正常。