首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

关于FEC驱动_FEC伍丰

说是网络,其实是网卡驱动。而且是针对于FREESCALE芯片的FEC端的驱动,我不知道别的芯片厂商的FEC模块是怎么样的, 但就我接触过的几款FREESCALE的芯片来看,比如基于POWERPC的860T和ARM系列的MX27等,他们的FEC有一个明显的特点就是 都是由BD和一个DMA缓冲组成,而这个DMA是专用的,也就是只是给FEC使用,区别于芯片内的DMAC模块。我们先来从fec.c这 个与硬件直接相关的看起: 首先找到module_init(fec_enet_module_init);这里fec_enet_module_init为入口点 fec_enet_module_init() 首先调用fec_arch_init,它调用gpio_fec_active设置GPIO为FEC模式,然后如果有电源管理的话,就调用 mxc_fec_power_on开启电源。接着调用clk_get,clk_enable, clk_put设置FEC的CLOCK,这里退出fec_arch_init函数,接 着循环FEC_MAX_PORTS次,也就是有几个FEC就循环几次,在这里我们只有一个FEC,所以这个循环不用管。接下来因为我们 用的是以太网,所以调用dev = alloc_etherdev(sizeof(struct fec_enet_private));申请一个以太网设备描述,其中 struct fec_enet_private是用来描述FEC专有的数据结构。如下: /* The FEC buffer descriptors track the ring buffers. The rx_bd_base and * tx_bd_base always point to the base of the buffer descriptors. The * cur_rx and cur_tx point to the currently available buffer. * The dirty_tx tracks the current buffer that is being sent by the * controller. The cur_tx and dirty_tx are equal under both completely * empty and completely full conditions. The empty/ready indicator in * the buffer descriptor determines the actual condition. */ struct fec_enet_private { /* Hardware registers of the FEC device */ volatile fec_t *hwp; /* The saved address of a sent-in-place packet/buffer, for skfree(). */ unsigned char *tx_bounce[TX_RING_SIZE]; struct sk_buff* tx_skbuff[TX_RING_SIZE]; struct sk_buff* rx_skbuff[RX_RING_SIZE]; ushort skb_cur; ushort skb_dirty; /* CPM dual port RAM relative addresses. */ void * cbd_mem_base; /* save the virtual base address of rx&tx buffer descripter */ cbd_t *rx_bd_base; /* Address of Rx and Tx buffers. */ cbd_t *tx_bd_base; cbd_t *cur_rx, *cur_tx; /* The next free ring entry */ cbd_t *dirty_tx; /* The ring entries to be free()ed. */ struct net_device_stats stats; uint tx_full; spinlock_t lock; uint phy_id; uint phy_id_done; uint phy_status; uint phy_speed; phy_info_t const *p

01
领券