요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
*ST pin controller.
Each multi-function pin is controlled, driven and routed through the
PIO multiplexing block. Each pin supports GPIO functionality (ALT0)
and multiple alternate functions(ALT1 - ALTx) that directly connect
the pin to different hardware blocks.
When a pin is in GPIO mode, Output Enable (OE), Open Drain(OD), and
Pull Up (PU) are driven by the related PIO block.
ST pinctrl driver controls PIO multiplexing block and also interacts with
gpio driver to configure a pin.
GPIO bank can have one of the two possible types of interrupt-wirings.
First type is via irqmux, single interrupt is used by multiple gpio banks. This
reduces number of overall interrupts numbers required. All these banks belong to
a single pincontroller.
_________
| |----> [gpio-bank (n) ]
| |----> [gpio-bank (n + 1)]
[irqN]-- | irq-mux |----> [gpio-bank (n + 2)]
| |----> [gpio-bank (... )]
|_________|----> [gpio-bank (n + 7)]
Second type has a dedicated interrupt per gpio bank.
[irqN]----> [gpio-bank (n)]
Pin controller node:
Required properties:
- compatible : should be "st,stih407-<pio-block>-pinctrl"
- st,syscfg : Should be a phandle of the syscfg node.
- st,retime-pin-mask : Should be mask to specify which pins can be retimed.
If the property is not present, it is assumed that all the pins in the
bank are capable of retiming. Retiming is mainly used to improve the
IO timing margins of external synchronous interfaces.
- ranges : defines mapping between pin controller node (parent) to gpio-bank
node (children).
Optional properties:
- interrupts : Interrupt number of the irqmux. If the interrupt is shared
with other gpio banks via irqmux.
a irqline and gpio banks.
- reg : irqmux memory resource. If irqmux is present.
- reg-names : irqmux resource should be named as "irqmux".
GPIO controller/bank node.
Required properties:
- gpio-controller : Indicates this device is a GPIO controller
- #gpio-cells : Must be two.
- First cell: specifies the pin number inside the controller
- Second cell: specifies whether the pin is logically inverted.
- 0 = active high
- 1 = active low
- st,bank-name : Should be a name string for this bank as specified in
datasheet.
Optional properties:
- interrupts : Interrupt number for this gpio bank. If there is a dedicated
interrupt wired up for this gpio bank.
- interrupt-controller : Indicates this device is a interrupt controller. GPIO
bank can be an interrupt controller iff one of the interrupt type either via
irqmux or a dedicated interrupt per bank is specified.
- #interrupt-cells: the value of this property should be 2.
- First Cell: represents the external gpio interrupt number local to the
gpio interrupt space of the controller.
- Second Cell: flags to identify the type of the interrupt
- 1 = rising edge triggered
- 2 = falling edge triggered
- 3 = rising and falling edge triggered
- 4 = high level triggered
- 8 = low level triggered
for related macros look in:
include/dt-bindings/interrupt-controller/irq.h
Example:
pin-controller-sbc {
#address-cells = <1>;
#size-cells = <1>;
compatible = "st,stih407-sbc-pinctrl";
st,syscfg = <&syscfg_sbc>;
reg = <0x0961f080 0x4>;
reg-names = "irqmux";
interrupts = <GIC_SPI 188 IRQ_TYPE_NONE>;
interrupt-names = "irqmux";
ranges = <0 0x09610000 0x6000>;
pio0: gpio@9610000 {
gpio-controller;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
reg = <0x0 0x100>;
st,bank-name = "PIO0";
};
...
pin-functions nodes follow...
};
Contents of function subnode node:
----------------------
Required properties for pin configuration node:
- st,pins : Child node with list of pins with configuration.
Below is the format of how each pin conf should look like.
<bank offset mux mode rt_type rt_delay rt_clk>
Every PIO is represented with 4-7 parameters depending on retime configuration.
Each parameter is explained as below.
-bank : Should be bank phandle to which this PIO belongs.
-offset : Offset in the PIO bank.
-mux : Should be alternate function number associated this pin.
Use same numbers from datasheet.
-mode :pin configuration is selected from one of the below values.
IN
IN_PU
OUT
BIDIR
BIDIR_PU
-rt_type Retiming Configuration for the pin.
Possible retime configuration are:
------- -------------
value args
------- -------------
NICLK <delay> <clk>
ICLK_IO <delay> <clk>
BYPASS <delay>
DE_IO <delay> <clk>
SE_ICLK_IO <delay> <clk>
SE_NICLK_IO <delay> <clk>
- delay is retime delay in pico seconds as mentioned in data sheet.
- rt_clk :clk to be use for retime.
Possible values are:
CLK_A
CLK_B
CLK_C
CLK_D
Example of mmcclk pin which is a bi-direction pull pu with retime config
as non inverted clock retimed with CLK_B and delay of 0 pico seconds:
pin-controller {
...
mmc0 {
pinctrl_mmc: mmc {
st,pins {
mmcclk = <&PIO13 4 ALT4 BIDIR_PU NICLK 0 CLK_B>;
...
};
};
...
};
};
sdhci0:sdhci@fe810000{
...
interrupt-parent = <&pio3>;
#interrupt-cells = <2>;
interrupts = <3 IRQ_TYPE_LEVEL_HIGH>; /* Interrupt line via PIO3-3 */
interrupt-names = "card-detect";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mmc>;
};
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
ST PIO multiplexing
1-13각 multi-function pin은 PIO multiplexing block을 통해 제어·drive·route됩니다. 모든 pin은 GPIO function ALT0과 hardware block에 직접 연결되는 alternate function ALT1부터 ALTx를 지원합니다.
GPIO mode에서는 관련 PIO block이 Output Enable(OE), Open Drain(OD), Pull Up(PU)을 drive합니다. ST pinctrl driver는 PIO mux block을 제어하고 GPIO driver와 협력해 pin을 구성합니다.
GPIO bank interrupt wiring
14-30첫 번째 방식은 하나의 irqmux interrupt를 여러 GPIO bank가 공유해 전체 interrupt 수를 줄입니다. 이 bank들은 모두 하나의 pin controller에 속합니다.
irqN 하나가 irq-mux를 거쳐 최대 여러 GPIO bank로 fan-out됩니다.
두 번째 방식은 각 GPIO bank마다 dedicated interrupt 하나를 직접 연결합니다.
irqN이 GPIO bank n에 직접 연결됩니다.
Pin controller node 속성
31-48필수 `compatible` 형식은 `st,stih407-<pio-block>-pinctrl`이고, `st,syscfg`는 syscfg node phandle입니다. `st,retime-pin-mask`는 retime 가능한 pin mask이며 없으면 bank의 모든 pin이 가능하다고 봅니다. Retiming은 external synchronous interface의 I/O timing margin을 개선하는 데 주로 사용합니다. `ranges`는 parent controller와 child GPIO bank mapping입니다.
선택적 `interrupts`는 여러 bank가 irqmux로 공유하는 interrupt 번호입니다. `reg`는 irqmux memory resource이고 `reg-names`는 `irqmux`여야 합니다.
GPIO bank와 interrupt controller
49-79GPIO bank에는 `gpio-controller`, 값이 2인 `#gpio-cells`, datasheet의 bank 이름인 `st,bank-name`이 필요합니다. 첫 GPIO cell은 controller 내부 pin 번호이고 두 번째 cell은 logical inversion으로 0은 active high, 1은 active low입니다.
Dedicated bank IRQ가 있으면 `interrupts`를 지정합니다. `interrupt-controller`는 bank를 interrupt controller로 표시하며 irqmux 또는 dedicated IRQ 중 하나가 있어야 합니다. `#interrupt-cells`는 2이고 첫 cell은 local GPIO interrupt 번호, 두 번째 cell은 trigger flag입니다.
| Flag | Interrupt type |
|---|---|
| 1 | Rising edge triggered |
| 2 | Falling edge triggered |
| 3 | Rising and falling edge triggered |
| 4 | High level triggered |
| 8 | Low level triggered |
관련 macro는 `include/dt-bindings/interrupt-controller/irq.h`를 참조합니다.
Controller와 GPIO bank 예제
80-104STiH407 SBC pin controller의 irqmux resource와 interrupt, address range를 선언하고 PIO0을 GPIO·interrupt controller로 구성하는 예제입니다.
pin-controller-sbc {
#address-cells = <1>;
#size-cells = <1>;
compatible = "st,stih407-sbc-pinctrl";
st,syscfg = <&syscfg_sbc>;
reg = <0x0961f080 0x4>;
reg-names = "irqmux";
interrupts = <GIC_SPI 188 IRQ_TYPE_NONE>;
interrupt-names = "irqmux";
ranges = <0 0x09610000 0x6000>;
pio0: gpio@9610000 {
gpio-controller;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
reg = <0x0 0x100>;
st,bank-name = "PIO0";
};
...
pin-functions nodes follow...
};
Function subnode와 pin parameter
105-127Pin configuration node의 필수 `st,pins` child는 구성할 pin 목록을 담습니다. 각 PIO는 retime configuration에 따라 `<bank offset mux mode rt_type rt_delay rt_clk>`의 4개부터 7개 parameter로 표현됩니다.
`bank`는 PIO가 속한 bank phandle, `offset`은 bank 내부 offset, `mux`는 datasheet의 alternate function 번호, `mode`는 아래 pin mode 중 하나입니다.
| Mode | Meaning |
|---|---|
| IN | Input |
| IN_PU | Input with pull-up |
| OUT | Output |
| BIDIR | Bidirectional |
| BIDIR_PU | Bidirectional with pull-up |
Retiming type·delay·clock
128-149`rt_type`은 pin retiming configuration이고 각 값이 요구하는 argument는 아래와 같습니다. `delay`는 datasheet에 명시된 picosecond 단위 retime delay입니다.
| rt_type | Arguments |
|---|---|
| NICLK | <delay> <clk> |
| ICLK_IO | <delay> <clk> |
| BYPASS | <delay> |
| DE_IO | <delay> <clk> |
| SE_ICLK_IO | <delay> <clk> |
| SE_NICLK_IO | <delay> <clk> |
`rt_clk`는 retime에 사용할 clock이며 가능한 값은 다음 네 개입니다.
| Clock |
|---|
| CLK_A |
| CLK_B |
| CLK_C |
| CLK_D |
MMC clock pin retiming 예제
150-165MMC clock pin을 bidirectional pull-up으로 설정하고, non-inverted clock retiming `NICLK`, `CLK_B`, delay 0 ps를 적용하는 예제입니다.
pin-controller {
...
mmc0 {
pinctrl_mmc: mmc {
st,pins {
mmcclk = <&PIO13 4 ALT4 BIDIR_PU NICLK 0 CLK_B>;
...
};
};
...
};
};
SDHCI card-detect 예제
166-174SDHCI0가 PIO3-3을 level-high card-detect interrupt로 사용하고 `pinctrl_mmc`를 default pinctrl state로 참조합니다.
sdhci0:sdhci@fe810000{
...
interrupt-parent = <&pio3>;
#interrupt-cells = <2>;
interrupts = <3 IRQ_TYPE_LEVEL_HIGH>; /* Interrupt line via PIO3-3 */
interrupt-names = "card-detect";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mmc>;
};
요약과 해설
pinctrl-st.txt:1-174공유 irqmux·bank 전용 IRQ 구조와 4~7개 pin parameter, retime type을 시각화합니다.