|
【求助】新人PWM问题提问~~~
发表于 2016-8-22 13:09:17
浏览:7952
|
回复:5
打印
只看该作者
[复制链接]
楼主
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/pwm.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_platform.h>
#define GPIO_LOW 0
#define GPIO_HIGH 1
struct pwm_device *pwm1 = NULL;
/*static int __init led_init(void)
{
int i;
for(i=0;i<=1000;i++)
{
//gpio_set_value(LED_GPIO,GPIO_LOW);
printk("---------------kkkkkkkkkkkkkk----------------------------------------------\n");
//mdelay(500);
//gpio_set_value(LED_GPIO,GPIO_HIGH);
mdelay(500);
}
return 0;
}*/
static int firefly_hello_probe(struct platform_device *pdev)
{
/*int ret = -1;
int i;
int gpio,flag;
struct device_node *hello_node = pdev->dev.of_node;
gpio = of_get_named_gpio_flags(hello_node,"led", 0,&flag);
if (!gpio_is_valid(gpio)){
return -1;
}
ret = gpio_request(gpio,"hello_led");
if (ret != 0){
gpio_free(gpio);
return -EIO;
}
gpio_direction_output(gpio,GPIO_HIGH);
for(i=0;i<=20;i++)
{
gpio_set_value(gpio,GPIO_LOW);
mdelay(500);
gpio_set_value(gpio,GPIO_HIGH);
mdelay(500);
}*/
pwm1 = pwm_request(1,"backlight-pwm");
pwm_enable(pwm1);
pwm_config(pwm1,500000, 1000000);
mdelay(1000000);
return 0;
}
static int firefly_hello_remove(struct platform_device *pdev)
{
return 0;
}
static const struct of_device_id rk_pwm_of_match[]={
{.compatible = "rockchip,rk-pwm"},
{ }
};
static struct platform_driver firefly_hello_driver = {
.probe = firefly_hello_probe,
.remove = firefly_hello_remove,
.driver = {
.name = "backlight-pwm",
.owner = THIS_MODULE,
.of_match_table = rk_pwm_of_match,
} ,
};
static int __init hello_init(void)
{
return platform_driver_register(&firefly_hello_driver);
return 0;
}
static void __exit hello_exit(void)
{
platform_driver_unregister(&firefly_hello_driver);
}
subsys_initcall(hello_init);
module_exit(hello_exit);
MODULE_AUTHOR("KK");
MODULE_DESCRIPTION("KK");
MODULE_LICENSE("GPL");
这是我的.C文件
pwm1: pwm@ff680010 {
compatible = "rockchip,rk-pwm";
reg = <0xff680010 0x10>;
#pwm-cells = <2>;
pinctrl-names = "default";
pinctrl-0 = <&pwm1_pin>;
clocks = <&clk_gates11 11>;
clock-names = "pclk_pwm";
status = "okay";
};
DTS配置按维基来的
现在情况是编译能通过 内核下进板子后我理解就是开机的时候用万用表打到DC档测试PWM1 接口应该有变化但是现在变化很微弱 求助啊。。。 |
|