The last time I talked about USB not booting was caused by the incorrect configuration of the Emio pin in the Vivado project, and how is this pin used on the software?
First, the Linux SDK provided by Xilinx already contains gpio drivers and Sysfs to match, and the OTG-RESETN is configured and declared in the device tree file.
Second, in practical use, the USB-OTG driver applies the OTG-RESETN to the system to complete the configuration of the PHY chip.
After booting, review the relevant status information for the GPIO in SYSFS:
cat /sys/kernel/debug/906-1023, parent:platform/E000a000.gpio, Zynq_gpio: Gpio-991 ( | ulpi resetb ) Out Hi[email protected]-ubuntu-desktop:~#
The number No. 991 Gpio is being used, labeled "Ulpi Resetb", which is literally known to have a relationship with the usb-phy and reset signals. The GPIO is the output state and the level is high.
The Usb-phy chip is low-reset and is now working properly.
Find the string "Ulpi Resetb" in the Linux kernel, located in the directory with the Usb-host driver file.
find . -type f "*.c"xargsgrep"ulpi resetb" . /DRIVERS/USB/CHIPIDEA/CORE.C: "ulpi resetb");
Open this file, find the relevant code, found that the usb-phy chip initialization has done two work
One is to read the relevant configuration in the device tree, and the second is to apply the Gpio to the Sysfs file system and set the low level, labeled "Ulpi Resetb".
Static intCi_hdrc_create_ulpi_phy (structDevice *dev,structCI_HDRC *ci) { structUsb_phy *ULPI; intReset_gpio; intret; Reset_gpio = Of_get_named_gpio (Dev->parent->of_node, "Xlnx,phy-reset-gpio", 0); Read related configuration in the device treeif(Gpio_is_valid (Reset_gpio)) { ret = Devm_gpio_request_one (Dev, Reset_gpio,//Applies the gpio to the Sysfs file system and initializes Gpiof_init_low, "Ulpi Resetb"); if(ret) {dev_err (dev,"Failed to request ULPI reset Gpio:%d\n", ret); returnret; } msleep (5); Gpio_set_value_cansleep (Reset_gpio,1); Msleep (1); } ULPI= Otg_ulpi_create (&Ulpi_viewport_access_ops, Ulpi_otg_drvvbus|ulpi_otg_drvvbus_ext); if(ULPI) {ULPI->io_priv = Ci->hw_bank.abs +0x170; CI->usb_phy =ULPI; } return 0;}
Then look at the device tree, driven by the above information, the number No. 991 pin in the device tree name is "Xlnx,phy-reset-gpio", in the directory search
[Email protected]:~/work/linux_xilinx/linux/arch/arm/boot/dts$Find. -type F-name"*zynq*.dts*"|Xargs grep "Phy-reset-gpio"./zynq-picozed-sdr2.dtsi:xlnx,phy-reset-gpio = <&gpio07 0>;./zynq-zc702.dts:phy-reset-gpio = <&gpio0 One 0>;./zynq-microzed.dtsi:xlnx,phy-reset-gpio = <&gpio07 0>;./zynq-zc706.dtsi:xlnx,phy-reset-gpio = <&gpio07 0>;./zynq-picozed-sdr-userspace.dts:xlnx,phy-reset-gpio = <&gpio07 0>;./zynq-picozed-sdr1.dtsi:xlnx,phy-reset-gpio = <&gpio07 0>; ./zynq-zed.dtsi:xlnx,phy-reset-gpio = <&gpio0 0>;./zynq-zc702.dtsi:xlnx,phy-reset-gpio = <&gpio07 0>;./zynq-mini-itx.dtsi:xlnx,phy-reset-gpio = <&gpio07 0>;
Zynq-zed.dtsi is the dependent file that generates the device tree, which is a configuration in usb0.
&usb0 { xlnx,phy0>;};
Now there is one question, what is the relationship between gpio-991 and <&gpio0 0>?
The ZYNQ has 54 Mio and 64 Emio with a total of 118 gpio. Order, the base address of the Gpio is 0xe000_a000.
The description of gpio0 in the device tree is as follows
gpio0: [email protected] {compatible="xlnx,zynq-gpio-1.0"; #gpio-cells = <2>; Clocks= <&CLKC the>; Gpio-Controller; Interrupt-Controller; #interrupt-cells = <2>; Interrupt-parent = <&intc>; Interrupts= <0 - 4>; Reg= <0xe000a000 0x1000>; };
OTG-RESETN corresponds to a network of gpib_bd[31], in 118 in the order of 54-bit mio+31emio=85, is exactly the 85th of the Gpio0.
So how did the 991 of Sysfs come from?
906-1023 platform/ E000a000.gpio, Zynq_gpio:gpio-991 ( |ulpi resetb ) out hi
In fact, 906-1023 has 118 gpio numbers, 85 offsets from 906, and exactly 991, which is the OTG-RESETN signal pin.
Suppose you enter the following command in the terminal:
[Email protected]:~#Echo 979>/sys/class/gpio/export #申请端口号[email protected]-ubuntu-desktop:~#EchoOut >/sys/class/gpio/gpio979/direction #指定IO方向[email protected]-ubuntu-desktop:~#Echo 1>/sys/class/gpio/gpio979/value #写入IO值[email protected]-ubuntu-desktop:~#Cat/sys/kernel/debug/Gpiogpiochip0:gpios906-1023, parent:platform/E000a000.gpio, Zynq_gpio: gpio -979 (| Sysfs) out Hi gpio-991( |ULPI Resetb) out Hi[email protected]-ubuntu-desktop:~#
Will find that the LD0 on the Zedboard is lit, refer to the xdc constraint file;
Set_property -dict {package_pin T22 gpio_bd[19] ; # # LD0
906 Start offset 54+19 units, exactly 979.
The above is to the Vivado in the construction of their own ZYNQ system encountered a little problem to explore, follow-up I will be the smallest system from zero to introduce, so that we can be more in-depth understanding of ZYNQ hardware environment use.
PS: At present, I am also a beginner, these content right when the point, there is what wrong place, also please master correct, greatly appreciated.
Zynq-zedboard USB host problem in the second analysis