FPGA+NIOS II 平台 DM9000最新驱动
2014-04-14 11:32
274 查看
QQ:1215483516 TEL:18589097498
#include <stdio.h>
#include "DM9000A.H"
#include "basic_io.h"
//-------------------------------------------------------------------------
void iow(unsigned int reg, unsigned int data)
{
usleep(STD_DELAY);
IOWR(DM9000A_BASE,IO_addr,reg);
usleep(STD_DELAY);
IOWR(DM9000A_BASE,IO_data,data);
}
//-------------------------------------------------------------------------
unsigned int ior(unsigned int reg)
{
usleep(STD_DELAY);
IOWR(DM9000A_BASE,IO_addr,reg);
usleep(STD_DELAY);
return IORD(DM9000A_BASE,IO_data);
}
//-------------------------------------------------------------------------
void phy_write (unsigned int reg, unsigned int value)
{
/* set PHY register address into EPAR REG. 0CH */
iow(0x0C, reg | 0x40); /* PHY register address setting, and DM9000_PHY offset = 0x40 */
/* fill PHY WRITE data into EPDR REG. 0EH & REG. 0DH */
iow(0x0E, ((value >> 8) & 0xFF)); /* PHY data high_byte */
iow(0x0D, value & 0xFF); /* PHY data low_byte */
/* issue PHY + WRITE command = 0xa into EPCR REG. 0BH */
iow(0x0B, 0x8); /* clear PHY command first */
IOWR(DM9000A_BASE, IO_data, 0x0A); /* issue PHY + WRITE command */
do
{
usleep(STD_DELAY);
}while(0x0a != IORD(DM9000A_BASE,IO_data));
IOWR(DM9000A_BASE, IO_data, 0x08); /* clear PHY command again */
usleep(50); /* wait 1~30 us (>20 us) for PHY + WRITE completion */
}
//-------------------------------------------------------------------------
/* DM9000_init I/O routine */
unsigned int DM9000_init (void) /* initialize DM9000 LAN chip */
{
unsigned int i;
/* software-RESET NIC */
iow(NCR, 0x03); /* NCR REG. 00 RST Bit [0] = 1 reset on, and LBK Bit [2:1] = 01b MAC loopback on */
usleep(20); /* wait > 10us for a software-RESET ok */
iow(NCR, 0x00); /* normalize */
iow(NCR, 0x03);
usleep(20);
iow(NCR, 0x00);
/* set the internal PHY power-on (GPIOs normal settings) */
iow(0x1E, 0x01); /* GPCR REG. 1EH = 1 selected GPIO0 "output" port for internal PHY */
iow(0x1F, 0x01); /* GPR REG. 1FH GEPIO0 Bit [0] = 0 to activate internal PHY */
msleep(5); /* wait > 2 ms for PHY power-up ready */
#include <stdio.h>
#include "DM9000A.H"
#include "basic_io.h"
//-------------------------------------------------------------------------
void iow(unsigned int reg, unsigned int data)
{
usleep(STD_DELAY);
IOWR(DM9000A_BASE,IO_addr,reg);
usleep(STD_DELAY);
IOWR(DM9000A_BASE,IO_data,data);
}
//-------------------------------------------------------------------------
unsigned int ior(unsigned int reg)
{
usleep(STD_DELAY);
IOWR(DM9000A_BASE,IO_addr,reg);
usleep(STD_DELAY);
return IORD(DM9000A_BASE,IO_data);
}
//-------------------------------------------------------------------------
void phy_write (unsigned int reg, unsigned int value)
{
/* set PHY register address into EPAR REG. 0CH */
iow(0x0C, reg | 0x40); /* PHY register address setting, and DM9000_PHY offset = 0x40 */
/* fill PHY WRITE data into EPDR REG. 0EH & REG. 0DH */
iow(0x0E, ((value >> 8) & 0xFF)); /* PHY data high_byte */
iow(0x0D, value & 0xFF); /* PHY data low_byte */
/* issue PHY + WRITE command = 0xa into EPCR REG. 0BH */
iow(0x0B, 0x8); /* clear PHY command first */
IOWR(DM9000A_BASE, IO_data, 0x0A); /* issue PHY + WRITE command */
do
{
usleep(STD_DELAY);
}while(0x0a != IORD(DM9000A_BASE,IO_data));
IOWR(DM9000A_BASE, IO_data, 0x08); /* clear PHY command again */
usleep(50); /* wait 1~30 us (>20 us) for PHY + WRITE completion */
}
//-------------------------------------------------------------------------
/* DM9000_init I/O routine */
unsigned int DM9000_init (void) /* initialize DM9000 LAN chip */
{
unsigned int i;
/* software-RESET NIC */
iow(NCR, 0x03); /* NCR REG. 00 RST Bit [0] = 1 reset on, and LBK Bit [2:1] = 01b MAC loopback on */
usleep(20); /* wait > 10us for a software-RESET ok */
iow(NCR, 0x00); /* normalize */
iow(NCR, 0x03);
usleep(20);
iow(NCR, 0x00);
/* set the internal PHY power-on (GPIOs normal settings) */
iow(0x1E, 0x01); /* GPCR REG. 1EH = 1 selected GPIO0 "output" port for internal PHY */
iow(0x1F, 0x01); /* GPR REG. 1FH GEPIO0 Bit [0] = 0 to activate internal PHY */
msleep(5); /* wait > 2 ms for PHY power-up ready */
相关文章推荐
- ATMEL 9263平台 DM9000 LINUX 驱动。
- 函数平台底层之旅——DM9000网卡驱动源码分析
- KELL 平台 DM9000驱动
- linux2.6.32.2 mini2440平台移植--移植DM9000网卡驱动
- U-boot移植 (v2012.04.1 S3C2440平台) (五) DM9000驱动支持,yaffs文件系统下载支持
- S3C2416平台 DM9000 WENCE 标准内驱动
- Redboot 的DM9000 网卡驱动在 MINI2440平台的移植
- linux-2.6.30平台下移植DM9000网卡驱动到TQ2440
- [问答].Nios II、MIPS、Microblaze、ARM这几个嵌入FPGA中的硬核,哪个运用广、前景好?
- Android平台下驱动的开发及测试框架概述(五)
- linux串口终端驱动——s3c6410平台(二)
- 平台驱动 探测到的资源出错
- Linux Kernel设备驱动模型之平台驱动
- linux串口终端驱动——s3c6410平台(三)
- 【linux驱动分析】之dm9000驱动分析
- IT 领域最新宏观趋势 – 平台与微服务
- Linux Kernel设备驱动模型之平台设备初始化
- mini2440上dm9000驱动分析(二)
- 嵌入式linux平台设备驱动(设备驱动模型)开发之linux内核中bus总线
- 【原创】基于NIOS II的ADS1256 SPI驱动