首先先上电路原理图,关于AT91芯片网卡部分的引脚:

内核源码中对网卡以及其他外设设备的驱动程序,设备的注册都在 Board_sam9260ek_.c文件中。

结构体原型:

/* Ethernet (EMAC & MACB) */

struct at91_eth_data {

u32phy_mask;
u8 phy_irq_pin;/* PHY IRQ */
u8 is_rmii;/* using RMII interface? */
};

注册为中断引脚为AT91_PIN_PA7,MII模式

/* MACB Ethernet device*/
static struct at91_eth_data __initdata ek_macb_data = {
.phy_irq_pin = AT91_PIN_PA7,
.is_rmii = 1,
};

添加设备

/* Ethernet */
at91_add_device_eth(&ek_macb_data);

static struct platform_device at91sam9260_eth_device = {
.name = "macb",
.id = -1,
.dev = {
.dma_mask = &eth_dmamask,
.coherent_dma_mask= DMA_BIT_MASK(32),
.platform_data= &eth_data,
},
.resource = eth_resources,
.num_resources= ARRAY_SIZE(eth_resources),
};

void __init at91_add_device_eth(struct at91_eth_data *data)
{
if (!data)
return;

if (data->phy_irq_pin) {
at91_set_gpio_input(data->phy_irq_pin, 0);
at91_set_deglitch(data->phy_irq_pin, 1);
}

/* Pins used for MII and RMII */
at91_set_A_periph(AT91_PIN_PA19, 0);/* ETXCK_EREFCK */
at91_set_A_periph(AT91_PIN_PA17, 0);/* ERXDV */
at91_set_A_periph(AT91_PIN_PA14, 0);/* ERX0 */
at91_set_A_periph(AT91_PIN_PA15, 0);/* ERX1 */
at91_set_A_periph(AT91_PIN_PA18, 0);/* ERXER */
at91_set_A_periph(AT91_PIN_PA16, 0);/* ETXEN */
at91_set_A_periph(AT91_PIN_PA12, 0);/* ETX0 */
at91_set_A_periph(AT91_PIN_PA13, 0);/* ETX1 */
at91_set_A_periph(AT91_PIN_PA21, 0);/* EMDIO */
at91_set_A_periph(AT91_PIN_PA20, 0);/* EMDC */

if (!data->is_rmii) {
at91_set_B_periph(AT91_PIN_PA28, 0);/* ECRS */
at91_set_B_periph(AT91_PIN_PA29, 0);/* ECOL */
at91_set_B_periph(AT91_PIN_PA25, 0);/* ERX2 */
at91_set_B_periph(AT91_PIN_PA26, 0);/* ERX3 */
at91_set_B_periph(AT91_PIN_PA27, 0);/* ERXCK */
at91_set_B_periph(AT91_PIN_PA23, 0);/* ETX2 */
at91_set_B_periph(AT91_PIN_PA24, 0);/* ETX3 */
at91_set_B_periph(AT91_PIN_PA22, 0);/* ETXER */
}

eth_data = *data;
platform_device_register(&at91sam9260_eth_device);

}

可以发现注册的为platform总线上的设备

在内核启动后可在 sys/bus/platform/devices中找到macb、除此之外,你也可以发现注册在platform总线上的nandflash、uart、spi、i2c等设备

[@SD9260: /]# cd sys/
[@SD9260: /sys]# ls
block     class     devices   fs        module
bus       dev       firmware  kernel    power
[@SD9260: /sys]# clear
[@SD9260: /sys]# ls
block     class     devices   fs        module
bus       dev       firmware  kernel    power
[@SD9260: /sys]# cd bus/
[@SD9260: bus]# ls
i2c       mmc       scsi      serio     usb
mdio_bus  platform  sdio      spi
[@SD9260: bus]# cd platform/
[@SD9260: platform]# ls
devices            drivers_autoprobe  uevent
drivers            drivers_probe
[@SD9260: platform]# cd devices/
[@SD9260: devices]# ls
at91_mci       atmel_nand     atmel_usart.1  atmel_usart.5  macb
at91_ohci      atmel_spi.0    atmel_usart.2  atmel_usart.6  ssc.0
at91_rtt.0     atmel_spi.1    atmel_usart.3  i2c-gpio
at91_udc       atmel_usart.0  atmel_usart.4  leds-gpio
[@SD9260: devices]# cd macb/
[@SD9260: macb]# ls
bus        driver     modalias   net:eth0   power      subsystem  uevent

对应引脚连接到DP83848以太网控制芯片,0用的是MII模式 百兆网口芯片,这样就网卡芯片驱动就起来了。
但是在网卡使用的过程中是如何判断网卡的状态的呢?
Linux内核通过读取网卡内置芯片中的寄存器来判断网卡的工作状态。下面来说明网卡link up过程。
地址为0x00 的寄存器的各位功能如下:
Table 6-9. Basic Mode Control Register (BMCR), address 0x00

