参考:官方文档
USB信号完整性取决于许多因素,如电路设计、PCB布局、堆叠和阻抗。每个产品可能彼此不同,因此客户需要微调参数,以获得最佳的信号质量。
测试板已经路由出两个USB端口:一个OTG1,一个主机。每个端口都有几个寄存器来调整信号电压水平和转换速率。请参见文档“配置USB on i.m mx 6 Series (AN4589)”中对寄存器的详细描述。
USB PHY发射机控制寄存器处理传输控制。位字段TXCAL45DP和TXCAL45DM, D_CAL调节输出电压幅值。
ps:该软件不支持OTG的全部功能,该端口通常用作设备或嵌入式主机,由USB_ID选择。
Command samples:
/unit_tests/memtool 0x20c9010 1 // OTG Port Read register data
/unit_tests/memtool 0x20cA010 1 // Host Port Read register data
/unit_tests/memtool 0x20c9010=0x1c060607 //write OTG_PHY_TX1
/unit_tests/memtool 0x20cA010=0x1c060607 //write HOST_PHY_TX
TXCAL45DP、TXCAL45DM:
位域TXCAL45DP和TXCAL45DM可以改变高速终端的电阻。增加终端电阻器的值将增加DM/DP信号电平。
解码选择45欧姆电阻到USB_DP输出引脚。
最大阻力= 0000。
D_CAL
有了这个字段,高速驱动器的当前参考可以修整。
降低电阻将增加驱动器电流,因此传输信号的幅度将增加。
电阻微调代码:
0000 = 0.16%
0111 = NORMAL
1111 = +25%
ps:请记住在调整寄存器之前将DUT连接到相应的主机/设备,否则操作可能无效或可能导致系统崩溃。
imx6qdl.dtsi+&usbphy1 {
+ tx-d-cal = <5>;
+ tx-txcal45dn = <4>;
+ tx-txcal45dp = <4>;
+};
phy-mxs-usb.c+#define HW_USBPHY_TX_TXCAL45DN_MASK 0xf00
+#define HW_USBPHY_TX_TXCAL45DP_MASK 0xf0000#define BM_USBPHY_CTRL_SFTRST BIT(31)#define BM_USBPHY_CTRL_CLKGATE BIT(30)
@@ -191,6 +193,8 @@ struct mxs_phy {struct regulator *phy_3p0;bool hardware_control_phy2_clk;u32 tx_d_cal;
+ u32 tx_txcal45dn;
+ u32 tx_txcal45dp;};static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy)
@@ -264,6 +268,20 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)writel(val | mxs_phy->tx_d_cal, base + HW_USBPHY_TX);}+ /* Change TXCAL45DN if necessary */
+ if (mxs_phy->tx_txcal45dn) {
+ val = readl(base + HW_USBPHY_TX);
+ val &= ~HW_USBPHY_TX_TXCAL45DN_MASK;
+ writel(val | (mxs_phy->tx_txcal45dn << 8), base + HW_USBPHY_TX);
+ }
+
+ /* Change TXCAL45DP if necessary */
+ if (mxs_phy->tx_txcal45dp) {
+ val = readl(base + HW_USBPHY_TX);
+ val &= ~HW_USBPHY_TX_TXCAL45DP_MASK;
+ writel(val | (mxs_phy->tx_txcal45dp << 16), base + HW_USBPHY_TX);
+ }
+return 0;}@@ -637,6 +655,26 @@ static int mxs_phy_probe(struct platform_device *pdev)}}+ if (of_find_property(np, "tx-txcal45dn", NULL)) {
+ ret = of_property_read_u32(np, "tx-txcal45dn",
+ &mxs_phy->tx_txcal45dn);
+ if (ret) {
+ dev_err(&pdev->dev,
+ "failed to get txcal45dn value\n");
+ return ret;
+ }
+ }
+
+ if (of_find_property(np, "tx-txcal45dp", NULL)) {
+ ret = of_property_read_u32(np, "tx-txcal45dp",
+ &mxs_phy->tx_txcal45dp);
+ if (ret) {
+ dev_err(&pdev->dev,
+ "failed to get txcal45dp value\n");
+ return ret;
+ }
+ }
+platform_set_drvdata(pdev, mxs_phy);
这个寄存器定义了内部LDO_USB模块的控制位和状态位,该模块由两个USB VBUS引脚中的任意一个供电。该调节器只提供低速和全速收发器USB PHYs。因此,它只影响全速和低速变速器的电压水平,而不影响高速变速器。
端口控制通常用于状态端口复位、挂起和当前连接状态。端口控制也用于启动测试模式或强制信令,并允许软件将PHY置于低功率悬挂模式并禁用PHY时钟。
Command samples:
/unit_tests/memtool 0x2184184 1 //OTG Port Read register data
/unit_tests/memtool 0x2184184=0x18441205 //OTG Port Test packet
/unit_tests/memtool 0x2184184=0x18411205 //OTG Port J_STATE
/unit_tests/memtool 0x2184184=0x18421205 //OTG Port K_STATE
/unit_tests/memtool 0x2184184=0x18431205 //OTG Port SE0 (host) / NAK (device)
/unit_tests/memtool 0x2184184=0x18401305 //OTG Port Reset
/unit_tests/memtool 0x2184184=0x18401285 //OTG Port Suspend
/unit_tests/memtool 0x2184184=0x18401245 //OTG Port Resume
/unit_tests/memtool 0x2184384 1 //Host Port Read register data
/unit_tests/memtool 0x2184384=0x18441205 //Host Port Test packet
/unit_tests/memtool 0x2184384=0x18411205 //Host Port J_STATE
/unit_tests/memtool 0x2184384=0x18421205 //Host Port K_STATE
/unit_tests/memtool 0x2184384=0x18431205 //Host Port SE0 (host) / NAK (device)
/unit_tests/memtool 0x2184384=0x18401305 //Host Port Reset
/unit_tests/memtool 0x2184384=0x18401285 //Host Port Suspend
/unit_tests/memtool 0x2184384=0x18401245 //Host Port Resume
Command samples:
echo mem > /sys/power/state // Let the system enter suspend (standby) mode
echo enabled > /sys/class/tty/ttymxc0/power/wakeup // Set Console as the
system wakeup source
for i in $(find /sys -name wakeup | grep usb);do echo enabled > $i;echo "echo
enabled > $i";done; // USB remote wakeup (as system wakeup source) is not
enabled by default, user can enable this feature by using this script, after
plugging in the USB device.
上一篇:BI项目中ETL设计与思考
下一篇:jupyter的使用