요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
========================
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
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,
}, {
.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.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
LP5521 channel과 engine program
1-48National 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일 때만 보입니다.
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-69Sysfs에는 `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를 뜻합니다.
각 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을 연결합니다.
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.
요약·해설
leds-lp5521.rst:1-115LP5521은 세 channel을 직접 제어하거나 internal engine program으로 구동하고, channel별 current와 board resource callback을 platform data로 정의합니다.