요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
==============================================
MFP Configuration for PXA2xx/PXA3xx Processors
==============================================
Eric Miao <eric.miao@marvell.com>
MFP stands for Multi-Function Pin, which is the pin-mux logic on PXA3xx and
later PXA series processors. This document describes the existing MFP API,
and how board/platform driver authors could make use of it.
Basic Concept
=============
Unlike the GPIO alternate function settings on PXA25x and PXA27x, a new MFP
mechanism is introduced from PXA3xx to completely move the pin-mux functions
out of the GPIO controller. In addition to pin-mux configurations, the MFP
also controls the low power state, driving strength, pull-up/down and event
detection of each pin. Below is a diagram of internal connections between
the MFP logic and the remaining SoC peripherals::
+--------+
| |--(GPIO19)--+
| GPIO | |
| |--(GPIO...) |
+--------+ |
| +---------+
+--------+ +------>| |
| PWM2 |--(PWM_OUT)-------->| MFP |
+--------+ +------>| |-------> to external PAD
| +---->| |
+--------+ | | +-->| |
| SSP2 |---(TXD)----+ | | +---------+
+--------+ | |
| |
+--------+ | |
| Keypad |--(MKOUT4)----+ |
+--------+ |
|
+--------+ |
| UART2 |---(TXD)--------+
+--------+
NOTE: the external pad is named as MFP_PIN_GPIO19, it doesn't necessarily
mean it's dedicated for GPIO19, only as a hint that internally this pin
can be routed from GPIO19 of the GPIO controller.
To better understand the change from PXA25x/PXA27x GPIO alternate function
to this new MFP mechanism, here are several key points:
1. GPIO controller on PXA3xx is now a dedicated controller, same as other
internal controllers like PWM, SSP and UART, with 128 internal signals
which can be routed to external through one or more MFPs (e.g. GPIO<0>
can be routed through either MFP_PIN_GPIO0 as well as MFP_PIN_GPIO0_2,
see arch/arm/mach-pxa/mfp-pxa300.h)
2. Alternate function configuration is removed from this GPIO controller,
the remaining functions are pure GPIO-specific, i.e.
- GPIO signal level control
- GPIO direction control
- GPIO level change detection
3. Low power state for each pin is now controlled by MFP, this means the
PGSRx registers on PXA2xx are now useless on PXA3xx
4. Wakeup detection is now controlled by MFP, PWER does not control the
wakeup from GPIO(s) any more, depending on the sleeping state, ADxER
(as defined in pxa3xx-regs.h) controls the wakeup from MFP
NOTE: with such a clear separation of MFP and GPIO, by GPIO<xx> we normally
mean it is a GPIO signal, and by MFP<xxx> or pin xxx, we mean a physical
pad (or ball).
MFP API Usage
=============
For board code writers, here are some guidelines:
1. include ONE of the following header files in your <board>.c:
- #include "mfp-pxa25x.h"
- #include "mfp-pxa27x.h"
- #include "mfp-pxa300.h"
- #include "mfp-pxa320.h"
- #include "mfp-pxa930.h"
NOTE: only one file in your <board>.c, depending on the processors used,
because pin configuration definitions may conflict in these file (i.e.
same name, different meaning and settings on different processors). E.g.
for zylonite platform, which support both PXA300/PXA310 and PXA320, two
separate files are introduced: zylonite_pxa300.c and zylonite_pxa320.c
(in addition to handle MFP configuration differences, they also handle
the other differences between the two combinations).
NOTE: PXA300 and PXA310 are almost identical in pin configurations (with
PXA310 supporting some additional ones), thus the difference is actually
covered in a single mfp-pxa300.h.
2. prepare an array for the initial pin configurations, e.g.::
static unsigned long mainstone_pin_config[] __initdata = {
/* Chip Select */
GPIO15_nCS_1,
/* LCD - 16bpp Active TFT */
GPIOxx_TFT_LCD_16BPP,
GPIO16_PWM0_OUT, /* Backlight */
/* MMC */
GPIO32_MMC_CLK,
GPIO112_MMC_CMD,
GPIO92_MMC_DAT_0,
GPIO109_MMC_DAT_1,
GPIO110_MMC_DAT_2,
GPIO111_MMC_DAT_3,
...
/* GPIO */
GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
};
a) once the pin configurations are passed to pxa{2xx,3xx}_mfp_config(),
and written to the actual registers, they are useless and may discard,
adding '__initdata' will help save some additional bytes here.
b) when there is only one possible pin configurations for a component,
some simplified definitions can be used, e.g. GPIOxx_TFT_LCD_16BPP on
PXA25x and PXA27x processors
c) if by board design, a pin can be configured to wake up the system
from low power state, it can be 'OR'ed with any of:
WAKEUP_ON_EDGE_BOTH
WAKEUP_ON_EDGE_RISE
WAKEUP_ON_EDGE_FALL
WAKEUP_ON_LEVEL_HIGH - specifically for enabling of keypad GPIOs,
to indicate that this pin has the capability of wake-up the system,
and on which edge(s). This, however, doesn't necessarily mean the
pin _will_ wakeup the system, it will only when set_irq_wake() is
invoked with the corresponding GPIO IRQ (GPIO_IRQ(xx) or gpio_to_irq())
and eventually calls gpio_set_wake() for the actual register setting.
d) although PXA3xx MFP supports edge detection on each pin, the
internal logic will only wakeup the system when those specific bits
in ADxER registers are set, which can be well mapped to the
corresponding peripheral, thus set_irq_wake() can be called with
the peripheral IRQ to enable the wakeup.
MFP on PXA3xx
=============
Every external I/O pad on PXA3xx (excluding those for special purpose) has
one MFP logic associated, and is controlled by one MFP register (MFPR).
The MFPR has the following bit definitions (for PXA300/PXA310/PXA320)::
31 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+-------------------------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| RESERVED |PS|PU|PD| DRIVE |SS|SD|SO|EC|EF|ER|--| AF_SEL |
+-------------------------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Bit 3: RESERVED
Bit 4: EDGE_RISE_EN - enable detection of rising edge on this pin
Bit 5: EDGE_FALL_EN - enable detection of falling edge on this pin
Bit 6: EDGE_CLEAR - disable edge detection on this pin
Bit 7: SLEEP_OE_N - enable outputs during low power modes
Bit 8: SLEEP_DATA - output data on the pin during low power modes
Bit 9: SLEEP_SEL - selection control for low power modes signals
Bit 13: PULLDOWN_EN - enable the internal pull-down resistor on this pin
Bit 14: PULLUP_EN - enable the internal pull-up resistor on this pin
Bit 15: PULL_SEL - pull state controlled by selected alternate function
(0) or by PULL{UP,DOWN}_EN bits (1)
Bit 0 - 2: AF_SEL - alternate function selection, 8 possibilities, from 0-7
Bit 10-12: DRIVE - drive strength and slew rate
0b000 - fast 1mA
0b001 - fast 2mA
0b002 - fast 3mA
0b003 - fast 4mA
0b004 - slow 6mA
0b005 - fast 6mA
0b006 - slow 10mA
0b007 - fast 10mA
MFP Design for PXA2xx/PXA3xx
============================
Due to the difference of pin-mux handling between PXA2xx and PXA3xx, a unified
MFP API is introduced to cover both series of processors.
The basic idea of this design is to introduce definitions for all possible pin
configurations, these definitions are processor and platform independent, and
the actual API invoked to convert these definitions into register settings and
make them effective there-after.
Files Involved
--------------
- arch/arm/mach-pxa/include/mach/mfp.h
for
1. Unified pin definitions - enum constants for all configurable pins
2. processor-neutral bit definitions for a possible MFP configuration
- arch/arm/mach-pxa/mfp-pxa3xx.h
for PXA3xx specific MFPR register bit definitions and PXA3xx common pin
configurations
- arch/arm/mach-pxa/mfp-pxa2xx.h
for PXA2xx specific definitions and PXA25x/PXA27x common pin configurations
- arch/arm/mach-pxa/mfp-pxa25x.h
arch/arm/mach-pxa/mfp-pxa27x.h
arch/arm/mach-pxa/mfp-pxa300.h
arch/arm/mach-pxa/mfp-pxa320.h
arch/arm/mach-pxa/mfp-pxa930.h
for processor specific definitions
- arch/arm/mach-pxa/mfp-pxa3xx.c
- arch/arm/mach-pxa/mfp-pxa2xx.c
for implementation of the pin configuration to take effect for the actual
processor.
Pin Configuration
-----------------
The following comments are copied from mfp.h (see the actual source code
for most updated info)::
/*
* a possible MFP configuration is represented by a 32-bit integer
*
* bit 0.. 9 - MFP Pin Number (1024 Pins Maximum)
* bit 10..12 - Alternate Function Selection
* bit 13..15 - Drive Strength
* bit 16..18 - Low Power Mode State
* bit 19..20 - Low Power Mode Edge Detection
* bit 21..22 - Run Mode Pull State
*
* to facilitate the definition, the following macros are provided
*
* MFP_CFG_DEFAULT - default MFP configuration value, with
* alternate function = 0,
* drive strength = fast 3mA (MFP_DS03X)
* low power mode = default
* edge detection = none
*
* MFP_CFG - default MFPR value with alternate function
* MFP_CFG_DRV - default MFPR value with alternate function and
* pin drive strength
* MFP_CFG_LPM - default MFPR value with alternate function and
* low power mode
* MFP_CFG_X - default MFPR value with alternate function,
* pin drive strength and low power mode
*/
Examples of pin configurations are::
#define GPIO94_SSP3_RXD MFP_CFG_X(GPIO94, AF1, DS08X, FLOAT)
which reads GPIO94 can be configured as SSP3_RXD, with alternate function
selection of 1, driving strength of 0b101, and a float state in low power
modes.
NOTE: this is the default setting of this pin being configured as SSP3_RXD
which can be modified a bit in board code, though it is not recommended to
do so, simply because this default setting is usually carefully encoded,
and is supposed to work in most cases.
Register Settings
-----------------
Register settings on PXA3xx for a pin configuration is actually very
straight-forward, most bits can be converted directly into MFPR value
in a easier way. Two sets of MFPR values are calculated: the run-time
ones and the low power mode ones, to allow different settings.
The conversion from a generic pin configuration to the actual register
settings on PXA2xx is a bit complicated: many registers are involved,
including GAFRx, GPDRx, PGSRx, PWER, PKWR, PFER and PRER. Please see
mfp-pxa2xx.c for how the conversion is made.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
PXA2xx/PXA3xx 프로세서의 MFP 구성
1-10저자는 Eric Miao `<eric.miao@marvell.com>`입니다.
MFP는 Multi-Function Pin의 약자로 PXA3xx와 이후 PXA 계열 프로세서의 pin-mux logic을 뜻합니다. 이 문서는 기존 MFP API와 board/platform 드라이버 작성자가 이를 사용하는 방법을 설명합니다.
기본 개념
11-73PXA25x와 PXA27x의 GPIO alternate-function 설정과 달리 PXA3xx부터는 새 MFP 메커니즘이 pin-mux 기능을 GPIO controller 밖으로 완전히 분리합니다. MFP는 pin-mux뿐 아니라 각 pin의 low-power state, drive strength, pull-up/down, event detection도 제어합니다.
GPIO19, PWM2, SSP2, Keypad, UART2의 내부 신호 가운데 선택된 하나가 MFP를 거쳐 동일한 외부 PAD로 라우팅됩니다.
외부 pad 이름이 `MFP_PIN_GPIO19`라고 해서 GPIO19 전용이라는 뜻은 아닙니다. GPIO controller의 GPIO19를 내부적으로 이 pin에 라우팅할 수 있다는 힌트일 뿐입니다.
PXA25x/PXA27x의 GPIO alternate function에서 새 MFP 방식으로 바뀐 핵심은 다음과 같습니다.
- PXA3xx의 GPIO controller는 PWM, SSP, UART 같은 다른 내부 controller와 동등한 전용 controller가 되었습니다. 128개 내부 신호는 하나 이상의 MFP를 거쳐 외부로 라우팅할 수 있습니다. 예를 들어 `GPIO<0>`은 `MFP_PIN_GPIO0` 또는 `MFP_PIN_GPIO0_2`로 라우팅할 수 있으며 `arch/arm/mach-pxa/mfp-pxa300.h`를 참조합니다.
- alternate-function 구성은 GPIO controller에서 제거되었습니다. 남은 기능은 GPIO signal level 제어, GPIO direction 제어, GPIO level-change detection처럼 순수 GPIO 기능입니다.
- 각 pin의 low-power state는 MFP가 제어하므로 PXA2xx의 `PGSRx` register는 PXA3xx에서 쓸모가 없습니다.
- wakeup detection도 MFP가 제어합니다. `PWER`는 더 이상 GPIO wakeup을 제어하지 않으며, sleep state에 따라 `pxa3xx-regs.h`에 정의된 `ADxER`가 MFP wakeup을 제어합니다.
MFP와 GPIO가 명확히 분리되므로 `GPIO<xx>`는 일반적으로 GPIO signal을, `MFP<xxx>` 또는 pin xxx는 물리 pad나 ball을 뜻합니다.
MFP API 사용법
74-151board code 작성자는 `<board>.c`에서 사용하는 processor에 맞춰 다음 header 중 하나만 include해야 합니다.
- `#include "mfp-pxa25x.h"`
- `#include "mfp-pxa27x.h"`
- `#include "mfp-pxa300.h"`
- `#include "mfp-pxa320.h"`
- `#include "mfp-pxa930.h"`
processor마다 같은 이름이 서로 다른 의미와 설정을 가질 수 있어 pin configuration 정의가 충돌하므로 `<board>.c`에는 하나만 포함해야 합니다. PXA300/PXA310과 PXA320을 모두 지원하는 zylonite는 `zylonite_pxa300.c`와 `zylonite_pxa320.c`로 나누어 MFP와 그 밖의 조합별 차이를 처리합니다.
PXA300과 PXA310의 pin configuration은 거의 같고 PXA310에 일부 설정이 추가된 정도이므로 두 processor의 차이는 하나의 `mfp-pxa300.h`가 다룹니다.
초기 pin configuration 배열은 다음과 같이 준비합니다.
static unsigned long mainstone_pin_config[] __initdata = {
/* Chip Select */
GPIO15_nCS_1,
/* LCD - 16bpp Active TFT */
GPIOxx_TFT_LCD_16BPP,
GPIO16_PWM0_OUT, /* Backlight */
/* MMC */
GPIO32_MMC_CLK,
GPIO112_MMC_CMD,
GPIO92_MMC_DAT_0,
GPIO109_MMC_DAT_1,
GPIO110_MMC_DAT_2,
GPIO111_MMC_DAT_3,
...
/* GPIO */
GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
};
- pin configuration을 `pxa{2xx,3xx}_mfp_config()`에 전달해 실제 register에 기록하면 배열은 더 이상 필요하지 않습니다. `__initdata`를 붙이면 초기화 후 버려져 몇 byte를 더 절약할 수 있습니다.
- 한 component에 가능한 pin configuration이 하나뿐이면 PXA25x/PXA27x의 `GPIOxx_TFT_LCD_16BPP`처럼 단순화한 정의를 사용할 수 있습니다.
- board 설계상 어떤 pin이 low-power state에서 system을 깨울 수 있다면 `WAKEUP_ON_EDGE_BOTH`, `WAKEUP_ON_EDGE_RISE`, `WAKEUP_ON_EDGE_FALL`, 또는 keypad GPIO 활성화용 `WAKEUP_ON_LEVEL_HIGH`를 OR하여 wakeup capability와 edge를 표시할 수 있습니다.
wakeup capability를 pin configuration에 표시했다고 해서 그 pin이 자동으로 system을 깨우는 것은 아닙니다. 대응 GPIO IRQ인 `GPIO_IRQ(xx)` 또는 `gpio_to_irq()`에 대해 `set_irq_wake()`를 호출하고, 최종적으로 `gpio_set_wake()`가 실제 register를 설정해야 합니다.
PXA3xx MFP는 pin마다 edge detection을 지원하지만 내부 logic은 `ADxER` register의 해당 bit가 설정된 경우에만 system을 깨웁니다. 이 bit는 대응 peripheral에 매핑할 수 있으므로 peripheral IRQ에 `set_irq_wake()`를 호출해 wakeup을 활성화할 수 있습니다.
PXA3xx의 MFP
152-187특수 목적 pad를 제외한 PXA3xx의 모든 외부 I/O pad에는 MFP logic 하나가 연결되며, 각각 하나의 MFP register인 `MFPR`로 제어합니다.
원문의 32-bit ASCII register 그림을 field별 구조로 다시 나타냈습니다.
각 control bit의 동작은 다음과 같습니다.
| bit | 이름 | 동작 |
|---|---|---|
| 3 | RESERVED | 예약됨 |
| 4 | `EDGE_RISE_EN` | 이 pin의 rising edge detection 활성화 |
| 5 | `EDGE_FALL_EN` | 이 pin의 falling edge detection 활성화 |
| 6 | `EDGE_CLEAR` | 이 pin의 edge detection 비활성화 |
| 7 | `SLEEP_OE_N` | low-power mode에서 output 활성화 |
| 8 | `SLEEP_DATA` | low-power mode에서 pin에 출력할 data |
| 9 | `SLEEP_SEL` | low-power mode signal 선택 제어 |
| 13 | `PULLDOWN_EN` | 내부 pull-down resistor 활성화 |
| 14 | `PULLUP_EN` | 내부 pull-up resistor 활성화 |
| 15 | `PULL_SEL` | pull state를 selected alternate function이 제어하면 `0`, `PULL{UP,DOWN}_EN` bit가 제어하면 `1` |
| 0-2 | `AF_SEL` | 0~7 가운데 하나를 고르는 8가지 alternate-function selection |
| 10-12 | `DRIVE` | drive strength와 slew rate 선택 |
| DRIVE 값 | slew | 전류 |
|---|---|---|
| `0b000` | fast | 1mA |
| `0b001` | fast | 2mA |
| `0b002` | fast | 3mA |
| `0b003` | fast | 4mA |
| `0b004` | slow | 6mA |
| `0b005` | fast | 6mA |
| `0b006` | slow | 10mA |
| `0b007` | fast | 10mA |
PXA2xx/PXA3xx 통합 MFP 설계
188-198PXA2xx와 PXA3xx는 pin-mux 처리 방식이 다르므로 두 processor 계열을 모두 포괄하는 통합 MFP API를 도입했습니다.
설계의 기본 생각은 가능한 모든 pin configuration을 processor와 platform에 독립적인 정의로 표현한 뒤, 실제 API가 이를 processor register 설정으로 변환해 적용하도록 하는 것입니다.
관련 파일
199-230| 파일 | 책임 |
|---|---|
| `arch/arm/mach-pxa/include/mach/mfp.h` | 모든 configurable pin의 통합 enum 정의와 processor-neutral MFP configuration bit 정의 |
| `arch/arm/mach-pxa/mfp-pxa3xx.h` | PXA3xx 고유 MFPR register bit와 PXA3xx 공통 pin configuration 정의 |
| `arch/arm/mach-pxa/mfp-pxa2xx.h` | PXA2xx 고유 정의와 PXA25x/PXA27x 공통 pin configuration |
| `mfp-pxa25x.h`, `mfp-pxa27x.h`, `mfp-pxa300.h`, `mfp-pxa320.h`, `mfp-pxa930.h` | processor별 정의. 원문 경로는 모두 `arch/arm/mach-pxa/` 아래입니다. |
| `arch/arm/mach-pxa/mfp-pxa3xx.c`, `arch/arm/mach-pxa/mfp-pxa2xx.c` | 실제 processor에서 pin configuration을 적용하는 구현 |
Pin configuration
231-276다음 주석은 `mfp.h`에서 복사한 것입니다. 최신 정보는 실제 source code를 확인해야 합니다.
/*
* a possible MFP configuration is represented by a 32-bit integer
*
* bit 0.. 9 - MFP Pin Number (1024 Pins Maximum)
* bit 10..12 - Alternate Function Selection
* bit 13..15 - Drive Strength
* bit 16..18 - Low Power Mode State
* bit 19..20 - Low Power Mode Edge Detection
* bit 21..22 - Run Mode Pull State
*
* to facilitate the definition, the following macros are provided
*
* MFP_CFG_DEFAULT - default MFP configuration value, with
* alternate function = 0,
* drive strength = fast 3mA (MFP_DS03X)
* low power mode = default
* edge detection = none
*
* MFP_CFG - default MFPR value with alternate function
* MFP_CFG_DRV - default MFPR value with alternate function and
* pin drive strength
* MFP_CFG_LPM - default MFPR value with alternate function and
* low power mode
* MFP_CFG_X - default MFPR value with alternate function,
* pin drive strength and low power mode
*/
가능한 MFP configuration 하나는 32-bit integer로 표현됩니다.
| bit | 필드 |
|---|---|
| 0..9 | MFP pin number, 최대 1024개 pin |
| 10..12 | Alternate Function Selection |
| 13..15 | Drive Strength |
| 16..18 | Low Power Mode State |
| 19..20 | Low Power Mode Edge Detection |
| 21..22 | Run Mode Pull State |
| macro | 용도 |
|---|---|
| `MFP_CFG_DEFAULT` | AF=0, fast 3mA(`MFP_DS03X`), 기본 low-power mode, edge detection 없음 |
| `MFP_CFG` | 기본 MFPR 값과 alternate function |
| `MFP_CFG_DRV` | 기본 MFPR 값, alternate function, pin drive strength |
| `MFP_CFG_LPM` | 기본 MFPR 값, alternate function, low-power mode |
| `MFP_CFG_X` | 기본 MFPR 값, alternate function, pin drive strength, low-power mode |
pin configuration 예는 다음과 같습니다.
#define GPIO94_SSP3_RXD MFP_CFG_X(GPIO94, AF1, DS08X, FLOAT)
이 정의는 GPIO94를 `SSP3_RXD`로 구성할 수 있으며 alternate-function selection은 1, drive strength는 `0b101`, low-power mode에서는 float state라는 뜻입니다.
이 값은 pin을 `SSP3_RXD`로 구성할 때의 기본 설정입니다. board code에서 일부를 바꿀 수는 있지만, 기본값은 보통 신중히 encoding되어 대부분의 경우 동작하도록 설계되므로 수정은 권장하지 않습니다.
Register 설정
277-288PXA3xx에서는 generic pin configuration의 대부분 bit를 MFPR 값으로 직접 변환할 수 있어 register 설정이 비교적 단순합니다. runtime용과 low-power mode용 MFPR 값을 각각 계산하여 두 상태에 다른 설정을 적용할 수 있습니다.
PXA2xx에서 generic pin configuration을 실제 register 설정으로 바꾸는 과정은 더 복잡합니다. `GAFRx`, `GPDRx`, `PGSRx`, `PWER`, `PKWR`, `PFER`, `PRER` 등 여러 register가 관여합니다. 변환 방법은 `mfp-pxa2xx.c`를 참조하십시오.
요약과 해설
mfp.rst:1-288PXA3xx의 MFP는 GPIO controller에서 pin-mux와 저전력·pull·edge 기능을 분리해 외부 pad 앞의 독립된 라우팅 계층으로 만듭니다. 따라서 GPIO 번호는 내부 signal을, MFP pin 번호는 물리 pad를 가리키며 둘을 같은 개념으로 취급하면 안 됩니다.
통합 API는 processor-neutral 32-bit pin configuration을 정의하고 PXA2xx 또는 PXA3xx 구현이 이를 서로 다른 실제 register 집합으로 변환합니다. board code는 processor별 header 하나를 선택하고 초기화 배열을 `__initdata`로 제공하며, wakeup capability와 실제 IRQ wakeup 활성화를 별도로 설정합니다.
board의 공통 pin 정의가 processor별 변환기를 거쳐 실제 register와 외부 pad를 구성합니다.