Beaglebone devm_pwm_get returns ENODEV

Beaglebone devm_pwm_get returns ENODEV

我正在试验 Beaglebone black 的 pwm 驱动程序,基于 this one

因为我将 Yocto 与 meta-bbb 层一起使用,所以我不得不重写 .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";
    };
};

但是,在驱动程序探测功能期间,调用

pwm_test->pwm = devm_pwm_get(&pdev->dev, NULL);

returns 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 的 sub-call 返回的:

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)。在设备树中使用 menuconfig and ensuring that EHRPWM and EPWMSS 启用它解决了我的问题:

使用meta-bbb层,我只是通过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";
    };
};