其他分享
首页 > 其他分享> > [RK3399][Android7.1] 调试笔记-add ethernet(RTL8306MB) support

[RK3399][Android7.1] 调试笔记-add ethernet(RTL8306MB) support

作者:互联网

平台 内核版本 安卓版本
RK3399 Linux4.4 Android7.1

文章目录

dts

目录arch/arm64/boot/dts/rockchip/rk3399-b201-rev1.dts

 	vcc_phy: vcc-phy-regulator {
 		compatible = "regulator-fixed";
 		regulator-name = "vcc_phy";
-		regulator-always-on;
-		regulator-boot-on;
+		enable-active-high;
+		gpio = <&gpio2 18 GPIO_ACTIVE_HIGH>;
 	};
 
 	vcc3v3_sys: vcc3v3-sys {
@@ -110,7 +110,7 @@
 
 	clkin_gmac: external-gmac-clock {
 		compatible = "fixed-clock";
-		clock-frequency = <125000000>;
+		clock-frequency = <50000000>;
 		clock-output-names = "clkin_gmac";
 		#clock-cells = <0>;
 	};
@@ -514,12 +514,12 @@
 
 &uart0 {
 	pinctrl-names = "default";
-	pinctrl-0 = <&uart0_xfer &uart0_cts>;
+	pinctrl-0 = <&uart0_xfer>;
 	status = "okay";
 };
 
 &uart2 {
-	status = "okay";
+	status = "disabled";
 };
 
 &usb_host0_ehci {
@@ -562,15 +562,15 @@
 
 &gmac {
 	phy-supply = <&vcc_phy>;
-	phy-mode = "rgmii";
+	phy-mode = "rmii";
 	clock_in_out = "input";
-	snps,reset-gpio = <&gpio3 15 GPIO_ACTIVE_LOW>;
+	snps,reset-gpio = <&gpio4 22 GPIO_ACTIVE_LOW>;
 	snps,reset-active-low;
-	snps,reset-delays-us = <0 10000 50000>;
+	snps,reset-delays-us = <0 10000 80000>;
 	assigned-clocks = <&cru SCLK_RMII_SRC>;
 	assigned-clock-parents = <&clkin_gmac>;
 	pinctrl-names = "default", "sleep";
-	pinctrl-0 = <&rgmii_pins>;
+	pinctrl-0 = <&rmii_pins>;
 	pinctrl-1 = <&rgmii_sleep_pins>;
 	tx_delay = <0x28>;
 	rx_delay = <0x11>;
@@ -618,13 +618,6 @@
 				<1 14 RK_FUNC_GPIO &pcfg_pull_down>;
 		};
 	};
-
-	gmac {
-		rgmii_sleep_pins: rgmii-sleep-pins {
-			rockchip,pins =
-				<3 15 RK_FUNC_GPIO &pcfg_output_low>;
-		};
-	};
 };
 
 &pvtm {
@@ -997,23 +990,6 @@
 	status = "okay";
 };
 
-/*
-&vcc_phy {
-	compatible = "regulator-fixed";
-	regulator-name = "vcc_phy";
-	enable-active-high;
-	gpio = <&gpio2 18 GPIO_ACTIVE_HIGH>;
-	regulator-always-on;
-	regulator-boot-on;
-};
-*/
-
-&gmac {
-	phy-is-integrated;
-	snps,reset-gpio = <&gpio4 22 GPIO_ACTIVE_LOW>;
-	status = "okay";
-};
-
 &isp0 {
 	status = "okay";
 };

config

目录arch/arm64/configs/rk3399_b201_defconfig

@@ -308,6 +308,7 @@ CONFIG_STMMAC_ETH=y
 # CONFIG_NET_VENDOR_VIA is not set
 # CONFIG_NET_VENDOR_WIZNET is not set
 CONFIG_ROCKCHIP_PHY=y
+CONFIG_FIXED_PHY=y
 CONFIG_PPP=y
 CONFIG_PPP_BSDCOMP=y
 CONFIG_PPP_DEFLATE=y
