linuxOS_D21X/doc/topics/sdk/usb/usb-otg_configuration.html
2025-01-23 16:35:08 +08:00

344 lines
47 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" data-whc_version="27.0">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="description" content="USB Host 0 和 USB Device 0 共享 1 路 phy。要么同时只能启用其中一种功能要么启用 USB OTG 功能通过 id 管脚的值来动态切换对外功能。 Linux Kernel Kconfig 文件中使能相应 OTG Driver &gt; Device Drivers &gt; USB support [*] OTG support [*] Support for ..."/><meta name="DC.rights.owner" content="(C) 版权 2025"/><meta name="copyright" content="(C) 版权 2025"/><meta name="generator" content="DITA-OT"/><meta name="DC.type" content="concept"/><meta name="DC.relation" content="../../../topics/sdk/usb/usb_config.html"/><meta name="DC.relation" content="../../../topics/sdk/usb/usb-device_configuration.html"/><meta name="DC.relation" content="../../../topics/sdk/usb/usb-debug_guide.html"/><meta name="DC.contributor" content="yan.wang"/><meta name="DC.contributor" content="yan.wang"/><meta name="DC.date.modified" content="2024-01-15"/><meta name="DC.format" content="HTML5"/><meta name="DC.identifier" content="usb_otg_configuration"/><meta name="DC.language" content="zh-CN"/><title>USB OTG 配置</title><!-- Generated with build number 2024112209. --><meta name="wh-path2root" content="../../../"/><meta name="wh-toc-id" content="usb_otg_configuration-d4445e7355"/><meta name="wh-source-relpath" content="topics/sdk/usb/usb-otg_configuration.dita"/><meta name="wh-out-relpath" content="topics/sdk/usb/usb-otg_configuration.html"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/commons.css?buildId=2024112209"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/topic.css?buildId=2024112209"/>
<script src="../../../webhelp/app/options/properties.js?buildId=20250123154945"></script>
<script src="../../../webhelp/app/localization/strings.js?buildId=2024112209"></script>
<script src="../../../webhelp/app/search/index/keywords.js?buildId=20250123154945"></script>
<script defer="defer" src="../../../webhelp/app/commons.js?buildId=2024112209"></script>
<script defer="defer" src="../../../webhelp/app/topic.js?buildId=2024112209"></script>
<link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-styles-web.css?buildId=2024112209"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/notes.css?buildId=2024112209"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-common.css?buildId=2024112209"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-images.css?buildId=2024112209"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/footnote.css?buildId=2024112209"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-web-watermark.css?buildId=2024112209"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/topic-body-list.css?buildId=2024112209"/></head>
<body id="usb_otg_configuration" class="wh_topic_page frmBody">
<a href="#wh_topic_body" class="sr-only sr-only-focusable">
跳转到主要内容
</a>
<header class="navbar navbar-default wh_header">
<div class="container-fluid">
<div class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
<div class="wh_logo_and_publication_title_container">
<div class="wh_logo_and_publication_title">
<a href="http://www.artinchip.com" class=" wh_logo d-none d-sm-block "><img src="../../../company-logo-white.png" alt=" Linux SDK 使用指南 SDK 指南文件 "/></a>
<div class=" wh_publication_title "><a href="../../../index.html"><span class="booktitle"> <span class="ph mainbooktitle">Linux SDK 使用指南</span> <span class="ph booktitlealt">SDK 指南文件</span> </span></a></div>
</div>
</div>
<div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
</div>
</div>
</div>
</header>
<div class=" wh_search_input navbar-form wh_topic_page_search search " role="form">
<form id="searchForm" method="get" role="search" action="../../../search.html"><div><input type="search" placeholder="搜索 " class="wh_search_textfield" id="textToSearch" name="searchQuery" aria-label="搜索查询" required="required"/><button type="submit" class="wh_search_button" aria-label="搜索"><span class="search_input_text">搜索</span></button></div></form>
</div>
<div class="container-fluid" id="wh_topic_container">
<div class="row">
<nav class="wh_tools d-print-none navbar-expand-md" aria-label="Tools">
<div data-tooltip-position="bottom" class=" wh_breadcrumb "><ol class="d-print-none"><li><span class="home"><a href="../../../index.html"><span>主页</span></a></span></li><li><div class="topicref" data-id="id"><div class="title"><a href="../../../topics/sdk/chapter-advanced-app.html">高级应用</a><div class="wh-tooltip"><p class="shortdesc">系统、存储、多媒体、接口、安全等模块的详细配置和设计说明。</p></div></div></div></li><li><div class="topicref" data-id="concept_nww_hzh_pzb"><div class="title"><a href="../../../topics/chapter-title/chapter-interface-sdk.html">接口</a><div class="wh-tooltip"><p class="shortdesc">CAN、CIR、GPAI、GPIO、I2C、PSADC、PWM 等接口模块的介绍和使用说明。</p></div></div></div></li><li><div class="topicref" data-id="usb_user_guide"><div class="title"><a href="../../../topics/sdk/usb/usb_user_guide.html">USB 使用指南</a></div></div></li><li><div class="topicref" data-id="usb_configuration"><div class="title"><a href="../../../topics/sdk/usb/usb_config.html">USB 配置</a></div></div></li><li class="active"><div class="topicref" data-id="usb_otg_configuration"><div class="title"><a href="../../../topics/sdk/usb/usb-otg_configuration.html">USB OTG 配置</a></div></div></li></ol></div>
<div class="wh_right_tools">
<button class="wh_hide_highlight" aria-label="切换搜索突出显示" title="切换搜索突出显示"></button>
<button class="webhelp_expand_collapse_sections" data-next-state="collapsed" aria-label="折叠截面" title="折叠截面"></button>
<div class=" wh_navigation_links "><span id="topic_navigation_links" class="navheader">
<span class="navprev"><a class="- topic/link link" href="../../../topics/sdk/usb/usb-device_configuration.html" title="USB Device 配置" aria-label="上一主题: USB Device 配置" rel="prev"></a></span>
<span class="navnext"><a class="- topic/link link" href="../../../topics/sdk/usb/usb-debug_guide.html" title="调试指南" aria-label="下一主题: 调试指南" rel="next"></a></span> </span></div>
<div class=" wh_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="打印此页" aria-label="打印此页"></button></div>
<button type="button" id="wh_toc_button" class="custom-toggler navbar-toggler collapsed wh_toggle_button navbar-light" aria-expanded="false" aria-label="Toggle publishing table of content" aria-controls="wh_publication_toc">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
</div>
<div class="wh_content_area">
<div class="row">
<nav id="wh_publication_toc" class="col-lg-3 col-md-3 col-sm-12 d-md-block d-none d-print-none" aria-label="Table of Contents Container">
<div id="wh_publication_toc_content">
<div class=" wh_publication_toc " data-tooltip-position="right"><span class="expand-button-action-labels"><span id="button-expand-action" role="button" aria-label="Expand"></span><span id="button-collapse-action" role="button" aria-label="Collapse"></span><span id="button-pending-action" role="button" aria-label="Pending"></span></span><ul role="tree" aria-label="Table of Contents"><li role="treeitem"><div data-tocid="revinfo_linux-d4445e1079" class="topicref" data-id="revinfo_linux" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/revinfo/revinfo_linux.html" id="revinfo_linux-d4445e1079-link">修订记录</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="id-d4445e1096" class="topicref" data-id="id" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action id-d4445e1096-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/env/sdk-compile.html" id="id-d4445e1096-link">SDK 编译</a><div class="wh-tooltip"><p class="shortdesc">介绍不同编译环境下 SDK 的详细编译流程。</p></div></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="tocId-d4445e1240" class="topicref" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action tocId-d4445e1240-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/advanced/lb_usage_commands.html" id="tocId-d4445e1240-link">使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="concept_rcx_czh_pzb-d4445e1360" class="topicref" data-id="concept_rcx_czh_pzb" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action concept_rcx_czh_pzb-d4445e1360-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/chapter-app.html" id="concept_rcx_czh_pzb-d4445e1360-link">应用场景</a><div class="wh-tooltip"><p class="shortdesc">描述了 SDK 在不同应用场景中的配置和使用包括系统更新、OTA、安全方案等。</p></div></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="id-d4445e1678" class="topicref" data-id="id" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action id-d4445e1678-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/peripheral/peripheral-intro.html" id="id-d4445e1678-link">外设移植</a><div class="wh-tooltip"><p class="shortdesc"><span class="ph">触摸屏、显示器、WIFI 模块、按键</span>等外设的介绍和使用说明。</p></div></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="id-d4445e1964" class="topicref" data-id="id" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action id-d4445e1964-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/bringup/chapter-bringup.html" id="id-d4445e1964-link">BringUp</a><div class="wh-tooltip"><p class="shortdesc">在硬件上电后快速初始化系统,为操作系统的启动准备好必要的硬件环境。</p></div></div></div></li><li role="treeitem" aria-expanded="true"><div data-tocid="id-d4445e2153" class="topicref" data-id="id" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action id-d4445e2153-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/chapter-advanced-app.html" id="id-d4445e2153-link">高级应用</a><div class="wh-tooltip"><p class="shortdesc">系统、存储、多媒体、接口、安全等模块的详细配置和设计说明。</p></div></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem" aria-expanded="false"><div data-tocid="uBoot-d4445e2170" class="topicref" data-id="uBoot" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action uBoot-d4445e2170-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/boot/uboot-module.html" id="uBoot-d4445e2170-link">U-Boot</a><div class="wh-tooltip"><p class="shortdesc">启动支持的基本功能以及运行时的基本硬件环境。</p></div></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="concept_mtx_tk3_pzb-d4445e3028" class="topicref" data-id="concept_mtx_tk3_pzb" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action concept_mtx_tk3_pzb-d4445e3028-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/linux/chapter_linux.html" id="concept_mtx_tk3_pzb-d4445e3028-link">Linux</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="chapter-system-d4445e3198" class="topicref" data-id="chapter-system" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action chapter-system-d4445e3198-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/chapter-title/chapter-system.html" id="chapter-system-d4445e3198-link">系统</a><div class="wh-tooltip"><p class="shortdesc"></p></div></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="chapter-memory-d4445e4054" class="topicref" data-id="chapter-memory" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action chapter-memory-d4445e4054-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/chapter-title/chapter-memory-sdk.html" id="chapter-memory-d4445e4054-link">存储</a><div class="wh-tooltip"><p class="shortdesc">SDMC、SPI NAND、SPI NOR 等存储模块的介绍和使用说明。</p></div></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="concept_mcc_32s_nbc-d4445e4438" class="topicref" data-id="concept_mcc_32s_nbc" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action concept_mcc_32s_nbc-d4445e4438-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/chapter-title/chapter-multi-media-sdk.html" id="concept_mcc_32s_nbc-d4445e4438-link">多媒体</a><div class="wh-tooltip"><p class="shortdesc">GE、VE、Display、DVP、MPP、MPP 播放器等多媒体模块的介绍和使用说明。</p></div></div></div></li><li role="treeitem" aria-expanded="true"><div data-tocid="concept_nww_hzh_pzb-d4445e5947" class="topicref" data-id="concept_nww_hzh_pzb" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action concept_nww_hzh_pzb-d4445e5947-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/chapter-title/chapter-interface-sdk.html" id="concept_nww_hzh_pzb-d4445e5947-link">接口</a><div class="wh-tooltip"><p class="shortdesc">CAN、CIR、GPAI、GPIO、I2C、PSADC、PWM 等接口模块的介绍和使用说明。</p></div></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem" aria-expanded="false"><div data-tocid="can-d4445e5964" class="topicref" data-id="can" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action can-d4445e5964-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/can/can_user_guide.html" id="can-d4445e5964-link">CAN 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="cir-d4445e6020" class="topicref" data-id="cir" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action cir-d4445e6020-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/cir/cir_user_guide.html" id="cir-d4445e6020-link">CIR 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="gpai-user-guide-d4445e6146" class="topicref" data-id="gpai-user-guide" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action gpai-user-guide-d4445e6146-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/gpai/gpai_user_guide.html" id="gpai-user-guide-d4445e6146-link">GPAI 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="i2c_user_guide-d4445e6288" class="topicref" data-id="i2c_user_guide" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action i2c_user_guide-d4445e6288-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/i2c/i2c_user_guide.html" id="i2c_user_guide-d4445e6288-link">I2C 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="id-d4445e6400" class="topicref" data-id="id" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action id-d4445e6400-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/mac/mac_user_guide.html" id="id-d4445e6400-link">MAC 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="pbus_user_guide-d4445e6514" class="topicref" data-id="pbus_user_guide" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action pbus_user_guide-d4445e6514-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/pbus/pbus-user-guide.html" id="pbus_user_guide-d4445e6514-link">PBUS 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="pinctrl_user_guide-d4445e6598" class="topicref" data-id="pinctrl_user_guide" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action pinctrl_user_guide-d4445e6598-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/pinctrl/pinctrl-user-guide.html" id="pinctrl_user_guide-d4445e6598-link">PINCTRL 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="id-d4445e6738" class="topicref" data-id="id" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action id-d4445e6738-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/pwm/pwm_user_guide.html" id="id-d4445e6738-link">PWM 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="rtp-user-guide-d4445e6822" class="topicref" data-id="rtp-user-guide" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action rtp-user-guide-d4445e6822-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/rtp/rtp_user_guide.html" id="rtp-user-guide-d4445e6822-link">RTP 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="spi-d4445e6962" class="topicref" data-id="spi" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action spi-d4445e6962-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/spi/spi_user_guide.html" id="spi-d4445e6962-link">SPI 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="id-d4445e7075" class="topicref" data-id="id" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action id-d4445e7075-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/psadc/psadc_user_guide.html" id="id-d4445e7075-link">PSADC 使用指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="uart_user_guide-d4445e7215" class="topicref" data-id="uart_user_guide" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action uart_user_guide-d4445e7215-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/uart/uart_user_guide.html" id="uart_user_guide-d4445e7215-link">UART 使用指南</a></div></div></li><li role="treeitem" aria-expanded="true"><div data-tocid="usb_user_guide-d4445e7299" class="topicref" data-id="usb_user_guide" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action usb_user_guide-d4445e7299-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb_user_guide.html" id="usb_user_guide-d4445e7299-link">USB 使用指南</a></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem" aria-expanded="true"><div data-tocid="usb_configuration-d4445e7313" class="topicref" data-id="usb_configuration" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action usb_configuration-d4445e7313-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb_config.html" id="usb_configuration-d4445e7313-link">USB 配置</a></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem"><div data-tocid="usb_host_configuration-d4445e7327" class="topicref" data-id="usb_host_configuration" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb-host_configuration.html" id="usb_host_configuration-d4445e7327-link">USB Host 配置</a></div></div></li><li role="treeitem"><div data-tocid="usb_device_configuration-d4445e7341" class="topicref" data-id="usb_device_configuration" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb-device_configuration.html" id="usb_device_configuration-d4445e7341-link">USB Device 配置</a></div></div></li><li role="treeitem" class="active"><div data-tocid="usb_otg_configuration-d4445e7355" class="topicref" data-id="usb_otg_configuration" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb-otg_configuration.html" id="usb_otg_configuration-d4445e7355-link">USB OTG 配置</a></div></div></li></ul></li><li role="treeitem"><div data-tocid="usb_debug_guide-d4445e7369" class="topicref" data-id="usb_debug_guide" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb-debug_guide.html" id="usb_debug_guide-d4445e7369-link">调试指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="usb_test_guide-d4445e7383" class="topicref" data-id="usb_test_guide" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action usb_test_guide-d4445e7383-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb-test_guide.html" id="usb_test_guide-d4445e7383-link">测试指南</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="usb_design_intro-d4445e7468" class="topicref" data-id="usb_design_intro" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action usb_design_intro-d4445e7468-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb-design_intro.html" id="usb_design_intro-d4445e7468-link">设计说明</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="usb_host_subsystem_code_structure-d4445e7594" class="topicref" data-id="usb_host_subsystem_code_structure" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action usb_host_subsystem_code_structure-d4445e7594-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb-host_subsystem_code_structure.html" id="usb_host_subsystem_code_structure-d4445e7594-link">USB Host 子系统代码架构</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="usb_device_subsystem_code_structure-d4445e7762" class="topicref" data-id="usb_device_subsystem_code_structure" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action usb_device_subsystem_code_structure-d4445e7762-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb-device_subsystem_code_structure.html" id="usb_device_subsystem_code_structure-d4445e7762-link">USB Device 子系统代码架构</a></div></div></li><li role="treeitem"><div data-tocid="usb_common_issues-d4445e7930" class="topicref" data-id="usb_common_issues" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/usb/usb_faq.html" id="usb_common_issues-d4445e7930-link">常见问题</a></div></div></li></ul></li></ul></li><li role="treeitem" aria-expanded="false"><div data-tocid="chapter-safety-d4445e7944" class="topicref" data-id="chapter-safety" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action chapter-safety-d4445e7944-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/chapter-title/chapter-safety-sdk.html" id="chapter-safety-d4445e7944-link">安全</a><div class="wh-tooltip"><p class="shortdesc">SPI ENC、CE、eFuse 等安全模块的介绍和使用说明。</p></div></div></div></li></ul></li></ul></div>
</div>
</nav>
<div class="col-lg-7 col-md-9 col-sm-12" id="wh_topic_body">
<button id="wh_close_publication_toc_button" class="close-toc-button d-none" aria-label="Toggle publishing table of content" aria-controls="wh_publication_toc" aria-expanded="true">
<span class="close-toc-icon-container">
<span class="close-toc-icon"></span>
</span>
</button>
<button id="wh_close_topic_toc_button" class="close-toc-button d-none" aria-label="Toggle topic table of content" aria-controls="wh_topic_toc" aria-expanded="true">
<span class="close-toc-icon-container">
<span class="close-toc-icon"></span>
</span>
</button>
<div class=" wh_topic_content body "><main role="main"><article class="- topic/topic concept/concept topic concept" role="article" aria-labelledby="ariaid-title1">
<span class="edit-link" style="font-size:12px; opacity:0.6; text-align:right; vertical-align:middle"><a target="_blank" title="Edit this document" href="http://172.16.35.88/tasks/jdssno1uvvbf2mltu9kb9v3if05d5gopuakboe8hlud18rma/edit/F:/aicdita/aicdita-cn/topics/sdk/usb/usb-otg_configuration.dita">Edit online</a></span><h1 class="- topic/title title topictitle1" id="ariaid-title1">USB OTG 配置</h1>
<div class="date inPage">15 Jan 2024</div><div style="color: gray;">
Read time: 3 minute(s)
</div>
<div class="- topic/body concept/conbody body conbody">
<div class="- topic/div div">
<p class="- topic/p p" data-ofbid="d132309e35__20250123155212">USB Host 0 和 USB Device 0 共享 1 路 phy。要么同时只能启用其中一种功能要么启用 USB OTG 功能通过
<code class="+ topic/ph pr-d/codeph ph codeph">id</code> 管脚的值来动态切换对外功能。</p>
<ol class="- topic/ol ol" id="usb_otg_configuration__ul_f4r_hdz_21c" data-ofbid="usb_otg_configuration__ul_f4r_hdz_21c">
<li class="- topic/li li" data-ofbid="d132309e43__20250123155212">
<div class="- topic/p p" data-ofbid="d132309e45__20250123155212">Linux Kernel Kconfig 文件中使能相应 OTG
Driver<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="usb_otg_configuration__codeblock_rcy_3hz_21c" data-ofbid="usb_otg_configuration__codeblock_rcy_3hz_21c"><code>&gt; Device Drivers &gt; USB support
[*] OTG support
[*] Support <strong class="hl-keyword">for</strong> ArtInChip on-chip OTG Switch</code></pre></div>
</li>
<li class="- topic/li li" data-ofbid="d132309e51__20250123155212">
<div class="- topic/p p" data-ofbid="d132309e53__20250123155212">DTS 文件中配置相应 OTG
Device:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="usb_otg_configuration__codeblock_qvj_jhz_21c" data-ofbid="usb_otg_configuration__codeblock_qvj_jhz_21c"><code>otg: usb-otg {
compatible = <span class="hl-string">"artinchip,aic-otg-v2.0"</span>;
};
&amp;otg {
otg-mode = <span class="hl-string">"auto"</span>; <em class="hl-comment">// = auto/host/device</em>
id-gpios = &lt;&amp;gpio_f <span class="hl-number">15</span> GPIO_ACTIVE_HIGH&gt;;
vbus-en-gpios = &lt;&amp;gpio_a <span class="hl-number">7</span> GPIO_ACTIVE_HIGH&gt;;
dp-sw-gpios = &lt;&amp;gpio_e <span class="hl-number">14</span> GPIO_ACTIVE_LOW&gt;;
status = <span class="hl-string">"okay"</span>;
};</code></pre></div>
</li>
</ol>
</div>
<section class="- topic/section section" id="usb_otg_configuration__section_kvg_l3z_21c" data-ofbid="usb_otg_configuration__section_kvg_l3z_21c"><h2 class="- topic/title title sectiontitle">OTG 模式配置</h2>
<div class="- topic/p p" data-ofbid="d132309e65__20250123155212">OTG 可以配置成 <code class="+ topic/ph pr-d/codeph ph codeph">Auto 模式</code> 或者 <code class="+ topic/ph pr-d/codeph ph codeph">Force
模式</code> 模式 <ul class="- topic/ul ul" id="usb_otg_configuration__ul_k4r_hdz_21c" data-ofbid="usb_otg_configuration__ul_k4r_hdz_21c">
<li class="- topic/li li" data-ofbid="d132309e75__20250123155212">
<p class="- topic/p p" data-ofbid="d132309e77__20250123155212"><code class="+ topic/ph pr-d/codeph ph codeph">Auto 模式</code>。根据 <code class="+ topic/ph pr-d/codeph ph codeph">id</code> 管脚的电平来决定当前 OTG 端口工作模式为
<code class="+ topic/ph pr-d/codeph ph codeph">Host</code> / <code class="+ topic/ph pr-d/codeph ph codeph">Device</code></p>
<p class="- topic/p p" data-ofbid="d132309e91__20250123155212">通常情况下 <code class="+ topic/ph pr-d/codeph ph codeph">id = low</code> 对应 <code class="+ topic/ph pr-d/codeph ph codeph">Host</code>
模式, <code class="+ topic/ph pr-d/codeph ph codeph">id = high</code> 对应 <code class="+ topic/ph pr-d/codeph ph codeph">Device</code> 模式。</p>
</li>
<li class="- topic/li li" data-ofbid="d132309e107__20250123155212">
<p class="- topic/p p" data-ofbid="d132309e109__20250123155212"><code class="+ topic/ph pr-d/codeph ph codeph">Force 模式</code>。手工配置工作模式,通过配置
<code class="+ topic/ph pr-d/codeph ph codeph">/sys/devices/platform/soc/soc\:usb-otg/otg_mode</code>
文件节点的值来改变当前 OTG 端口的工作模式, <code class="+ topic/ph pr-d/codeph ph codeph">host</code> 对应 <code class="+ topic/ph pr-d/codeph ph codeph">Host</code>
模式, <code class="+ topic/ph pr-d/codeph ph codeph">device</code> 对应 <code class="+ topic/ph pr-d/codeph ph codeph">Device</code> 模式。另外
<code class="+ topic/ph pr-d/codeph ph codeph">auto</code> 对应 <code class="+ topic/ph pr-d/codeph ph codeph">Auto</code> 模式,需要使用
<code class="+ topic/ph pr-d/codeph ph codeph">id</code> 管脚来进行判断。</p>
</li>
</ul></div> 两种模式对应 DTS 文件中的 <code class="+ topic/ph pr-d/codeph ph codeph">otg</code> 节点的不同配置:<div class="table-container"><table class="- topic/table table frame-all" id="usb_otg_configuration__table_l4r_hdz_21c" data-ofbid="usb_otg_configuration__table_l4r_hdz_21c" data-cols="4"><caption></caption><colgroup><col style="width:13.755158184319122%"/><col style="width:27.097661623108664%"/><col style="width:25.722145804676757%"/><col style="width:33.425034387895465%"/></colgroup><thead class="- topic/thead thead">
<tr class="- topic/row">
<th class="- topic/entry entry colsep-1 rowsep-1" id="usb_otg_configuration__table_l4r_hdz_21c__entry__1">Mode</th>
<th class="- topic/entry entry colsep-1 rowsep-1" id="usb_otg_configuration__table_l4r_hdz_21c__entry__2">DTS <code class="+ topic/ph pr-d/codeph ph codeph">otg-mode</code> 属性</th>
<th class="- topic/entry entry colsep-1 rowsep-1" id="usb_otg_configuration__table_l4r_hdz_21c__entry__3">DTS <code class="+ topic/ph pr-d/codeph ph codeph">xxx-gpios</code> 属性</th>
<th class="- topic/entry entry colsep-0 rowsep-1" id="usb_otg_configuration__table_l4r_hdz_21c__entry__4">运行时 <code class="+ topic/ph pr-d/codeph ph codeph">Host</code> / <code class="+ topic/ph pr-d/codeph ph codeph">Device</code> 切换方法</th>
</tr>
</thead><tbody class="- topic/tbody tbody">
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-1" headers="usb_otg_configuration__table_l4r_hdz_21c__entry__1">Auto</td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="usb_otg_configuration__table_l4r_hdz_21c__entry__2"><code class="+ topic/ph pr-d/codeph ph codeph">otg-mode = "auto";</code> (如果没有配置
<code class="+ topic/ph pr-d/codeph ph codeph">otg-mode</code> 属性, 默认也是 Auto 模式)</td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="usb_otg_configuration__table_l4r_hdz_21c__entry__3"><code class="+ topic/ph pr-d/codeph ph codeph">id-gpios</code> 属性必须配置。 <code class="+ topic/ph pr-d/codeph ph codeph">vbus-en-gpios</code>
<code class="+ topic/ph pr-d/codeph ph codeph">dp-sw-gpios</code> 属性根据硬件配置选配。</td>
<td class="- topic/entry entry colsep-0 rowsep-1" headers="usb_otg_configuration__table_l4r_hdz_21c__entry__4">OTG 驱动根据 <code class="+ topic/ph pr-d/codeph ph codeph">id-gpios</code> 管脚的电平变化 自动切换 USB 工作模式为
<code class="+ topic/ph pr-d/codeph ph codeph">Host</code> / <code class="+ topic/ph pr-d/codeph ph codeph">Device</code></td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-0" headers="usb_otg_configuration__table_l4r_hdz_21c__entry__1">Force</td>
<td class="- topic/entry entry colsep-1 rowsep-0" headers="usb_otg_configuration__table_l4r_hdz_21c__entry__2"><code class="+ topic/ph pr-d/codeph ph codeph">otg-mode = "device";</code> 或者 <code class="+ topic/ph pr-d/codeph ph codeph">otg-mode =
"host";</code></td>
<td class="- topic/entry entry colsep-1 rowsep-0" headers="usb_otg_configuration__table_l4r_hdz_21c__entry__3"><code class="+ topic/ph pr-d/codeph ph codeph">id-gpios</code> 属性不需要配置。 <code class="+ topic/ph pr-d/codeph ph codeph">vbus-en-gpios</code>
<code class="+ topic/ph pr-d/codeph ph codeph">dp-sw-gpios</code> 属性根据硬件配置选配。</td>
<td class="- topic/entry entry colsep-0 rowsep-0" headers="usb_otg_configuration__table_l4r_hdz_21c__entry__4">需要配置文件节点来手工切换: <code class="+ topic/ph pr-d/codeph ph codeph">echo devices &gt;
/sys/devices/platform/soc/soc\:usb-otg/otg_mode</code> 或者
<code class="+ topic/ph pr-d/codeph ph codeph">echo host &gt;
/sys/devices/platform/soc/soc\:usb-otg/otg_mode</code></td>
</tr>
</tbody></table></div>
</section>
<section class="- topic/section section" id="usb_otg_configuration__section_m4r_hdz_21c" data-ofbid="usb_otg_configuration__section_m4r_hdz_21c"><h2 class="- topic/title title sectiontitle">OTG 相关 GPIO</h2>
<p class="- topic/p p" data-ofbid="d132309e267__20250123155212">从上面配置可以看到和 OTG 功能相关的 GPIO 管脚有 3 个:</p>
<ul class="- topic/ul ul" id="usb_otg_configuration__ul_n4r_hdz_21c" data-ofbid="usb_otg_configuration__ul_n4r_hdz_21c">
<li class="- topic/li li" data-ofbid="d132309e272__20250123155212">
<p class="- topic/p p" data-ofbid="d132309e274__20250123155212"><code class="+ topic/ph pr-d/codeph ph codeph">id-gpios</code> 。用来检测当前插入的是不是 OTG 线,如果为 OTG 线则需要把本机切换到 USB Host
模式,否则本机切换到 USB Device 模式。该管脚在 <code class="+ topic/ph pr-d/codeph ph codeph">Auto 模式</code> 模式下是必须配置的,如果缺少该管脚 OTG
只能工作在 <code class="+ topic/ph pr-d/codeph ph codeph">Force </code> 模式手工进行切换。</p>
</li>
<li class="- topic/li li" data-ofbid="d132309e286__20250123155212">
<p class="- topic/p p" data-ofbid="d132309e288__20250123155212"><code class="+ topic/ph pr-d/codeph ph codeph">vbus-en-gpios</code> 。该管脚是用来控制 VBUS 的 5V 输出的,通常情况下:切换到 USB Host
模式时需要使能本机端的 VBUS 5V 输出给对端 Device 供电,切换到 USB Device 模式时需要关闭本机端的 VBUS 5V
输出转而对端 Host 的供电。(实际使用上来说,不论本端是 Host/Device 模式,也可以在 VBUS 上一直供电 5V 两边 VBUS
无压差则无漏电,这种情况下 <code class="+ topic/ph pr-d/codeph ph codeph">vbus-en-gpios</code> 无需配置。)</p>
</li>
<li class="- topic/li li" data-ofbid="d132309e297__20250123155212">
<p class="- topic/p p" data-ofbid="d132309e299__20250123155212"><code class="+ topic/ph pr-d/codeph ph codeph">dp-sw-gpios</code> 。该管脚是在 OTG 外出两个独立 Host、Device 端口时,用来控制外部 Switch
的。非该模式时, <code class="+ topic/ph pr-d/codeph ph codeph">dp-sw-gpios</code> 无需配置。</p>
<div class="- topic/p p" data-ofbid="d132309e307__20250123155212"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="usb_otg_configuration__image_p4r_hdz_21c" src="../../../images/usb/otg_gpio.png" alt="image2"/></div><br/></div>
</li>
</ul>
<p class="- topic/p p" data-ofbid="d132309e316__20250123155212">3 个 GPIO 管脚的具体使用场景如上图所示,用户根据自己的使用场景来选择配置哪些 GPIO。每个 GPIO 的 输入输出正反电平有效,可以通过 <span class="- topic/ph ph">DTS 中的 <code class="+ topic/ph pr-d/codeph ph codeph">GPIO_ACTIVE_HIGH</code>
<code class="+ topic/ph pr-d/codeph ph codeph">GPIO_ACTIVE_LOW</code> 来配置</span></p>
<div class="table-container"><table class="- topic/table table frame-all" id="usb_otg_configuration__table_q4r_hdz_21c" data-ofbid="usb_otg_configuration__table_q4r_hdz_21c" data-cols="4"><caption></caption><colgroup><col style="width:18.939393939393938%"/><col style="width:15.151515151515152%"/><col style="width:34.24242424242424%"/><col style="width:31.666666666666664%"/></colgroup><thead class="- topic/thead thead">
<tr class="- topic/row">
<th class="- topic/entry entry colsep-1 rowsep-1" id="usb_otg_configuration__table_q4r_hdz_21c__entry__1">GPIO Name</th>
<th class="- topic/entry entry colsep-1 rowsep-1" id="usb_otg_configuration__table_q4r_hdz_21c__entry__2">Direction</th>
<th class="- topic/entry entry colsep-1 rowsep-1" id="usb_otg_configuration__table_q4r_hdz_21c__entry__3">GPIO_ACTIVE_HIGH</th>
<th class="- topic/entry entry colsep-0 rowsep-1" id="usb_otg_configuration__table_q4r_hdz_21c__entry__4">GPIO_ACTIVE_LOW</th>
</tr>
</thead><tbody class="- topic/tbody tbody">
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-1" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__1"><code class="+ topic/ph pr-d/codeph ph codeph">id-gpios</code></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__2">input</td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__3">
<p class="- topic/p p" data-ofbid="d132309e372__20250123155212">输入低电平 = Host</p>
<p class="- topic/p p" data-ofbid="d132309e375__20250123155212">输入高电平 = Device</p>
</td>
<td class="- topic/entry entry colsep-0 rowsep-1" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__4">
<p class="- topic/p p" data-ofbid="d132309e381__20250123155212">输入低电平 = Device</p>
<p class="- topic/p p" data-ofbid="d132309e384__20250123155212">输入高电平 = Host</p>
</td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-1" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__1"><code class="+ topic/ph pr-d/codeph ph codeph">vbus-en-gpios</code></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__2">output</td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__3">
<p class="- topic/p p" data-ofbid="d132309e400__20250123155212">Host (VBUS on) = 输出高电平</p>
<p class="- topic/p p" data-ofbid="d132309e403__20250123155212">Device (VBUS off) = 输出低电平</p>
</td>
<td class="- topic/entry entry colsep-0 rowsep-1" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__4">
<p class="- topic/p p" data-ofbid="d132309e409__20250123155212">Host (VBUS on) = 输出低电平</p>
<p class="- topic/p p" data-ofbid="d132309e412__20250123155212">Device (VBUS off) = 输出高电平</p>
</td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-0" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__1"><code class="+ topic/ph pr-d/codeph ph codeph">dp-sw-gpios</code></td>
<td class="- topic/entry entry colsep-1 rowsep-0" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__2">output</td>
<td class="- topic/entry entry colsep-1 rowsep-0" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__3">
<p class="- topic/p p" data-ofbid="d132309e428__20250123155212">Host = 输出高电平</p>
<p class="- topic/p p" data-ofbid="d132309e431__20250123155212">Device = 输出低电平</p>
</td>
<td class="- topic/entry entry colsep-0 rowsep-0" headers="usb_otg_configuration__table_q4r_hdz_21c__entry__4">
<p class="- topic/p p" data-ofbid="d132309e437__20250123155212">Host = 低电平</p>
<p class="- topic/p p" data-ofbid="d132309e440__20250123155212">Device = 高电平</p>
</td>
</tr>
</tbody></table></div>
</section>
</div>
</article></main></div>
</div>
<nav role="navigation" id="wh_topic_toc" aria-label="On this page" class="col-lg-2 d-none d-lg-block navbar d-print-none">
<div id="wh_topic_toc_content">
<div class=" wh_topic_toc "><div class="wh_topic_label">在本页上</div><ul><li class="section-item"><div class="section-title"><a href="#usb_otg_configuration__section_kvg_l3z_21c" data-tocid="usb_otg_configuration__section_kvg_l3z_21c">OTG 模式配置</a></div></li><li class="section-item"><div class="section-title"><a href="#usb_otg_configuration__section_m4r_hdz_21c" data-tocid="usb_otg_configuration__section_m4r_hdz_21c">OTG 相关 GPIO</a></div></li></ul></div>
</div>
</nav>
</div>
</div>
</div>
<footer class="navbar navbar-default wh_footer">
<div class=" footer-container mx-auto ">
<title>footer def</title>
<style><!--
.p1 {
font-family: FangZhengShuSong, Times, serif;
}
.p2 {
font-family: Arial, Helvetica, sans-serif;
}
.p3 {
font-family: "Lucida Console", "Courier New", monospace;
}
--></style>
<div class="webhelp.fragment.footer">
<p class="p1">Copyright © 2019-2024 广东匠芯创科技有限公司. All rights reserved.</p>
</div><div>
<div class="generation_time">
Update Time: 2025-01-23
</div>
</div>
</div>
</footer>
<button id="go2top" class="d-print-none" title="返回顶部">
<span class="oxy-icon oxy-icon-up"></span>
</button>
<div id="modal_img_large" class="modal">
<span class="close oxy-icon oxy-icon-remove"></span>
<div id="modal_img_container"></div>
<div id="caption"></div>
</div>
<script src="${pd}/publishing/publishing-styles-AIC-template/js/custom.js" defer="defer"></script>
</body>
</html>