[U-Boot-Users] AT91SAM9260EK with KS8721 PHY

Hello,
I'm trying to build a U-Boot from your git tree with the AT91 patches. My board is a custom board with a KS8721 instead of the DM9161 network PHY chip. This is the same chip as Olimex used on their development board.
Olimex build a U-Boot for their board, they did some code hacking on u-boot. As far as I know they did the following to get the ethernet up and running. [1] This is in the board/at91sam9260ek/dm9161a.c file
On the latest git version with the AT91 patches the ethernet driver is called macb??!!
Do you know how I can get this working? (as hack and in the future more clean)
Kind regards,
Sander Vermin
[1] static unsigned int dm9161a_IsPhyConnected (AT91PS_EMAC p_mac) { unsigned short Id1, Id2;
at91_EmacEnableMDIO (p_mac); at91_EmacReadPhy (p_mac, SAM9260EK_PHY_ADDRESS, DM9161_PHYID1, &Id1); at91_EmacReadPhy (p_mac, SAM9260EK_PHY_ADDRESS, DM9161_PHYID2, &Id2); at91_EmacDisableMDIO (p_mac);
/*printf(" Id1 0x%04x\n", Id1); printf(" Id1 0x%04x\n", Id2);*/
if ((Id1 == (DM9161_PHYID1_OUI >> 6)) && ((Id2 >> 10) == (DM9161_PHYID1_OUI & DM9161_LSB_MASK))) { printf("DM9161A PHY Detected\n\r"); return TRUE; }
if ((Id1 == MICREL_ID_1) && (Id2 == MICREL_ID_2)) { printf("KS8721 PHY Detected\n\r"); return TRUE; }
return FALSE; }

Le lundi 07 avril 2008 à 15:16 +0200, Sander Vermin a écrit :
Hello,
I'm trying to build a U-Boot from your git tree with the AT91 patches. My board is a custom board with a KS8721 instead of the DM9161 network PHY chip. This is the same chip as Olimex used on their development board.
Olimex build a U-Boot for their board, they did some code hacking on u-boot. As far as I know they did the following to get the ethernet up and running. [1] This is in the board/at91sam9260ek/dm9161a.c file
Are the changes limited to recognizing the MICREL_* phy id
On the latest git version with the AT91 patches the ethernet driver is called macb??!!
Yes.
Do you know how I can get this working? (as hack and in the future more clean)
Did you test it as is ? From what I see in the code, the macb driver doesn't care much about the PHY type...
Stelian.

Stelian Pop a écrit :
Le lundi 07 avril 2008 à 15:16 +0200, Sander Vermin a écrit :
Hello,
I'm trying to build a U-Boot from your git tree with the AT91 patches. My board is a custom board with a KS8721 instead of the DM9161 network PHY chip. This is the same chip as Olimex used on their development board.
Olimex build a U-Boot for their board, they did some code hacking on u-boot. As far as I know they did the following to get the ethernet up and running. [1] This is in the board/at91sam9260ek/dm9161a.c file
Are the changes limited to recognizing the MICREL_* phy id
from memory, on AT91RM9200 with KS8721SL, it was necessary to tweak some bits in order to change the "isolate" setting of the PHY.
Eric

Stelian Pop schreef:
Le lundi 07 avril 2008 à 15:16 +0200, Sander Vermin a écrit :
Hello,
I'm trying to build a U-Boot from your git tree with the AT91 patches. My board is a custom board with a KS8721 instead of the DM9161 network PHY chip. This is the same chip as Olimex used on their development board.
Olimex build a U-Boot for their board, they did some code hacking on u-boot. As far as I know they did the following to get the ethernet up and running. [1] This is in the board/at91sam9260ek/dm9161a.c file
Are the changes limited to recognizing the MICREL_* phy id
On the latest git version with the AT91 patches the ethernet driver is called macb??!!
Yes.
Do you know how I can get this working? (as hack and in the future more clean)
Did you test it as is ? From what I see in the code, the macb driver doesn't care much about the PHY type...
Stelian.
I did test it, u-boot says no PHY present. I had to change from RMII mode to MII mode due to my hardware design.
Regards,
Sander

Le lundi 07 avril 2008 à 16:14 +0200, Sander Vermin a écrit :
Did you test it as is ? From what I see in the code, the macb driver doesn't care much about the PHY type...
I did test it, u-boot says no PHY present. I had to change from RMII mode to MII mode due to my hardware design.
Ok, so there must be something else in the code which was changed to support your PHY (look for some "isolate" setting like Eric said). You'll need to find out what it is...

Stelian Pop a écrit :
Le lundi 07 avril 2008 à 16:14 +0200, Sander Vermin a écrit :
Did you test it as is ? From what I see in the code, the macb driver doesn't care much about the PHY type...
I did test it, u-boot says no PHY present. I had to change from RMII mode to MII mode due to my hardware design.
Ok, so there must be something else in the code which was changed to support your PHY (look for some "isolate" setting like Eric said). You'll need to find out what it is...
please find attached a quick and dirty hacked ks8721.c and the corresponding .h It works on an AT91RM9200 with u-boot 1.3.2.
Eric

