您尚未登录。

楼主 # 2022-01-02 17:07:47

leefei
会员
注册时间: 2020-12-19
已发帖子: 33
积分: 114

V3x控制PC4-PC10的GPIO

坑站上好像有不少人像我一样,去linux官网下载的kernel。然后使用荔枝派的设备树文件,发现控制不了PC口。
那是因为V3s的GPIO是阉割了的。由于V3x只是S3换了封装,所以得用S3的dts设备树文件 。再打开内核文件夹看一下S3的dts文件包含的是V3的dtsi文件,V3的dtsi文件包含的是V3S.dtsi,V3的dtsi文件是在V3S.dtsi的基础上把pio换成sun8i-v3-pinctrl,把ccu也换成了sun8i-v3-ccu
这是sun8i-v3.dtsi文件

#include "sun8i-v3s.dtsi"

&ccu {
	compatible = "allwinner,sun8i-v3-ccu";
};

&emac {
	/delete-property/ phy-handle;
	/delete-property/ phy-mode;
};

&mdio_mux {
	external_mdio: mdio@2 {
		reg = <2>;
		#address-cells = <1>;
		#size-cells = <0>;
	};
};

&pio {
	compatible = "allwinner,sun8i-v3-pinctrl";
};

说了一大堆,我自己都绕晕了,直接上代码验证,其实很简单,把荔枝派的设备树文件包含的#include "sun8i-v3s.dtsi"换成#include "sun8i-v3.dtsi"就行了

#include "sun8i-v3.dtsi"
#include "sunxi-common-regulators.dtsi"
#include <dt-bindings/input/input.h>

/ {
	model = "Lichee Pi Zero";
	compatible = "licheepi,licheepi-zero", "allwinner,sun8i-v3s";

	aliases {
		serial0 = &uart0;
	};

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

	leds {
		compatible = "gpio-leds";
		green_led {
			label = "green";
			linux,default-trigger = "heartbeat";
			gpios = <&pio 4 22 GPIO_ACTIVE_HIGH>; 
		};
	};
};

&spi0 {
    status = "okay";
    st7789v@0 {
            compatible = "sitronix,st7789v";
            reg = <0>;
            spi-max-frequency = <96000000>;
            rotate = <0>;
            rgb;
            width=<240>;
            height=<320>;
            fps = <30>;
            buswidth = <8>;
            led-gpios = <&pio 1 5 GPIO_ACTIVE_LOW>;
            reset-gpios = <&pio 1 6 GPIO_ACTIVE_HIGH>;
            dc-gpios = <&pio 1 7 GPIO_ACTIVE_HIGH>;
            debug = <0>;
    };
};

&codec {
	allwinner,audio-routing =
		"Headphone", "HP",
		"Headphone", "HPCOM";
	status = "okay";
};

&ehci0 {
	status = "okay";
};

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

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

&i2c0 {
	status = "disabled";

	ns2009: ns2009@48 {
		compatible = "nsiway,ns2009";
		reg = <0x48>;
	};
};

&ohci0 {
	status = "okay";
};

&uart0 {
	pinctrl-0 = <&uart0_pb_pins>;
	pinctrl-names = "default";
	status = "okay";
};
/*
&uart1 {
	pinctrl-0 = <&uart1_pins_a>;
	pinctrl-names = "default";
	status = "okay";
};
&uart2 {
	pinctrl-0 = <&uart2_pins_a>;
	pinctrl-names = "default";
	status = "okay";
};
*/
&usb_otg {
	dr_mode = "otg";
	status = "okay";
};
&usbphy {
	usb0_id_det-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>;
	status = "okay";
};

&lradc {
	vref-supply = <&reg_vcc3v3>;
	status = "okay";

	button@200 {
		label = "Volume Up";
		linux,code = <KEY_L>;
		channel = <0>;
		//voltage = <500000>;
		voltage = <550000>;
	};

	button@400 {
		label = "Volume Down";
		linux,code = <KEY_ENTER>;
		channel = <0>;
		//voltage = <1060000>;
		voltage = <1270000>;
	};

	button@600 {
		label = "Select";
		linux,code = <KEY_S>;
		channel = <0>;
		//voltage = <1560000>;
		voltage = <2030000>;
	};
};

编译并拷贝新设备树文件到TF卡启动系统
控制PC4方法:
导出GPIO

echo 68 > /sys/class/gpio/export

   
设置GPIO为输出 

echo out > /sys/class/gpio/gpio68/direction

 
设置GPIO输出高电平

echo 1 >/sys/class/gpio/gpio68/value

同理设置GPIO输出低电平

echo 0 >/sys/class/gpio/gpio68/value

最近编辑记录 leefei (2022-01-02 17:08:16)

离线

#1 2022-01-02 22:39:34

twzy
会员
注册时间: 2021-04-16
已发帖子: 162
积分: 316.5
个人网站

Re: V3x控制PC4-PC10的GPIO

感谢分享,看来我那个板子又可以填一个坑了

离线

页脚

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

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