您尚未登录。

楼主 #1 2018-09-27 15:56:49

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

设置PWM参数

QQ20180927155429.png

这个PWM参数配置的sysfs里使能具体指的是哪个文件了

离线

#2 2018-09-27 15:59:52

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

/sys/class/pwm/pwmchip0/pwm0/enable





离线

楼主 #3 2018-09-27 16:06:14

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

/sys/class/pwm/pwmchip0/pwm0/enable


我搜了下  没有这个文件路径  而且在jffs2.img中也没有 了 yikes

离线

#4 2018-09-27 16:26:06

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

你要执行 echo 0 > /sys/class/pwm/pwmchip0/export





离线

楼主 #5 2018-09-27 16:33:01

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

你要执行 echo 0 > /sys/class/pwm/pwmchip0/export

主要是 我的Pwm下面没有pwmchip0这个了  就是就一个空目录了

离线

#6 2018-09-27 16:34:36

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

1. 检查一下驱动有没有使能 SUNXI 的 pwm
2. 检查dts有没有配置pwm





离线

楼主 #7 2018-09-27 16:49:34

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

1. 检查一下驱动有没有使能 SUNXI 的 pwm
2. 检查dts有没有配置pwm

我是配置下面截图  是按着文档去配置的


这个是配置sun8i-v3s.dtsi
dtsi.png

sun8i-v3s-licheepi-zero.dts的配置
dts.png

离线

#8 2018-09-27 17:06:35

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

你有没有挂载 sysfs 虚拟文件系统?





离线

#9 2018-09-27 17:07:09

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

离线

楼主 #10 2018-09-27 17:18:53

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

  我是没有挂载 ,你说说的那些sysfs/sys  只有Linux内核中的fs里面有这个 但是sysfs 这个虚拟文件系统 具体是指的哪个目录下?找不到目录文件

最近编辑记录 无情一刀 (2018-09-27 17:23:17)

离线

楼主 #11 2018-09-27 17:22:33

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

我这里修改的dts喝dtsi都是在u-boot里面修改的

离线

#12 2018-09-27 17:28:06

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

无情一刀 说:

我这里修改的dts喝dtsi都是在u-boot里面修改的

改 u-boot 的没有用的, 一定要改 kernel 的 dts/dtsi 才行, 还有 mount sysfs 也是不能少哦。





离线

楼主 #13 2018-09-27 20:41:53

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:
无情一刀 说:

我这里修改的dts喝dtsi都是在u-boot里面修改的

改 u-boot 的没有用的, 一定要改 kernel 的 dts/dtsi 才行, 还有 mount sysfs 也是不能少哦。


我去挂载的时候提示我已经挂载了 但是我输入echo 0 > /sys/class/pwm/pwmchip0/export
这里pwm的目录下是空的
111.png

最近编辑记录 无情一刀 (2018-09-27 20:43:29)

离线

#14 2018-09-27 20:44:54

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

是不是 linux 没开 sunxi 的 pwm 驱动?





离线

楼主 #15 2018-09-28 08:50:55

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

是不是 linux 没开 sunxi 的 pwm 驱动?


你说的menuconfig里面已经设置了
pwm.png

离线

#16 2018-09-28 09:18:58

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

命令行执行

mdev -s

然后看下有没有 /sys/class/pwm/pwmchip0/export 这些文件





离线

楼主 #17 2018-09-28 09:36:18

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

命令行执行

mdev -s

然后看下有没有 /sys/class/pwm/pwmchip0/export 这些文件

222.png

离线

#18 2018-09-28 09:45:46

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

mdev -s 是在 嵌入式linux控制台下执行.





离线

楼主 #19 2018-09-28 09:48:40

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

mdev -s 是在 嵌入式linux控制台下执行.

关键我在Linux的menuconfig 中配置了使能  就应该会调用下面截图的这个PWM驱动 里面是有创建pwmchip0X,,应该就是这个驱动没有调用
pwm_20180927-2146.png

离线

楼主 #20 2018-09-28 09:53:46

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

无情一刀 说:
晕哥 说:

mdev -s 是在 嵌入式linux控制台下执行.

