0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

RK3588編解碼盒子之RTL8211FS-CG光口調(diào)試

jf_30051736 ? 來源:jf_30051736 ? 作者:jf_30051736 ? 2023-06-10 09:00 ? 次閱讀

?

1. 簡(jiǎn)介

  • 本文是基于RK3588平臺(tái),SDK版本:RK3588_ANDROID12.0 RTL8211FS-CG光口調(diào)試總結(jié)。
  • 視頻橋接芯片:RTL8211FS-CG
  • 驅(qū)動(dòng)代碼:"kernel/drivers/net/phy/realtek.c"
  • 本次調(diào)試的方案功能:RK3588 調(diào)試RTL8211FS-CG 轉(zhuǎn)接出光口

2. 硬件部分

硬件工程師參考RTL8211FS-CG發(fā)布的設(shè)計(jì)圖設(shè)計(jì)

以下為部分截圖

在設(shè)計(jì)過程中參考realtek發(fā)過的參考設(shè)計(jì),建議咨詢一下phy廠家,看有哪些注意地方

注意: 8211FS使用外部3.3V,電平要與主控GMAC1相匹配;

使用UTP<->RGMII的接法,且CFG_MODE2:0=010兼容光口和電口;

3. 軟件部分

建議先調(diào)電口RJ45,調(diào)通后再接光口,可能更容易;調(diào)電口時(shí)先插百兆網(wǎng)線調(diào)百兆,成功后再換千兆網(wǎng)線

3.1 代碼

3.1.1 Realtek phy的內(nèi)核配置

在kernel下輸入make menuconfig

Device Drivers  --- >

[*] Network device support  --- >

-*-   PHY Device support and infrastructure  --- >

 -*-   Realtek PHYs

這樣realtek.c就可以編譯到kernel了

3.1.2 dts配置

&gmac1 {
    /* Use rgmii-rxid mode to disable rx delay inside Soc */
    phy-mode = "rgmii-rxid";
    clock_in_out = "output";

    snps,reset-gpio = < &gpio3 RK_PB7 GPIO_ACTIVE_LOW >;
    snps,reset-active-low;
    /* Reset time is 20ms, 100ms for rtl8211f */
    snps,reset-delays-us = < 0 20000 100000 >;

    pinctrl-names = "default";
    pinctrl-0 = < &gmac1_miim
             &gmac1_tx_bus2
             &gmac1_rx_bus2
             &gmac1_rgmii_clk
             &gmac1_rgmii_bus
             &gmac1_clkinout >;

    tx_delay = < 0x43 >;
    /* rx_delay = < 0x4f >; */

    phy-handle = < &rgmii_phy1 >;
    status = "okay";
};

&mdio1 {
    rgmii_phy1: phy@1 {
        compatible = "ethernet-phy-ieee802.3-c22";
        reg = < 0x1 >;
    };
};

3.1.3 代碼驗(yàn)證

插千兆網(wǎng)線有相關(guān)打印且可以ping通百度

此時(shí)插光口沒有分配IP地址

3.1.4 調(diào)試

打開IO調(diào)試命令

CONFIG_DEVMEM=y

3.1.5 操作寄存器

find /sys -name phy_registers //先找到以太網(wǎng)寄存器的配置節(jié)點(diǎn)并進(jìn)入所在目錄

echo 31 0xdc0 >phy_registers //切換到PHY的PAGE 0xdc0

cat phy_registers //讀取當(dāng)前PAGE寄存器的值,核對(duì)PHYID1,PHYID2是否正確來確認(rèn)寄存器是否正確

echo 0 0x value >phy_registers //改寫PAGE00個(gè)寄存器的值為需要的value

cat phy_registers //讀取值檢查是否修改成功

echo 31 0 > phy_registers //切回到PAGE0寄存器?。。?!重要,一定寫完要切回來才會(huì)生效

如果修改無效,參閱PHY規(guī)格書的8.5章節(jié)修改

3.1.6 將芯片強(qiáng)制固定光口模式

setup_fiber_mode

