← Documents Documentation/leds/leds-lp5521.rst GitHub 원문 ↗

Linux 6.18.37 · LEDs

LP5521 LED Driver

3-channel LP5521의 engine micro-program, selftest, current와 platform data contract입니다.

Source pathDocumentation/leds/leds-lp5521.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

leds-lp5521.rst:1-115

LP5521은 세 channel을 직접 제어하거나 internal engine program으로 구동하고, channel별 current와 board resource callback을 platform data로 정의합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ========================
2 Kernel driver for lp5521
3 ========================
4
5 * National Semiconductor LP5521 led driver chip
6 * Datasheet: http://www.national.com/pf/LP/LP5521.html
7
8 Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
9
10 Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
11
12 Description
13 -----------
14
15 LP5521 can drive up to 3 channels. Leds can be controlled directly via
16 the led class control interface. Channels have generic names:
17 lp5521:channelx, where x is 0 .. 2
18
19 All three channels can be also controlled using the engine micro programs.
20 More details of the instructions can be found from the public data sheet.
21
22 LP5521 has the internal program memory for running various LED patterns.
23 There are two ways to run LED patterns.
24
25 1) Legacy interface - enginex_mode and enginex_load
26 Control interface for the engines:
27
28 x is 1 .. 3
29
30 enginex_mode:
31 disabled, load, run
32 enginex_load:
33 store program (visible only in engine load mode)
34
35 Example (start to blink the channel 2 led)::
36
37 cd /sys/class/leds/lp5521:channel2/device
38 echo "load" > engine3_mode
39 echo "037f4d0003ff6000" > engine3_load
40 echo "run" > engine3_mode
41
42 To stop the engine::
43
44 echo "disabled" > engine3_mode
45
46 2) Firmware interface - LP55xx common interface
47
48 For the details, please refer to 'firmware' section in leds-lp55xx.txt
49
50 sysfs contains a selftest entry.
51
52 The test communicates with the chip and checks that
53 the clock mode is automatically set to the requested one.
54
55 Each channel has its own led current settings.
56
57 - /sys/class/leds/lp5521:channel0/led_current - RW
58 - /sys/class/leds/lp5521:channel0/max_current - RO
59
60 Format: 10x mA i.e 10 means 1.0 mA
61
62 example platform data::
63
64 static struct lp55xx_led_config lp5521_led_config[] = {
65 {
66 .name = "red",
67 .chan_nr = 0,
68 .led_current = 50,
69 .max_current = 130,
70 }, {
71 .name = "green",
72 .chan_nr = 1,
73 .led_current = 0,
74 .max_current = 130,
75 }, {
76 .name = "blue",
77 .chan_nr = 2,
78 .led_current = 0,
79 .max_current = 130,
80 }
81 };
82
83 static int lp5521_setup(void)
84 {
85 /* setup HW resources */
86 }
87
88 static void lp5521_release(void)
89 {
90 /* Release HW resources */
91 }
92
93 static void lp5521_enable(bool state)
94 {
95 /* Control of chip enable signal */
96 }
97
98 static struct lp55xx_platform_data lp5521_platform_data = {
99 .led_config = lp5521_led_config,
100 .num_channels = ARRAY_SIZE(lp5521_led_config),
101 .clock_mode = LP55XX_CLOCK_EXT,
102 .setup_resources = lp5521_setup,
103 .release_resources = lp5521_release,
104 .enable = lp5521_enable,
105 };
106
107 Note:
108 chan_nr can have values between 0 and 2.
109 The name of each channel can be configurable.
110 If the name field is not defined, the default name will be set to 'xxxx:channelN'
111 (XXXX : pdata->label or i2c client name, N : channel number)
112
113
114 If the current is set to 0 in the platform data, that channel is
115 disabled and it is not visible in the sysfs.
116

3. 한국어 전문 번역

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

LP5521 channel과 engine program

1-48

National Semiconductor LP5521은 최대 3개 channel을 구동합니다. LED class interface에서 직접 제어할 수 있고 기본 channel 이름은 `lp5521:channel0`부터 `lp5521:channel2`입니다.

세 channel 모두 internal program memory의 engine micro-program으로 제어할 수 있습니다. Instruction 세부 형식은 public datasheet를 참조합니다.

Legacy interface는 engine 1~3마다 `enginex_mode`와 `enginex_load`를 제공합니다. Mode는 `disabled`, `load`, `run`이고 program을 쓰는 `enginex_load`는 engine이 load mode일 때만 보입니다.

Legacy engine program
Device sysfs directory로 이동`engine3_mode`에 `load` 기록`engine3_load`에 `037f4d0003ff6000` program 기록`engine3_mode`에 `run` 기록중지할 때 `engine3_mode`에 `disabled` 기록

Channel 2 blink 예제의 상태 전환입니다.

두 번째 방법은 LP55xx common firmware interface입니다. 자세한 내용은 `leds-lp55xx.txt`의 firmware section을 참조합니다.

========================
Kernel driver for lp5521
========================

