作者

QQ群:852283276
微信:arm80x86
微信公众号:青儿创客基地
B站:主页 https://space.bilibili.com/208826118

参考

Linux USB DWC3 Host/Peripheral Driver
Zynq Ultrascale MPSOC Linux USB device driver
U-Boot USB Driver
Zynq UltraScale+ MPSoC USB 3.0 Mass Storage Device Class Design
Zynq UltraScale+ MPSoC USB 3.0 CDC Device Class Design
Linux USB Gadget Driver
USB Host System Setup
USB Host Controller Driver
AXI USB Device Driver
AXI USB gadget driver
USB boot with Linux 2015.2 build
[U-Boot,3/4] ARM64: zynqmp: Add support for USB ulpi phy reset via mode pins
USB Phy/ULPI (2-读写USB Phy寄存器)
USB2 UAS NULL pointer dereference
USB Mass Storage大容量存储的基本知识
怎么通过 /proc/scsi/usb-storage来确定u盘是/dev/sdb还是sdc
如何实现Linux下的U盘(USB Mass Storage)驱动
USB3.0 HDMI输入方案之FT601Q
米联客(MSXBO)USB3.0 FT600/FT601/FT602测试图集
米联客(MSXBO)USB3.0 UVC摄像头实现基于FT602Q芯片方案
【工程师分享】MPSoC设计中USB Phy的复位信号

介绍

zynqmp上用的是synopsis的ip,dwc3。

u-boot

基于zcu102开发板的基本配置,配错了编译都无法通过,

CONFIG_USB=y
CONFIG_USB_ULPI_VIEWPORT=y
CONFIG_USB_ULPI=y
CONFIG_USB_STORAGE=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_MANUFACTURER="Xilinx"
CONFIG_USB_GADGET_VENDOR_NUM=0x03fd
CONFIG_USB_GADGET_PRODUCT_NUM=0x0300
CONFIG_CMD_USB=y
CONFIG_USB_DWC3=y
CONFIG_USB_XHCI_DWC3=y
CONFIG_USB_XHCI_ZYNQMP=y
CONFIG_USB_DWC3_GADGET=y
CONFIG_USB_HOST=y
CONFIG_USB_DWC3_GENERIC=y
CONFIG_ZYNQMP_USB=y
CONFIG_USB_STORAGE=y
CONFIG_USB_XHCI_HCD=y
CONFIG_USB_GADGET_DOWNLOAD=y

代码,dwc3 usb驱动入口在drivers\usb\dwc3\dwc3-generic.cdwc3_generic_bind函数遍历设备树子节点,绑定host,peripheral或otg的驱动,子节点驱动不使用设备树来获取,对于host类型,绑定的子节点驱动为drivers\usb\host\xhci-zynqmp.c

//drivers\usb\dwc3\dwc3-generic.c
dwc3_generic_bind (trigger)->>
//drivers\usb\host\xhci-zynqmp.c
xhci_usb_probezynqmp_xhci_core_init

u-boot下操作usb,

