|
发表于 2018-7-13 13:34:10
浏览:9502
|
回复:0
打印
只看该作者
[复制链接]
楼主
硬件平台:rk3288 reload
软件平台:android 5.1 kernel
1.参照这个帖子http://dev.t-firefly.com/thread-10801-1-1.html 把系统占用的pwm1 驱动给屏蔽掉,参考背光的pwm(kernel/drivers/video/backlight/pwm_bl.c)进行pwm1申请
2.写驱动
1)源码
- include<linux/kernel.h>
- #include<linux/init.h>
- #include<linux/module.h>
- #include<linux/delay.h>
- #include<linux/pwm.h>
- #include<linux/platform_device.h>
- #include<linux/err.h>
- #include<linux/slab.h>
- static int pwm_probe(struct platform_device *pdev)
- {
- struct pwm_device *pwm1 = NULL;
- pwm1 = devm_pwm_get(&pdev->dev,NULL);
- if(IS_ERR(pwm1))
- {
- dev_err(&pdev->dev,"unable to get pwm1\n");
- pwm1 = pwm_request(1,"pwm");
- if(IS_ERR(pwm1)){
- dev_err(&pdev->dev,"unable to request pwm1\n");
- printk("pwm1 err %ld\n",PTR_ERR(pwm1));
- }
- }
- pwm_config(pwm1,50000,100000);
- pwm_enable(pwm1);
- printk("pwm1 sucess\n");
- return 0;
- }
- static struct of_device_id pwm_of_match[] = {
- { .compatible = "pwm1_test"},
- {}
- };
- static int ub_pwm_remove(struct platform_device *pdev)
- {
- return 0;
- }
- static struct platform_driver pwm_driver={
- .driver = {
- .name ="pwm",
- .owner =THIS_MODULE,
- .of_match_table = of_match_ptr(pwm_of_match),
- },
- .probe = pwm_probe,
- .remove = pwm_remove,
- };
- module_platform_driver(pwm_driver);
- MODULE_DESCRIPTION("pwm driver");
- MODULE_LICENSE("GPL");
复制代码
2)dts加入
- pwm1_test:pwm1_test{
- compatible="pwm1_test";
- pwms=<&pwm1 0 10000>;
- };
复制代码
- &pwm1 {
- status = "okay";
- };
复制代码
|
|