This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] PROCESSOR-SDK-AM62X:GPIO 配置

Guru**** 2333880 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1516352/processor-sdk-am62x-gpio-configuration

器件型号:PROCESSOR-SDK-AM62X

工具/软件:

我正在处理 GPIO 配置、其中添加了两个引脚的配置、如下所示:

// SPDX-License-Identifier: GPL-2.0-only OR MIT
/*
 * Not actually "common", but alternative to k3-am62x-sk-common - baseline for 
 * CBC-9000 prototype hardware without SK/Development board settings
 *
 * Copyright (C) 2021-2024 Texas Instruments Incorporated - https://www.ti.com/
 */

#include <dt-bindings/leds/common.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/net/ti-dp83867.h>
#include "k3-am625.dtsi"

/ {
	aliases {
		gpio = &main_pmx0;
	};

	sensor {
		compatible = "gpio-keys";
		pinctrl-names = "default";
		pinctrl-0 = <&gpio_pins_default>;

		close {
			label = "Close";
			gpios = <&main_gpio1 10 GPIO_ACTIVE_LOW>;
			// linux,code = <KEY_ENTER>;
		};

		open {
			label = "Open";
			gpios = <&main_gpio1 9 GPIO_ACTIVE_LOW>;
			// linux,code = <KEY_ENTER>;
		};
	};
};

&main_pmx0 {
	gpio_pins_default: gpio-default-pins {
		bootph-all;
		pinctrl-single,pins = <
			AM62X_IOPAD(0x1A0, PIN_INPUT, 7) /* (E18) */
			AM62X_IOPAD(0x19C, PIN_INPUT, 7) /* (B18) */
		>;
	};
};

但无法获取并设置 GPIO、我需要有关如何操作的帮助。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Amit、

    Unknown 说:
    、但我无法获取和设置 GPIO、

    请详细说明。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    基本上、我无法看到驱动程序、我能够看到通过 dmessages 添加的 IOS

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    基本上我看不到驱动程序、

    很抱歉、但仍然不明白。 您指的是内核驱动程序还是其他什么?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    是的内核驱动程序

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我的日志:

    root@device:~# dmesg | grep sensor
    [    2.687451] gpio-keys sensor: Button without keycode
    [    2.696554] gpio-keys sensor: probe with driver gpio-keys failed with error -22
    root@device:~# find / -type f -name *sensor*
    /run/udev/data/+platform:sensor
    /sys/firmware/devicetree/base/__symbols__/door_pins_default

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    [2.687451]   GPIO-键传感器:按钮无键码

    这是导致下一行出现错误-22的错误。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我已经解决了这个问题、但需要有关如何获取输入状态(高电平/低电平)的帮助?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您将该 GPIO 引脚定义为 GPIO 密钥。 请查看以下链接中的 ev_key 部分。

    https://www.kernel.org/doc/html/v4.17/input/event-codes.html#ev-key

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    是的、我将它们定义为 GPIO 密钥、因为这些 IO 用作输入检测、并希望将它们设置为中断。