ZynqMP> usb
usb - USB sub-systemUsage:
usb start - start (scan) USB controller
usb reset - reset (rescan) USB controller
usb stop [f] - stop USB [f]=force stop
usb tree - show USB device tree
usb info [dev] - show available USB devices
usb test [dev] [port] [mode] - set USB 2.0 test mode(specify port 0 to indicate the device's upstream port)Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable]
usb storage - show details of USB storage devices
usb dev [dev] - show or set current USB storage device
usb part [dev] - print partition table of one or all USB storage    devices
usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'to memory address `addr'
usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'from memory address `addr'ZynqMP> usb start
starting USB...
USB0:   Register 2000440 NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus 0 for devices... 1 USB Device(s) foundscanning usb for storage devices... 0 Storage Device(s) foundZynqMP> usb tree
USB device tree:1  Hub (5 Gb/s, 0mA)U-Boot XHCI Host Controller ZynqMP> usb reset
resetting USB...
USB0:   Register 2000440 NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) foundscanning usb for storage devices... 1 Storage Device(s) found
ZynqMP> usb tree
USB device tree:1  Hub (5 Gb/s, 0mA)|  U-Boot XHCI Host Controller |+-2  Mass Storage (480 Mb/s, 300mA)Kingston DataTraveler 2.0 001A4D5F1A5CB0419945C2A1ZynqMP> usb info
1: Hub,  USB Revision 3.0- U-Boot XHCI Host Controller - Class: Hub- PacketSize: 512  Configurations: 1- Vendor: 0x0000  Product 0x0000 Version 1.0Configuration: 1- Interfaces: 1 Self Powered 0mAInterface: 0- Alternate Setting 0, Endpoints: 1- Class Hub- Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms2: Mass Storage,  USB Revision 2.0- Kingston DataTraveler 2.0 001A4D5F1A5CB0419945C2A1- Class: (from Interface) Mass Storage- PacketSize: 64  Configurations: 1- Vendor: 0x0930  Product 0x6545 Version 1.16Configuration: 1- Interfaces: 1 Bus Powered 300mAInterface: 0- Alternate Setting 0, Endpoints: 2- Class Mass Storage, Transp. SCSI, Bulk only- Endpoint 1 In Bulk MaxPacket 512- Endpoint 2 Out Bulk MaxPacket 512ZynqMP> usb storageDevice 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler 2.0Type: Removable Hard DiskCapacity: 14766.0 MB = 14.4 GB (30240768 x 512)ZynqMP> usb devIDE device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler 2.0Type: Removable Hard DiskCapacity: 14766.0 MB = 14.4 GB (30240768 x 512)ZynqMP> usb partPartition Map for USB device 0  --   Partition Type: DOSPart    Start Sector    Num Sectors     UUID            Type1     16128           30224640        8d9140c4-01     0c Boot

linux

驱动分析

xilinx驱动入口代码drivers\usb\dwc3\dwc3-of-simple.c,dwc3驱动入口代码drivers\usb\dwc3\core.c

dwc3_probedwc3_get_properties //获取设备树属性usb_get_maximum_speed //USB_SPEED_SUPER "super-speed"usb_get_dr_modeof_usb_get_phy_mode dwc->hsphy_mode //nothing to be done when hsphy_mode == ulpisnps,hsphy_interface //used when DWC3_GHWPARAMS3 == DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPIdwc3_simple_check_quirks //针对Xilinx的芯片修正,drivers\usb\dwc3\dwc3-of-simple.cdwc3_cache_hwparamsDWC3_GHWPARAMS3 //DWC_USB3_HSPHY_INTERFACE = 0x2dma_set_coherent_maskdwc3_get_dr_mode //根据上面设备树和内核驱动配置设置芯片是host还是peripheraldwc3_core_initdwc3_core_get_phydwc->usb2_phy/dwc->usb3_phydwc->usb2_generic_phy/dwc->usb3_generic_phydwc3_core_soft_resetusb_phy_init usb2_phy/usb3_phy/usb2_generic_phy/usb3_generic_phydwc3_config_soc_busdwc3_phy_setupdwc3_ulpi_init //DWC3_GHWPARAMS3 == DWC3_GHWPARAMS3_HSPHY_IFC_ULPIulpi_register_interfaceulpi_register...usb_phy_set_suspend dwc->usb2_phyusb_phy_set_suspend dwc->usb3_phyphy_power_on dwc->usb2_generic_phyphy_power_on dwc->usb3_generic_phy...dwc3_check_paramsdwc3_core_init_modeotg_set_vbus(usb2_phy)/phy_set_mode(usb2_generic_phy)dwc3_debugfs_init
...

设备树

设备树节点含义,

 - usb-phy : array of phandle for the PHY device.  The first element in the array is expected to be a handle to the USB2/HS PHY and the second element is expected to be a handle to the USB3/SS PHY- phys: from the *Generic PHY* bindings- phy-names: from the *Generic PHY* bindings; supported names are "usb2-phy" or "usb3-phy".

例子,

&pinctrl0 {pinctrl_usb0_default: usb0-default {mux {groups = "usb0_0_grp";function = "usb0";};conf {groups = "usb0_0_grp";slew-rate = <1>;/*SLEW_RATE_SLOW*/io-standard = <1>;/*IO_STANDARD_LVCMOS18*/};conf-rx {pins = "MIO52", "MIO53", "MIO55";bias-high-impedance;};conf-tx {pins = "MIO54", "MIO56", "MIO57", "MIO58", "MIO59","MIO60", "MIO61", "MIO62", "MIO63";bias-disable;};};
};&usb0 {pinctrl-names = "default";pinctrl-0 = <&pinctrl_usb0_default>;
};&dwc3_0 {dr_mode = "host";snps,usb3_lpm_capable;phy-names = "usb3-phy";phys = <&lane0 4 0 2 100000000>;/*2->PHY_TYPE_USB3=4*/maximum-speed = "super-speed";
};