关键我在Linux的menuconfig 中配置了使能  就应该会调用下面截图的这个PWM驱动 里面是有创建pwmchip0X,,应该就是这个驱动没有调用
https://whycan.cn/files/members/1116/pwm_20180927-2146.png


我刚才也试过了   在目录下面也是没有

离线

#21 2018-09-28 10:18:21

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

看 13 楼的图片,为什么是在 ubuntu (电脑?)挂载 sysfs ?为什么不是在V3s嵌入式设备?





离线

楼主 #22 2018-09-28 11:24:10

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

看 13 楼的图片,为什么是在 ubuntu (电脑?)挂载 sysfs ?为什么不是在V3s嵌入式设备?


我这边在终端这边是挂载不上的 但是在虚拟机里面去挂载跟文件系统中 然后去mkfs他是报错的  不是很明白了
我在虚拟机里面测试区挂载了下  pwm在sys里面的哪个pwm目录也是空的

最近编辑记录 无情一刀 (2018-09-28 11:35:11)

离线

#23 2018-09-28 11:37:11

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

无情一刀 说:
晕哥 说:

看 13 楼的图片,为什么是在 ubuntu (电脑?)挂载 sysfs ?为什么不是在V3s嵌入式设备?


我这边在终端这边是挂载不上的 但是在虚拟机里面去挂载跟文件系统中 然后去mkfs他是报错的  不是很明白了
我在虚拟机里面测试区挂载了下  pwm在sys里面的哪个pwm目录也是空的

你的虚拟机当然已经挂载了sysfs, 无需你再操作了。

终端这边是挂载不上的, 是如何挂不上的?错误呢?





离线

楼主 #24 2018-09-28 11:38:19

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:
无情一刀 说:
晕哥 说:

看 13 楼的图片,为什么是在 ubuntu (电脑?)挂载 sysfs ?为什么不是在V3s嵌入式设备?


我这边在终端这边是挂载不上的 但是在虚拟机里面去挂载跟文件系统中 然后去mkfs他是报错的  不是很明白了
我在虚拟机里面测试区挂载了下  pwm在sys里面的哪个pwm目录也是空的

你的虚拟机当然已经挂载了sysfs, 无需你再操作了。

终端这边是挂载不上的, 是如何挂不上的?错误呢?


# mount -t sysfs sysfs ./sys/
mount: mounting sysfs on ./sys/ failed: Device or resource busy
# mdev -s
# mount -t sysfs sysfs ./sys/
mount: mounting sysfs on ./sys/ failed: Device or resource busy
#

离线

#25 2018-09-28 11:53:25

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

无情一刀 说:
晕哥 说:
无情一刀 说:

我这边在终端这边是挂载不上的 但是在虚拟机里面去挂载跟文件系统中 然后去mkfs他是报错的  不是很明白了
我在虚拟机里面测试区挂载了下  pwm在sys里面的哪个pwm目录也是空的

你的虚拟机当然已经挂载了sysfs, 无需你再操作了。

终端这边是挂载不上的, 是如何挂不上的?错误呢?


# mount -t sysfs sysfs ./sys/
mount: mounting sysfs on ./sys/ failed: Device or resource busy
# mdev -s
# mount -t sysfs sysfs ./sys/
mount: mounting sysfs on ./sys/ failed: Device or resource busy
#

酱紫:

mkdir -p /sys/
mount -t sysfs sysfs /sys





离线

楼主 #26 2018-09-28 11:54:51

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:
无情一刀 说:
晕哥 说:

你的虚拟机当然已经挂载了sysfs, 无需你再操作了。

终端这边是挂载不上的, 是如何挂不上的?错误呢?


# mount -t sysfs sysfs ./sys/
mount: mounting sysfs on ./sys/ failed: Device or resource busy
# mdev -s
# mount -t sysfs sysfs ./sys/
mount: mounting sysfs on ./sys/ failed: Device or resource busy
#

酱紫:

mkdir -p /sys/
mount -t sysfs sysfs /sys


none_20180927-2353.png

我这里用mount看了所有挂载的  已经挂载上了  但是就是里面pwm目录里面啥都没有

离线

#27 2018-09-28 11:56:30

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

