Documentation/driver-api/zorro.rst GitHub 원문 ↗

Linux 6.18.37 · Driver API

Writing Device Drivers for Zorro Devices

Amiga Zorro 장치 검색, resource 확보, Zorro II·III 주소 매핑을 설명하는 한국어 전문 번역입니다.

Source pathDocumentation/driver-api/zorro.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

zorro.rst:1-104

Zorro 드라이버는 `zorro_find_device()`로 Amiga Zorro II·III 장치를 순회하고, 레지스터 접근 전에 메모리 resource를 확보해야 합니다. Zorro II는 항상 매핑되어 `ZTWO_VADDR()`·`ZTWO_PADDR()`로 변환하지만 Zorro III는 `z_ioremap()`과 `z_iounmap()`을 사용합니다.

Zorro 드라이버 초기화
Find supported Zorro IDClaim register resourceConvert Zorro II or map Zorro III addressInitialize hardwareUnmap and release resources on removal

검색, 자원 확보, 주소 매핑, 장치 초기화 순서를 지킵니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ========================================
2 Writing Device Drivers for Zorro Devices
3 ========================================
4
5 :Author: Written by Geert Uytterhoeven <[email protected]>
6 :Last revised: September 5, 2003
7
8
9 Introduction
10 ------------
11
12 The Zorro bus is the bus used in the Amiga family of computers. Thanks to
13 AutoConfig(tm), it's 100% Plug-and-Play.
14
15 There are two types of Zorro buses, Zorro II and Zorro III:
16
17 - The Zorro II address space is 24-bit and lies within the first 16 MB of the
18 Amiga's address map.
19
20 - Zorro III is a 32-bit extension of Zorro II, which is backwards compatible
21 with Zorro II. The Zorro III address space lies outside the first 16 MB.
22
23
24 Probing for Zorro Devices
25 -------------------------
26
27 Zorro devices are found by calling ``zorro_find_device()``, which returns a
28 pointer to the ``next`` Zorro device with the specified Zorro ID. A probe loop
29 for the board with Zorro ID ``ZORRO_PROD_xxx`` looks like::
30
31 struct zorro_dev *z = NULL;
32
33 while ((z = zorro_find_device(ZORRO_PROD_xxx, z))) {
34 if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
35 "My explanation"))
36 ...
37 }
38
39 ``ZORRO_WILDCARD`` acts as a wildcard and finds any Zorro device. If your driver
40 supports different types of boards, you can use a construct like::
41
42 struct zorro_dev *z = NULL;
43
44 while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
45 if (z->id != ZORRO_PROD_xxx1 && z->id != ZORRO_PROD_xxx2 && ...)
46 continue;
47 if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
48 "My explanation"))
49 ...
50 }
51
52
53 Zorro Resources
54 ---------------
55
56 Before you can access a Zorro device's registers, you have to make sure it's
57 not yet in use. This is done using the I/O memory space resource management
58 functions::
59
60 request_mem_region()
61 release_mem_region()
62
63 Shortcuts to claim the whole device's address space are provided as well::
64
65 zorro_request_device
66 zorro_release_device
67
68
69 Accessing the Zorro Address Space
70 ---------------------------------
71
72 The address regions in the Zorro device resources are Zorro bus address
73 regions. Due to the identity bus-physical address mapping on the Zorro bus,
74 they are CPU physical addresses as well.
75
76 The treatment of these regions depends on the type of Zorro space:
77
78 - Zorro II address space is always mapped and does not have to be mapped
79 explicitly using z_ioremap().
80
81 Conversion from bus/physical Zorro II addresses to kernel virtual addresses
82 and vice versa is done using::
83
84 virt_addr = ZTWO_VADDR(bus_addr);
85 bus_addr = ZTWO_PADDR(virt_addr);
86
87 - Zorro III address space must be mapped explicitly using z_ioremap() first
88 before it can be accessed::
89
90 virt_addr = z_ioremap(bus_addr, size);
91 ...
92 z_iounmap(virt_addr);
93
94
95 References
96 ----------
97
98 #. linux/include/linux/zorro.h
99 #. linux/include/uapi/linux/zorro.h
100 #. linux/include/uapi/linux/zorro_ids.h
101 #. linux/arch/m68k/include/asm/zorro.h
102 #. linux/drivers/zorro
103 #. /proc/bus/zorro
104
105

