Xilinx zynqmp USB开发-程序员宅基地

技术标签: Xilinx Zynq/ZynqMP处理器开发  usb  zynqmp  

作者

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_probe
  zynqmp_xhci_core_init

u-boot下操作usb,

ZynqMP> usb
usb - USB sub-system

Usage:
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) found
       scanning usb for storage devices... 0 Storage Device(s) found
       
ZynqMP> 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) found
       scanning 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 001A4D5F1A5CB0419945C2A1
     
ZynqMP> 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.0
   Configuration: 1
   - Interfaces: 1 Self Powered 0mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms

2: 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.16
   Configuration: 1
   - Interfaces: 1 Bus Powered 300mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 2
     - Class Mass Storage, Transp. SCSI, Bulk only
     - Endpoint 1 In Bulk MaxPacket 512
     - Endpoint 2 Out Bulk MaxPacket 512

ZynqMP> usb storage
  Device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler 2.0
            Type: Removable Hard Disk
            Capacity: 14766.0 MB = 14.4 GB (30240768 x 512)

ZynqMP> usb dev

IDE device 0: Vendor: Kingston Rev: PMAP Prod: DataTraveler 2.0
            Type: Removable Hard Disk
            Capacity: 14766.0 MB = 14.4 GB (30240768 x 512)
            
ZynqMP> usb part

Partition Map for USB device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     16128           30224640        8d9140c4-01     0c Boot

linux

驱动分析

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

dwc3_probe
  dwc3_get_properties //获取设备树属性
    usb_get_maximum_speed //USB_SPEED_SUPER "super-speed"
    usb_get_dr_mode
    of_usb_get_phy_mode dwc->hsphy_mode //nothing to be done when hsphy_mode == ulpi
    snps,hsphy_interface //used when DWC3_GHWPARAMS3 == DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI
    dwc3_simple_check_quirks //针对Xilinx的芯片修正,drivers\usb\dwc3\dwc3-of-simple.c
  dwc3_cache_hwparams
    DWC3_GHWPARAMS3 //DWC_USB3_HSPHY_INTERFACE = 0x2
  dma_set_coherent_mask
  dwc3_get_dr_mode //根据上面设备树和内核驱动配置设置芯片是host还是peripheral
  dwc3_core_init
    dwc3_core_get_phy
      dwc->usb2_phy/dwc->usb3_phy
      dwc->usb2_generic_phy/dwc->usb3_generic_phy
    dwc3_core_soft_reset
      usb_phy_init usb2_phy/usb3_phy/usb2_generic_phy/usb3_generic_phy
    dwc3_config_soc_bus
    dwc3_phy_setup
      dwc3_ulpi_init //DWC3_GHWPARAMS3 == DWC3_GHWPARAMS3_HSPHY_IFC_ULPI
        ulpi_register_interface
          ulpi_register
            
    ...
    usb_phy_set_suspend dwc->usb2_phy
	usb_phy_set_suspend dwc->usb3_phy
	phy_power_on dwc->usb2_generic_phy
    phy_power_on dwc->usb3_generic_phy
    ...
  dwc3_check_params
  dwc3_core_init_mode
    otg_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
date

date
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。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Zhu_Zhu_2009/article/details/100067176

智能推荐

EasyDarwin开源流媒体云平台之EasyRMS录播服务器功能设计_开源录播系统-程序员宅基地

文章浏览阅读3.6k次。需求背景EasyDarwin开发团队维护EasyDarwin开源流媒体服务器也已经很多年了,之前也陆陆续续尝试过很多种服务端录像的方案,有:在EasyDarwin中直接解析收到的RTP包,重新组包录像;也有:在EasyDarwin中新增一个RecordModule,再以RTSPClient的方式请求127.0.0.1自己的直播流录像,但这些始终都没有成气候;我们的想法是能够让整套EasyDarwin_开源录播系统

oracle Plsql 执行update或者delete时卡死问题解决办法_oracle delete update 锁表问题-程序员宅基地

文章浏览阅读1.1w次。今天碰到一个执行语句等了半天没有执行:delete table XXX where ......,但是在select 的时候没问题。后来发现是在执行select * from XXX for update 的时候没有commit,oracle将该记录锁住了。可以通过以下办法解决: 先查询锁定记录 Sql代码 SELECT s.sid, s.seri_oracle delete update 锁表问题

Xcode Undefined symbols 错误_xcode undefined symbols:-程序员宅基地

文章浏览阅读3.4k次。报错信息error:Undefined symbol: typeinfo for sdk::IConfigUndefined symbol: vtable for sdk::IConfig具体信息:Undefined symbols for architecture x86_64: "typeinfo for sdk::IConfig", referenced from: typeinfo for sdk::ConfigImpl in sdk.a(config_impl.o) _xcode undefined symbols:

项目05(Mysql升级07Mysql5.7.32升级到Mysql8.0.22)_mysql8.0.26 升级32-程序员宅基地

