← Documents Documentation/devicetree/bindings/pwm/pwm.txt GitHub 원문 ↗

Linux 6.18.37 · Devicetree Bindings

PWM consumer와 controller

PWM consumer와 controller의 property, cell 형식과 device-tree 예제를 설명합니다.

Source pathDocumentation/devicetree/bindings/pwm/pwm.txt
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

pwm.txt:1-60

필수·선택 property의 의미와 원문의 실제 선언 예제를 함께 읽을 수 있습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 Specifying PWM information for devices
2 ======================================
3
4 1) PWM user nodes
5 -----------------
6
7 PWM users should specify a list of PWM devices that they want to use
8 with a property containing a 'pwm-list':
9
10 pwm-list ::= <single-pwm> [pwm-list]
11 single-pwm ::= <pwm-phandle> <pwm-specifier>
12 pwm-phandle : phandle to PWM controller node
13 pwm-specifier : array of #pwm-cells specifying the given PWM
14 (controller specific)
15
16 PWM properties should be named "pwms". The exact meaning of each pwms
17 property must be documented in the device tree binding for each device.
18 An optional property "pwm-names" may contain a list of strings to label
19 each of the PWM devices listed in the "pwms" property. If no "pwm-names"
20 property is given, the name of the user node will be used as fallback.
21
22 Drivers for devices that use more than a single PWM device can use the
23 "pwm-names" property to map the name of the PWM device requested by the
24 pwm_get() call to an index into the list given by the "pwms" property.
25
26 The following example could be used to describe a PWM-based backlight
27 device:
28
29 pwm: pwm {
30 #pwm-cells = <2>;
31 };
32
33 [...]
34
35 bl: backlight {
36 pwms = <&pwm 0 5000000>;
37 pwm-names = "backlight";
38 };
39
40 Note that in the example above, specifying the "pwm-names" is redundant
41 because the name "backlight" would be used as fallback anyway.
42
43 pwm-specifier typically encodes the chip-relative PWM number and the PWM
44 period in nanoseconds.
45
46 Optionally, the pwm-specifier can encode a number of flags (defined in
47 <dt-bindings/pwm/pwm.h>) in a third cell:
48 - PWM_POLARITY_INVERTED: invert the PWM signal polarity
49
50 Example with optional PWM specifier for inverse polarity
51
52 bl: backlight {
53 pwms = <&pwm 0 5000000 PWM_POLARITY_INVERTED>;
54 pwm-names = "backlight";
55 };
56
57 2) PWM controller nodes
58 -----------------------
59
60 See pwm.yaml.
61

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

PWM 목록 문법

1-15

PWM consumer node는 사용할 PWM device 목록을 `pwm-list` 형식의 property로 지정합니다. 각 `single-pwm`은 PWM controller node의 `pwm-phandle`과 controller별 `#pwm-cells` 배열인 `pwm-specifier`로 구성됩니다.

pwm-list ::= <single-pwm> [pwm-list]
single-pwm ::= <pwm-phandle> <pwm-specifier>
pwm-phandle : phandle to PWM controller node
pwm-specifier : array of #pwm-cells specifying the given PWM
                (controller specific)

`pwms`와 `pwm-names`

16-24

PWM property 이름은 `pwms`여야 하며 각 cell의 정확한 의미는 해당 device binding에 문서화해야 합니다. 선택 property `pwm-names`는 `pwms`의 PWM device마다 label을 붙입니다. 생략하면 consumer node 이름을 fallback으로 사용합니다.

여러 PWM device를 쓰는 driver는 `pwm_get()`에 요청한 이름을 `pwm-names`에서 찾아 `pwms` 목록의 index로 대응시킬 수 있습니다.

Backlight 예제

25-41

PWM 기반 backlight는 controller의 `#pwm-cells`와 consumer의 `pwms`를 연결합니다. 아래 예제의 `pwm-names = "backlight"`는 node 이름도 `backlight`이므로 생략해도 같은 fallback 이름을 얻습니다.

pwm: pwm {
        #pwm-cells = <2>;
};

[...]

bl: backlight {
        pwms = <&pwm 0 5000000>;
        pwm-names = "backlight";
};

Specifier와 polarity flag

42-55

일반적인 `pwm-specifier`는 chip-relative PWM 번호와 ns 단위 PWM period를 담습니다. 선택적인 세 번째 cell에는 `<dt-bindings/pwm/pwm.h>`가 정의한 flag를 넣을 수 있으며 `PWM_POLARITY_INVERTED`는 PWM signal polarity를 반전합니다.

bl: backlight {
        pwms = <&pwm 0 5000000 PWM_POLARITY_INVERTED>;
        pwm-names = "backlight";
};

PWM controller node

56-60

PWM controller node의 공통 형식은 같은 directory의 `pwm.yaml`을 참조합니다.