3. 한국어 전문 번역

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

Zorro 버스와 AutoConfig

1-23

Geert Uytterhoeven가 작성하고 2003년 9월 5일 마지막으로 개정한 이 문서는 Amiga 컴퓨터의 Zorro 장치 드라이버 작성법을 설명합니다.

Zorro는 Amiga 계열 컴퓨터의 확장 버스이며 `AutoConfig(tm)` 덕분에 완전한 Plug-and-Play 구성을 제공합니다.

Zorro II의 주소 공간은 24비트이며 Amiga 주소 맵의 첫 16MB 안에 있습니다. Zorro III는 Zorro II와 하위 호환되는 32비트 확장으로, 주소 공간은 첫 16MB 바깥에 놓입니다.

Zorro 버스 비교
버스주소 폭주소 공간호환성
Zorro II24 bitAmiga 주소 맵의 첫 16MB기본 규격
Zorro III32 bit첫 16MB 바깥Zorro II 하위 호환

========================================
Writing Device Drivers for Zorro Devices
========================================

:Author: Written by Geert Uytterhoeven <[email protected]>
:Last revised: September 5, 2003


Introduction
------------

The Zorro bus is the bus used in the Amiga family of computers. Thanks to
AutoConfig(tm), it's 100% Plug-and-Play.

There are two types of Zorro buses, Zorro II and Zorro III:

  - The Zorro II address space is 24-bit and lies within the first 16 MB of the
    Amiga's address map.

  - Zorro III is a 32-bit extension of Zorro II, which is backwards compatible
    with Zorro II. The Zorro III address space lies outside the first 16 MB.

Zorro 장치 검색과 주소 영역 확보

24-52

`zorro_find_device()`는 지정한 Zorro ID와 일치하는 다음 장치를 찾아 `struct zorro_dev` 포인터를 반환합니다. 첫 호출에서는 이전 장치 포인터를 `NULL`로 전달하고, 이후에는 방금 반환된 장치를 다시 전달해 반복 검색합니다.

`ZORRO_PROD_xxx` 보드를 찾는 루프에서는 각 장치의 `z->resource.start + MY_START`부터 `MY_SIZE`만큼을 `zorro_request_region()`으로 확보합니다. 요청이 실패하면 해당 영역은 이미 사용 중이므로 장치 레지스터에 접근해서는 안 됩니다.

`ZORRO_WILDCARD`는 모든 Zorro 장치와 일치합니다. 여러 보드 종류를 지원하는 드라이버는 wildcard로 순회한 뒤 `z->id`를 지원 목록과 비교하고, 일치하는 장치의 영역만 요청할 수 있습니다.

Zorro probe 반복
Start with `struct zorro_dev *z = NULL`Call `zorro_find_device()` with product ID or wildcardFilter `z->id` when several products are supportedClaim `resource.start + MY_START` using `zorro_request_region()`Initialize only successfully claimed devices

반환된 장치를 다음 검색의 시작점으로 넘기고, 지원하는 장치의 필요한 하위 영역을 독점합니다.

Probing for Zorro Devices
-------------------------

Zorro devices are found by calling ``zorro_find_device()``, which returns a
pointer to the ``next`` Zorro device with the specified Zorro ID. A probe loop
for the board with Zorro ID ``ZORRO_PROD_xxx`` looks like::

    struct zorro_dev *z = NULL;

    while ((z = zorro_find_device(ZORRO_PROD_xxx, z))) {
        if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
                                  "My explanation"))
        ...
    }

``ZORRO_WILDCARD`` acts as a wildcard and finds any Zorro device. If your driver
supports different types of boards, you can use a construct like::

    struct zorro_dev *z = NULL;

    while ((z = zorro_find_device(ZORRO_WILDCARD, z))) {
        if (z->id != ZORRO_PROD_xxx1 && z->id != ZORRO_PROD_xxx2 && ...)
            continue;
        if (!zorro_request_region(z->resource.start+MY_START, MY_SIZE,
                                  "My explanation"))
        ...
    }

