您尚未登录。

#1 全志 SOC » tiny200 通过配置 device tree 碰到 GPIO 驱动获取节点失败的问题 » 2020-02-06 23:44:59

xiao.huang
回复: 1

想通过 tiny200 学习一下驱动,我知道官方已经支持 gpio-leds 的方式配置 GPIO 了,自己折腾。。。

这个是我的 device tree 配置:

// SPDX-License-Identifier: (GPL-2.0+ OR X11)
/*
 * Copyright 2018 Icenowy Zheng <icenowy@aosc.io>
 */

/dts-v1/;
#include "suniv-f1c100s.dtsi"

#include <dt-bindings/gpio/gpio.h>

/ {
	model = "Lichee Pi Nano";
	compatible = "licheepi,licheepi-nano", "allwinner,suniv-f1c100s",
		     "allwinner,suniv";

	aliases {
		serial0 = &uart0;
		spi0 = &spi0;
	};

	chosen {
		stdout-path = "serial0:115200n8";
	};

	panel: panel {
		compatible = "qiaodian,qd43003c0-40", "simple-panel";
		#address-cells = <1>;
		#size-cells = <0>;
		enable-gpios = <&pio 4 6 GPIO_ACTIVE_HIGH>;

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

			panel_input: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&tcon0_out_lcd>;
			};
		};
	};

	reg_vcc3v3: vcc3v3 {
		compatible = "regulator-fixed";
		regulator-name = "vcc3v3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
	};

	tiny200 {
		compatible = "hello";
		beep-gpio = <&pio 4 5 GPIO_ACTIVE_HIGH>; /* PE5 */
		beep2-gpio = <&pio 0 0 GPIO_ACTIVE_HIGH>; /* PA0 */
		status = "okay";
	};
};

&de {
	status = "okay";
};

&mmc0 {
	vmmc-supply = <&reg_vcc3v3>;
	bus-width = <4>;
	broken-cd;
	status = "okay";
};

&otg_sram {
	status = "okay";
};

&spi0 {
    pinctrl-names = "default";
    pinctrl-0 = <&spi0_pins_a>;
    status = "okay";
    spi-max-frequency = <50000000>;
    flash: w25q128@0 {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "winbond,w25q128", "jedec,spi-nor";
        reg = <0>;   
        spi-max-frequency = <50000000>;
        partitions {
            compatible = "fixed-partitions";
            #address-cells = <1>;
            #size-cells = <1>;

            partition@0 {
                label = "u-boot";
                reg = <0x000000 0x100000>;
                read-only;
            };

            partition@100000 {
                label = "dtb";
                reg = <0x100000 0x10000>;
                read-only;
            };

            partition@110000 {
                label = "kernel";
                reg = <0x110000 0x400000>;
                read-only;
            };

            partition@510000 {
                label = "rootfs";
                reg = <0x510000 0xAF0000>;
            };
        };
    };
};   

&tcon0 {
	pinctrl-names = "default";
	pinctrl-0 = <&lcd_rgb666_pins>;
	status = "okay";
};

&tcon0_out {
	tcon0_out_lcd: endpoint@0 {
		reg = <0>;
		remote-endpoint = <&panel_input>;
	};
};

&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart0_pins_a>;
	status = "okay";
};

&usb_otg {
	dr_mode = "otg";
	status = "okay";
};

&usbphy {
	usb0_id_det-gpio = <&pio 4 2 GPIO_ACTIVE_HIGH>; /* PE2 */
	status = "okay";
};

新增了:

	tiny200 {
		compatible = "hello";
		beep-gpio = <&pio 4 5 GPIO_ACTIVE_HIGH>; /* PE5 */
		beep2-gpio = <&pio 0 0 GPIO_ACTIVE_HIGH>; /* PA0 */
		status = "okay";
	};

这是我的驱动代码,of_get_named_gpio 返回总是返回 -517(EPROBE_DEFER)

	printk(KERN_INFO "node name %s\n", node->name);
	printk(KERN_INFO "node full_name %s\n", node->full_name);

	tmp = of_find_property(node, "compatible", NULL);
	if (!tmp) {
		printk(KERN_ALERT "[Error] of_find_property(node, \"compatible\", NULL) err!!\n");
        return -EINVAL;
	}
	printk(KERN_INFO "property name %s value %s\n", tmp->name, tmp->value);

	tmp = of_find_property(node, "status", NULL);
	if (!tmp) {
		printk(KERN_ALERT "[Error] of_find_property(node, \"compatible\", NULL) err!!\n");
        return -EINVAL;
	}
	printk(KERN_INFO "property name %s value %s\n", tmp->name, tmp->value);

	//

	ret = gpio_is_valid(133);
	printk(KERN_INFO "gpio_is_valid(133) ret %d\n", ret);

	tiny200_priv.beep[0] = of_get_named_gpio(node, "beep2-gpio", 0);
	printk(KERN_INFO "tiny200_priv.beep[0] %d\n", tiny200_priv.beep[0]);

	ret = gpio_is_valid(tiny200_priv.beep[0]);
	printk(KERN_INFO "gpio_is_valid(tiny200_priv.beep[0]) ret %d\n", ret);
	if(!ret)
        {
                printk(KERN_ALERT "[Error] wrong beep-gpio from dts!!\n");
                return -EINVAL;
        }

这是 log 打印:

[    0.185362] node name tiny200
[    0.185388] node full_name tiny200
[    0.185405] property name compatible value hello
[    0.185422] property name status value okay
[    0.185436] gpio_is_valid(133) ret 1
[    0.185484] tiny200_priv.beep[0] -517
[    0.185502] gpio_is_valid(tiny200_priv.beep[0]) ret 0
[    0.185516] [Error] wrong beep-gpio from dts!!
[    0.185575] hello_driver_name: probe of tiny200 failed with error -22

哪位大神能指点一下,谢谢!

#2 Re: 全志 SOC » 尝试从零构建F1C100s开发环境 » 2020-01-09 08:58:50

LinjieGuo 说:

现在传上来。包里面存在两个文件".config"以及"config.in"

buildroot配置文件
下载后解包看看。

感谢@LinjieGuo
下载最新的 buildroot-2019.02.8,然后重新按上述配置就没有问题,rootfs 编出来 2MB,已经能启动到 shell 了;
接下来在想 f1c200s 能做什么呢 neutral

#3 Re: 全志 SOC » 尝试从零构建F1C100s开发环境 » 2020-01-06 20:52:17

红白机 说:

@xiao.huang 你上传 buildroot 根目录下面的 .config, 不是 kernel 的 .config

这个就是 buildroot 下的 .config 了

#4 Re: 全志 SOC » 尝试从零构建F1C100s开发环境 » 2020-01-06 02:45:27

$ ls -lh output/images/
total 95M
-rw-r--r-- 1 ted ted 95M 1月   6 02:41 rootfs.tar

大神指点一下,为什么我编出来的根文件系统有 95MB?
我是想烧录到16MB spiflash,解压出来发现 gdb 和 mplayer 占了几十M;
.config文件

FluxBB bbcode 测试

页脚

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

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