본문 바로가기
device tree

Linux and the Device tree 문서 정리

by jsh91 2023. 5. 9.

아래에 있는 문서에서 중요한 내용을 정리해보자

Kernel Devicetree Usage

 

 

Linux에서 device tree를 사용하는 방법은 아래 사이트에서 문서를 보면 알 수 있다.

https://www.devicetree.org/specifications/

 

Specifications

Devicetree.org is a community effort by many companies and individuals to facilitate the future evolution of the Devicetree Standard.

www.devicetree.org

 

binding이라는 용어는 gpio, interrupt, data buss 등 물리적 하드웨어를 표현하는 방법이다 

차후 devicetree api를 공부 할 때 binding 키워드를 공부 할 때 참고하자

Conceptually, a common set of usage conventions, called 'bindings', is defined for how data should appear in the tree to describe typical hardware characteristics including data busses, interrupt lines, GPIO connections, and peripheral devices.

 

devicd tree의 중요 기능들이다.

Linux uses DT data for three major purposes:

  1. platform identification,
  2. runtime configuration, and
  3. device population.

 

 

대부분의 경우 머신 ID는 관련이 없으며 커널은 대신 머신의 코어 CPU 또는 SoC를 기반으로 설정 코드를 선택합니다. 예를 들어 ARM에서 arch/arm/kernel/setup.c의 setup_arch()는 machine_desc 테이블을 검색하고 장치 트리 데이터와 가장 일치하는 machine_desc를 선택하는 arch/arm/kernel/devtree.c의 setup_machine_fdt()를 호출합니다. . 루트 장치 트리 노드에서 'compatible' 속성을 보고 이를 struct machine_desc의 dt_compat 목록과 비교하여 가장 일치하는 항목을 결정합니다.

 

In the majority of cases, the machine identity is irrelevant, and the kernel will instead select setup code based on the machine's core CPU or SoC. On ARM for example, setup_arch() in arch/arm/kernel/setup.c will call setup_machine_fdt() in arch/arm/kernel/devtree.c which searches through the machine_desc table and selects the machine_desc which best matches the device tree data. It determines the best match by looking at the 'compatible' property in the root device tree node, and comparing it with the dt_compat list in struct machine_desc (which is defined in arch/arm/include/asm/mach/arch.h if you're curious).

 

 

 

호환 가능한 값에 대한 참고 사항이 하나 더 있습니다. 호환 가능한 속성에 사용된 모든 문자열은 그것이 나타내는 내용을 문서화해야 합니다. Documentation/devicetree/bindings에서 호환되는 문자열에 대한 문서를 추가합니다.

 

One more note on compatible values. Any string used in a compatible property must be documented as to what it indicates. Add documentation for compatible strings in Documentation/devicetree/bindings.

 

 

 

일반적으로 early_init_dt_scan_chosen() 도우미는 커널 매개 변수, DT 주소 공간 모델을 초기화하는 early_init_dt_scan_root() 및 사용 가능한 RAM의 크기와 위치를 결정하는 early_init_dt_scan_memory()를 포함하여 선택한 노드를 구문 분석하는 데 사용

 

Typically the early_init_dt_scan_chosen() helper is used to parse the chosen node including kernel parameters, early_init_dt_scan_root() to initialize the DT address space model, and early_init_dt_scan_memory() to determine the size and location of usable RAM.

 

 

 

초기 부팅 중에 아키텍처 설정 코드는 페이징이 설정되기 전에 장치 트리 데이터를 구문 분석하기 위해 서로 다른 도우미 콜백을 사용하여 of_scan_flat_dt()를 여러 번 호출합니다. of_scan_flat_dt() 코드는 장치 트리를 스캔하고 도우미를 사용하여 초기 부팅 중에 필요한 정보를 추출합니다. 일반적으로 early_init_dt_scan_chosen() 도우미는 커널 매개 변수, DT 주소 공간 모델을 초기화하는 early_init_dt_scan_root() 및 사용 가능한 RAM의 크기와 위치를 결정하는 early_init_dt_scan_memory()를 포함하여 선택한 노드를 구문 분석하는 데 사용됩니다.

 

As can be guessed by the names, .init_early() is used for any machine- specific setup that needs to be executed early in the boot process, and .init_irq() is used to set up interrupt handling. Using a DT doesn't materially change the behaviour of either of these functions. If a DT is provided, then both .init_early() and .init_irq() are able to call any of the DT query functions (of_* in include/linux/of*.h) to get additional data about the platform.

 

'device tree' 카테고리의 다른 글

device tree 참조  (0) 2023.11.19
unflatten_device_tree -> __unflatten_device_tree 분석  (0) 2023.05.17
디버깅 방법  (0) 2023.05.12
device tree 연대기  (0) 2023.05.09

댓글