讀取Intel Lan PHY 的內部register (非EEPROM)。

1. 在D25:F0 的 10h-13h為PHY CSR 的base address, 需透過這個位置去讀取PHY register.

2. 在PHY的spec內,有章節在定義PHY的register,以 #421009 82579 GBE的datasheet為例,在第12章Intel 6 series express chipset MAC programming Interface內,有介紹每個offset的作用。

3. 若要讀取MDIC(MDI Control register),則是在offset 0x00020內。

4. 在MDI中,register是利用PHY address 及 page去分類的,因此需要在0x00020中,將op-code, PHY Address, register address, and DATA(if write)設定好,便可讀寫此MDIC register.

5. 範例:讀取MDIC page 770, register 17.

#define PHY_PAGE770_SET_REG 0x43F6040   //0x6040需除以32,便是770,Spec上說要除32的。寫page要寫在register 31,也是Spec上寫的。

//
// Write PHY_CONFIG_REG with set page 770
//
MmioWrite32 ((GbEBar + 0x00020), PHY_PAGE770_SET_REG);
for (LoopTime = 0; LoopTime < GBE_MAX_LOOP_TIME; LoopTime++) {
RegisterValue = MmioRead32 (GbEBar + 0x00020);

if (RegisterValue & BIT28) {
break;
}

pBS->Stall (10);
}

if (LoopTime >= GBE_MAX_LOOP_TIME) {
return ;
}
//
// Delay 4ms after page change
//
pBS->Stall (4000);

//
// Read register 16 
//
MmioWrite32 ((GbEBar + 0x00020), 0x8310000);   //0x8310000: bit27:26-> read, bit25:21->PHY addr, bit20:16->register, bit15:0->Data
for (LoopTime = 0; LoopTime < GBE_MAX_LOOP_TIME; LoopTime++) {
RegisterValue = MmioRead32 (GbEBar + 0x00020);

if (RegisterValue & BIT28) {
break;
}

pBS->Stall (10);
}

if (LoopTime >= GBE_MAX_LOOP_TIME) {
return ;
}

 

文章標籤
全站熱搜
創作者介紹
創作者 pipiwau 的頭像
pipiwau

pipiwau的部落格

pipiwau 發表在 痞客邦 留言(0) 人氣(671)