|
OK6410 板,S3C6410核心,板载DM9000A,DM9000的CS脚连接到XM0CSN1 (SROM Bank1 : 0x1800_0000 0x1FFF_FFFF ),CMD连接到ADDR2,所以INDEX口地址应该是0x18000000,DATA口地址应该是0x18000004。现在的问题是读写DM9000没反应,读ID返回0,程序如下:
#define __REG(x) (*(volatile unsigned int *)(x))
#define rSROM_BW __REG(0x70000000)
#define rSROM_BC0 __REG(0x70000004)
#define rSROM_BC1 __REG(0x70000008)
#define rSROM_BC2 __REG(0x7000000C)
#define rSROM_BC3 __REG(0x70000010)
#define rSROM_BC4 __REG(0x70000014)
#define rSROM_BC5 __REG(0x70000018)
#define rGPNCON __REG(0x7F008830)
#define rGPNDAT __REG(0x7F008834)
#define rGPNPUD __REG(0x7F008838)
#define rEINT0CON0 __REG(0x7F008900)
#define rEINT0FLTCON0 __REG(0x7F008910)
#define rEINT0MASK __REG(0x7F008920)
#define rEINT0PEND __REG(0x7F008924)
#define rVIC0INTENABLE __REG(0x71200010)
#define rVIC1INTENABLE __REG(0x71300010)
static void iow(u32 adr, u32 dat)
{
__REG(0x18000300) = adr;
__REG(0x18000304) = dat;
}
static u32 ior(u32 adr)
{
__REG(0x18000300) = adr;
return (__REG(0x18000304));
}
void DM9000A_Init(void)
{
u8 rMAC[8];
u32 id_val;
Uart_Printf("\r\nS3C6410: DM9000 Init...");
//SROM: Bank1, Not using UB/LB, WAIT disable, 16-bit
rSROM_BW = (rSROM_BW & 0xFFFFFF0F) | (0<<7) | (0<<6) | (0<<5) | (1<<4) ;
rSROM_BC1 = (0x2<<28)|(0x4<<24)|(0x6<<16)|(0x4<<12)|(0x2<<8)|(0x6<<4)|(0x0<<0);
//GPIO:GPN,For EINT7
rGPNCON = (rGPNCON & (~(0x3<<14))) | (0x2 << 14);
rGPNPUD = rGPNPUD & (~(0x3<<14));
//EINT7 Enable
rEINT0CON0 = (rEINT0CON0 & (~(0x7 <<12))) | (0x1 << 12); //High Level Interrupt
rEINT0PEND = rEINT0PEND | (0x01<<7); //Clear EINT7
rEINT0MASK = rEINT0MASK & (~(0x1<<7)); //Enable EINT7
iow(0x1F, 0x00); //GPR: Power on
iow(0x00, 0x03); //NCR: Reset
delay(200000);
iow(0x00, 0x03); //
delay(200000);
iow(0x00, 0x00); //NCR: Normal Mode
id_val = ior(DM9000_VIDL);
id_val |= (ior(DM9000_VIDH) << 8);
id_val |= (ior(DM9000_PIDL) << 16);
id_val |= (ior(DM9000_PIDH) << 24);
Uart_Printf("\r\nS3C6410: DM9000 ID:%d",id_val);
if (id_val != 0x90000A46)
{
Uart_Printf("\r\nS3C6410: Warning!!! DM9000 is not working."); //--------------------只能读到0
return;
}
iow(0x02, 0x00); //TCR: TX Polling clear
iow(0x08, 0x3F); //BPTR: Less 3Kb, 200us
iow(0x09, 0x38); //FCTR: Flow Control : High/Low Water
iow(0x0A, 0x00); //FCR: Flow Control
iow(0x2F, 0x00); //SMCR: Special Mode
iow(0xFF, 0x80); //IMR:Enable Pointer Auto Return
iow(0x10, MAC[0]); //Physical Address Registers
iow(0x11, MAC[1]);
iow(0x12, MAC[2]);
iow(0x13, MAC[3]);
iow(0x14, MAC[4]);
iow(0x15, MAC[5]);
rMAC[0] = ior(0x10);
rMAC[1] = ior(0x11);
rMAC[2] = ior(0x12);
rMAC[3] = ior(0x13);
rMAC[4] = ior(0x14);
rMAC[5] = ior(0x15);
Uart_Printf("\r\nS3C6410: DM9000 MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",rMAC[0],rMAC[1],rMAC[2],rMAC[3],rMAC[4],rMAC[5]);//--------------------读MAC也返回不对的值
iow(0x16, 0xFF); //Multicast Address Registers
iow(0x17, 0xFF);
iow(0x18, 0xFF);
iow(0x19, 0xFF);
iow(0x1A, 0xFF);
iow(0x1B, 0xFF);
iow(0x1C, 0xFF);
iow(0x1D, 0xFF);
iow(0xFE, 0x3F); //ISR: Clear Interrupt;
iow(0x01, 0x2D); //NSR: Clear Interrupt;
//Enable EINT7
iow(0xFF, 0x83); //IMR: Enable Rx / Tx Interrupt
iow(0x05, 0x31); //RCR: Discard Long Packet , Discard CRC Error Packet , Enable Rx
Eth.IO_Width = (ior( 0xFE ) >> 7 ) & 0x01;
}
GPOCON GPPCON GPQCON 默认已设置为MEM PORT, MEM PORT 的时钟也默认打开了。
怀疑是时序问题 ,HCLK = 133MHz ,照上面的时序应该是没问题的。在官方提供的Linux源码里找到一个时序:
rSROM_BC1 = (0x0<<28)|(0x4<<24)|(0xd<<16)|(0x1<<12)|(0x4<<8)|(0x6<<4)|(0x0<<0);
结果还是一样。。。
我是初学者,现在找不到原因了,或许还漏掉什么东西,请高手帮忙~ |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|