← Documents Documentation/i2c/busses/i2c-ocores.rst GitHub 원문 ↗

Linux 6.18.37 · I2C Buses

Kernel driver i2c-ocores

OpenCores I2C IP의 플랫폼 자원, 타이밍 데이터, 선택적 보드 장치 등록 예제를 설명합니다.

Source pathDocumentation/i2c/busses/i2c-ocores.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

i2c-ocores.rst:1-70

보드 코드는 OpenCores I2C IP의 메모리·IRQ, 레지스터 간격, 입력 클록과 선택적 하위 장치 목록을 플랫폼 데이터로 전달합니다.

문서 개요
항목
SourceDocumentation/i2c/busses/i2c-ocores.rst
분량70 source lines
필수 자원memory + IRQ
예제 하위 장치tsc2003 + adv7180

원문 분량과 핵심 기능을 요약합니다.

동작 흐름
플랫폼 자원 정의타이밍 데이터 작성보드 장치 목록 연결platform_device 등록I2C 버스 생성

장치 인식부터 기능 제공까지의 순서입니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ========================
2 Kernel driver i2c-ocores
3 ========================
4
5 Supported adapters:
6 * OpenCores.org I2C controller by Richard Herveille (see datasheet link)
7 https://opencores.org/project/i2c/overview
8
9 Author: Peter Korsgaard <peter@korsgaard.com>
10
11 Description
12 -----------
13
14 i2c-ocores is an i2c bus driver for the OpenCores.org I2C controller
15 IP core by Richard Herveille.
16
17 Usage
18 -----
19
20 i2c-ocores uses the platform bus, so you need to provide a struct
21 platform_device with the base address and interrupt number. The
22 dev.platform_data of the device should also point to a struct
23 ocores_i2c_platform_data (see linux/platform_data/i2c-ocores.h) describing the
24 distance between registers and the input clock speed.
25 There is also a possibility to attach a list of i2c_board_info which
26 the i2c-ocores driver will add to the bus upon creation.
27
28 E.G. something like::
29
30 static struct resource ocores_resources[] = {
31 [0] = {
32 .start = MYI2C_BASEADDR,
33 .end = MYI2C_BASEADDR + 8,
34 .flags = IORESOURCE_MEM,
35 },
36 [1] = {
37 .start = MYI2C_IRQ,
38 .end = MYI2C_IRQ,
39 .flags = IORESOURCE_IRQ,
40 },
41 };
42
43 /* optional board info */
44 struct i2c_board_info ocores_i2c_board_info[] = {
45 {
46 I2C_BOARD_INFO("tsc2003", 0x48),
47 .platform_data = &tsc2003_platform_data,
48 .irq = TSC_IRQ
49 },
50 {
51 I2C_BOARD_INFO("adv7180", 0x42 >> 1),
52 .irq = ADV_IRQ
53 }
54 };
55
56 static struct ocores_i2c_platform_data myi2c_data = {
57 .regstep = 2, /* two bytes between registers */
58 .clock_khz = 50000, /* input clock of 50MHz */
59 .devices = ocores_i2c_board_info, /* optional table of devices */
60 .num_devices = ARRAY_SIZE(ocores_i2c_board_info), /* table size */
61 };
62
63 static struct platform_device myi2c = {
64 .name = "ocores-i2c",
65 .dev = {
66 .platform_data = &myi2c_data,
67 },
68 .num_resources = ARRAY_SIZE(ocores_resources),
69 .resource = ocores_resources,
70 };
71

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>입니다.

OpenCores I2C 지원 정보
항목
컨트롤러OpenCores.org I2C controller
IP 작성자Richard Herveille
드라이버`i2c-ocores`
자료`https://opencores.org/project/i2c/overview`
드라이버 작성자Peter Korsgaard <peter@korsgaard.com>

IP 코어와 공개 자료를 구조화했습니다.

OpenCores I2C 구성
OpenCores I2C IP 인스턴스메모리와 IRQ 자원`platform_device` 등록`i2c-ocores` 프로브I2C 버스 생성

플랫폼 장치가 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` 목록을 연결할 수 있으며, 드라이버는 버스를 만들 때 이 장치들을 버스에 추가합니다.

ocores 플랫폼 데이터
구성내용
`platform_device` 자원 0기본 메모리 주소와 범위
`platform_device` 자원 1인터럽트 번호
`ocores_i2c_platform_data.regstep`레지스터 사이 거리
`ocores_i2c_platform_data.clock_khz`입력 클록 속도
`devices` / `num_devices`선택적 `i2c_board_info` 목록과 크기

드라이버 프로브에 필요한 자원과 선택 항목입니다.

ocores 플랫폼 등록
메모리 자원 지정IRQ 자원 지정레지스터 간격과 입력 클록 지정선택적 보드 장치 목록 연결플랫폼 장치 등록

보드 코드가 제공한 정보로 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` 자원 배열을 연결합니다.

ocores 예제 값
구조체·필드의미
`ocores_resources[0]``MYI2C_BASEADDR`~`+8`메모리 자원
`ocores_resources[1]``MYI2C_IRQ`IRQ 자원
`tsc2003``0x48`, `TSC_IRQ`선택적 터치 컨트롤러
`adv7180``0x42 >> 1`, `ADV_IRQ`선택적 비디오 디코더
`regstep``2`레지스터 간 2바이트
`clock_khz``50000`50MHz 입력 클록
플랫폼 장치 이름`ocores-i2c`드라이버 매칭 이름

원문 C 예제의 핵심 구조체와 값을 대응시킵니다.

ocores 예제 초기화
`ocores_resources`에 메모리·IRQ 정의`ocores_i2c_board_info`에 선택 장치 정의`myi2c_data`에 타이밍·장치 표 연결`myi2c.dev.platform_data`에 `myi2c_data` 연결`myi2c.resource`에 자원 배열 연결

예제 코드의 구조체 연결 관계를 단계로 다시 그렸습니다.

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,
  };