我想尝试在linux内核模块中使用PWM来实现Rasperry。我已经通过SYSFS接口成功地启用了PWM。对于在内核模块中使用pwm,文档声明:
新用户应该使用pwm_get()函数,并将使用者设备或使用者名称传递给它。pwm_put()用于释放脉宽调制装置。这些函数的托管变体devm_pwm_get()和devm_pwm_put()也存在。
pwm_get函数如下所示:
/**
* pwm_get() - look up and request a PWM device
* @dev: device for PWM consumer
* @con_id: consumer name
....
*/
struct pwm_device *pwm_get(struct device *dev, const char *con_id)在哪里可以找到德夫和con_id?我怀疑它们应该在设备树中定义,但这只是一种怀疑。
发布于 2016-12-24 18:16:08
pwm_get()的一个例子在Intel PWM背光板驱动程序中可用。 在这里,它被用来获得一个PWM电源的名称。 /*获得用于背光控制的PWM芯片*/面板-> backlight .PWM= pwm_get(dev->dev,"pwm_backlight"); 脉宽调制提供者本身定义为这里. /* pwm_lookup crc_pwm_lookup[] ={ PWM_LOOKUP("crystal_cove_pwm",0,0000:00:02.0,"pwm_backlight",0,PWM_POLARITY_NORMAL); ...and初始化了这里。 /*为crc */ pwm_add_table(crc_pwm_lookup,ARRAY_SIZE(Crc_pwm_lookup))添加查找表;
脉宽调制传呼机是pwm_get()的另一个例子。
beeper->pwm = pwm_get(&pdev->dev, NULL);设备树中的对应条目是这里。
buzzer {
compatible = "pwm-beeper";
pwms = <&pwm 0 1000000 0>;
pinctrl-names = "default";
pinctrl-0 = <&pwm0_out>;
};
pwm_get()描述了可以使用它的两种方式。
/**
* pwm_get() - look up and request a PWM device
* @dev: device for PWM consumer
* @con_id: consumer name
*
* Lookup is first attempted using DT. If the device was not instantiated from
* a device tree, a PWM chip and a relative index is looked up via a table
* supplied by board setup code (see pwm_add_table()).
*
* Once a PWM chip has been found the specified PWM device will be requested
* and is ready to be used.
*
* Returns: A pointer to the requested PWM device or an ERR_PTR()-encoded
* error code on failure.
*/https://stackoverflow.com/questions/41268534
复制相似问题