那酱紫, 先卸载,再挂载,看看什么情况:

umount /sys
mkdir -p /sys
mount -t sysfs sysfs /sys





离线

楼主 #28 2018-09-28 13:42:39

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

那酱紫, 先卸载,再挂载,看看什么情况:

umount /sys
mkdir -p /sys
mount -t sysfs sysfs /sys

还是一样的 进入pwm目录下什么都没有

离线

#29 2018-09-28 13:48:52

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

这个好像没办法解释了.

http://zero.lichee.pro/%E9%A9%B1%E5%8A%A8/PWM.html

看下 static int sun4i_pwm_probe(struct platform_device *pdev) 这个函数有没有输出,

初步怀疑你改错dts文件,或者烧错设备树(dtb)文件了,

确认一定是要改 linux kernel目录下的 dts/dtsi 文件,而不是 u-boot 的 dts/dtsi 文件哦。





离线

楼主 #30 2018-09-28 13:59:33

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

这个好像没办法解释了.

http://zero.lichee.pro/%E9%A9%B1%E5%8A%A8/PWM.html

看下 static int sun4i_pwm_probe(struct platform_device *pdev) 这个函数有没有输出,

初步怀疑你改错dts文件,或者烧错设备树(dtb)文件了,

确认一定是要改 linux kernel目录下的 dts/dtsi 文件,而不是 u-boot 的 dts/dtsi 文件哦。

这里是加入的的arch/arm/boot/dts/sun8i-v3s.dtsi在这个文件中

dtsi_20180928-0156.png
dtsi2.png

然后下面是我是修改的这里是加入的的arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dts中修改的中截图
dts_20180928-0158.png

我这样配置也是按着文档上面配置的

离线

#31 2018-09-28 14:03:00

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

那会不会烧错设备树(dtb)文件了, 看下 static int sun4i_pwm_probe(struct platform_device *pdev) 这个函数有没有输出.





离线

楼主 #32 2018-09-28 14:20:34

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

那会不会烧错设备树(dtb)文件了, 看下 static int sun4i_pwm_probe(struct platform_device *pdev) 这个函数有没有输出.


我烧写的dtb 是linux/arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dtb这个文件

现在你说的这个函数sun4i_pwm_probe可以确定没有执行   所以里面就没有创建pwmchip0X

然后在终端打印出了这个 [    0.060058] sun4i-pwm 1c21400.pwm: could not find pctldev for node /soc/pwm0, deferring probe

最近编辑记录 无情一刀 (2018-09-28 14:23:10)

离线

#33 2018-09-28 15:09:10

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

我跟踪了一下出错的地方, 找到源码 https://github.com/torvalds/linux/blob/master/drivers/pinctrl/devicetree.c

发现是 pinctrl 出问题了,

根据你的截图, 发现

pwm0_pins: pwm0 {
        pins = "PB4";
        function = "pwm0";
};
pwm1_pins: pwm1 {
        pins = "PB5";
        function = "pwm1";
};

放错地方了.





离线

楼主 #34 2018-09-28 15:21:28

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

我跟踪了一下出错的地方, 找到源码 https://github.com/torvalds/linux/blob/master/drivers/pinctrl/devicetree.c

发现是 pinctrl 出问题了,

根据你的截图, 发现

pwm0_pins: pwm0 {
        pins = "PB4";
        function = "pwm0";
};
pwm1_pins: pwm1 {
        pins = "PB5";
        function = "pwm1";
};

放错地方了.

我刚才定位到Devicetree.c文件中的dt_to_map_one_config这个函数中


pwm0_pins: pwm0 {
        pins = "PB4";
        function = "pwm0";
};
pwm1_pins: pwm1 {
        pins = "PB5";
        function = "pwm1";
};我这些是放在sun8i-v3s.dtsi中的SOC括号中
0.png

离线

#35 2018-09-28 15:29:08

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

这样做是不对的, 你参考一下其他外设的 pins 设置, 就知道应该放哪里了。





离线

楼主 #36 2018-09-28 15:47:30

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

这样做是不对的, 你参考一下其他外设的 pins 设置, 就知道应该放哪里了。