Le lundi 07 avril 2008 à 22:23 +0200, Eric BENARD a écrit :
Stelian Pop a écrit :
Le lundi 07 avril 2008 à 16:14 +0200, Sander Vermin a écrit :
Did you test it as is ? From what I see in the code, the macb driver doesn't care much about the PHY type...
I did test it, u-boot says no PHY present. I had to change from RMII mode to MII mode due to my hardware design.
Ok, so there must be something else in the code which was changed to support your PHY (look for some "isolate" setting like Eric said). You'll need to find out what it is...
please find attached a quick and dirty hacked ks8721.c and the corresponding .h It works on an AT91RM9200 with u-boot 1.3.2.
Hmm, if I sed: s/KS8721/DM9161/g and s/ks8721/dm9161/g
on your files I find almost no change with regard to the original version, except:
#define PHY_ADDRESS (1<<5)
and a #if 0 commenting out a bit of the initialisation sequence...
This makes me think it may only be a PHY_ADDRESS issue: what happens if you change in cpu/arm926ejs/at91sam9/ether.c :
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 0x00);
to
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 1<<5);
Stelian.

Stelian Pop a écrit :
Hmm, if I sed: s/KS8721/DM9161/g and s/ks8721/dm9161/g
on your files I find almost no change with regard to the original version, except:
#define PHY_ADDRESS (1<<5)
and a #if 0 commenting out a bit of the initialisation sequence...
yes, goal was to make a clean driver starting from dm9161 with PHY_ADDRESS in the config file ... but I didn't had time to progress on it :-( Isolate problem can happen depending on the pullup/down configuration I think (I didn't check in tthe datasheet, but I once met the problem).
This makes me think it may only be a PHY_ADDRESS issue: what happens if you change in cpu/arm926ejs/at91sam9/ether.c :
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 0x00);
to
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 1<<5);
It's not running on a 9260 so I can't test but it should work (and this may be the problem Sander have).
Eric

Eric BENARD schreef:
Stelian Pop a écrit :
Hmm, if I sed: s/KS8721/DM9161/g and s/ks8721/dm9161/g
on your files I find almost no change with regard to the original version, except:
#define PHY_ADDRESS (1<<5)
and a #if 0 commenting out a bit of the initialisation sequence...
yes, goal was to make a clean driver starting from dm9161 with PHY_ADDRESS in the config file ... but I didn't had time to progress on it :-( Isolate problem can happen depending on the pullup/down configuration I think (I didn't check in tthe datasheet, but I once met the problem).
This makes me think it may only be a PHY_ADDRESS issue: what happens if you change in cpu/arm926ejs/at91sam9/ether.c :
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 0x00);
to
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 1<<5);
It's not running on a 9260 so I can't test but it should work (and this may be the problem Sander have).
Eric
I did a new build with:
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 1<<5);
in stead of:
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 0x00);
But still no PHY detected :-(
The files that Eric send were for a AT91RM9200? and don't work on my AT91SAM9260?
Sander

Sander Vermin a écrit :
I did a new build with:
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 1<<5);
in stead of:
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 0x00);
But still no PHY detected :-(
You need to check your schematic, and the PHY datasheet in order to know what could be the address of your PHY (set by pull up/down resistors on several pins of the PHY at reset of the PHY).
Or you can try a loop on the PHY address and see if it answers at any address ...
Eric

Eric BENARD schreef:
Sander Vermin a écrit :
I did a new build with:
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 1<<5);
in stead of:
macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 0x00);
But still no PHY detected :-(
You need to check your schematic, and the PHY datasheet in order to know what could be the address of your PHY (set by pull up/down resistors on several pins of the PHY at reset of the PHY).
Or you can try a loop on the PHY address and see if it answers at any address ...
Eric
It works!!
The detection of the PHY works, the base address was 0x01 instead of 0x00.
Wen I try to enable RII mode (CONFIG_CMD_MII) I get all kinds of errors about variable not being found:
macb.c: In function 'miiphy_read': macb.c:528: error: 'macb' undeclared (first use in this function) macb.c:528: error: (Each undeclared identifier is reported only once macb.c:528: error: for each function it appears in.) macb.c:528: error: 'MACB_EMACB_NCR' undeclared (first use in this function) macb.c:539: error: 'MACB_EMACB_MAN' undeclared (first use in this function) macb.c:542: error: 'MACB_EMACB_NSR' undeclared (first use in this function) macb.c: In function 'miiphy_write': macb.c:566: error: 'macb' undeclared (first use in this function) macb.c:566: error: 'MACB_EMACB_NCR' undeclared (first use in this function) macb.c:578: error: 'MACB_EMACB_MAN' undeclared (first use in this function) macb.c:581: error: 'MACB_EMACB_NSR' undeclared (first use in this function) make[1]: *** [macb.o] Error 1
Looking at the code I see that macb should be a pointer to "struct macb_device *macb" how should this code work? I don't see any functions point to the miiphy_read an write functions.
Sander

Hi,
Sander Vermin a écrit :> I did a new build with:> > macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 1<<5);> > in stead of:> > macb_eth_initialize(0, (void *)AT91_BASE_EMAC, 0x00);> > But still no PHY detected :-(> You need to check your schematic, and the PHY datasheet in order to know what could be the address of your PHY (set by pull up/down resistors on several pins of the PHY at reset of the PHY). Or you can try a loop on the PHY address and see if it answers at any address ...
Try this code to do the loop test.
#if defined(CONFIG_YOURBOARD) #define MAX_PHY_ADDR 64 for (i = 0 ; i < MAX_PHY_ADDR; i++) { macb->phy_addr = i; phy_id = macb_mdio_read(macb, MII_PHYSID1); if (phy_id != 0xffff) break; } printf("phy_id %x found at %d\n", phy_id, i); #else phy_id = macb_mdio_read(macb, MII_PHYSID1); #endif
Michael
participants (4)
-
Eric BENARD
-
michael
-
Sander Vermin
-
Stelian Pop