开机打印,

[    7.690943] xilinx-psgtr fd400000.zynqmp_phy: Lane:2 type:0 protocol:3 pll_locked:yes
[    7.698965] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[    7.704383] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 1
[    7.712216] xhci-hcd xhci-hcd.0.auto: hcc params 0x0238f625 hci version 0x100 quirks 0x22010010
[    7.720864] xhci-hcd xhci-hcd.0.auto: irq 48, io mem 0xfe200000
[    7.726853] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    7.733562] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    7.740765] usb usb1: Product: xHCI Host Controller
[    7.745626] usb usb1: Manufacturer: Linux 4.14.0-xilinx-v2018.2 xhci-hcd
[    7.752308] usb usb1: SerialNumber: xhci-hcd.0.auto
[    7.757438] hub 1-0:1.0: USB hub found
[    7.761132] hub 1-0:1.0: 1 port detected
[    7.765189] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[    7.770607] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 2
[    7.778286] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[    7.786385] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003
[    7.793098] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    7.800301] usb usb2: Product: xHCI Host Controller
[    7.805159] usb usb2: Manufacturer: Linux 4.14.0-xilinx-v2018.2 xhci-hcd
[    7.811843] usb usb2: SerialNumber: xhci-hcd.0.auto
[    7.816926] hub 2-0:1.0: USB hub found
[    7.820617] hub 2-0:1.0: 1 port detected

大概测了一个SSD的速度,读写都可以达到292.57MB/s

root@xilinx-zcu104-2018_2:~# cat test.sh
#!/bin/sh
date
dd if=/dev/zero of=/dev/sda1 bs=4M count=512
datedate
dd if=/dev/sda1 of=/dev/null bs=4M count=512
date
root@xilinx-zcu104-2018_2:~# ./test.sh
Fri Jul  6 04:20:40 UTC 2018
512+0 records in
512+0 records out
Fri Jul  6 04:20:46 UTC 2018
Fri Jul  6 04:20:46 UTC 2018
512+0 records in
512+0 records out
Fri Jul  6 04:20:52 UTC 2018

读写ULPI PHY寄存器

zynqmp通过GUSB2PHYACC_ULPI寄存器来访问ULPI PHY,地址,

  • 0xFE20C280 (USB3_0_XHCI)
  • 0xFE30C280 (USB3_1_XHCI)


读PHY芯片 USB3315 ID,

ZynqMP> mw 0xFE20C280 0x2000000
ZynqMP> md 0xFE20C280 1
fe20c280: 01000024                               $...

SMSC 3320