Bit Bit Name Default Description
15 Reset 0, RW/SC Reset:
1 = Initiate software Reset / Reset in Process.
0 = Normal operation.
This bit, which is self-clearing, returns a value of one until the reset process is complete. The
configuration is re-strapped.
14 Loopback 0, RW Loopback:
1 = Loopback enabled.
0 = Normal operation.
The loopback function enables MII transmit data to be routed to the MII receive data path.
Setting this bit may cause the descrambler to lose synchronization and produce a 500 µs “dead
time” before any valid data will appear at the MII receive outputs.
13 Speed Selection RW Speed Select:
When auto-negotiation is disabled writing to this bit allows the port speed to be selected.
1 = 100 Mb/s.
0 = 10 Mb/s.
12 Auto-Negotiation
Enable
RW Auto-Negotiation Enable:
Strap controls initial value at reset.
1 = Auto-Negotiation Enabled - bits 8 and 13 of this register are ignored when this bit is set.
0 = Auto-Negotiation Disabled - bits 8 and 13 determine the port speed and duplex mode.
11 Power Down 0, RW Power Down:
1 = Power down.
0 = Normal operation.
Setting this bit powers down the PHY. Only the register block is enabled during a power-down
condition.
10 Isolate 0, RW Isolate:
1 = Isolates the Port from the MII with the exception of the serial management.
0 = Normal operation.
9 Restart Auto
Negotiation
0, RW/SC Restart Auto-Negotiation:
1 = Restart Auto-Negotiation. Re-initiates the Auto-Negotiation process. If Auto-Negotiation is
disabled (bit 12 = 0), this bit is ignored. This bit is self-clearing and will return a value of 1 until
Auto-Negotiation is initiated, whereupon it will self-clear. Operation of the Auto-Negotiation
process is not affected by the management entity clearing this bit.
0 = Normal operation.
8 Duplex Mode RW Duplex Mode:
When auto-negotiation is disabled writing to this bit allows the port Duplex capability to be
selected.
1 = Full Duplex operation.
0 = Half Duplex operation.
Bit Bit Name Default Description
7 Collision Test 0, RW Collision Test:
1 = Collision test enabled.
0 = Normal operation.
When set, this bit will cause the COL signal to be asserted in response to the assertion of
TX_EN within 512-bit times. The COL signal will be deasserted within 4-bit times in response to
the deassertion of TX_EN.
6:0 RESERVED 0, RO RESERVED: Write ignored, read as 0

关于以太网芯片寄存器的详细描述可参考该博客 http://blog.csdn.net/subfate/article/details/44958597
Linux中通过程序来读取寄存器当前的值:源代码如下:

#include #include #include #include #include #include #include #include #include #include #include #define reteck(ret) \ if(ret < 0){ \ printf("%m! \"%s\" : line: %d\n", __func__, __LINE__); \ goto lab; \ } #define help() \ printf("mdio:\n"); \ printf("read operation: mdio reg_addr\n"); \ printf("write operation: mdio reg_addr value\n"); \ printf("For example:\n"); \ printf("mdio eth0 1\n"); \ printf("mdio eth0 0 0x12\n\n"); \ exit(0); int sockfd; int main(int argc, char *argv[]){ if(argc == 1 || !strcmp(argv[1], "-h")){ help(); } struct mii_ioctl_data *mii = NULL; struct ifreq ifr; int ret; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, argv[1], IFNAMSIZ - 1); sockfd = socket(PF_LOCAL, SOCK_DGRAM, 0); reteck(sockfd); //get phy address in smi bus ret = ioctl(sockfd, SIOCGMIIPHY, &ifr); reteck(ret); mii = (struct mii_ioctl_data*)&ifr.ifr_data; if(argc == 3){ mii->reg_num = (uint16_t)strtoul(argv[2], NULL, 0); ret = ioctl(sockfd, SIOCGMIIREG, &ifr); reteck(ret); printf("read phy addr: 0x%x reg: 0x%x value : 0x%x\n\n", mii->phy_id, mii->reg_num, mii->val_out); }else if(argc == 4){ mii->reg_num = (uint16_t)strtoul(argv[2], NULL, 0); mii->val_in = (uint16_t)strtoul(argv[3], NULL, 0); ret = ioctl(sockfd, SIOCSMIIREG, &ifr); reteck(ret); printf("write phy addr: 0x%x reg: 0x%x value : 0x%x\n\n", mii->phy_id, mii->reg_num, mii->val_in); } lab: close(sockfd); return 0; }

通过对PHY层 的寄存器来判断网卡的工作状态。

./phy eth0 0x1

./phy eth0 0x1 0x7849  将0x7849写入寄存器1

以上就是我对AT91SAM9260网卡驱动以及DP83848网卡芯片的一些理解。