文章浏览阅读249次。背景《承接上文,项目05(Mysql升级06Mysql5.6.51升级到Mysql5.7.32)》,写在前面需要(考虑)检查和测试的层面很多,不限于以下内容。参考文档https://dev.mysql.com/doc/refman/8.0/en/upgrade-prerequisites.htmllink推荐阅读以上链接,因为对应以下问题,有详细的建议。官方文档:不得存在以下问题:0.不得有使用过时数据类型或功能的表。不支持就地升级到MySQL 8.0,如果表包含在预5.6.4格_mysql8.0.26 升级32

高通编译8155源码环境搭建_高通8155 qnx 源码-程序员宅基地

文章浏览阅读3.7k次。一.安装基本环境工具:1.安装git工具sudo apt install wget g++ git2.检查并安装java等环境工具2.1、执行下面安装命令#!/bin/bashsudoapt-get-yinstall--upgraderarunrarsudoapt-get-yinstall--upgradepython-pippython3-pip#aliyunsudoapt-get-yinstall--upgradeopenjdk..._高通8155 qnx 源码

firebase 与谷歌_Firebase的好与不好-程序员宅基地

文章浏览阅读461次。firebase 与谷歌 大多数开发人员都听说过Google的Firebase产品。 这就是Google所说的“ 移动平台,可帮助您快速开发高质量的应用程序并发展业务。 ”。 它基本上是大多数开发人员在构建应用程序时所需的一组工具。 在本文中,我将介绍这些工具,并指出您选择使用Firebase时需要了解的所有内容。 在开始之前,我需要说的是,我不会详细介绍Firebase提供的所有工具。 我..._firsebase 与 google

随便推点

k8s挂载目录_kubernetes(k8s)的pod使用统一的配置文件configmap挂载-程序员宅基地

文章浏览阅读1.2k次。在容器化应用中,每个环境都要独立的打一个镜像再给镜像一个特有的tag,这很麻烦,这就要用到k8s原生的配置中心configMap就是用解决这个问题的。使用configMap部署应用。这里使用nginx来做示例,简单粗暴。直接用vim常见nginx的配置文件,用命令导入进去kubectl create cm nginx.conf --from-file=/home/nginx.conf然后查看kub..._pod mount目录会自动创建吗

java计算机毕业设计springcloud+vue基于微服务的分布式新生报到系统_关于spring cloud的参考文献有啥-程序员宅基地

文章浏览阅读169次。随着互联网技术的发发展,计算机技术广泛应用在人们的生活中,逐渐成为日常工作、生活不可或缺的工具,高校各种管理系统层出不穷。高校作为学习知识和技术的高等学府,信息技术更加的成熟,为新生报到管理开发必要的系统,能够有效的提升管理效率。一直以来,新生报到一直没有进行系统化的管理,学生无法准确查询学院信息,高校也无法记录新生报名情况,由此提出开发基于微服务的分布式新生报到系统,管理报名信息,学生可以在线查询报名状态,节省时间,提高效率。_关于spring cloud的参考文献有啥

VB.net学习笔记(十五)继承与多接口练习_vb.net 继承多个接口-程序员宅基地

文章浏览阅读3.2k次。Public MustInherit Class Contact '只能作基类且不能实例化 Private mID As Guid = Guid.NewGuid Private mName As String Public Property ID() As Guid Get Return mID End Get_vb.net 继承多个接口

【Nexus3】使用-Nexus3批量上传jar包 artifact upload_nexus3 批量上传jar包 java代码-程序员宅基地

文章浏览阅读1.7k次。1.美图# 2.概述因为要上传我的所有仓库的包,希望nexus中已有的包,我不覆盖,没有的添加。所以想批量上传jar。3.方案1-脚本批量上传PS:nexus3.x版本只能通过脚本上传3.1 批量放入jar在mac目录下,新建一个文件夹repo,批量放入我们需要的本地库文件夹,并对文件夹授权(base) lcc@lcc nexus-3.22.0-02$ mkdir repo2..._nexus3 批量上传jar包 java代码

关于去隔行的一些概念_mipi去隔行-程序员宅基地

文章浏览阅读6.6k次,点赞6次,收藏30次。本文转自http://blog.csdn.net/charleslei/article/details/486519531、什么是场在介绍Deinterlacer去隔行处理的方法之前,我们有必要提一下关于交错场和去隔行处理的基本知识。那么什么是场呢,场存在于隔行扫描记录的视频中,隔行扫描视频的每帧画面均包含两个场,每一个场又分别含有该帧画面的奇数行扫描线或偶数行扫描线信息,_mipi去隔行

ABAP自定义Search help_abap 自定义 search help-程序员宅基地

文章浏览阅读1.7k次。DATA L_ENDDA TYPE SY-DATUM. IF P_DATE IS INITIAL. CONCATENATE SY-DATUM(4) '1231' INTO L_ENDDA. ELSE. CONCATENATE P_DATE(4) '1231' INTO L_ENDDA. ENDIF. DATA: LV_RESET(1) TY_abap 自定义 search help