Linux Beaglebone dev_pwm_get返回ENODEV

Linux Beaglebone dev_pwm_get返回ENODEV,linux,linux-device-driver,beagleboneblack,yocto,pwm,Linux,Linux Device Driver,Beagleboneblack,Yocto,Pwm,我正在试验一个pwm驱动程序,用于Beaglebone black,基于 由于我在层中使用Yocto,我必须重写.dtsi: &am33xx_pinmux { bbb_pwm_P8_13_pins: bbb_pwm_P8_13_pins { pinctrl-single,pins = <0x024 0x4>; /* P8_13 (ZCZ ball T10) | MODE 4 */ }; }; / { bbb-pwm@123 {

我正在试验一个pwm驱动程序,用于Beaglebone black,基于

由于我在层中使用Yocto,我必须重写.dtsi:

&am33xx_pinmux {
    bbb_pwm_P8_13_pins: bbb_pwm_P8_13_pins {
        pinctrl-single,pins = <0x024  0x4>; /* P8_13 (ZCZ ball T10) | MODE 4 */
    };
};


/ {
    bbb-pwm@123 {
        compatible  = "tfe,bbb_pwm-1.00.a";
        pwms        = <&ehrpwm2 1 0 1>;
        pwm-names   = "PWM_P8_13";

        pinctrl-names   = "default";
        pinctrl-0   = <&bbb_pwm_P8_13_pins>;

        enabled     = <0>;
        duty        = <0>;
        status      = "okay";
    };
};
返回ENODEV:

[    7.538249] pinctrl-single 44e10800.pinmux: found group selector 15 for bbb_pwm_P8_13_pins
[    7.538278] pinctrl-single 44e10800.pinmux: request pin 9 (44e10824.0) for bbb-pwm@123
[    7.538291] pinctrl-single 44e10800.pinmux: enabling bbb_pwm_P8_13_pins function15
[    7.538366] Loading bbb_pwm
[    7.541304] bbb-pwm bbb-pwm@123: obtain a copy of previously claimed pinctrl
[    7.541321] bbb-pwm bbb-pwm@123: Unable to request PWM (err = -19)
我发现错误代码是由devm_pwm_get返回的:

static int pwm_device_request(struct pwm_device *pwm, const char *label)
{
    /* .... */

    if (!try_module_get(pwm->chip->ops->owner))
        return -ENODEV;

    /* ... */
}

然而,由于我对Linux驱动程序相当陌生,我不明白为什么会发生这种情况。有什么线索吗?

原来内核中禁用了低电平PWM驱动器(EHRPWM)。通过使用并确保在设备树中启用,解决了我的问题:

使用该层,我只是通过bitbake访问了menuconfig:

bitbake virtual/kernel -c menuconfig
并加载位于/meta-bbb/recipes-kernel/linux/linux-stable-4.4/beaglebone/defconfig的defconfig

我还向local.conf添加了以下行

PREFERRED_VERSION_linux-stable = "4.4"
这是我的dtsi:

&am33xx_pinmux {
    bbb_pwm_P8_13_pins: bbb_pwm_P8_13_pins {
        pinctrl-single,pins = <0x024  0x4>; /* P8_13 (ZCZ ball T10) | MODE 4 */
    };
};

&ehrpwm2 {
    status = "okay";
};

&epwmss2 {
    status = "okay";
};

/ {
    bbb-pwm@123 {
        compatible  = "tfe,bbb_pwm-1.00.a";
        pwms        = <&ehrpwm2 1 0 1>;
        pwm-names   = "PWM_P8_13";

        pinctrl-names   = "default";
        pinctrl-0   = <&bbb_pwm_P8_13_pins>;

        enabled     = <0>;
        duty        = <0>;
        status      = "okay";
    };
};
&am33xx\u pinmux{
bbb_pwm_P8_13_引脚:bbb_pwm_P8_13_引脚{
pinctrl单,引脚=;/*P8_13(ZCZ球T10)|模式4*/
};
};
&ehrpwm2{
status=“好”;
};
&epwmss2{
status=“好”;
};
/ {
bbb-pwm@123 {
compatible=“tfe,bbb_pwm-1.00.a”;
pwms=;
pwm名称=“pwm_P8_13”;
pinctrl names=“默认”;
pinctrl-0=;
启用=;
关税=;
status=“好”;
};
};
&am33xx_pinmux {
    bbb_pwm_P8_13_pins: bbb_pwm_P8_13_pins {
        pinctrl-single,pins = <0x024  0x4>; /* P8_13 (ZCZ ball T10) | MODE 4 */
    };
};

&ehrpwm2 {
    status = "okay";
};

&epwmss2 {
    status = "okay";
};

/ {
    bbb-pwm@123 {
        compatible  = "tfe,bbb_pwm-1.00.a";
        pwms        = <&ehrpwm2 1 0 1>;
        pwm-names   = "PWM_P8_13";

        pinctrl-names   = "default";
        pinctrl-0   = <&bbb_pwm_P8_13_pins>;

        enabled     = <0>;
        duty        = <0>;
        status      = "okay";
    };
};