요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
========================
Kernel driver i2c-ocores
========================
Supported adapters:
* OpenCores.org I2C controller by Richard Herveille (see datasheet link)
https://opencores.org/project/i2c/overview
Author: Peter Korsgaard <peter@korsgaard.com>
Description
-----------
i2c-ocores is an i2c bus driver for the OpenCores.org I2C controller
IP core by Richard Herveille.
Usage
-----
i2c-ocores uses the platform bus, so you need to provide a struct
platform_device with the base address and interrupt number. The
dev.platform_data of the device should also point to a struct
ocores_i2c_platform_data (see linux/platform_data/i2c-ocores.h) describing the
distance between registers and the input clock speed.
There is also a possibility to attach a list of i2c_board_info which
the i2c-ocores driver will add to the bus upon creation.
E.G. something like::
static struct resource ocores_resources[] = {
[0] = {
.start = MYI2C_BASEADDR,
.end = MYI2C_BASEADDR + 8,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MYI2C_IRQ,
.end = MYI2C_IRQ,
.flags = IORESOURCE_IRQ,
},
};
/* optional board info */
struct i2c_board_info ocores_i2c_board_info[] = {
{
I2C_BOARD_INFO("tsc2003", 0x48),
.platform_data = &tsc2003_platform_data,
.irq = TSC_IRQ
},
{
I2C_BOARD_INFO("adv7180", 0x42 >> 1),
.irq = ADV_IRQ
}
};
static struct ocores_i2c_platform_data myi2c_data = {
.regstep = 2, /* two bytes between registers */
.clock_khz = 50000, /* input clock of 50MHz */
.devices = ocores_i2c_board_info, /* optional table of devices */
.num_devices = ARRAY_SIZE(ocores_i2c_board_info), /* table size */
};
static struct platform_device myi2c = {
.name = "ocores-i2c",
.dev = {
.platform_data = &myi2c_data,
},
.num_resources = ARRAY_SIZE(ocores_resources),
.resource = ocores_resources,
};
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
지원 OpenCores I2C IP
1-16`i2c-ocores`는 Richard Herveille가 만든 OpenCores.org I2C 컨트롤러 IP 코어용 I2C 버스 드라이버입니다. 지원 어댑터의 개요와 데이터시트는 `https://opencores.org/project/i2c/overview`에서 확인할 수 있습니다.
작성자는 Peter Korsgaard <peter@korsgaard.com>입니다.
IP 코어와 공개 자료를 구조화했습니다.
플랫폼 장치가 IP 코어의 자원과 설정을 드라이버에 전달합니다.
========================
Kernel driver i2c-ocores
========================
Supported adapters:
* OpenCores.org I2C controller by Richard Herveille (see datasheet link)
https://opencores.org/project/i2c/overview
Author: Peter Korsgaard <peter@korsgaard.com>
Description
-----------
i2c-ocores is an i2c bus driver for the OpenCores.org I2C controller
IP core by Richard Herveille.
플랫폼 장치와 보드 정보
17-27`i2c-ocores`는 플랫폼 버스를 사용하므로 기본 주소와 인터럽트 번호를 가진 `struct platform_device`를 제공해야 합니다.
장치의 `dev.platform_data`는 레지스터 간격과 입력 클록 속도를 설명하는 `struct ocores_i2c_platform_data`를 가리켜야 합니다. 정의는 `linux/platform_data/i2c-ocores.h`를 참조하십시오.
선택적으로 `i2c_board_info` 목록을 연결할 수 있으며, 드라이버는 버스를 만들 때 이 장치들을 버스에 추가합니다.
드라이버 프로브에 필요한 자원과 선택 항목입니다.
보드 코드가 제공한 정보로 I2C 버스와 하위 장치를 만듭니다.
Usage
-----
i2c-ocores uses the platform bus, so you need to provide a struct
platform_device with the base address and interrupt number. The
dev.platform_data of the device should also point to a struct
ocores_i2c_platform_data (see linux/platform_data/i2c-ocores.h) describing the
distance between registers and the input clock speed.
There is also a possibility to attach a list of i2c_board_info which
the i2c-ocores driver will add to the bus upon creation.
플랫폼 코드 예제
28-70예제의 `ocores_resources`는 `MYI2C_BASEADDR`부터 `MYI2C_BASEADDR + 8`까지의 메모리 자원과 `MYI2C_IRQ` 인터럽트 자원을 정의합니다.
선택적 `ocores_i2c_board_info`에는 주소 `0x48`의 `tsc2003` 장치가 `tsc2003_platform_data` 및 `TSC_IRQ`와 함께 들어가고, `adv7180`은 `0x42 >> 1` 주소와 `ADV_IRQ`를 사용합니다.
`myi2c_data`는 레지스터 사이가 2바이트임을 나타내는 `regstep = 2`, 50MHz 입력 클록을 나타내는 `clock_khz = 50000`, 선택적 장치 표와 `ARRAY_SIZE(ocores_i2c_board_info)` 크기를 지정합니다.
마지막으로 `myi2c` 플랫폼 장치는 이름 `ocores-i2c`, `myi2c_data` 플랫폼 데이터, `ARRAY_SIZE(ocores_resources)` 자원 수와 `ocores_resources` 자원 배열을 연결합니다.
원문 C 예제의 핵심 구조체와 값을 대응시킵니다.
예제 코드의 구조체 연결 관계를 단계로 다시 그렸습니다.
E.G. something like::
static struct resource ocores_resources[] = {
[0] = {
.start = MYI2C_BASEADDR,
.end = MYI2C_BASEADDR + 8,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MYI2C_IRQ,
.end = MYI2C_IRQ,
.flags = IORESOURCE_IRQ,
},
};
/* optional board info */
struct i2c_board_info ocores_i2c_board_info[] = {
{
I2C_BOARD_INFO("tsc2003", 0x48),
.platform_data = &tsc2003_platform_data,
.irq = TSC_IRQ
},
{
I2C_BOARD_INFO("adv7180", 0x42 >> 1),
.irq = ADV_IRQ
}
};
static struct ocores_i2c_platform_data myi2c_data = {
.regstep = 2, /* two bytes between registers */
.clock_khz = 50000, /* input clock of 50MHz */
.devices = ocores_i2c_board_info, /* optional table of devices */
.num_devices = ARRAY_SIZE(ocores_i2c_board_info), /* table size */
};
static struct platform_device myi2c = {
.name = "ocores-i2c",
.dev = {
.platform_data = &myi2c_data,
},
.num_resources = ARRAY_SIZE(ocores_resources),
.resource = ocores_resources,
};
요약·해설
i2c-ocores.rst:1-70보드 코드는 OpenCores I2C IP의 메모리·IRQ, 레지스터 간격, 입력 클록과 선택적 하위 장치 목록을 플랫폼 데이터로 전달합니다.
원문 분량과 핵심 기능을 요약합니다.
장치 인식부터 기능 제공까지의 순서입니다.