Firefly开源社区

标题: 无法申请pwm1,这是驱动和log,麻烦看一下,提问很多天了 [打印本页]

作者: zzj    时间: 2016-8-26 14:10
标题: 无法申请pwm1,这是驱动和log,麻烦看一下,提问很多天了
/*pt.c*/
#include<linux/pwm.h>
#include<linux/init.h>
#include<linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>

MODULE_LICENSE("GPL");
struct pwm_device * pwm1 = NULL;


static int __init pwm_init(void)
{
        pwm1 = pwm_request(1, "backlight-pwm");
        pwm_config(pwm1, 100000, 500000);
        printk("success\n");
        pwm_enable(pwm1);
        return 0;
}

static void __exit pwm_exit(void)
{
        printk("Exit pwm\n");
}

subsys_initcall(pwm_init);
module_exit(pwm_exit);


firefly@firefly:~/temp/makepra/pwm$ dmesg|tail
[  127.675031] bfa0: 814f4e00 c000da00 be97a6f4 be97a874 00000003 b6f85398 00000000 00000000
[  127.675044] bfc0: be97a6f4 be97a874 814f4e00 0000017b b6f91e08 00000000 b6f81b60 00000000
[  127.675057] bfe0: be97a6a0 be97a690 b6f7c177 b6eec982 80030030 00000003 00000000 00000000
[  127.675081] [<c028a454>] (pwm_config+0x40/0x60) from [<bf03a024>] (pwm_init+0x24/0x50 [pt])
[  127.675105] [<bf03a024>] (pwm_init+0x24/0x50 [pt]) from [<c00086a4>] (do_one_initcall+0x34/0xc8)
[  127.675126] [<c00086a4>] (do_one_initcall+0x34/0xc8) from [<c0080d34>] (do_init_module+0x44/0x168)
[  127.675144] [<c0080d34>] (do_init_module+0x44/0x168) from [<c00819bc>] (SyS_finit_module+0x6c/0x94)
[  127.675164] [<c00819bc>] (SyS_finit_module+0x6c/0x94) from [<c000da00>] (ret_fast_syscall+0x0/0x30)
[  127.675177] Code: e1540003 c3822001 e3520000 1a000005 (e5910010)
[  127.675258] ---[ end trace 0be8b8afa4266cfb ]---
:'(
作者: zzj    时间: 2016-8-26 14:12
还有就是注册pwm-rockchip.c这个驱动文件的具体步骤是什么
作者: leung先森    时间: 2016-8-26 14:35
zzj 发表于 2016-8-26 14:12
还有就是注册pwm-rockchip.c这个驱动文件的具体步骤是什么

无法申请应该具体看pwm_request报什么问题,一般申请不了都是占用,检查一下dts,那里也用到了pwm1

作者: zzj    时间: 2016-8-26 14:39
leung先森 发表于 2016-8-26 14:35
无法申请应该具体看pwm_request报什么问题,一般申请不了都是占用,检查一下dts,那里也用到了pwm1

请问怎么检查dts?检查出来后又要怎么释放?用pwm_free()吗
作者: HelloBirthday    时间: 2016-8-26 16:11
检查dts中是否被占用,disabled掉       pwm_request申请失败表明pwm1已经被占用,你可以直接操作它。若想自己另写驱动,那只能在sts中disabled,然后自己添加
作者: zzj    时间: 2016-8-28 14:29
HelloBirthday 发表于 2016-8-26 16:11
检查dts中是否被占用,disabled掉       pwm_request申请失败表明pwm1已经被占用,你可以直接操作它。若想 ...

我把firefly rk3288.dts里和rk3288.dtsi里的pwm都设置成okay,然后跟你说的一样直接操作pwm1,函数调用顺序是struct pwm_device * pwm1;pwm_enable(pwm1);pwm_config(pwm1,100000,500000);
然后用示波器测pwm1口,结果没有电压变化,还是搞不明白:'(
作者: xaityyy    时间: 2016-8-28 15:38
dmesg给全呀。log太少了
作者: zzj    时间: 2016-8-28 16:14
xaityyy 发表于 2016-8-28 15:38
dmesg给全呀。log太少了

没办法:dizzy:,用的dmesg|tail命令只给这些
用dmesg的话就给的超出屏幕
作者: xaityyy    时间: 2016-8-28 16:21
dmesg | tee dmesg.log。然后发dmesg.log出来。
如果是串口,打开log,就会有log到本地。
作者: 长的    时间: 2016-8-30 10:16
pwm_regulator {
        compatible = "rockchip_pwm_regulator";
        pwms = <&pwm1 0 2000>;
        rockchip,pwm_id= <1>;
        rockchip,pwm_voltage_map= <925000 950000 975000 1000000 1025000 1050000 1075000 1100000 1125000 1150000 1175000 1200000 1225000 1250000 1275000 1300000 1325000 1350000 1375000 1400000>;
        rockchip,pwm_voltage= <1100000>;
        rockchip,pwm_min_voltage= <925000>;
        rockchip,pwm_max_voltage= <1400000>;
        rockchip,pwm_suspend_voltage= <950000>;
        rockchip,pwm_coefficient= <475>;
        regulators {
            #address-cells = <1>;
            #size-cells = <0>;
            pwm_reg0: regulator@0 {
                regulator-compatible = "pwm_dcdc1";
                regulator-name= "vdd_logic";
                regulator-min-microvolt = <925000>;
                regulator-max-microvolt = <1400000>;
                regulator-always-on;
                regulator-boot-on;
            };
        };
    };