现在我已经将刚才的那两个配置IO口 放到pin:pinctrl@1c20400里面了 因为里面也有spi 和I2C也在里面 
但是更新后出现[    0.059417] sun4i-pwm: probe of 1c21400.pwm failed with error -12


出现问题的打印源码是

static int really_probe(struct device *dev, struct device_driver *drv)
{
    int ret = -EPROBE_DEFER;
    int local_trigger_count = atomic_read(&deferred_trigger_count);
    bool test_remove = IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE) &&
               !drv->suppress_bind_attrs;

    if (defer_all_probes) {
        /*
         * Value of defer_all_probes can be set only by
         * device_defer_all_probes_enable() which, in turn, will call
         * wait_for_device_probe() right after that to avoid any races.
         */
        dev_dbg(dev, "Driver %s force probe deferral\n", drv->name);
        driver_deferred_probe_add(dev);
        return ret;
    }

    ret = device_links_check_suppliers(dev);
    if (ret)
        return ret;

    atomic_inc(&probe_count);
    pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
         drv->bus->name, __func__, drv->name, dev_name(dev));
    WARN_ON(!list_empty(&dev->devres_head));

re_probe:
    dev->driver = drv;

    /* If using pinctrl, bind pins now before probing */
    ret = pinctrl_bind_pins(dev);
    if (ret)
        goto pinctrl_bind_failed;

    if (driver_sysfs_add(dev)) {
        printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
            __func__, dev_name(dev));
        goto probe_failed;
    }

    if (dev->pm_domain && dev->pm_domain->activate) {
        ret = dev->pm_domain->activate(dev);
        if (ret)
            goto probe_failed;
    }

最近编辑记录 无情一刀 (2018-09-28 15:52:51)

离线

#37 2018-09-28 15:49:22

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

去驱动跟踪一下,我也帮你看下 pwm-sun4i.c 源码.





离线

楼主 #38 2018-09-28 15:53:53

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

去驱动跟踪一下,我也帮你看下 pwm-sun4i.c 源码.


现在我在看Dd.c下的这个函数really_probe

离线

#39 2018-09-28 15:57:05

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

https://github.com/torvalds/linux/blob/master/drivers/base/dd.c

default:
        /* driver matched but the probe failed */
        printk(KERN_WARNING
               "%s: probe of %s failed with error %d\n",
               drv->name, dev_name(dev), ret);

好像是这里面报出来的错误, 检查一下看什么原因。





离线

#40 2018-09-28 15:57:32

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

无情一刀 说:
晕哥 说:

去驱动跟踪一下,我也帮你看下 pwm-sun4i.c 源码.


现在我在看Dd.c下的这个函数really_probe

对, 就是这里, 检查一下.





离线

楼主 #41 2018-09-28 17:36:27

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:
无情一刀 说:
晕哥 说:

去驱动跟踪一下,我也帮你看下 pwm-sun4i.c 源码.


现在我在看Dd.c下的这个函数really_probe

对, 就是这里, 检查一下.

看了好久都没有看出什么 打印的信息返回值一直为-12

离线

楼主 #42 2018-09-29 09:50:16

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 现在看了下  就是文档上面的配置 都配置过了  就是没有调用那个驱动  所以就没有创建那个pwm的pwmchip0X 不知道还要配置或是修改哪里了

离线

#43 2018-09-29 10:52:03

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html

#define EPERM            1      /* Operation not permitted */
#define ENOENT           2      /* No such file or directory */
#define ESRCH            3      /* No such process */
#define EINTR            4      /* Interrupted system call */
#define EIO              5      /* I/O error */
#define ENXIO            6      /* No such device or address */
#define E2BIG            7      /* Arg list too long */
#define ENOEXEC          8      /* Exec format error */
#define EBADF            9      /* Bad file number */
#define ECHILD          10      /* No child processes */
#define EAGAIN          11      /* Try again */
#define ENOMEM          12      /* Out of memory */
#define EACCES          13      /* Permission denied */

我查了一下 错误号 12 是 没内存错误???
年纪轻轻怎么会没内存?





离线

#44 2018-09-29 10:55:42

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