在 USB 控制器针对 USB 2.0 配置以及启用待机/重启状态时,该控制器会通过发送 ULPI PHY 单命令来选择终止和收发器。在 PHY 要求这些通过两个单独的命令发送时,这会导致系统挂起。GUCTL1(0x0000C11C)寄存器的位 10 需要设置为 1,以便实现与 USB 2.0 PHY 设备(SMSC 3320)的更佳互操作性,以及预防高速设备的挂起/恢复有任何问题(06/13/2017 AR# 67667)。

UAS

UAS在2018.2还不稳定,等待改进,建议使用usb-storage (BOT) driver。

Xilinx zynqmp USB开发相关推荐

  1. Xilinx zynq USB开发

    如何区分/dev/input/event cat /proc/bus/input/devices Xilinx zynq USB开发 https://blog.csdn.net/Zhu_Zhu_200 ...

  2. Android USB 开发详解

    Android USB 开发详解 先附上 Android USB 官方文档 Android通过两种模式支持各种 USB 外设和 Android USB 附件(实现Android附件协议的硬件):USB ...

  3. Xilinx 黑金ZYNQ开发板AX7020,利用VIVADO进行FPGA程序烧录

    参考黑金的AX7020开发板资料中的SDK实验篇PDF教程文件. (1)创建工程,步骤与SDK实验篇中的步骤一致:配置PS端时应该可以只选需要的加载方式,如QSPI或者SD,我目前是两种都勾选了,但是 ...

  4. 【安卓USB开发】让手机与物联网设备鹊桥相会

    安卓USB开发详解 一.前言 1.是什么 2.为什么 3.怎么做 二.简析USB 1.外部总线标准 2.主从结构星型拓扑 3.自.总供电模式 4.OTG 5.数据传输模式 6.小结 三.安卓USB开发 ...

  5. Android USB开发小结:host模式与accessory模式

    很早之前就想对Android USB的两种模式作个小结,但是一直没有空去搞,毕竟USB这块应该属于冷门方向,并且应用层能够做的比较少也很简单.最近刚好在做大疆无人机的二次开发,想着对USB连接检测这块 ...

  6. Linux libusb USB开发(一)—— USB设备基础概念

    在终端用户看来,USB设备为主机提供了多种多样的附加功能,如文件传输,声音播放等,但对USB主机来说,它与所有USB设备的接口都是一致的.一个USB设备由3个功能模块组成:USB总线接口.USB逻辑设 ...

  7. 《USB开发大全》—USB软硬件开发指南,无可替代的工具书

    <USB开发大全>-USB软硬件开发指南,无可替代的工具书 内容简介 <USB开发大全(第4版)>介绍了有关通用串行总线(Universal Serial Bus,USB)的工 ...

  8. 嵌入式USB开发系列(1):USB简介

    嵌入式USB开发系列(1):USB简介 文章目录 嵌入式USB开发系列(1):USB简介 1. USB的优势 2. USB协议标准 3. USB通信接口 声明 声明:USB资料网站 链接,相关协议和文 ...

  9. Vivado将程序固化到Xilinx的FPGA开发板的flash芯片中

    Vivado将程序固化到Xilinx的FPGA开发板 准备工作 开始 准备.mcs文件 在HardWare Manager界面操作 固化程序到flash中 对开发板进行操作 另外 准备工作 Vivad ...

  10. android usb设置波特率,USB开发中设置波特率

    最近在做Android设备与外设通信,需要用的串口通信.如果使用android-serialport-api发现Android设备需要获取root权限,否则会报权限不足的异常.所以决定使用Androi ...

最新文章

  1. Struts的select两种遍历方法
  2. AJAX实现简单的注册页面异步请求
  3. seo说_百度指数看世间沉浮_如何快速排名-互点快速排名_网站seo优化排名,网络推广的优化服务...
  4. android导航二级分类,Android实现腾讯新闻的新闻类别导航效果
  5. Android之在ubuntu上用aapt查看apk的名字以及相关信息
  6. wso2 esb_使用WSO2 ESB进行邮件内容过滤
  7. 航测大数据量处理_揭秘航测局“航空摄影质量自动检查系统”的“黑科技”
  8. boot lvm 分区_LVM磁盘逻辑卷管理
  9. 视觉SLAM笔记(30) 特征点法
  10. Linux系统是什么
  11. C#利用WCF改进文件流传输的三种方式
  12. 因社会不公大学生找不到工作
  13. java面试自我介绍
  14. mac操作系统如何访问共享计算机,windows电脑怎么访问苹果电脑共享文件夹
  15. 好看的皮囊 · 也是大自然的杰作 · 全球高质量 · 美图 · 集中营 · 美女 · 2017-08-22期...
  16. python虚拟串口_python 虚拟串口通信
  17. 证明HITTING SET 是NP完全
  18. 大数据在快狗打车中的应用与实践
  19. 如何用计算机名查看共享打印机,如何查找网络共享打印机名称
  20. ChatGPT替代品使用指南

热门文章

  1. shader篇-处理复杂光照
  2. 安兔兔:2018年8月iOS设备性能排行榜
  3. 杭州是个技术乐观派的城市
  4. 行为树 --- [4] 简单树
  5. 第六版PMBOK豆知识
  6. H5:MathJax解析数学公式
  7. 如何查询域名whois?域名whois查询能获得哪些信息
  8. owncloud 私有云搭建
  9. win2008系统漏洞扫描所得的几个漏洞详解
  10. 中国有多少家银行?(最全名单统计)