Пример #1
0
void sunxi_pwm_init(void)
{
    int i;

    for(i = 0; i < PWM_NUM; i++)
        sunxi_pwm_get_sys_config(i);
}
Пример #2
0
static int __init pwm_module_init(void)
{
    int ret = 0;
    int err;
    int i;

    pr_info("pwm module init!\n");
    alloc_chrdev_region(&devid, 0, 1, "sunxi_pwm");
    my_cdev = cdev_alloc();
    cdev_init(my_cdev, &sunxi_pwm_fops);
    err = cdev_add(my_cdev, devid, 1);

    if(err) {
        pr_warn("cdev add fail!\n");
        return -1;
        }

    pwm_class = class_create(THIS_MODULE, "sunxi_pwm");
    if (IS_ERR(pwm_class))
    {
        pr_warn("class_create fail\n");
        return -1;
    }

    pwm_dev = device_create(pwm_class, NULL, devid, NULL, "sunxi_pwm");

    ret = platform_device_register(&sunxi_pwm_device);

    if (ret == 0)
    {
    ret = platform_driver_register(&sunxi_pwm_driver);
    }

    for(i=0; i<PWM_NUM; i++) {
        sunxi_pwm_get_sys_config(i, &pwm_cfg[i]);
    }

    return ret;

}