dts中有这么一段,好像已经占用了pwm1,所以申请会失败,
但是这个是用来做电源控制吗,对应的硬件设备是什么?
作者: zzj    时间: 2016-8-30 15:31
长的 发表于 2016-8-30 10:16
pwm_regulator {
        compatible = "rockchip_pwm_regulator";
        pwms = ;

我看wiki里面是控制什么backlight的,但是就算我全部都设为disabled还是无法申请,对应的硬件设备是你自己接LCD时的屏幕背光
作者: zzj    时间: 2016-8-30 15:54
xaityyy 发表于 2016-8-28 16:21
dmesg | tee dmesg.log。然后发dmesg.log出来。
如果是串口,打开log,就会有log到本地。

是这个吗 我选了一段跟申请有关的
[    2.300069] init success
[    2.300247] probe device ff9c0000.hevc_service
[    2.300856] hevc_service: power on
[    2.301996] checking hw id 6867
[    2.302857] vcodec hevc_service: vcodec ion client create success!
[    2.303753] hevc_service: power off...
[    2.303855] done
[    2.303909] init success
[    2.304279] rknandbase v1.0 2014-03-31
[    2.304906] rknand_probe clk rate = 148500000
[    2.305302] rknand_driver:ret = 0
[    2.306411] audit: initializing netlink socket (disabled)
[    2.306553] type=2000 audit(1.270:1): initialized
[    2.309435] bounce pool size: 64 pages
[    2.324875] fuse init (API version 7.22)
[    2.326121] msgmni has been set to 1424
[    2.326307] SELinux:  Registering netfilter hooks
[    2.332471] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 246)
[    2.332571] io scheduler noop registered
[    2.332630] io scheduler deadline registered
[    2.332971] io scheduler cfq registered (default)
[    2.334435] Console: switching to colour frame buffer device 240x67
[    2.383801] rga ff920000.rga: rga ion client create success!
[    2.384451] rga: Driver loaded succesfully
[    2.386058] IEP Power ON
[    2.386290] iep ion client create success!
[    2.387440] rk_iommu ff900800.iep_mmu: (iep) Enabled
[    2.387697] rk_iommu ff900800.iep_mmu: rockchip_iommu_attach_device: Attached new IOMMU with pgtable 0x2e244000
[    2.387796] IEP Power OFF
[    2.387962] rk_iommu ff900800.iep_mmu: (iep) Disabled
[    2.388210] rk_iommu ff900800.iep_mmu: rockchip_iommu_detach_device: Detached IOMMU with pgtable 0x2e244000
[    2.388635] IEP Driver loaded succesfully
[    2.389093] Module initialized.
[    2.391763] dma-pl330 ffb20000.pdma: Loaded driver for PL330 DMAC-2364208
[    2.392107] dma-pl330 ffb20000.pdma:         DBUFF-64x8bytes Num_Chans-5 Num_Peri-6 Num_Events-10
[    2.396826] dma-pl330 ff250000.pdma: Loaded driver for PL330 DMAC-2364208
[    2.397169] dma-pl330 ff250000.pdma:         DBUFF-128x8bytes Num_Chans-8 Num_Peri-20 Num_Events-16
[    2.398304] pwm-voltage-regulator pwm_regulator.22: unable to request PWM, trying legacy API
[    2.398695] pwm-voltage-regulator pwm_regulator.22: unable to request legacy PWM
[    2.399018] pwm_regulator_probe:error
[    2.399235] platform pwm_regulator.22: Driver pwm-voltage-regulator requests probe deferral
[    2.400625] rk_serial.c v1.8 2014-03-04
[    2.401434] ff180000.serial: ttyS0 at MMIO 0xff180000 (irq = 87) is a rk29_serial.0
[    2.402365] serial ff180000.serial: membase f0172000
[    2.403007] ff690000.serial: ttyS2 at MMIO 0xff690000 (irq = 89) is a rk29_serial.2

作者: 长的    时间: 2016-8-30 17:28
zzj 发表于 2016-8-30 15:31
我看wiki里面是控制什么backlight的,但是就算我全部都设为disabled还是无法申请,对应的硬件设备是你自 ...

你看我发的这个帖子,按照帖子的方法pwm1可以使用http://developer.t-firefly.com/thread-10801-1-1.html




欢迎光临 Firefly开源社区 (https://dev.t-firefly.com/) Powered by Discuz! X3.1