* National Semiconductor LP5521 led driver chip
* Datasheet: http://www.national.com/pf/LP/LP5521.html

Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo

Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)

Description
-----------

LP5521 can drive up to 3 channels. Leds can be controlled directly via
the led class control interface. Channels have generic names:
lp5521:channelx, where x is 0 .. 2

All three channels can be also controlled using the engine micro programs.
More details of the instructions can be found from the public data sheet.

LP5521 has the internal program memory for running various LED patterns.
There are two ways to run LED patterns.

1) Legacy interface - enginex_mode and enginex_load
   Control interface for the engines:

   x is 1 .. 3

   enginex_mode:
        disabled, load, run
   enginex_load:
        store program (visible only in engine load mode)

  Example (start to blink the channel 2 led)::

        cd   /sys/class/leds/lp5521:channel2/device
        echo "load" > engine3_mode
        echo "037f4d0003ff6000" > engine3_load
        echo "run" > engine3_mode

  To stop the engine::

        echo "disabled" > engine3_mode

2) Firmware interface - LP55xx common interface

For the details, please refer to 'firmware' section in leds-lp55xx.txt

Selftest와 channel current

49-69

Sysfs에는 `selftest` entry가 있습니다. Test는 chip과 통신하고 clock mode가 요청한 값으로 자동 설정되는지 확인합니다.

각 channel은 독립적인 LED current 설정을 갖습니다. `led_current`는 read/write, `max_current`는 read-only입니다. Path 예는 `/sys/class/leds/lp5521:channel0/led_current`와 `max_current`입니다.

Current 값 형식은 0.1mA 단위입니다. 즉 값 `10`은 1.0mA를 뜻합니다.

LP5521 current attribute
Attribute접근단위
`led_current`Read/write`0.1 mA`
`max_current`Read-only`0.1 mA`
예: `10`-`1.0 mA`

각 channel에서 현재값과 hardware limit를 분리합니다.


sysfs contains a selftest entry.

The test communicates with the chip and checks that
the clock mode is automatically set to the requested one.

Each channel has its own led current settings.

- /sys/class/leds/lp5521:channel0/led_current - RW
- /sys/class/leds/lp5521:channel0/max_current - RO

Format: 10x mA i.e 10 means 1.0 mA

example platform data::

  static struct lp55xx_led_config lp5521_led_config[] = {
          {
                .name = "red",
                  .chan_nr        = 0,
                  .led_current    = 50,
                .max_current    = 130,

Platform data 구성

70-115

예제 platform data는 red, green, blue 세 `lp55xx_led_config` entry를 channel 0, 1, 2에 연결합니다. Red의 initial current는 50, green과 blue는 0이며 각 `max_current`는 130입니다.

Board code는 hardware resource 준비용 `lp5521_setup`, 해제용 `lp5521_release`, chip enable signal 제어용 `lp5521_enable(bool state)` callback을 제공합니다.

`lp55xx_platform_data`에는 channel config array, `num_channels`, `LP55XX_CLOCK_EXT` clock mode, 세 resource callback을 연결합니다.

LP5521 platform data
Field역할
`led_config`Channel별 이름·번호·current·최대 current
`num_channels`Config array 크기
`clock_mode`Internal 또는 external clock 선택
`setup_resources`Hardware resource 준비
`release_resources`Resource 해제
`enable`Chip enable signal 제어

Channel 설정과 board-level callback의 역할입니다.

`chan_nr`는 0~2입니다. Channel 이름은 설정 가능하고 생략하면 `xxxx:channelN`이 기본값입니다. `xxxx`는 `pdata->label` 또는 I2C client 이름, `N`은 channel 번호입니다.

Platform data에서 current를 0으로 설정한 channel은 비활성화되며 sysfs에도 나타나지 않습니다.

          }, {
                .name = "green",
                  .chan_nr        = 1,
                  .led_current    = 0,
                .max_current    = 130,
          }, {
                .name = "blue",
                  .chan_nr        = 2,
                  .led_current    = 0,
                .max_current    = 130,
          }
  };

  static int lp5521_setup(void)
  {
        /* setup HW resources */
  }

  static void lp5521_release(void)
  {
        /* Release HW resources */
  }

  static void lp5521_enable(bool state)
  {
        /* Control of chip enable signal */
  }

  static struct lp55xx_platform_data lp5521_platform_data = {
          .led_config     = lp5521_led_config,
          .num_channels   = ARRAY_SIZE(lp5521_led_config),
          .clock_mode     = LP55XX_CLOCK_EXT,
          .setup_resources   = lp5521_setup,
          .release_resources = lp5521_release,
          .enable            = lp5521_enable,
  };

Note:
  chan_nr can have values between 0 and 2.
  The name of each channel can be configurable.
  If the name field is not defined, the default name will be set to 'xxxx:channelN'
  (XXXX : pdata->label or i2c client name, N : channel number)


If the current is set to 0 in the platform data, that channel is
disabled and it is not visible in the sysfs.