同时支持10m 100m 1000m的phy设备驱动

以下是一个简单的Linux PHY驱动示例,支持10Mbps、100Mbps和1000Mbps的链路速度。该驱动程序可以与常见的以太网PHY设备配合使用,并实现了不同速率的自动协商。

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/phy.h>
#include <linux/netdevice.h>
#include <linux/ethtool.h>
#include <linux/platform_device.h>

static struct phy_device *phydev;
static struct net_device *netdev;

// 自定义链路速度和双工模式回调函数
static int my_phy_config_init(struct phy_device *phydev)
{
    // 配置PHY支持的链路速度和双工模式
    phydev->supported &= (SUPPORTED_10baseT_Half |
                          SUPPORTED_10baseT_Full |
                          SUPPORTED_100baseT_Half |
                          SUPPORTED_100baseT_Full |
                          SUPPORTED_1000baseT_Full);
    phydev->advertising = phydev->supported;

    printk(KERN_INFO "PHY configured to support 10M/100M/1000M speeds\n");
    return 0;
}

// 自定义自动协商配置函数
static int my_phy_config_aneg(struct phy_device *phydev)
{
    int 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值