博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
慢慢欣赏linux phy设备配置
阅读量:4068 次
发布时间:2019-05-25

本文共 3207 字,大约阅读时间需要 10 分钟。

走ifconfig ethx

sys_ioctl	do_vfs_ioctl		vfs_ioctl			sock_ioctl				inet_ioctl					devinet_ioctl						dev_change_flags							__dev_charge_flag								__dev_open									gfar_enet_open

进入真正的流程

int gfar_enet_open(struct net_device *dev){	struct gfar_private *priv = netdev_priv(dev);	skb_queue_head_init(&priv->rx_recycle);	/* Initialize a bunch of registers */	init_registers(dev);	gfar_set_mac_address(dev);	err = init_phy(dev);	=>int init_phy(struct net_device *dev)	{		struct gfar_private *priv = netdev_priv(dev);		interface = gfar_get_interface(dev);		priv->phydev = of_phy_connect(dev, priv->phy_node, &adjust_link, 0,						  interface);//net_device的priv的phy_node就是phy		=>struct phy_device *of_phy_connect(struct net_device *dev,				  struct device_node *phy_np,				  void (*hndlr)(struct net_device *), u32 flags,				  phy_interface_t iface)		{			struct phy_device *phy = of_phy_find_device(phy_np);			if (!phy)				return NULL;			return phy_connect_direct(dev, phy, hndlr, flags, iface) ? NULL : phy;			=>int phy_connect_direct(struct net_device *dev, struct phy_device *phydev,		       void (*handler)(struct net_device *), u32 flags,		       phy_interface_t interface)			{				int rc = phy_attach_direct(dev, phydev, flags, interface);				=>int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,						u32 flags, phy_interface_t interface)				{					struct device *d = &phydev->dev;					/* Assume that if there is no driver, that it doesn't					 * exist, and we should use the genphy driver. */					if (NULL == d->driver) {	//如果找不到phy的驱动, 则挂接通用phy启动						d->driver = &genphy_driver.driver;						int err = d->driver->probe(d);						if (err >= 0)							err = device_bind_driver(d);					}					phydev->attached_dev = dev;					phydev->dev_flags = flags;					phydev->interface = interface;					/* Do initial configuration here, now that					 * we have certain key parameters					 * (dev_flags and interface) */					return phy_init_hw(phydev);					=>int phy_init_hw(struct phy_device *phydev)					{						return phydev->drv->config_init(phydev);					}				}				phy_prepare_link(phydev, handler);				phy_start_machine(phydev, NULL);				if (phydev->irq > 0)					phy_start_interrupts(phydev);				return 0;			}		}		if (interface == PHY_INTERFACE_MODE_SGMII)			gfar_configure_serdes(dev);	}		err = startup_gfar(dev);	netif_tx_start_all_queues(dev);	device_set_wakeup_enable(&dev->dev, priv->wol_en);}

mac初始化与phy联系起来

int gfar_of_init(struct of_device *ofdev, struct net_device **pdev){	struct net_device *dev = NULL;	struct gfar_private *priv = NULL;	*pdev = alloc_etherdev_mq(sizeof(*priv), num_tx_qs);	dev = *pdev;	priv = netdev_priv(dev);	priv->node = ofdev->node;	priv->ndev = dev;	priv->phy_node = of_parse_phandle(np, "phy-handle", 0);	/* Find the TBI PHY.  If it's not there, we don't support SGMII */	priv->tbi_node = of_parse_phandle(np, "tbi-handle", 0);}

ifconfig ethx之后查看sysfs文件系统

#ls /sys/bus/mdio_bus/devices#	mdio@xxxx24520:10	mdios@xxx24520:11	#ls /sys/bus/mdio_bus/drivers#	Marvell 88E1111	Generic PHY	Generic 10GPHY	#ls /sys/class/mdio_bus -l#	0->../../devices/platform/Fixed MDIO bus.0/mdio_bus/0	mdio@xxxx24520->../../devices/xxxx00000.soc8572/xxxx24520.mdio/mdio_bus/mdio@xxxx24520

 

转载地址:http://vflji.baihongyu.com/

你可能感兴趣的文章
Android中AsyncTask的简单用法
查看>>
概念区别
查看>>
Jenkins 启动命令
查看>>
[LeetCode By Python]121. Best Time to Buy and Sell Stock
查看>>
Android/Linux 内存监视
查看>>
Android2.1消息应用(Messaging)源码学习笔记
查看>>
剑指offer算法题分析与整理(三)
查看>>
JVM并发机制探讨—内存模型、内存可见性和指令重排序
查看>>
nginx+tomcat+memcached (msm)实现 session同步复制
查看>>
WAV文件解析
查看>>
WPF中PATH使用AI导出SVG的方法
查看>>
QT打开项目提示no valid settings file could be found
查看>>
android 代码实现圆角
查看>>
java LinkedList与ArrayList迭代器遍历和for遍历对比
查看>>
drat中构造方法
查看>>
JavaScript的一些基础-数据类型
查看>>
coursesa课程 Python 3 programming 统计文件有多少单词
查看>>
coursesa课程 Python 3 programming course_2_assessment_7 多参数函数练习题
查看>>
coursesa课程 Python 3 programming course_2_assessment_8 sorted练习题
查看>>
多线程使用随机函数需要注意的一点
查看>>