你的板子是自己做的吗?电源处理好了吗?CPU频率多少?DDR频率多少?





离线

#45 2018-09-29 11:04:24

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

把你的 dts/dtsi 传上来,用 code 标签包一下,我看下是不是设备树引起。





离线

楼主 #46 2018-09-29 11:12:17

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

你的板子是自己做的吗?电源处理好了吗?CPU频率多少?DDR频率多少?


板子是买的

离线

#47 2018-09-29 11:28:59

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

https://github.com/torvalds/linux/blob/master/drivers/base/dd.c

我跟踪了一下代码, 是因为进入了 pinctrl_bind_failed 标号, 显示错误信息退出。

在这里进入了标号:

/* If using pinctrl, bind pins now before probing */
    ret = pinctrl_bind_pins(dev);
    if (ret)
        goto pinctrl_bind_failed;

是不是你的PB4, PB5被别的功能使用了?





离线

楼主 #48 2018-09-29 11:30:33

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

把你的 dts/dtsi 传上来,用 code 标签包一下,我看下是不是设备树引起。

/*
 * Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.xyz>
 *
 * This file is dual-licensed: you can use it either under the terms
 * of the GPL or the X11 license, at your option. Note that this dual
 * licensing only applies to this file, and not this project as a
 * whole.
 *
 *  a) This file is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License as
 *     published by the Free Software Foundation; either version 2 of the
 *     License, or (at your option) any later version.
 *
 *     This file is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 * Or, alternatively,
 *
 *  b) Permission is hereby granted, free of charge, to any person
 *     obtaining a copy of this software and associated documentation
 *     files (the "Software"), to deal in the Softwarwithout
 *     restriction, including without limitation the rights to use,
 *     copy, modify, merge, publish, distribute, sublicense, and/or
 *     sell copies of the Software, and to permit persons to whom the
 *     Software is furnished to do so, subject to the following
 *     conditions:
 *
 *     The above copyright notice and this permission notice shall be
 *     included in all copies or substantial portions of the Software.
 *
 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *     OTHER DEALINGS IN THE SOFTWARE.
 */ 

#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/clock/sun8i-v3s-ccu.h>
#include <dt-bindings/reset/sun8i-v3s-ccu.h>