AT91Sam9260的网卡驱动相关推荐

  1. 无法安装此计算机不存在英特尔,win2008serverr2intel网卡驱动无法安装不存在英特尔PRO适配器的解决方法...

    无法安装驱动程序,此计算机上不存在英特尔(R),PRO适配器,甚至去官网下载了 intel 82579vforwindows 2008 r2 的驱动 都提示这个. 解决方法: intel官网下载for ...

  2. 备份一个万能网卡驱动

    昨天安装了一个windows2008,因为是在pc上安装,还是个老机器,安装完成后竟然发现我的网卡驱动未成功安装,我就觉得弄个驱动精灵不就ok了吗,结果安装提示不支持server版本,安装驱动人生也不 ...

  3. linux拓实n87驱动下载,拓实n87网卡驱动for xp/win7官方版

    拓实n87网卡驱动for xp/win7官方版是一个十分强大的网卡驱动管理软件,拓实n87网卡驱动for xp/win7官方版是ts N87高增益全向无线USB网卡驱动程序,拓实n87全面支持移动cm ...

  4. (超贴心)Centos7安装2.5G网卡驱动(Realtek 3000)

    文章目录 前言 准备 正题 问题1: 问题2 问题3 问题4 前言 首先跟大家聊聊我的情况吧.因为网络极其关键,要不然服务器还服务个毛,就会是一个废物. 我是在最小化安装Centos7系统的时候,设置 ...

  5. 【技术贴】虚拟机 VMware win7 win8网卡驱动下载 解决虚拟机不识别网卡没有本地连接...

    解决虚拟机VMware7.0下虚拟win7 win8找不到网卡,不能识别网卡.没有本地连接.(本篇文章只适合虚拟机win7/win8 32位环境) 废话不多说,直接入题.vmware 虚拟机 win7 ...

  6. Linux 网卡驱动相关——03

    紧接上一篇,这里简要介绍net_device 结构和网卡驱动框架. struct net_device  是一个比sk_buff 更复杂的结构,里面包含了与TCP/IP协议栈通信的接口函数,但是自从2 ...

  7. 普通PC安装ESXI6.0无法识别网卡驱动问题

    VMware官方镜像中没有封装普通网卡的驱动,无法识别REALTEK RTL 8111E等.需要通过ESXi-Customizer-v2.7.2工具将驱动程序封装到安装镜像里面,在网上收了一些资料,借 ...

  8. 在Centos6.5下安装AR8161网卡驱动

    不确定网卡驱动是否安装了的话,先在终端输入ifconfig看看有没有eth0. 若没有按照以下几个方法安装: 1.下载Atheros AR8161驱动,下面是网址 http://pan.baidu.c ...

  9. linux编译安装网卡驱动详解(网卡丢包)

    安装编译网卡驱动 这两天发现一台server丢包很严重,使用cacti监控工具时能获得snmp包,时常又不能,丢包严重,导致使用ssh工具连接过慢,连接数据库访问超时,此时要先确定是中病毒还是网卡问题 ...

最新文章

  1. python opencv 实现Reinhard颜色迁移算法
  2. 独家 | 使用Python的OpenAI Gym对Deep Q-Learning的实操介绍(附学习资源)
  3. 【机器学习PAI实践二】人口普查统计
  4. 将用户添加到sudoers里面,使用户拥有sudo权限
  5. Saving Tang Monk II HihoCoder - 1828(2018北京网络赛三维标记+bfs)
  6. 企业管理软件随想-透视-包容,无形思想-有形方便
  7. 智乃的数据库(STL+小技巧)
  8. iis7 下php 环境配置文件,IIS7.X配置PHP运行环境小结_php
  9. egret 使用frame转载
  10. Executing an update/delete query
  11. 4-20mA电流光纤中继器的原理和应用
  12. 相机快门和曝光时间的确定
  13. TSW马宝国杯 web(我马宝国被黑了)
  14. 算法题:岛屿最大面积
  15. git与github从入门到精通
  16. 【大数据入门核心技术-Spark】(二)Spark核心模块
  17. 自己动手写CSDN博客提取器源码分析之三:处理网页保存为pdf文件
  18. 计算机学院寝室文明风景线活动,计算机工程学院院文明寝室评选活动圆满结束...
  19. 不同网站备案需要相同的服务器么,不同域名备案在一个服务器吗
  20. AES算法加解密及简单图像化界面实现

热门文章

  1. 目前应用计算机管理系统在护理管理中不包括,目前应用计算机管理系统在护理管理中不包括...
  2. 三自由度求解正逆运动学
  3. Zookeeper之开源客户端ZkClient
  4. 测试成本--半导体测试最大的障碍
  5. easypoi教程_easypoi导出Excel
  6. 第八届河南省程序设计大赛 引水工程 Prim算法
  7. 微信公众号聊天室 私聊功能演示
  8. android 4.4拍照后图片镜像处理
  9. 强大的科学统计软件 Stata 16 中文Mac版(内附安装包链接)
  10. 科技以换皮为本:路遥工具箱 V4 版本发布