#endif
+static int phy_8211fS_fiber_mode_fixup(struct phy_device *phydev)
+{	int i;
+	printk("%s in\\\\n", __func__);
+	phy_write(phydev, 31, 0xdc0 );
+   phy_write(phydev, 16, 0x79ad );
+   //phy_write(phydev, 20, 0x79ad );
+	printk("page 0xdc0 register\\\\n");
+	for(i =0; i< 8,i++)
+		printk("%d: %x\\\\n",i,phy_read(phydev,i));
+    phy_write(phydev, 31, 0xdc1 );
+   printk("23: %x\\\\n", phy_read(phydev,23));
+   phy_write(phydev, 31, 0x0 );
+   printk("page 0 register\\\\n");
+	for(i =0; i< 32,i++)
+		printk("%d: %x\\\\n",i,phy_read(phydev,i));
+	
+	return 0;
+}
/**
 * stmmac_dvr_probe
 * @device: device pointer
#ifdef CONFIG_DWMAC_RK_AUTO_DELAYLINE
	INIT_DELAYED_WORK(&priv- >scan_dwork, stmmac_scan_delayline_dwork);
#endif
+	ret = phy_register_fixup_for_uid(RTL_8211FS_PHY_ID, 0xffffffff, +phy_8211fS_fiber_mode_fixup);
+	if (ret)
+		pr_warn("Cannot register PHY board fixup.\\\\n");
	return ret;
error_netdev_register:

編譯燒寫之后網(wǎng)口燈狀態(tài)已經(jīng)變?yōu)楣饪谀J搅耍藭r(shí)插入光口還是無法分配IP地址

3.1.7 補(bǔ)丁

--- a/kernel/drivers/net/phy/realtek.c
+++ b/kernel/drivers/net/phy/realtek.c
@@ -46,6 +46,11 @@
 #define RTL8366RB_POWER_SAVE			0x15
 #define RTL8366RB_POWER_SAVE_ON			BIT(12)
 
+#define RTL8211FS_FIBER_ESR			0x0F
+#define RTL8211FS_MODE_MASK			0xC000
+#define RTL8211F_MODE_COPPER		0
+#define RTL8211FS_MODE_FIBER		1
+
 #define RTL_SUPPORTS_5000FULL			BIT(14)
 #define RTL_SUPPORTS_2500FULL			BIT(13)
 #define RTL_SUPPORTS_10000FULL			BIT(0)
@@ -58,6 +63,10 @@
 
 #define RTL_GENERIC_PHYID			0x001cc800
 
+struct rtl8211f_priv {
+	int lastmode;
+};
+
 MODULE_DESCRIPTION("Realtek PHY driver");
 MODULE_AUTHOR("Johnson Leung");
 MODULE_LICENSE("GPL");
@@ -93,7 +102,6 @@ static int rtl821x_ack_interrupt(struct phy_device *phydev)
 static int rtl8211f_ack_interrupt(struct phy_device *phydev)
 {
 	int err;
-
 	err = phy_read_paged(phydev, 0xa43, RTL8211F_INSR);
 
 	return (err < 0) ? err : 0;
@@ -140,7 +148,6 @@ static int rtl8211e_config_intr(struct phy_device *phydev)
 static int rtl8211f_config_intr(struct phy_device *phydev)
 {
 	u16 val;
-
 	if (phydev- >interrupts == PHY_INTERRUPT_ENABLED)
 		val = RTL8211F_INER_LINK_STATUS;
 	else
@@ -242,7 +249,7 @@ static int rtl8211f_config_init(struct phy_device *phydev)
 			"2ns RX delay was already %s (by pin-strapping RXD0 or bootloader configuration)\\\\n",
 			val_rxdly ? "enabled" : "disabled");
 	}
-
+	
 	return 0;
 }
 
@@ -560,6 +567,89 @@ static int rtlgen_resume(struct phy_device *phydev)
 	return ret;
 }
 
+static int rtl8211f_probe(struct phy_device *phydev)
+{
+	struct device *dev = &phydev- >mdio.dev;
+	struct rtl8211f_priv *priv;
+
+	priv = devm_kzalloc(dev, sizeof(struct rtl8211f_priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+	
+	phydev- >priv = priv;
+
+	return 0;
+}
+
+static void rtl8211f_remove(struct phy_device *phydev)
+{
+	struct device *dev = &phydev- >mdio.dev;
+	struct rtl8211f_priv *priv = phydev- >priv;
+
+	if (priv)
+		devm_kfree(dev, priv);
+}
+
+static int rtl8211f_mode(struct phy_device *phydev)
+{
+	u16 val;
+
+	val = phy_read(phydev, RTL8211FS_FIBER_ESR);
+	val &= RTL8211FS_MODE_MASK;
+
+	if(val)
+		return RTL8211FS_MODE_FIBER;
+	else
+		return RTL8211F_MODE_COPPER;
+}
+
+static int rtl8211f_config_aneg(struct phy_device *phydev)
+{
+	int ret;
+
+	struct rtl8211f_priv *priv = phydev- >priv;
+
+	ret = genphy_read_abilities(phydev);
+	if(ret < 0)
+		return ret;
+
+	linkmode_copy(phydev- >advertising, phydev- >supported);
+
+	if (rtl8211f_mode(phydev) == RTL8211FS_MODE_FIBER) {
+		dev_info(&phydev- >mdio.dev, "Fiber Mode");
+		priv- >lastmode = RTL8211FS_MODE_FIBER;
+		return genphy_c37_config_aneg(phydev);
+	}
+
+	dev_info(&phydev- >mdio.dev, "Copper Mode");
+
+	priv- >lastmode = RTL8211F_MODE_COPPER;
+
+	return genphy_config_aneg(phydev);
+}
+
+static int rtl8211f_read_status(struct phy_device *phydev)
+{
+	int ret;
+	struct rtl8211f_priv *priv = phydev- >priv;
+
+	if(rtl8211f_mode(phydev) != priv- >lastmode) {
+		ret = rtl8211f_config_aneg(phydev);
+		if(ret < 0)
+			return ret;
+
+		ret = genphy_restart_aneg(phydev);
+		if(ret < 0)
+			return ret;
+	}
+
+	if (rtl8211f_mode(phydev) == RTL8211FS_MODE_FIBER)
+		return genphy_c37_read_status(phydev);
+
+	return genphy_read_status(phydev);
+}
+
+
 static struct phy_driver realtek_drvs[] = {
 	{
 		PHY_ID_MATCH_EXACT(0x00008201),
@@ -632,10 +722,15 @@ static struct phy_driver realtek_drvs[] = {
 		.write_page	= rtl821x_write_page,
 	}, {
 		PHY_ID_MATCH_EXACT(0x001cc916),
-		.name		= "RTL8211F Gigabit Ethernet",
+		// .name		= "RTL8211F Gigabit Ethernet",
+		.name		= "RTL8211F(S) Gigabit Ethernet",
+		.probe		= rtl8211f_probe,
+		.remove		= rtl8211f_remove,		
 		.config_init	= &rtl8211f_config_init,
 		.ack_interrupt	= &rtl8211f_ack_interrupt,
 		.config_intr	= &rtl8211f_config_intr,
+		.config_aneg	= rtl8211f_config_aneg,
+		.read_status	= rtl8211f_read_status,		
 		.suspend	= genphy_suspend,
 		.resume		= rtl821x_resume,
 		.read_page	= rtl821x_read_page,

將補(bǔ)丁加進(jìn)去

上電之后再?gòu)?fù)位reset腳一次可以識(shí)別到光口了

3.1.7 phy reset

io -4 0xFEC40000 0x80000000 拉低

sleep 0.1

io -4 0xFEC40000 0x80008000 拉高

RTL8211F(S) Gigabit Ethernet stmmac-1:01: Copper Mode

總結(jié)

RTL8211FS,只要硬件線路配置為RGMII to Fiber 等涉及到Fiber的模式,即可工作。Fiber相關(guān)的模式設(shè)定可參考RTL8211FS數(shù)據(jù)手冊(cè)中寄存器描述,公司推動(dòng) realtek 跟進(jìn)解決。

在這里插入圖片描述

?
審核編輯:湯梓紅

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 電路板
    +關(guān)注

    關(guān)注

    140

    文章

    4960

    瀏覽量

    97830
  • 調(diào)試
    +關(guān)注

    關(guān)注

    7

    文章

    578

    瀏覽量

    33936
  • 編解碼
    +關(guān)注

    關(guān)注

    1

    文章

    140

    瀏覽量

    19617
  • RK3588
    +關(guān)注

    關(guān)注

    6

    文章

    329

    瀏覽量

    4338
收藏 人收藏

    評(píng)論

    相關(guān)推薦

    瑞芯微RK3588開發(fā)板RK3588 EVB和RK3588S EVB解讀

    瑞芯微RK3588開發(fā)板RK3588 EVB和RK3588S EVB解讀 瑞芯微旗艦芯RK3588系列開發(fā)板受到廣大開發(fā)者伙伴的關(guān)注和問詢。針對(duì)相關(guān)的開發(fā)板功能、操作指南等問題,我們一
    的頭像 發(fā)表于 09-22 15:54 ?1.8w次閱讀
    瑞芯微<b class='flag-5'>RK3588</b>開發(fā)板<b class='flag-5'>RK3588</b> EVB和<b class='flag-5'>RK3588</b>S EVB解讀

    RK3588-Camera:MIPI-CSI調(diào)試通路解析

    RK3588-Camera:MIPI-CSI調(diào)試通路解析
    的頭像 發(fā)表于 06-10 10:29 ?5254次閱讀
    <b class='flag-5'>RK3588</b>-Camera:MIPI-CSI<b class='flag-5'>調(diào)試</b><b class='flag-5'>之</b>通路解析

    RK3588-MIPI屏幕調(diào)試筆記:RK3588-MIPI-DSILCD上電初始化時(shí)序

    RK3588-MIPI屏幕調(diào)試筆記:RK3588-MIPI-DSILCD上電初始化時(shí)序
    的頭像 發(fā)表于 06-10 10:32 ?4654次閱讀

    RK3588-WIF/BT調(diào)試AP6256

    RK3588-WIF/BT調(diào)試AP6256
    的頭像 發(fā)表于 06-10 10:33 ?3786次閱讀
    <b class='flag-5'>RK3588</b>-WIF/BT<b class='flag-5'>調(diào)試</b><b class='flag-5'>之</b>AP6256

    RK3588-MIPI屏幕調(diào)試筆記:RK3588-MIPI-DSI屏參配置

    RK3588-MIPI屏幕調(diào)試筆記:RK3588-MIPI-DSI屏參配置
    的頭像 發(fā)表于 06-10 10:36 ?2308次閱讀
    <b class='flag-5'>RK3588</b>-MIPI屏幕<b class='flag-5'>調(diào)試</b>筆記:<b class='flag-5'>RK3588</b>-MIPI-DSI<b class='flag-5'>之</b>屏參配置

    RK3588芯片支持8K視頻的硬編解碼

    RK3588芯片的性能輸出。RK3588在視頻編解碼方面也十分突出,支持8K視頻的硬編硬解,非常適合VR(虛擬現(xiàn)實(shí))、AR(增強(qiáng)現(xiàn)實(shí))、MR(混合現(xiàn)實(shí))和XR(拓展現(xiàn)實(shí))類的產(chǎn)品,可滿足高端娛樂
    發(fā)表于 07-28 15:59

    RTL8211F-CGRTL8211D-CG芯片規(guī)格書pdf下載

    RTL8211F-CGRTL8211D-CG芯片規(guī)格書
    發(fā)表于 03-08 11:49 ?105次下載

    RK3588RK3588S之間的區(qū)別是什么

    的通用型ARM SoC芯片,芯片性能也十分均衡,視頻解碼能力十分突出,在影音領(lǐng)域?qū)?huì)有廣泛的應(yīng)用,豐富的接口也十分適合行業(yè)客戶的定制開發(fā)。因此,RK3588是面向高端的行業(yè)應(yīng)用,而RK3588S框架
    發(fā)表于 03-10 19:22 ?2.7w次閱讀

    RTL8211FS以太網(wǎng)光電精密收發(fā)器手冊(cè)

    Realtek RTL8211FS-CG/RTL8211FS-VS-CG/RTL8211FSI-CG/RTL8211FSI-VS-CG是一款高度可靠的產(chǎn)品符合10Base-T、100B
    發(fā)表于 05-11 14:22 ?81次下載

    RTL8211英文完整手冊(cè)

    Realtek RTL8211FS-CG/RTL8211FS-VS-CG/RTL8211FSI-CG/RTL8211FSI-VS-CG是高度符合10Base-T、100Base-TX
    發(fā)表于 05-23 17:49 ?59次下載

    瑞昱RTL8211FS集成10/100/1000M以太網(wǎng)精密收發(fā)器

    ReaLTEk RTL8211FS-CG/RTL8211FS-VS-CG/RTL8211FSI-CG/RTL8211FSI-VS-CG是一款高度集成的以太網(wǎng)收發(fā)器,兼容10ba
    發(fā)表于 06-15 14:36 ?29次下載

    RK3588-MIPI屏幕調(diào)試筆記:RK3588-MIPI-DSI

    RK3588-MIPI屏幕調(diào)試筆記:RK3588-MIPI-DSI
    的頭像 發(fā)表于 06-10 10:31 ?4023次閱讀
    <b class='flag-5'>RK3588</b>-MIPI屏幕<b class='flag-5'>調(diào)試</b>筆記:<b class='flag-5'>RK3588</b>-MIPI-DSI

    rk3588rk3588s的區(qū)別

    rk3588rk3588s的區(qū)別 Rockchip是一家專業(yè)的半導(dǎo)體公司,成立于2001年,總部位于中國(guó)深圳,主要從事集成電路的設(shè)計(jì)、開發(fā)和銷售。他們的熱門產(chǎn)品RK3588RK3588
    的頭像 發(fā)表于 08-15 16:44 ?1.4w次閱讀

    RK3588有幾路千M網(wǎng)?

    RK3588有幾路千M網(wǎng)? RK3588是一款基于ARM架構(gòu)的處理器,由Rockchip公司推出。它是一款集成度高、性能優(yōu)越的SoC芯片,適用于多種應(yīng)用場(chǎng)景,如智能電視、臺(tái)式機(jī)、安防監(jiān)控、機(jī)器人等
    的頭像 發(fā)表于 08-15 17:04 ?1928次閱讀

    RK3588-MPP解碼詳解

    一.簡(jiǎn)介[RK3588從入門到精通]專欄總目錄本篇文章進(jìn)行RK3588-MPP解碼的詳細(xì)解析二.環(huán)境介紹硬件環(huán)境:ArmSoM-W3RK3588開發(fā)板軟件版本:OS
    的頭像 發(fā)表于 11-21 11:04 ?1765次閱讀
    <b class='flag-5'>RK3588</b>-MPP<b class='flag-5'>解碼</b>詳解