/ {
	#address-cells = <1>;
	#size-cells = <1>;
	interrupt-parent = <&gic>;

	chosen {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		simplefb_lcd: framebuffer@0 {
			compatible = "allwinner,simple-framebuffer",
				     "simple-framebuffer";
			allwinner,pipeline = "de0-lcd0";
			clocks = <&ccu CLK_BUS_TCON0>, <&display_clocks 0>,
				 <&display_clocks 6>, <&ccu CLK_TCON0>;
			status = "disabled";
		};
	};

	cpus {
		#address-cells = <1>;
		#size-cells = <0>;

		cpu@0 {
			compatible = "arm,cortex-a7";
			device_type = "cpu";
			reg = <0>;
			clocks = <&ccu CLK_CPU>;
		};
	};

	de: display-engine {
		compatible = "allwinner,sun8i-v3s-display-engine";
		allwinner,pipelines = <&mixer0>;
		status = "disabled";
	};

	timer {
		compatible = "arm,armv7-timer";
		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
	};
       clocks {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		osc24M: osc24M_clk {
			#clock-cells = <0>;
			compatible = "fixed-clock";
			clock-frequency = <24000000>;
			clock-output-names = "osc24M";
		};

		osc32k: osc32k_clk {
			#clock-cells = <0>;
			compatible = "fixed-clock";
			clock-frequency = <32768>;
			clock-output-names = "osc32k";
		};
	};
      soc {
		compatible = "simple-bus";
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		display_clocks: clock@1000000 {
			compatible = "allwinner,sun8i-v3s-de2-clk";
			reg = <0x01000000 0x100000>;
			clocks = <&ccu CLK_DE>,
				 <&ccu CLK_BUS_DE>;
			clock-names = "mod",
				      "bus";
			resets = <&ccu RST_BUS_DE>;
			#clock-cells = <1>;
			#reset-cells = <1>;
		};

		mixer0: mixer@1100000 {
			compatible = "allwinner,sun8i-v3s-de2-mixer";
			reg = <0x01100000 0x100000>;
			clocks = <&display_clocks 0>,
				 <&display_clocks 6>;
			clock-names = "bus",
				      "mod";
			resets = <&display_clocks 0>;
			assigned-clocks = <&display_clocks 6>;
			assigned-clock-rates = <150000000>;

			ports {
				#address-cells = <1>;
				#size-cells = <0>;

				mixer0_out: port@1 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <1>;

					mixer0_out_tcon0: endpoint@0 {
						reg = <0>;
						remote-endpoint = <&tcon0_in_mixer0>;
					};
				};
			};
	};
         mmc1: mmc@01c10000 {
			compatible = "allwinner,sun7i-a20-mmc";
			reg = <0x01c10000 0x1000>;
			clocks = <&ccu CLK_BUS_MMC1>,
				 <&ccu CLK_MMC1>,
				 <&ccu CLK_MMC1_OUTPUT>,
				 <&ccu CLK_MMC1_SAMPLE>;
			clock-names = "ahb",
				      "mmc",
				      "output",
				      "sample";
			resets = <&ccu RST_BUS_MMC1>;
			reset-names = "ahb";
			interrupts = <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>;
			pinctrl-names = "default";
			pinctrl-0 = <&mmc1_pins>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		mmc2: mmc@01c11000 {
			compatible = "allwinner,sun7i-a20-mmc";
			reg = <0x01c11000 0x1000>;
			clocks = <&ccu CLK_BUS_MMC2>,
				 <&ccu CLK_MMC2>,
				 <&ccu CLK_MMC2_OUTPUT>,
				 <&ccu CLK_MMC2_SAMPLE>;
			clock-names = "ahb",
				      "mmc",
				      "output",
				      "sample";
			resets = <&ccu RST_BUS_MMC2>;
			reset-names = "ahb";
			interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};
               usb_otg: usb@01c19000 {
			compatible = "allwinner,sun8i-h3-musb";
			reg = <0x01c19000 0x0400>;
			clocks = <&ccu CLK_BUS_OTG>;
			resets = <&ccu RST_BUS_OTG>;
			interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>;
			interrupt-names = "mc";
			phys = <&usbphy 0>;
			phy-names = "usb";
			extcon = <&usbphy 0>;
			status = "disabled";
		};

		usbphy: phy@01c19400 {
			compatible = "allwinner,sun8i-v3s-usb-phy";
			reg = <0x01c19400 0x2c>,
			      <0x01c1a800 0x4>;
			reg-names = "phy_ctrl",
				    "pmu0";
			clocks = <&ccu CLK_USB_PHY0>;
			clock-names = "usb0_phy";
			resets = <&ccu RST_USB_PHY0>;
			reset-names = "usb0_reset";
			status = "disabled";
			#phy-cells = <1>;
		};

		ehci0: usb@01c1a000 {
			compatible = "allwinner,sun8i-v3s-ehci", "generic-ehci";
			reg = <0x01c1a000 0x100>;
			interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>;
			resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;
			status = "disabled";
		};
               ohci0: usb@01c1a400 {
			compatible = "allwinner,sun8i-v3s-ohci", "generic-ohci";
			reg = <0x01c1a400 0x100>;
			interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>,
				 <&ccu CLK_USB_OHCI0>;
			resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;
			status = "disabled";
		};

		ccu: clock@01c20000 {
			compatible = "allwinner,sun8i-v3s-ccu";
			reg = <0x01c20000 0x400>;
			clocks = <&osc24M>, <&osc32k>;
			clock-names = "hosc", "losc";
			#clock-cells = <1>;
			#reset-cells = <1>;
		};
              rtc: rtc@01c20400 {
			compatible = "allwinner,sun6i-a31-rtc";
			reg = <0x01c20400 0x54>;
			interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
		};

		pio: pinctrl@01c20800 {
			compatible = "allwinner,sun8i-v3s-pinctrl";
			reg = <0x01c20800 0x400>;
			interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&osc32k>;
			clock-names = "apb", "hosc", "losc";
			gpio-controller;
			#gpio-cells = <3>;
			interrupt-controller;
			#interrupt-cells = <3>;

			i2c0_pins: i2c0 {
				pins = "PB6", "PB7";
				function = "i2c0";
			};

			uart0_pins_a: uart0@0 {
				pins = "PB8", "PB9";
				function = "uart0";
			};

			lcd_rgb666_pins_a: lcd-rgb666-pe {
				pins = "PE0", "PE1", "PE2", "PE3", "PE4", "PE5",
				       "PE6", "PE7", "PE8", "PE9", "PE10", "PE11",
				       "PE12", "PE13", "PE14", "PE15", "PE16", "PE17",
				       "PE18", "PE19", "PE23", "PE24";
				function = "lcd0";
			};

			mmc0_pins_a: mmc0@0 {
				pins = "PF0", "PF1", "PF2", "PF3",
				       "PF4", "PF5";
				function = "mmc0";
				drive-strength = <30>;
				bias-pull-up;
			};

			mmc1_pins: mmc1 {
				pins = "PG0", "PG1", "PG2", "PG3",
				       "PG4", "PG5";
				function = "mmc1";
				drive-strength = <30>;
				bias-pull-up;
			};

			spi0_pins: spi0 {
				pins = "PC0", "PC1", "PC2", "PC3";
				function = "spi0";
			};
			pwm0_pins:pwm0{
                        	pins = "PB4";
                        	function = "pwm0";
               		 };
                	pwm1_pins:pwm1{
                        	pins ="PB5";
                       		 function = "pwm1";
               		};
			
		};
                timer@01c20c00 {
			compatible = "allwinner,sun4i-a10-timer";
			reg = <0x01c20c00 0xa0>;
			interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&osc24M>;
		};

		wdt0: watchdog@01c20ca0 {
			compatible = "allwinner,sun6i-a31-wdt";
			reg = <0x01c20ca0 0x20>;
			interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
		};

		pwm: pwm@1c21400 {
			compatible = "allwinner,sun7i-a20-pwm";
			reg = <0x01c21400 0xC>;
			clocks = <&osc24M>;
			#pwm-cells = <3>;
			status = "okay";
		};
                lradc: lradc@1c22800 {
			compatible = "allwinner,sun4i-a10-lradc-keys";
			reg = <0x01c22800 0x400>;
			interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
			status = "disabled";
		};

		codec: codec@01c22c00 {
			#sound-dai-cells = <0>;
			compatible = "allwinner,sun8i-v3s-codec";
			reg = <0x01c22c00 0x400>;
			interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>;
			clock-names = "apb", "codec";
			resets = <&ccu RST_BUS_CODEC>;
			dmas = <&dma 15>, <&dma 15>;
			dma-names = "rx", "tx";
			allwinner,codec-analog-controls = <&codec_analog>;
			status = "disabled";
		};

		codec_analog: codec-analog@01c23000 {
			compatible = "allwinner,sun8i-v3s-codec-analog";
			reg = <0x01c23000 0x4>;
		};

		uart0: serial@01c28000 {
			compatible = "snps,dw-apb-uart";
			reg = <0x01c28000 0x400>;
			interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
			reg-shift = <2>;
			reg-io-width = <4>;
			clocks = <&ccu CLK_BUS_UART0>;
			resets = <&ccu RST_BUS_UART0>;
			status = "disabled";
	       }
              uart1: serial@01c28400 {
			compatible = "snps,dw-apb-uart";
			reg = <0x01c28400 0x400>;
			interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
			reg-shift = <2>;
			reg-io-width = <4>;
			clocks = <&ccu CLK_BUS_UART1>;
			resets = <&ccu RST_BUS_UART1>;
			status = "disabled";
		};

		uart2: serial@01c28800 {
			compatible = "snps,dw-apb-uart";
			reg = <0x01c28800 0x400>;
			interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
			reg-shift = <2>;
			reg-io-width = <4>;
			clocks = <&ccu CLK_BUS_UART2>;
			resets = <&ccu RST_BUS_UART2>;
			status = "disabled";
		};
                i2c0: i2c@01c2ac00 {
			compatible = "allwinner,sun6i-a31-i2c";
			reg = <0x01c2ac00 0x400>;
			interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_I2C0>;
			resets = <&ccu RST_BUS_I2C0>;
			pinctrl-names = "default";
			pinctrl-0 = <&i2c0_pins>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		i2c1: i2c@01c2b000 {
			compatible = "allwinner,sun6i-a31-i2c";
			reg = <0x01c2b000 0x400>;
			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_I2C1>;
			resets = <&ccu RST_BUS_I2C1>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};
                emac: ethernet@1c30000 {
			compatible = "allwinner,sun8i-v3s-emac";
			syscon = <&syscon>;
			reg = <0x01c30000 0x104>;
			interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
			interrupt-names = "macirq";
			resets = <&ccu RST_BUS_EMAC>;
			reset-names = "stmmaceth";
			clocks = <&ccu CLK_BUS_EMAC>;
			clock-names = "stmmaceth";
			phy-handle = <&int_mii_phy>;
			phy-mode = "mii";
			#address-cells = <1>;
			#size-cells = <0>;
			status = "disabled";

			mdio {
				#address-cells = <1>;
				#size-cells = <0>;
				int_mii_phy: ethernet-phy@1 {
					compatible = "ethernet-phy-ieee802.3-c22";
					reg = <1>;
					clocks = <&ccu CLK_BUS_EPHY>;
					resets = <&ccu RST_BUS_EPHY>;
					#phy-is-integrated;
				};
			};
		};

		spi0: spi@1c68000 {
			compatible = "allwinner,sun8i-h3-spi";
			reg = <0x01c68000 0x1000>;
			interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>;
			clock-names = "ahb", "mod";
			pinctrl-names = "default";
			pinctrl-0 = <&spi0_pins>;
			resets = <&ccu RST_BUS_SPI0>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};
               gic: interrupt-controller@01c81000 {
			compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic";
			reg = <0x01c81000 0x1000>,
			      <0x01c82000 0x1000>,
			      <0x01c84000 0x2000>,
			      <0x01c86000 0x2000>;
			interrupt-controller;
			#interrupt-cells = <3>;
			interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
		};
		
	};
};

离线

楼主 #49 2018-09-29 11:41:12

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

晕哥 说:

https://github.com/torvalds/linux/blob/master/drivers/base/dd.c

我跟踪了一下代码, 是因为进入了 pinctrl_bind_failed 标号, 显示错误信息退出。

在这里进入了标号:

/* If using pinctrl, bind pins now before probing */
    ret = pinctrl_bind_pins(dev);
    if (ret)
        goto pinctrl_bind_failed;

是不是你的PB4, PB5被别的功能使用了?

没有使用这两个管脚

离线

楼主 #50 2018-09-29 11:51:50

无情一刀
会员
注册时间: 2018-09-04
已发帖子: 694
积分: 685

Re: 设置PWM参数

/* If using pinctrl, bind pins now before probing */
    ret = pinctrl_bind_pins(dev);
    if (ret)
        goto pinctrl_bind_failed;

但是我在前面打印 这个ret为0  不是从这里进去的

离线

#51 2018-09-29 11:56:29

晕哥
管理员
所在地: 微信 whycan_cn
注册时间: 2017-09-06
已发帖子: 9,238
积分: 9197

Re: 设置PWM参数

无情一刀 说:

/* If using pinctrl, bind pins now before probing */
    ret = pinctrl_bind_pins(dev);
    if (ret)
        goto pinctrl_bind_failed;

但是我在前面打印 这个ret为0  不是从这里进去的

那你跟踪一下,到底是哪一行执行了 ret ENOMEM

把完整的log信息贴一下.

dts 文件也贴一下.





离线

#52 2020-01-13 10:35:18

yuanlwjt
会员
注册时间: 2019-10-23
已发帖子: 129
积分: 109

Re: 设置PWM参数

遇到同样问题,不知道该问题解决没有?

离线

#53 2020-01-13 10:39:14

yuanlwjt
会员
注册时间: 2019-10-23
已发帖子: 129
积分: 109

Re: 设置PWM参数

pwm.png
没有全志PWM选项

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn