요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
==============================================
ChipIdea Highspeed Dual Role Controller Driver
==============================================
1. How to test OTG FSM(HNP and SRP)
-----------------------------------
To show how to demo OTG HNP and SRP functions via sys input files
with 2 Freescale i.MX6Q sabre SD boards.
1.1 How to enable OTG FSM
-------------------------
1.1.1 Select CONFIG_USB_OTG_FSM in menuconfig, rebuild kernel
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Image and modules. If you want to check some internal
variables for otg fsm, mount debugfs, there are 2 files
which can show otg fsm variables and some controller registers value::
cat /sys/kernel/debug/ci_hdrc.0/otg
cat /sys/kernel/debug/ci_hdrc.0/registers
1.1.2 Add below entries in your dts file for your controller node
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
::
otg-rev = <0x0200>;
adp-disable;
1.2 Test operations
-------------------
1) Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded
(e.g. g_mass_storage).
2) Connect 2 boards with usb cable: one end is micro A plug, the other end
is micro B plug.
The A-device (with micro A plug inserted) should enumerate B-device.
3) Role switch
On B-device::
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
B-device should take host role and enumerate A-device.
4) A-device switch back to host.
On B-device::
echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
or, by introducing HNP polling, B-Host can know when A-peripheral wishes to
be in the host role, so this role switch also can be triggered in
A-peripheral side by answering the polling from B-Host. This can be done on
A-device::
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
A-device should switch back to host and enumerate B-device.
5) Remove B-device (unplug micro B plug) and insert again in 10 seconds;
A-device should enumerate B-device again.
6) Remove B-device (unplug micro B plug) and insert again after 10 seconds;
A-device should NOT enumerate B-device.
if A-device wants to use bus:
On A-device::
echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
if B-device wants to use bus:
On B-device::
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
7) A-device power down the bus.
On A-device::
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
A-device should disconnect with B-device and power down the bus.
8) B-device does data pulse for SRP.
On B-device::
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
A-device should resume usb bus and enumerate B-device.
1.3 Reference document
----------------------
"On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification
July 27, 2012 Revision 2.0 version 1.1a"
2. How to enable USB as system wakeup source
--------------------------------------------
Below is the example for how to enable USB as system wakeup source
on an imx6 platform.
2.1 Enable core's wakeup::
echo enabled > /sys/bus/platform/devices/ci_hdrc.0/power/wakeup
2.2 Enable glue layer's wakeup::
echo enabled > /sys/bus/platform/devices/2184000.usb/power/wakeup
2.3 Enable PHY's wakeup (optional)::
echo enabled > /sys/bus/platform/devices/20c9000.usbphy/power/wakeup
2.4 Enable roothub's wakeup::
echo enabled > /sys/bus/usb/devices/usb1/power/wakeup
2.5 Enable related device's wakeup::
echo enabled > /sys/bus/usb/devices/1-1/power/wakeup
If the system has only one usb port, and you want usb wakeup at this port, you
can use the below script to enable usb wakeup::
for i in $(find /sys -name wakeup | grep usb);do echo enabled > $i;done;
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
제목
1-4이 문서는 ChipIdea Highspeed Dual Role Controller driver의 OTG FSM 시험과 USB system wakeup 설정을 설명합니다.
==============================================
ChipIdea Highspeed Dual Role Controller Driver
==============================================
OTG FSM, HNP, SRP 시험 개요
5-10두 대의 Freescale i.MX6Q Sabre SD board와 sys input file을 사용해 OTG의 HNP(Host Negotiation Protocol) 및 SRP(Session Request Protocol) 기능을 시연하는 절차입니다.
1. How to test OTG FSM(HNP and SRP)
-----------------------------------
To show how to demo OTG HNP and SRP functions via sys input files
with 2 Freescale i.MX6Q sabre SD boards.
OTG FSM 활성화와 debugfs
11-23`menuconfig`에서 `CONFIG_USB_OTG_FSM`을 선택한 뒤 kernel image와 module을 다시 빌드합니다.
OTG FSM 내부 변수나 controller register 값을 확인하려면 debugfs를 mount합니다. `/sys/kernel/debug/ci_hdrc.0/otg`는 FSM 상태를, `/sys/kernel/debug/ci_hdrc.0/registers`는 controller register 값을 보여 줍니다.
1.1 How to enable OTG FSM
-------------------------
1.1.1 Select CONFIG_USB_OTG_FSM in menuconfig, rebuild kernel
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Image and modules. If you want to check some internal
variables for otg fsm, mount debugfs, there are 2 files
which can show otg fsm variables and some controller registers value::
cat /sys/kernel/debug/ci_hdrc.0/otg
cat /sys/kernel/debug/ci_hdrc.0/registers
Device tree 설정
24-31대상 controller node의 DTS에 `otg-rev = <0x0200>;`와 `adp-disable;` 항목을 추가합니다. 전자는 OTG revision을 지정하고 후자는 ADP를 비활성화합니다.
1.1.2 Add below entries in your dts file for your controller node
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
::
otg-rev = <0x0200>;
adp-disable;
두 보드의 시험 구성
32-42두 i.MX6Q Sabre SD board를 켜고 양쪽에 `g_mass_storage` 같은 gadget class driver를 load합니다.
한쪽 끝이 micro A plug이고 다른 쪽이 micro B plug인 USB cable로 두 board를 연결합니다. micro A plug가 삽입된 A-device가 B-device를 enumerate해야 합니다.
1.2 Test operations
-------------------
1) Power up 2 Freescale i.MX6Q sabre SD boards with gadget class driver loaded
(e.g. g_mass_storage).
2) Connect 2 boards with usb cable: one end is micro A plug, the other end
is micro B plug.
The A-device (with micro A plug inserted) should enumerate B-device.
B-device의 host 전환
43-50B-device에서 `b_bus_req`에 `1`을 쓰면 role switch를 요청합니다. 그러면 B-device가 host role을 맡아 A-device를 enumerate해야 합니다.
A-device와 B-device 사이에서 bus request가 host role을 넘기는 순서입니다.
3) Role switch
On B-device::
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
B-device should take host role and enumerate A-device.
A-device의 host 복귀
51-64B-device에서 `b_bus_req`에 `0`을 쓰면 A-device가 host로 돌아갑니다.
HNP polling을 사용하는 경우 B-Host는 A-peripheral이 host role을 원하는 시점을 알 수 있습니다. A-device가 polling에 응답하도록 `a_bus_req`에 `1`을 써도 같은 전환을 시작할 수 있습니다.
전환 후 A-device가 다시 host가 되어 B-device를 enumerate해야 합니다.
4) A-device switch back to host.
On B-device::
echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
or, by introducing HNP polling, B-Host can know when A-peripheral wishes to
be in the host role, so this role switch also can be triggered in
A-peripheral side by answering the polling from B-Host. This can be done on
A-device::
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
A-device should switch back to host and enumerate B-device.
재연결 시간과 bus 요청
65-84B-device의 micro B plug를 뽑았다가 10초 안에 다시 꽂으면 A-device가 B-device를 다시 enumerate해야 합니다. 10초가 지난 뒤 다시 꽂으면 자동 enumerate되지 않아야 합니다.
그 뒤 A-device가 bus를 사용하려면 `a_bus_drop`을 `0`으로 되돌리고 `a_bus_req`에 `1`을 씁니다. B-device가 bus를 원하면 B-device의 `b_bus_req`에 `1`을 씁니다.
시험에서 사용하는 FSM 입력과 기대 효과를 정리합니다.
5) Remove B-device (unplug micro B plug) and insert again in 10 seconds;
A-device should enumerate B-device again.
6) Remove B-device (unplug micro B plug) and insert again after 10 seconds;
A-device should NOT enumerate B-device.
if A-device wants to use bus:
On A-device::
echo 0 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_req
if B-device wants to use bus:
On B-device::
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
Bus 전원 차단과 SRP
85-100A-device에서 `a_bus_drop`에 `1`을 쓰면 B-device 연결을 끊고 bus 전원을 내려야 합니다.
이 상태에서 B-device가 `b_bus_req`에 `1`을 써 data pulse를 발생시키면 SRP가 시작됩니다. A-device는 USB bus를 resume하고 B-device를 다시 enumerate해야 합니다.
7) A-device power down the bus.
On A-device::
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/a_bus_drop
A-device should disconnect with B-device and power down the bus.
8) B-device does data pulse for SRP.
On B-device::
echo 1 > /sys/bus/platform/devices/ci_hdrc.0/inputs/b_bus_req
A-device should resume usb bus and enumerate B-device.
참고 규격
101-105참고 문서는 2012년 7월 27일자 `On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification`, Revision 2.0 version 1.1a입니다.
1.3 Reference document
----------------------
"On-The-Go and Embedded Host Supplement to the USB Revision 2.0 Specification
July 27, 2012 Revision 2.0 version 1.1a"
USB system wakeup 개요
106-110다음은 i.MX6 platform에서 USB를 system wakeup source로 활성화하는 예입니다. wakeup 경로에 참여하는 여러 계층을 각각 켜야 합니다.
2. How to enable USB as system wakeup source
--------------------------------------------
Below is the example for how to enable USB as system wakeup source
on an imx6 platform.
Core, glue, PHY, roothub, device wakeup
111-129Core의 `ci_hdrc.0`, glue layer의 `2184000.usb`, 선택적인 PHY의 `20c9000.usbphy`, roothub `usb1`, 관련 USB device `1-1`의 각 `power/wakeup`에 `enabled`를 씁니다.
실제 platform의 device 이름과 topology는 예제와 다를 수 있으므로 sysfs에서 대응하는 node를 확인해야 합니다. PHY wakeup은 문서에 표시된 대로 선택 사항입니다.
예제 sysfs 경로와 각 계층을 대응시킵니다.
2.1 Enable core's wakeup::
echo enabled > /sys/bus/platform/devices/ci_hdrc.0/power/wakeup
2.2 Enable glue layer's wakeup::
echo enabled > /sys/bus/platform/devices/2184000.usb/power/wakeup
2.3 Enable PHY's wakeup (optional)::
echo enabled > /sys/bus/platform/devices/20c9000.usbphy/power/wakeup
2.4 Enable roothub's wakeup::
echo enabled > /sys/bus/usb/devices/usb1/power/wakeup
2.5 Enable related device's wakeup::
echo enabled > /sys/bus/usb/devices/1-1/power/wakeup
단일 USB port 시스템용 일괄 설정
130-134USB port가 하나뿐이고 그 port의 모든 관련 wakeup 항목을 켜려면 예제 script가 `/sys` 아래 이름이 `wakeup`인 항목 중 `usb`가 포함된 경로를 찾아 모두 `enabled`로 설정합니다.
이 명령은 검색 결과 전체를 변경하므로 대상 시스템의 sysfs 경로를 먼저 검토한 뒤 사용해야 합니다.
If the system has only one usb port, and you want usb wakeup at this port, you
can use the below script to enable usb wakeup::
for i in $(find /sys -name wakeup | grep usb);do echo enabled > $i;done;
요약·해설
chipidea.rst:1-134이 절차의 핵심은 두 dual-role board에서 `a_bus_req`, `b_bus_req`, `a_bus_drop`을 조작해 HNP와 SRP 상태 전이를 관찰하는 것입니다. System wakeup은 controller core만 켜는 것으로 끝나지 않으며, platform glue·필요한 PHY·USB roothub·실제 device의 `power/wakeup` 경로를 topology에 맞게 활성화해야 합니다.