@@ -506,7 +507,6 @@ CONFIG_MALI_EXPERT=y
 CONFIG_MALI_PLATFORM_THIRDPARTY=y
 CONFIG_MALI_PLATFORM_THIRDPARTY_NAME="rk"
 CONFIG_MALI_DEBUG=y
-CONFIG_MALI_PWRSOFT_765=y
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 # CONFIG_LCD_CLASS_DEVICE is not set
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
@@ -539,9 +539,11 @@ CONFIG_SND_SOC_ROCKCHIP_HDMI_ANALOG=y
 CONFIG_SND_SOC_ROCKCHIP_HDMI_DP=y
 CONFIG_SND_SOC_ROCKCHIP_RT5651_TC358749=y
 CONFIG_SND_SOC_ROCKCHIP_CDNDP=y
+CONFIG_SND_SOC_ROCKCHIP_ES8323=y
 CONFIG_SND_SOC_CX2072X=y
 CONFIG_SND_SOC_BT_SCO=y
 CONFIG_SND_SOC_ES8316=y
+CONFIG_SND_SOC_ES8323=y
 CONFIG_SND_SOC_ES8396=y
 CONFIG_SND_SOC_FM1288=y
 CONFIG_SND_SOC_RK1000=y
@@ -745,10 +747,14 @@ CONFIG_TEE=y
 CONFIG_OPTEE=y
 CONFIG_RK_NAND=y
 CONFIG_RK_HEADSET=y
+CONFIG_HQ=y
+CONFIG_HQIO=y
+CONFIG_HQDEVICE_ADASPLUS=y
 CONFIG_ROCKCHIP_SIP=y
 # CONFIG_ACPI is not set
 CONFIG_EXT4_FS=y
 CONFIG_EXT4_FS_SECURITY=y
+CONFIG_EXFAT_FS=y
 CONFIG_F2FS_FS=y
 # CONFIG_F2FS_FS_POSIX_ACL is not set
 CONFIG_F2FS_FS_SECURITY=y

drivers

目录drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

 static int stmmac_init_phy(struct net_device *dev)
 {
+#ifdef CONFIG_FIXED_PHY
+	int ret;
+#endif
 	struct stmmac_priv *priv = netdev_priv(dev);
 	struct phy_device *phydev;
 	char phy_id_fmt[MII_BUS_ID_SIZE + 3];
@@ -825,6 +828,41 @@ static int stmmac_init_phy(struct net_device *dev)
 	priv->speed = 0;
 	priv->oldduplex = -1;
 
+#ifdef CONFIG_FIXED_PHY
+	if (interface == PHY_INTERFACE_MODE_RMII) {
+		/*
+		 * MoCA port or no MDIO access.
+		 * Use fixed PHY to represent the link layer.
+		 */
+		struct fixed_phy_status fphy_status = {
+			.link = 1,
+			.speed = SPEED_100,
+			.duplex = DUPLEX_FULL,
+			.pause = 0,
+			.asym_pause = 0,
+		};
+
+		phydev = fixed_phy_register(PHY_POLL, &fphy_status, -1, NULL);
+		if (!phydev || IS_ERR(phydev)) {
+			netdev_err(dev, "failed to register fixed PHY device %ld\n", (long)phydev);
+			return -ENODEV;
+		}
+
+		ret = phy_connect_direct(dev, phydev, stmmac_adjust_link,
+					 interface);
+		if (ret) {
+			pr_err("could not attach to PHY\n");
+			return -ENODEV;
+		}
+
+		/* Make sure we initialize MoCA PHYs with a link down */
+		phydev->link = 0;
+		priv->phydev = phydev;
+
+		return 0;
+	}
+#endif
+
 	if (priv->plat->phy_node) {
 		phydev = of_phy_connect(dev, priv->plat->phy_node,
 					&stmmac_adjust_link, 0, interface);
-- 
雪松研究所 发布了270 篇原创文章 · 获赞 95 · 访问量 13万+ 私信 关注

标签:SND,PHY,support,RTL8306MB,SOC,phydev,Android7.1,phy,CONFIG
来源: https://blog.csdn.net/qq_33487044/article/details/104451391