요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
===============================================
Ingenic JZ47xx SoCs Timer/Counter Unit hardware
===============================================
The Timer/Counter Unit (TCU) in Ingenic JZ47xx SoCs is a multi-function
hardware block. It features up to eight channels, that can be used as
counters, timers, or PWM.
- JZ4725B, JZ4750, JZ4755 only have six TCU channels. The other SoCs all
have eight channels.
- JZ4725B introduced a separate channel, called Operating System Timer
(OST). It is a 32-bit programmable timer. On JZ4760B and above, it is
64-bit.
- Each one of the TCU channels has its own clock, which can be reparented to three
different clocks (pclk, ext, rtc), gated, and reclocked, through their TCSR register.
- The watchdog and OST hardware blocks also feature a TCSR register with the same
format in their register space.
- The TCU registers used to gate/ungate can also gate/ungate the watchdog and
OST clocks.
- Each TCU channel works in one of two modes:
- mode TCU1: channels cannot work in sleep mode, but are easier to
operate.
- mode TCU2: channels can work in sleep mode, but the operation is a bit
more complicated than with TCU1 channels.
- The mode of each TCU channel depends on the SoC used:
- On the oldest SoCs (up to JZ4740), all of the eight channels operate in
TCU1 mode.
- On JZ4725B, channel 5 operates as TCU2, the others operate as TCU1.
- On newest SoCs (JZ4750 and above), channels 1-2 operate as TCU2, the
others operate as TCU1.
- Each channel can generate an interrupt. Some channels share an interrupt
line, some don't, and this changes between SoC versions:
- on older SoCs (JZ4740 and below), channel 0 and channel 1 have their
own interrupt line; channels 2-7 share the last interrupt line.
- On JZ4725B, channel 0 has its own interrupt; channels 1-5 share one
interrupt line; the OST uses the last interrupt line.
- on newer SoCs (JZ4750 and above), channel 5 has its own interrupt;
channels 0-4 and (if eight channels) 6-7 all share one interrupt line;
the OST uses the last interrupt line.
Implementation
==============
The functionalities of the TCU hardware are spread across multiple drivers:
=========== =====
clocks drivers/clk/ingenic/tcu.c
interrupts drivers/irqchip/irq-ingenic-tcu.c
timers drivers/clocksource/ingenic-timer.c
OST drivers/clocksource/ingenic-ost.c
PWM drivers/pwm/pwm-jz4740.c
watchdog drivers/watchdog/jz4740_wdt.c
=========== =====
Because various functionalities of the TCU that belong to different drivers
and frameworks can be controlled from the same registers, all of these
drivers access their registers through the same regmap.
For more information regarding the devicetree bindings of the TCU drivers,
have a look at Documentation/devicetree/bindings/timer/ingenic,tcu.yaml.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
TCU hardware와 clock
1-24GPL-2.0 문서입니다. Ingenic JZ47xx SoC의 Timer/Counter Unit은 counter, timer, PWM으로 쓸 수 있는 최대 8-channel multi-function block입니다.
| SoC/Block | Channel 또는 timer 특성 |
|---|---|
| JZ4725B, JZ4750, JZ4755 | TCU channel 6개 |
| 기타 JZ47xx | TCU channel 8개 |
| JZ4725B OST | 별도 32-bit programmable Operating System Timer |
| JZ4760B 이상 OST | 64-bit programmable timer |
각 TCU channel은 독립 clock과 `TCSR` register를 가지며 parent를 `pclk`, `ext`, `rtc` 중 하나로 바꾸고 gate/reclock할 수 있습니다. Watchdog와 OST도 같은 format의 `TCSR`를 자기 register space에 갖고, TCU gate/ungate register는 watchdog과 OST clock도 제어합니다.
TCU1/TCU2 mode와 interrupt
25-50| SoC | TCU mode 배치 |
|---|---|
| JZ4740 이하 | 8개 channel 모두 TCU1 |
| JZ4725B | Channel 5는 TCU2, 나머지는 TCU1 |
| JZ4750 이상 | Channel 1-2는 TCU2, 나머지는 TCU1 |
TCU1 channel은 sleep mode에서 동작하지 않지만 조작이 쉽습니다. TCU2 channel은 sleep 중에도 동작하는 대신 operation이 더 복잡합니다.
| SoC | 독립 IRQ | 공유 IRQ | OST IRQ |
|---|---|---|---|
| JZ4740 이하 | Channel 0, 1 각각 | Channel 2-7 | 해당 없음 |
| JZ4725B | Channel 0 | Channel 1-5 | 마지막 line |
| JZ4750 이상 | Channel 5 | Channel 0-4와 8-channel SoC의 6-7 | 마지막 line |
Linux driver 분할과 shared regmap
51-71TCU 기능은 Linux framework별 여러 driver에 나뉩니다.
| 기능 | Source path |
|---|---|
| `clocks` | `drivers/clk/ingenic/tcu.c` |
| `interrupts` | `drivers/irqchip/irq-ingenic-tcu.c` |
| `timers` | `drivers/clocksource/ingenic-timer.c` |
| `OST` | `drivers/clocksource/ingenic-ost.c` |
| `PWM` | `drivers/pwm/pwm-jz4740.c` |
| `watchdog` | `drivers/watchdog/jz4740_wdt.c` |
서로 다른 driver와 framework의 기능이 같은 register에서 제어되므로 모든 driver는 동일한 `regmap`을 통해 접근합니다.
Devicetree binding은 `Documentation/devicetree/bindings/timer/ingenic,tcu.yaml`을 참조합니다.
요약과 해설
ingenic-tcu.rst:1-71TCU는 clock, interrupt, clocksource, PWM, watchdog framework가 같은 register block을 공유하는 multi-function device입니다. SoC generation마다 channel 수, TCU1/TCU2 mode와 IRQ sharing이 달라 driver가 variant data를 정확히 적용해야 합니다.
동일 regmap을 여러 Linux subsystem driver가 공유합니다.
SoC 세대별 mode와 독립 IRQ가 다릅니다.