1.3 px30驱动移植-网卡驱动框架

文章目录

写在前面

移植瑞芯微px30 网卡RTL8363的时候,不能识别到网卡 日志打印No found PHY, 只能调试一下代码,调试完成后,梳理网卡框架如下

一 、驱动框架

此框架是很老的linux kernel 4.4内核思路,我看最新内核的GMAC结构体略有不同

在这里插入图片描述

匹配过程如下

1 在phy_device.c中,通过get_phy_device 函数拿到设备的id号
2 phy_device_register 将设备节点挂到phy_map中
3 通过mii_bus 注册的函数操作设备读写

二、驱动调用流程

kernel/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
rk_gmac_probe() //探测px30 gmac
kernel/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
stmmac_dvr_probe()

kernel/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
stmmac_mdio_register()

kernel/drivers/of/of_mdio.c	
of_mdiobus_register()
mdiobus_register()
	
	kernel/drivers/net/phy/mdio_bus.c // 
	__mdiobus_register()
	mdiobus_scan()
		
		kernel/drivers/net/phy/phy_device.c              
		get_phy_device()
		rtl8367rb_init()
		rtk_switch_init()

get_phy_device()
a、通过bus->id区别rtl8363 phy设备与fixed phy设备
b、rtl8363NB 扫描端口1 3 16

// 测试函数,读取到的默认数据为 0x0432 mdio读取没问题
rtk_switch_reg1b03()
drivers/net/ethernet/stmicro/stmmac/rtl8367c/rtk_switch.c
smi_readreg1b03()
drivers/net/ethernet/stmicro/stmmac/rtl8367c/smi.c
MDC_MDIO_READ
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
stmmac_mdio_write_switch()// 真正调用mdio的地方
stmmac_mdio_read_switch()//所有的通信都是通过这两个函数去通信的 这是rk平台自定的,正常通过mii_bus->stmmac_read_switch/mii_bus->stmmac_write_switch

            </div><div data-report-view="{&quot;mod&quot;:&quot;1585297308_001&quot;,&quot;spm&quot;:&quot;1001.2101.3001.6548&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/weixin_34799243/article/details/123949848&quot;,&quot;extend1&quot;:&quot;pc&quot;,&quot;ab&quot;:&quot;new&quot;}"><div></div></div>
            <link href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/markdown_views-22a2fefd3b.css" rel="stylesheet">
            <link href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/style-4f8fbf9108.css" rel="stylesheet">
    </div>
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值