diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 5aec673a0120..024c4a5d4dcc 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -664,6 +664,10 @@ static int m88e1510_config_aneg(struct phy_device *phydev)
static void marvell_config_led(struct phy_device *phydev)
{
+ u16 led_reg_value;
+ int ret;
+ struct device_node *np = phydev->mdio.dev.of_node;
+
u16 def_config;
int err;
@@ -688,6 +692,14 @@ static void marvell_config_led(struct phy_device *phydev)
return;
}
+ ret = of_property_read_u16(np, "led-reg-value", &led_reg_value);
+ if (ret) {
+ phydev_info(phydev, "No custom led reg value, set default value\n");
+ } else {
+ def_config = led_reg_value;
+ phydev_info(phydev, "Set custom led reg value%d\n", led_reg_value);
+ }
+
err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL,
def_config);
if (err < 0)
USB 调试
Petalinux2021.1 中 USB 的配置已经很简单了,zynqmp ip 核按照原理图正确配置后,一般可以直接自动生成正确的设备树。但是由于都使用了 dwc3 的驱动,usb2.0 存在问题,Petalinux2021.2 修复了这个问题,我摘取了其中有关 usb 的代码,直接添加到当前工程的 patch 中。
diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c
index 7231c5a3eece..85bb308959fb 100644
--- a/drivers/usb/dwc3/dwc3-xilinx.c
+++ b/drivers/usb/dwc3/dwc3-xilinx.c
@@ -374,14 +374,6 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
u32 reg;
struct gpio_desc *reset_gpio = NULL;
- usb3_phy = devm_phy_get(dev, "usb3-phy");
- if (PTR_ERR(usb3_phy) == -EPROBE_DEFER) {
- ret = -EPROBE_DEFER;
- goto err;
- } else if (IS_ERR(usb3_phy)) {
- usb3_phy = NULL;
- }
-
crst = devm_reset_control_get_exclusive(dev, "usb_crst");
if (IS_ERR(crst)) {
ret = PTR_ERR(crst);
@@ -407,6 +399,15 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
goto err;
}
+ usb3_phy = devm_phy_get(dev, "usb3-phy");
+ if (PTR_ERR(usb3_phy) == -EPROBE_DEFER) {
+ ret = -EPROBE_DEFER;
+ goto err;
+ } else if (IS_ERR(usb3_phy)) {
+ ret = 0;
+ goto skip_usb3_phy;
+ }
+
ret = reset_control_assert(crst);
if (ret < 0) {
dev_err(dev, "Failed to assert core reset\n");
@@ -461,17 +462,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
goto err;
}
- /*
- * This routes the USB DMA traffic to go through FPD path instead
- * of reaching DDR directly. This traffic routing is needed to
- * make SMMU and CCI work with USB DMA.
- */
- if (of_dma_is_coherent(dev->of_node) || device_iommu_mapped(dev)) {
- reg = readl(priv_data->regs + XLNX_USB_TRAFFIC_ROUTE_CONFIG);
- reg |= XLNX_USB_TRAFFIC_ROUTE_FPD;
- writel(reg, priv_data->regs + XLNX_USB_TRAFFIC_ROUTE_CONFIG);
- }
-
+skip_usb3_phy:
/* ulpi reset via gpio-modepin or gpio-framework driver */
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(reset_gpio)) {
@@ -488,6 +479,17 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
usleep_range(5000, 10000); /* delay */
}
+ /*
+ * This routes the USB DMA traffic to go through FPD path instead
+ * of reaching DDR directly. This traffic routing is needed to
+ * make SMMU and CCI work with USB DMA.
+ */
+ if (of_dma_is_coherent(dev->of_node) || device_iommu_mapped(dev)) {
+ reg = readl(priv_data->regs + XLNX_USB_TRAFFIC_ROUTE_CONFIG);
+ reg |= XLNX_USB_TRAFFIC_ROUTE_FPD;
+ writel(reg, priv_data->regs + XLNX_USB_TRAFFIC_ROUTE_CONFIG);
+ }
+
err:
return ret;
}
除了自动生成的设备树,需要指定 usb phy 的工作模式以及最大速度,对于 usb3,需要启用lpm(不启用也可以,只不过内核会报warning,强迫症难受)
1
2
3
4
5
6
7
8
9
10
11
&dwc3_0{dr_mode="host";maximum-speed="high-speed";/* usb 2.0 */snps,usb3_lpm_capable;};&dwc3_1{dr_mode="host";maximum-speed="super-speed";/* usb 3.0 */snps,usb3_lpm_capable;};
SD 卡调试
SD 卡主要出现了两个问题。
第一,SD 卡识别报错Buffer I/O error on dev mmcblk0, logical block 0, async page read,根据论坛的描述,这是一个在 2019.2 就存在的问题,需要在设备树中声明no-1-8-v;,声明后注意 sd 的供电电压。
解决上述问题后,内核报错时钟和速率不匹配,并且驱动报错More than allowed devices are using the vpll_int, which is forbidden,参考 zynqmp IP 核的样例工程,修改了 DP 使用的输出时钟,解决了后者报错。通过modetest -M xlnx发现Encoders、Connectors、CRTCs、Planes的对应关系错误,并且Connectors的状态是disconnected,示波器查看 dp 的 aux 输出是反的,原因在于 MIO 数量不足,所以 dp 连在了 PL 端,通过 EMIO 连接到 arm,而文档中提到了dp_aux_data_oe连接到 EMIO 的极性会反转,这是我一开始忽略的地方,手动取反之后,modetest的测试结果正常。但是此时显示器依旧没有输出。这里就是上文提到的DP Lane与GT Lane的对应关系的问题了。