요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/spi/spi-controller.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: SPI Controller Common Properties
maintainers:
- Mark Brown <broonie@kernel.org>
description: |
SPI busses can be described with a node for the SPI controller device
and a set of child nodes for each SPI slave on the bus. The system SPI
controller may be described for use in SPI master mode or in SPI slave mode,
but not for both at the same time.
properties:
$nodename:
pattern: "^spi(@.*|-([0-9]|[1-9][0-9]+))?$"
"#address-cells":
enum: [0, 1]
"#size-cells":
const: 0
cs-gpios:
description: |
GPIOs used as chip selects.
If that property is used, the number of chip selects will be
increased automatically with max(cs-gpios, hardware chip selects).
So if, for example, the controller has 4 CS lines, and the
cs-gpios looks like this
cs-gpios = <&gpio1 0 0>, <0>, <&gpio1 1 0>, <&gpio1 2 0>;
Then it should be configured so that num_chipselect = 4, with
the following mapping
cs0 : &gpio1 0 0
cs1 : native
cs2 : &gpio1 1 0
cs3 : &gpio1 2 0
The second flag of a gpio descriptor can be GPIO_ACTIVE_HIGH (0)
or GPIO_ACTIVE_LOW(1). Legacy device trees often use 0.
There is a special rule set for combining the second flag of an
cs-gpio with the optional spi-cs-high flag for SPI slaves.
Each table entry defines how the CS pin is to be physically
driven (not considering potential gpio inversions by pinmux):
device node | cs-gpio | CS pin state active | Note
================+===============+=====================+=====
spi-cs-high | - | H |
- | - | L |
spi-cs-high | ACTIVE_HIGH | H |
- | ACTIVE_HIGH | L | 1
spi-cs-high | ACTIVE_LOW | H | 2
- | ACTIVE_LOW | L |
Notes:
1) Should print a warning about polarity inversion.
Here it would be wise to avoid and define the gpio as
ACTIVE_LOW.
2) Should print a warning about polarity inversion
because ACTIVE_LOW is overridden by spi-cs-high.
Should be generally avoided and be replaced by
spi-cs-high + ACTIVE_HIGH.
The simplest way to obtain an active-high CS signal is to configure the
controller's cs-gpio property with the ACTIVE_HIGH flag and set the
peripheral's spi-cs-high property. See example below for a better
understanding.
fifo-depth:
$ref: /schemas/types.yaml#/definitions/uint32
description:
Size of the RX and TX data FIFOs in bytes.
rx-fifo-depth:
$ref: /schemas/types.yaml#/definitions/uint32
description:
Size of the RX data FIFO in bytes.
tx-fifo-depth:
$ref: /schemas/types.yaml#/definitions/uint32
description:
Size of the TX data FIFO in bytes.
num-cs:
$ref: /schemas/types.yaml#/definitions/uint32
description:
Total number of chip selects.
spi-slave:
$ref: /schemas/types.yaml#/definitions/flag
description:
The SPI controller acts as a slave, instead of a master.
slave:
type: object
properties:
compatible:
description:
Compatible of the SPI device.
required:
- compatible
patternProperties:
"^.*@[0-9a-f]+$":
type: object
$ref: spi-peripheral-props.yaml
additionalProperties: true
properties:
spi-3wire:
$ref: /schemas/types.yaml#/definitions/flag
description:
The device requires 3-wire mode.
spi-cpha:
$ref: /schemas/types.yaml#/definitions/flag
description:
The device requires shifted clock phase (CPHA) mode.
spi-cpol:
$ref: /schemas/types.yaml#/definitions/flag
description:
The device requires inverse clock polarity (CPOL) mode.
required:
- compatible
- reg
dependencies:
rx-fifo-depth: [ tx-fifo-depth ]
tx-fifo-depth: [ rx-fifo-depth ]
allOf:
- if:
not:
required:
- spi-slave
then:
properties:
"#address-cells":
const: 1
else:
properties:
"#address-cells":
const: 0
- not:
required:
- fifo-depth
- rx-fifo-depth
- not:
required:
- fifo-depth
- tx-fifo-depth
additionalProperties: true
examples:
- |
spi@80010000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx28-spi";
reg = <0x80010000 0x2000>;
interrupts = <96>;
dmas = <&dma_apbh 0>;
dma-names = "rx-tx";
display@0 {
compatible = "lg,lg4573";
spi-max-frequency = <1000000>;
reg = <0>;
};
sensor@1 {
compatible = "bosch,bme680";
spi-max-frequency = <100000>;
reg = <1>;
};
flash@2 {
compatible = "jedec,spi-nor";
spi-max-frequency = <50000000>;
reg = <2>, <3>;
stacked-memories = /bits/ 64 <0x10000000 0x10000000>;
};
};
- |
#include <dt-bindings/gpio/gpio.h>
spi@20204000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "brcm,bcm2835-spi";
reg = <0x7e204000 0x1000>;
interrupts = <2 22>;
clocks = <&clk_spi>;
cs-gpios = <&gpio 8 GPIO_ACTIVE_HIGH>;
display@0 {
compatible = "lg,lg4573";
spi-max-frequency = <1000000>;
reg = <0>;
spi-cs-high;
};
};
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
SPI controller 공통 schema
1-17이 GPL-2.0 YAML schema는 SPI controller 공통 속성을 정의합니다. Schema ID는 `http://devicetree.org/schemas/spi/spi-controller.yaml#`, maintainer는 Mark Brown입니다.
SPI bus는 controller device node와 bus 위 각 SPI peripheral의 child node 집합으로 기술합니다. System SPI controller는 master mode 또는 slave mode 중 하나로만 기술할 수 있고 동시에 두 mode로 사용할 수 없습니다.
Node 이름과 bus cell
18-27Controller node 이름은 정규식 `^spi(@.*|-([0-9]|[1-9][0-9]+))?$`를 따릅니다. `#address-cells`는 0 또는 1이고 `#size-cells`는 0으로 고정됩니다.
GPIO와 native chip-select 매핑
28-46`cs-gpios`는 chip-select로 사용하는 GPIO 목록입니다. 이 속성을 사용하면 chip-select 수는 `max(cs-gpios, hardware chip selects)`로 자동 증가합니다.
예를 들어 hardware CS line이 4개이고 `cs-gpios = <&gpio1 0 0>, <0>, <&gpio1 1 0>, <&gpio1 2 0>;`이면 `num_chipselect = 4`이며 빈 둘째 항목은 native CS를 뜻합니다. GPIO descriptor의 둘째 flag는 `GPIO_ACTIVE_HIGH(0)` 또는 `GPIO_ACTIVE_LOW(1)`이고 legacy device tree는 흔히 0을 사용합니다.
원문 4-line 예제를 chip-select 번호별로 구조화했습니다.
spi-cs-high와 GPIO polarity 조합
47-75SPI peripheral의 선택적 `spi-cs-high`와 `cs-gpio`의 둘째 flag를 조합하는 특별 규칙이 있습니다. 표의 active state는 pinmux가 가할 수 있는 GPIO inversion은 고려하지 않은 물리적 CS pin 구동 상태입니다.
H는 active-high, L은 active-low로 구동되는 상태입니다.
Active-high CS를 얻는 가장 단순한 방법은 controller의 `cs-gpio`를 `ACTIVE_HIGH`로 지정하고 peripheral에 `spi-cs-high`를 설정하는 것입니다.
FIFO depth, chip-select 수와 slave mode
76-112`fifo-depth`는 RX와 TX data FIFO의 공통 크기, `rx-fifo-depth`와 `tx-fifo-depth`는 각 방향 FIFO 크기이며 단위는 byte입니다. `num-cs`는 chip-select 총수입니다.
Flag `spi-slave`를 지정하면 controller가 master 대신 slave로 동작합니다. `slave` object는 SPI device의 `compatible`을 필수로 포함합니다.
Peripheral child와 SPI mode flag
113-138정규식 `^.*@[0-9a-f]+$`에 맞는 child는 `spi-peripheral-props.yaml`을 참조하고 추가 속성을 허용합니다. Child에는 `compatible`과 `reg`가 필수입니다.
`spi-3wire`는 장치가 3-wire mode를 요구함을, `spi-cpha`는 shifted clock phase(CPHA)를, `spi-cpol`은 inverse clock polarity(CPOL)를 요구함을 나타내는 flag입니다.
FIFO dependency와 master/slave address cell
139-166`rx-fifo-depth`와 `tx-fifo-depth`는 서로 의존하므로 한쪽을 쓰면 다른 쪽도 필요합니다. 공통 `fifo-depth`와 방향별 `rx-fifo-depth` 또는 `tx-fifo-depth`를 동시에 지정할 수 없습니다.
`spi-slave`가 없으면 master mode이므로 `#address-cells`는 1입니다. `spi-slave`가 있으면 slave mode이므로 `#address-cells`는 0입니다. 이 공통 schema는 controller별 확장을 위해 최상위 추가 속성을 허용합니다.
Master controller와 세 peripheral 예제
167-197첫 예제는 `fsl,imx28-spi` master controller에 display, sensor, flash child를 둡니다. Flash는 chip select 2와 3을 묶어 두 개의 `0x10000000` stacked memory를 구성합니다.
spi@80010000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "fsl,imx28-spi";
reg = <0x80010000 0x2000>;
interrupts = <96>;
dmas = <&dma_apbh 0>;
dma-names = "rx-tx";
display@0 {
compatible = "lg,lg4573";
spi-max-frequency = <1000000>;
reg = <0>;
};
sensor@1 {
compatible = "bosch,bme680";
spi-max-frequency = <100000>;
reg = <1>;
};
flash@2 {
compatible = "jedec,spi-nor";
spi-max-frequency = <50000000>;
reg = <2>, <3>;
stacked-memories = /bits/ 64 <0x10000000 0x10000000>;
};
};
Active-high GPIO chip-select 예제
198-216둘째 예제는 BCM2835 SPI controller의 GPIO 8을 `GPIO_ACTIVE_HIGH`로 지정하고 display child에 `spi-cs-high`를 설정해 active-high CS를 구성합니다.
#include <dt-bindings/gpio/gpio.h>
spi@20204000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "brcm,bcm2835-spi";
reg = <0x7e204000 0x1000>;
interrupts = <2 22>;
clocks = <&clk_spi>;
cs-gpios = <&gpio 8 GPIO_ACTIVE_HIGH>;
display@0 {
compatible = "lg,lg4573";
spi-max-frequency = <1000000>;
reg = <0>;
spi-cs-high;
};
};
요약과 해설
spi-controller.yaml:1-216SPI controller와 peripheral의 공통 속성, CS polarity, FIFO·mode 조건과 예제를 설명합니다. 접을 수 있는 영어 원문 전체와 줄 좌표를 보존하고, 한국어 전문 번역에서는 compatible·property·symbol·source path·표·수치·조건부 제약·예제 코드를 원형대로 유지합니다.