Zorro I/O 메모리 자원 관리

53-68

Zorro 장치 레지스터에 접근하기 전에 다른 드라이버가 이미 사용 중인지 확인하고 주소 영역을 독점해야 합니다. 일반 I/O 메모리 자원 관리 함수인 `request_mem_region()`과 `release_mem_region()`을 사용합니다.

장치 주소 공간 전체를 확보하거나 반환할 때는 Zorro 전용 단축 함수 `zorro_request_device`와 `zorro_release_device`를 사용할 수 있습니다.

Zorro 자원 API
범위확보반환
장치의 일부 메모리 영역`request_mem_region()` 또는 `zorro_request_region()``release_mem_region()`
장치 주소 공간 전체`zorro_request_device``zorro_release_device`

Zorro Resources
---------------

Before you can access a Zorro device's registers, you have to make sure it's
not yet in use. This is done using the I/O memory space resource management
functions::

    request_mem_region()
    release_mem_region()

Shortcuts to claim the whole device's address space are provided as well::

    zorro_request_device
    zorro_release_device

Zorro II·III 주소 공간 매핑

69-94

`struct zorro_dev`의 resource가 나타내는 주소 영역은 Zorro 버스 주소입니다. Zorro 버스는 버스 주소와 물리 주소가 동일하게 매핑되므로 이 값은 CPU 물리 주소이기도 합니다.

Zorro II 주소 공간은 항상 매핑되어 있어 `z_ioremap()`을 별도로 호출할 필요가 없습니다. 버스·물리 주소에서 커널 가상 주소로 바꿀 때 `ZTWO_VADDR(bus_addr)`, 반대 변환에는 `ZTWO_PADDR(virt_addr)`를 사용합니다.

Zorro III 주소 공간은 접근 전에 `z_ioremap(bus_addr, size)`로 명시적으로 매핑해야 합니다. 사용이 끝나면 `z_iounmap(virt_addr)`으로 매핑을 해제합니다.

Zorro 주소 접근 방식
공간매핑변환·해제
Zorro II항상 매핑됨`ZTWO_VADDR()` / `ZTWO_PADDR()`
Zorro III`z_ioremap()` 필요`z_iounmap()`으로 해제

Accessing the Zorro Address Space
---------------------------------

The address regions in the Zorro device resources are Zorro bus address
regions. Due to the identity bus-physical address mapping on the Zorro bus,
they are CPU physical addresses as well.

The treatment of these regions depends on the type of Zorro space:

  - Zorro II address space is always mapped and does not have to be mapped
    explicitly using z_ioremap().

    Conversion from bus/physical Zorro II addresses to kernel virtual addresses
    and vice versa is done using::

        virt_addr = ZTWO_VADDR(bus_addr);
        bus_addr = ZTWO_PADDR(virt_addr);

  - Zorro III address space must be mapped explicitly using z_ioremap() first
    before it can be accessed::

        virt_addr = z_ioremap(bus_addr, size);
        ...
        z_iounmap(virt_addr);

Zorro 헤더·구현·런타임 참조

95-104

Zorro 드라이버의 API와 ID 정의는 `linux/include/linux/zorro.h`, `linux/include/uapi/linux/zorro.h`, `linux/include/uapi/linux/zorro_ids.h`에서 확인합니다.

m68k 아키텍처별 매핑 정의는 `linux/arch/m68k/include/asm/zorro.h`, 드라이버 구현은 `linux/drivers/zorro`, 런타임 장치 정보는 `/proc/bus/zorro`에 있습니다.

Zorro 참조 위치
경로내용
`linux/include/linux/zorro.h`커널 Zorro API
`linux/include/uapi/linux/zorro*.h`사용자 ABI와 장치 ID
`linux/arch/m68k/include/asm/zorro.h`m68k 주소 변환
`linux/drivers/zorro`Zorro 구현
`/proc/bus/zorro`발견된 장치 정보

References
----------

#. linux/include/linux/zorro.h
#. linux/include/uapi/linux/zorro.h
#. linux/include/uapi/linux/zorro_ids.h
#. linux/arch/m68k/include/asm/zorro.h
#. linux/drivers/zorro
#. /proc/bus/zorro