精华内容
下载资源
问答
  • Xilinx zynq USB开发

    千次阅读 2020-04-08 12:31:50
    参考 U-Boot USB Driver Zynq Linux USB Device Driver U-Boot USB Driver Zynq-7000 AP SoC USB Mass Storage Device Class Design Example Techtip Z...

    如何区分/dev/input/event

    cat /proc/bus/input/devices

    Xilinx zynq USB开发

    https://blog.csdn.net/Zhu_Zhu_2009/article/details/82954359

    参考

    U-Boot USB Driver
    Zynq Linux USB Device Driver
    U-Boot USB Driver
    Zynq-7000 AP SoC USB Mass Storage Device Class Design Example Techtip
    Zynq-7000 AP SoC USB CDC Device Class Design Example Techtip
    Zynq Linux USB Device Driver
    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
    zynq-7000学习笔记(八)——USB摄像头图像采集
    ZYNQ-ZedBoard USB HOST问题初探
    ZYNQ-ZedBoard USB HOST问题二探
    Zynq usb无法识别
    USB Phy/ULPI (2-读写USB Phy寄存器)
    USB Mass Storage大容量存储的基本知识
    怎么通过 /proc/scsi/usb-storage来确定u盘是/dev/sdb还是sdc
    如何实现Linux下的U盘(USB Mass Storage)驱动
    Zynq Linux USB Driver Customization
    Linux/DRA77P: ULPI USB interface

    介绍

    zynq上用的是chipidea的ip,ULPI 接口要求输入保持时间为1ns,TI TUSB1210 PHY 的最低 CTO 并未规定,但报告的最低 CTO 为 100 ps,无法满足 Zynq-7000 的要求(AR# 53450)。
    When the USB controller is configured in device mode, and Vbus voltage is varied such that it crosses the Vbus valid threshold multiple times, the ULPI interface becomes unresponsive.(AR# 61313)

    u-boot

    u-boot下操作usb,

    zynq-uboot> 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 </span>cnt' blocks starting at block <span class="token variable">blk#’

    to memory address </span>addr' usb <span class="token function">write</span> addr blk# cnt - <span class="token function">write</span> <span class="token variable">cnt’ blocks starting at block </span>blk#' from memory address <span class="token variable">addr’
    zynq-uboot> usb start
    starting USB.
    USB0: USB EHCI 1.00
    scanning bus 0 for devices. 3 USB Device(s) found
    USB1: usb1 wrong num MIO: 0, Index 1
    lowlevel init failed
    scanning usb for storage devices. 1 Storage Device(s) found
    zynq-uboot> usb tree
    USB device tree:
    1 Hub (480 Mb/s, 0mA)
    | u-boot EHCI Host Controller
    |
    ±2 Hub (480 Mb/s, 2mA)
    |
    ±3 Mass Storage (480 Mb/s, 300mA)
    Kingston DataTraveler 2.0 001A4D5F1A5CB0419945C2A1

    zynq-uboot> usb info
    1: Hub, USB Revision 2.0

    • u-boot EHCI Host Controller
    • Class: Hub
    • PacketSize: 64 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: Hub, USB Revision 2.0

    • Class: Hub
    • PacketSize: 64 Configurations: 1
    • Vendor: 0x0424 Product 0x2514 Version 11.179
      Configuration: 1
      • Interfaces: 1 Self Powered Remote Wakeup 2mA
        Interface: 0
        • Alternate Setting 0, Endpoints: 1
        • Class Hub
        • Endpoint 1 In Interrupt MaxPacket 1 Interval 12ms
        • Endpoint 1 In Interrupt MaxPacket 1 Interval 12ms

    3: 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
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73

    linux

    petalinux 2018.2下的内核与设备树,

    Device Drivers
    USB support
        <*> Support for Host-side USB
        <*> EHCI HCD (USB 2.0) support
        <*> USB Mass Storage support
        <*> ChipIdea Highspeed Dual Role Controller
        <*> ChipIdea host controller
            USB Physical Layer drivers --->
            <*> Generic ULPI Transceiver Driver
    

    usb_0: usb@e0002000 {
    compatible = “xlnx,zynq-usb-2.20.a”, “chipidea,usb2”;
    clocks = <&clkc 28>
    dr_mode = “host”;
    interrupt-parent = <&intc>;
    interrupts = <0 21 4>;
    reg = <0xe0002000 0x1000>;
    usb-phy = <&usb_phy0>;
    };

    usb_phy0: phy0 { //Z:\program\fdk\bsp\zynqmp\linux-xlnx-v2018.2\drivers\usb\phy\phy-ulpi.c
    compatible = “ulpi-phy”;
    #phy-cells = <0>;
    reg = <0xe0002000 0x1000>;
    view-port = <0x170>;
    drv-vbus;
    }

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    petalinux 2015.2.1也是"xlnx,zynq-usb-2.20.a",参考drivers\usb\chipidea\ci_hdrc_usb2.c,petalinux 2015.2.1下的设备树,

    &usb0 {
    	compatible = "xlnx,zynq-usb-2.20.a";
    	dr_mode = "host";
    	phy_type = "ulpi";
    	status = "okay";
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    对内核打补丁,

    static int ci_hdrc_create_ulpi_phy(struct device *dev, struct ci_hdrc *ci)
    {
            struct usb_phy *ulpi;
            int reset_gpio;
            int ret;
    
        reset_gpio <span class="token operator">=</span> <span class="token function">of_get_named_gpio</span><span class="token punctuation">(</span>dev<span class="token operator">-&gt;</span>parent<span class="token operator">-&gt;</span>of_node<span class="token punctuation">,</span> <span class="token string">"xlnx,phy-reset-gpio"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">gpio_is_valid</span><span class="token punctuation">(</span>reset_gpio<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                ret <span class="token operator">=</span> <span class="token function">devm_gpio_request_one</span><span class="token punctuation">(</span>dev<span class="token punctuation">,</span> reset_gpio<span class="token punctuation">,</span> GPIOF_INIT_LOW<span class="token punctuation">,</span> <span class="token string">"ulpi resetb"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span> <span class="token punctuation">(</span>ret<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                        <span class="token function">dev_err</span><span class="token punctuation">(</span>dev<span class="token punctuation">,</span> <span class="token string">"Failed to request ULPI reset gpio: %d\n"</span><span class="token punctuation">,</span> ret<span class="token punctuation">)</span><span class="token punctuation">;</span>
                        <span class="token keyword">return</span> ret<span class="token punctuation">;</span>
                <span class="token punctuation">}</span>
                <span class="token function">msleep</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">gpio_set_value_cansleep</span><span class="token punctuation">(</span>reset_gpio<span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">msleep</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    
        ulpi <span class="token operator">=</span> <span class="token function">otg_ulpi_create</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>ulpi_viewport_access_ops<span class="token punctuation">,</span>
                ULPI_OTG_DRVVBUS <span class="token operator">|</span> ULPI_OTG_DRVVBUS_EXT<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>ulpi<span class="token punctuation">)</span> <span class="token punctuation">{</span>
                ulpi<span class="token operator">-&gt;</span>io_priv <span class="token operator">=</span> ci<span class="token operator">-&gt;</span>hw_bank<span class="token punctuation">.</span>abs <span class="token operator">+</span> <span class="token number">0x170</span><span class="token punctuation">;</span>
                ci<span class="token operator">-&gt;</span>usb_phy <span class="token operator">=</span> ulpi<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    
        <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
    

    }

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    开机打印,

    ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
    ehci-pci: EHCI PCI platform driver
    usbcore: registered new interface driver usb-storage
    e0002000.usb supply vbus not found, using dummy regulator
    ULPI transceiver vendor/product ID 0x0451/0x1507
    Found TI TUSB1210 ULPI transceiver.
    ULPI integrity check: passed.
    ci_hdrc ci_hdrc.0: EHCI Host Controller
    ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
    ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
    hub 1-0:1.0: USB hub found
    hub 1-0:1.0: 1 port detected
    ...
    hub 1-1:1.0: USB hub found
    hub 1-1:1.0: 4 ports detected
    INIT: version 2.88 booting
    usb 1-1.3: new high-speed USB device number 3 using ci_hdrc
    mount: mounting devtmpfs on /dev failed: Device or resource busy
    usb-storage 1-1.3:1.0: USB Mass Storage device detected
    scsi host0: usb-storage 1-1.3:1.0
    ...
    login[887]: root login on 'ttyPS0'
    scsi 0:0:0:0: Direct-Access     Kingston DataTraveler 2.0 PMAP PQ: 0 ANSI: 6
    sd 0:0:0:0: Attached scsi generic sg0 type 0
    sd 0:0:0:0: [sda] 30240768 512-byte logical blocks: (15.4 GB/14.4 GiB)
    sd 0:0:0:0: [sda] Write Protect is off
    sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
     sda: sda1
    sd 0:0:0:0: [sda] Attached SCSI removable disk
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29

    TUSB1210 OTG_CTRL寄存器,可控制CPEN管脚,配合硬件完成,OTG电源切换,USB3320也是一样,
    196
    zc706 usb原理图,
    197

    读写ULPI PHY寄存器

    zynq的usb0基地址在0xE0002000,usb1在0xE0003000,通过ULPI Viewport来访问寄存器,zynq芯片不能使用ULPI Viewport读写ULPI PHY的扩展寄存器集(地址 0x40 及更高)。写入操作将地址本身写为数据,读取操作返回不正确的数据。
    在这里插入图片描述
    Viewport寄存器,低8位是写入的寄存器地址,
    在这里插入图片描述
    唤醒,

    memtool mw 0xE0002170 0xa0000000
    
    • 1

    读TUSB1210 ID,

    root@zynq:~# memtool mw 0xE0002170 0x40000000
    root@zynq:~# memtool md 0xE0002170+4
    e0002170: 08005100                                           .Q..
    root@zynq:~# memtool mw 0xE0002170 0x40010000
    root@zynq:~# memtool md 0xE0002170+4
    e0002170: 08010400                                           ....
    root@zynq:~# memtool mw 0xE0002170 0x40020000
    root@zynq:~# memtool md 0xE0002170+4
    e0002170: 08020700                                           ....
    root@zynq:~# memtool mw 0xE0002170 0x40030000
    root@zynq:~# memtool md 0xE0002170+4
    e0002170: 08031500 
    

    写OTG_CTRL寄存器,

    memtool mw 0xE0002170 0x400a0000
    memtool md 0xE0002170+4
    
                                    </div>
    
    展开全文
  • Xilinx zynqmp USB开发

    千次阅读 2019-08-25 20:31:28
    参考 Linux USB DWC3 Host/Peripheral ...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...

    作者

    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芯片方案

    介绍

    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。

    展开全文
  • Zynq usb无法识别

    千次阅读 2017-08-11 20:00:55
    最近遇到zynq更新内核版本后usb无法识别问题,查找资料在xilinx wili百科上有关于usb的详细配置: 链接地址:http://www.wiki.xilinx.com/Zynq+Linux+USB+Device+Driver USB host模式下,内核配置的时候需要选中如...


    最近遇到zynq更新内核版本后usb无法识别问题,查找资料在xilinx wiki百科上有关于usb的详细配置:

    链接地址:http://www.wiki.xilinx.com/Zynq+Linux+USB+Device+Driver


    USB host模式下,内核配置的时候需要选中如下图所示选项:


    目前用的2014.3的内核版本, 进入内核源码目录,打开内核图形配置界面:


    进入到usb配置选项,发现如下图所示红框标识的两项没有选中:



    选中后重新编译内核,能正常识别usb设备。



    展开全文
  • zynq linux usb phy寄存器读写工具
  • Zynq移植USB触摸屏

    2020-08-07 12:15:59
    Zynq平台移植USB触摸屏的实现(Qt5.7) 使用的环境: 1. CPU type:ARM CortexA9(Xilinx zynq7000)(使用的是黑金AX7021开发板) 2. Kernel version:4.9 3. no X-window, GUI system:QT5.7 4. Controller...

    Zynq平台移植USB触摸屏的实现(Qt5.7)

    使用的环境:

    1. CPU typeARM CortexA9Xilinx zynq7000)(使用的是黑金AX7021开发板)

    2. Kernel version4.9

    3. no X-window, GUI systemQT5.7

    4. Controller Interface:USB(EETI的EIR4000--eGalax,USB转接板ETP-RAP4502-E)

    5. Controller Type : Resistive(四线电阻触摸屏)

    6. 显示接口:HDMI

     

    需求:在开发板上通过USB接口插入触摸屏,能够校准,能正常在QT中使用。

    一、USB触摸屏驱动

    1、下载驱动包

    由于使用的是EETI的USB转接芯片,从官网https://www.eeti.com/drivers_Linux.html下载最新版驱动包eGTouch_v2.5.8825.L-ma。tar.gz。

    2、修改Linux内核

    按安装包中EETI_eGTouch_Linux_Programming_Guide_v2.5l.pdf说明,修改内核配置和相关驱动源码。由于我使用的是petalinux,在peta_prj工程目录下执行petalinux-config -c kernel (等同make menuconfig)修改:

    按文档“8-1.2  kernel 2.6.34 upwards”修改内核代码。

    重新编译内核:

    petalinux-build

    petalinux-package --boot --fsbl ./images/linux/zynq_fsbl.elf --fpga --u-boot --force打包生成image.ub、BOOT.BIN。拷入SD卡,启动开发板。

    2、开发板加载驱动

    插上USB接口的触摸屏,检查:

    1)UINPUT设备节点是否存在: /dev/input/uinput or /dev/uinput

    2)hidraw device node:/dev/hidraw0

    3)“cat /proc/bus/input/devices”查看是否有eGalax产品的输入设备

    安装驱动包:

    将上述官网下载的安装包解压到目录“eGTouch_v2.5.8825.L-ma”,执行setup.sh。实际上在我的平台上用到的是eGTouchARMhf-->eGTouchARMhfnonX下的“eGTouchD--守护进程,配置文件eGTouchL.ini”。

    注意点:(1)我的系统使用的交叉编译器是arm-linux-gnueabihf-gcc,显然对应的ARM是ARMhf

    (2)利用setup.sh过程实际是修改了配置文件eGTouchL.ini的内容,我最终使用的配置文件如下:

    [eGTouchL.ini]
    DebugEnableBits                 1
    ShowDebugPosition               0
    DeviceNums                      1  #只有一个触摸屏设备
    BaudRate                        0
    ScanInterface                   1
    UseDriverCalib                  0
    SkipFirstByte                   0
    ShiftByteBothEnd                1
    ScanDevStartDelayTime           0
    
    [String]
    SerialPath0                             default
    SerialPath1                             default
    DevPID0                                 null
    DevPID1                                 null
    
    [Device_No.0]
    Physical_Address
    
    #电阻屏单点触摸
    SupportPoints                   1
    
    SendRawPoints                   0
    
    #X、Y坐标方向不准,可以转换
    Direction                       3
    
    Orientation                     0
    EdgeCompensate                  0
            EdgeLeft                        100
            EdgeRight                       100
            EdgeTop                         100
            EdgeBottom                      100
    HoldFilterEnable                1
            HoldRange                       20
    SplitRectMode                   0
            CustomRectLeft                  0
            CustomRectRight                 2047
            CustomRectTop                   0
            CustomRectBottom                2047
    MonitorName                             null
    DetectRotation                  0
    ReportMode                              1
    
    EventType                               1
    
    #Report single event as ABS_PRESSURE. (Generally for Tslib) 
    BtnType                                 1  
    
    RightClickEnable                1
            RightClickDuration              1500
            RightClickRange                 20
    BeepState                       0
            BeepDevice                      0
            BeepFreq                        1000
            BeepLen                         200
    VKEYEnable                      1
            VKEYReportMod           1
                    VKEY_MODIFIER_0         0
            VKEY_0                  0
    [EndOfDevice]
    
    [EndOfFile]
    

    (3)我们也可直接修改eGTouchL.ini文件放置/etc/目录下。

    (4)在安装过程中执行eGTouchD,出现了错误:

    /usr/bin/eGTouchD: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

    原因解释:可能是交叉编译器的版本较高,而系统的GCC版本低需要更高版本的libstdc++.so.6。

    解决方案:从交叉编译器中找到libstdc++.so.6加到当前系统。我是请eGalax的技术重新用我的交叉编译器生成了静态加入libstdc++.so.6库的eGTouchD。

    eGTouchD启动正常后,插入触摸屏,能看到:ls /dev/input/event0节点。当然若有USB鼠标等其它输入设备接入,节点会是event1。

    cat /proc/bus/input/devices可以看到

     

    二、tslib库移植

    在上述驱动加载成功后,可以利用安装包中的测试源码GetEvent.c,交叉编译后执行 ./GetEvent /dev/input/event0。发现能有触摸数据,但数据与屏的尺寸不一致,需要触摸屏校准才能使用。目前EETI不支持NON-X的校正。需要使用tslib來校正触摸屏。

    有关tslib库移植网上资料较多,不详述。

    1、下载tslib-1.4.tar.gz,解压。

    2、确认交叉编译环境,编译生成安装库。

    ./autogen-clean.sh
    ./autogen.sh
    echo "ac_cv_func_malloc_0_nonnull=yes"  > tmp.cache
    ./configure --host=arm-linux-gnueabihf ac_cv_func_malloc_0_nonnull=yes CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ -prefix=/home/alinx/work/touchScreen/tslib/tslib_install

    (--host=arm-linux-gnueabihf  交叉编译器名

    -prefix=/home/alinx/work/touchScreen/tslib/tslib_install 生成的安装库路径。)

    make

    make install

     

    修改ts.conf文件:

    下面是ts.conf文件的第一行与第二行

    # Uncomment if you wish to use the linux input layer event interface

    # module_raw input

    去掉# module_raw input前面的注释,一定注意中间的空格也去掉,module顶格。

    pthres 为Tslib 提供的触摸屏灵敏度门槛插件;

    variance 为Tslib 提供的触摸屏滤波算法插件;

    dejitter 为Tslib 提供的触摸屏去噪算法插件;

    linear 为Tslib 提供的触摸屏坐标变换插件

    进入tslib_install目录,将目录中生成的所有文件打包压缩。

    sudo tar -cvf tslib.tar ./*

    3、ARM板上设置,校准。

    开发板上新建tslib目录,将上述文件解压。

    # mkdir /qt-arm/tslib

    # tar –xvf tslib.tar –C /qt-arm/tslib

    设置环境变量:

    # vim /etc/profile

    export TSLIB_ROOT=/qt-arm/tslib

    // tslib路径

    export LD_LIBRARY_PATH=$TSLIB_ROOT/lib

    // 指定tslib校准库    

    export TSLIB_TSDEVICE=/dev/input/event0

              // 指定触摸屏对应驱动设备

    export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf

             // 指定tslib配置文件

    export TSLIB_CONSOLEDEVICE=none

    // 指定控制台设备为none,这里是LCD显示屏,否则默认/dev/tty,会出现”open consol device:No such file or directory KD…..”的错误

    export TSLIB_FBDEVICE=/dev/fb0

             // 指定帧缓冲设备

    export TSLIB_CALIBFILE=$TSLIB_ROOT/etc/pointercal

    // 校准的数据文件,由ts_calibrate校准程序生成,

    export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts

             //指定tslib数据读取库,插件目录

    更新环境变量

    # source /etc/profile

    运行测验

    cd  /qt-arm/tslib/bin

    ./ts_calibrate      // 校准触摸屏

    ./ts_test          // 测试触摸屏

    出现的问题:

    1、校准触摸屏时看不到屏幕上应该出现的十字定位框。暂时只能估计位置上点击校准。(该问题尚未解决,尚不知原因)

    2、一开始测试触摸屏时,X\Y坐标方向是相反的。修改了eGTouchL.ini文件中的参数:

    Direction                       3     #X\Y坐标均方向相反

    BtnType                        1     #用了tslib必须设为1,否则缺失ABS_PRESSURE事件报告,提示:selected device is not a touchscreen I understand

    三、QTE库移植

    按Alinx开发板提供的QT移植资料完成build.sh,但由于使用了tslib,在编译qte库时需要加入编译参数:

        -qt-mouse-tslib \
        -tslib \
        -I /home/alinx/work/touchScreen/tslib/tslib_install/include \
        -L /home/alinx/work/touchScreen/tslib/tslib_install/lib \

    最后的-I和-L指定到上述移植的tslib的安装目录。

    将生成的QTE库目录打包成qt_lib.img,送到开发板。

    开发板上挂载qt_lib.img到指定目录,如/tmp/qt

    修改qt环境变量:(由于使用QT5,与以前Qt4有较大区别,详细参考了QT官网关于交叉编译说明的翻译https://blog.csdn.net/chongzi865458/article/details/54406865

    export QTDIR=$Cur_Dir
    export QT_QPA_FONTDIR=$QTDIR/fonts
    export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins/
    export LD_LIBRARY_PATH=$QTDIR:$LD_LIBRARY_PATH
    export QT_QPA_PLATFORM=linuxfb
    export QWS_MOUSE_PROTO="Tslib:/dev/input/event0"
    export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event0
    export QT_QPA_GENERIC_PLUGINS=tslib
    export QT_QPA_EGLFS_DISABLE_INPUT=1
    export QT_QPA_FB_DISABLE_INPUT=1
    

    在一开始测试qt程序运行时,出现问题:

    1、界面未出现光标(鼠标箭头)。

    2、点击Qt的应用程序主界面按钮,能动作。但有时点击一次按钮,会出现只有down的动作而没有up,或多了一次down的动作。

    3、点击Qt的应用程序主界面按钮调出子窗口全屏后,在子窗口上的点击动作,子窗口没有接受,反而是已被子窗口隐藏的主窗口有响应。

    以上的问题,若换成USB的鼠标插入系统操作,均是正常的。

    上述2、3问题,经技术咨询,了解QT上不止TSLIB一个触摸源。需要确认,QT上除TSLIB以外的其他触摸源已被关闭。所以临时采用方法是,qt环境变量修改后正常工作:

    export QT_QPA_EGLFS_DISABLE_INPUT=1

    export QT_QPA_FB_DISABLE_INPUT=1

    上述问题1,仍没有解决。

     

    问题总结:

    1、tslib触摸屏叫准时,看不到屏幕上的定位光标。

    2、QT运行后,看不到光标。但触摸动作均正常。

    以上问题尚待解决,有大侠了解的,希望赐教!

    展开全文
  • ZYNQ USB SD驱动问题总结

    千次阅读 2018-03-28 11:27:29
    首先我利用zynq 带的迷你型的文件系统uramdisk.image.gz,启动起来,因为此文件系统全部加载到内存里面运行,启动起来之后,将SD拔出。此后问题没有出现。可能问题出现的SD卡的布线上。当通信频率比较高时,有可能会...

空空如也

空空如也

1 2 3 4 5 ... 12
收藏数 237
精华内容 94
关键字:

usbzynq