英文:
To configure pin define in a SoC, what's different between doing it in U-Boot and Linux Device Tree?
问题
根据我对(嵌入式)Linux平台引导流程的了解,首先在CPU上运行引导加载程序(例如U-Boot),然后将Linux内核加载到内存中。
尽管U-Boot和Linux内核都可以配置引脚定义(或引脚复用),但我应该决定将引脚定义代码放在哪里?如果它们将一个引脚定义为不同的引脚复用方式,U-Boot的定义会被Linux内核的定义覆盖吗?
英文:
As my knowledge about the booting flow of a (embedded) Linux platform, there's a bootloader (e.g. U-Boot) running on the CPU first, then load the Linux kernel into memory.
While both U-Boot and Linux kernel can configure pin-define (or pin-mux), where should I decide where to put the pin-define code? If they define a pin into different pin-mux, will the U-Boot's define be overriden by Linux kernel's define?
答案1
得分: 2
While both U-Boot and Linux kernel can configure pin-define (or pin-mux), where should I decide where to put the pin-define code?
无论U-Boot如何操作,您希望内核完全配置所有引脚到内核期望/需要的状态。然后,实际的硬件状态始终与软件知道/假设的一致。设备树中的引脚定义同时指定引脚复用以及设备的所有权。因此,您需要向Linux内核提供一个设备树,完全指定所有设备的引脚使用情况。
对于许多SoC,如果一个引脚未为外设功能复用,则它将成为未使用的GPIO。因此,如果您只在U-Boot中为外设复用这样的引脚,那么如果该引脚在Linux的设备树中被省略,它可能会意外地被用作GPIO,并干扰Linux设备驱动程序的操作。
引脚和GPIO是由Linux内核的pinctrl和gpio子系统管理的资源。通过设备树提供不完整的规范可能被视为错误。
If they define a pin into different pin-mux, will the U-Boot's define be override by Linux kernel's define?
是的,较新的操作将取代先前的操作。
英文:
> While both U-Boot and Linux kernel can configure pin-define (or pin-mux), where should I decide where to put the pin-define code?
Regardless of what U-Boot does, you want the kernel to fully configure all pins to a state that the kernel expects/requires. Then the actual HW state is always consistent with what the software knows/assumes. Pin definitions in the Device Tree specify both pin multiplexing as well as ownership by a device. So you need to provide the Linux kernel with a Device Tree that fully specifies all pin usage of all devices.
For many SoCs, a pin that in not muxed for a peripheral function becomes an unused GPIO. So if you only multiplex such a pin in U-Boot for the peripheral, then, if that pin is left out of Linux's Device Tree, it could be inadvertently used as a GPIO, and interfere with the operations of the Linux device driver.
Pins and GPIOs are resources managed by the pinctrl and gpio subsystems of the Linux kernel. Providing incomplete specifications through the Device Tree could be considered a bug.
> If they define a pin into different pin-mux, will the U-Boot's define be override by Linux kernel's define?
Yes, the more recent operation supplants the prior operation.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论