I am working on a custom u-boot project for Yocto. I pretty much have everything working but cannot get the ethernet to connect. The issue appears to be with the Phy device but once at the command prompt, I can see the KSZ9031 Phy device. I have added a board_phy_config() function in my board file and it is being executed. I am using the same config code that was previously used and verified under LTIB.
Following is the u-boot output with some printf debug lines I added to the phy driver. As can be seen, the Phy is addressable but still isn't seen during the boot.
Any ideas what is wrong?
U-Boot 2014.04 (Sep 17 2015 - 11:37:59)
CPU: Freescale i.MX6Q rev1.2 at 792 MHz
CPU: Temperature 37 C, calibration data: 0x5534cc69
Reset cause: POR
Board: SBC35-C398Q
Boot Device: SD
I2C: ready
DRAM: 2 GiB
MMC: FSL_SDHC: 0, FSL_SDHC: 1
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
mmc1 is current device
Net: Phy not found
phy_read++ addr = 7 devad = ffffffff regnum = 0
phy_write++ addr = 7 devad = ffffffff regnum = 0 val = ffff
phy_read++ addr = 7 devad = ffffffff regnum = 0
phy_read++ addr = 7 devad = ffffffff regnum = 9
phy_write++ addr = 7 devad = ffffffff regnum = 9 val = 1b00
phy_write++ addr = 7 devad = ffffffff regnum = d val = 2
phy_write++ addr = 7 devad = ffffffff regnum = e val = 4
phy_write++ addr = 7 devad = ffffffff regnum = d val = c002
phy_write++ addr = 7 devad = ffffffff regnum = e val = 0
phy_write++ addr = 7 devad = ffffffff regnum = d val = 2
phy_write++ addr = 7 devad = ffffffff regnum = e val = 5
phy_write++ addr = 7 devad = ffffffff regnum = d val = c002
phy_write++ addr = 7 devad = ffffffff regnum = e val = 0
phy_write++ addr = 7 devad = ffffffff regnum = d val = 2
phy_write++ addr = 7 devad = ffffffff regnum = e val = 6
phy_write++ addr = 7 devad = ffffffff regnum = d val = c002
phy_write++ addr = 7 devad = ffffffff regnum = e val = 0
phy_write++ addr = 7 devad = ffffffff regnum = d val = 2
phy_write++ addr = 7 devad = ffffffff regnum = e val = 8
phy_write++ addr = 7 devad = ffffffff regnum = d val = c002
phy_write++ addr = 7 devad = ffffffff regnum = e val = 3ff
phy_write++ addr = 7 devad = ffffffff regnum = d val = 2
phy_write++ addr = 7 devad = ffffffff regnum = e val = 10
phy_write++ addr = 7 devad = ffffffff regnum = d val = c002
phy_write++ addr = 7 devad = ffffffff regnum = e val = 4000
phy_read++ addr = 7 devad = ffffffff regnum = 0
phy_write++ addr = 7 devad = ffffffff regnum = 0 val = 1340
ksz9031_config()++
phy_read++ addr = 7 devad = ffffffff regnum = 1
phy_read++ addr = 7 devad = ffffffff regnum = f
phy_read++ addr = 7 devad = ffffffff regnum = 4
phy_read++ addr = 7 devad = ffffffff regnum = 9
phy_read++ addr = 7 devad = ffffffff regnum = 0
ksz9031_config()--
FEC
Normal Boot
Hit any key to stop autoboot: 0
SBC35-C398Q U-Boot > mii info
PHY 0x07: OUI = 0x0885, Model = 0x22, Rev = 0x01, 100baseT, FDX
SBC35-C398Q U-Boot > mdio read 7 2
7 is not a known ethernet
Reading from bus FEC
PHY at address 7:
2 - 0x22
SBC35-C398Q U-Boot > mdio read 7 3
7 is not a known ethernet
Reading from bus FEC
PHY at address 7:
3 - 0x1621
SBC35-C398Q U-Boot >
Solved! Go to Solution.
Yes I did. The following code in my board specific file was not scanning the appropriate phy addr
/* scan phy 4,5,6,7 */
phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII);
The second variable passed to the function phy_find_by_mask() needed to include address 7 which is the MSB of the mask. If you want to scan all addresses from 0-7, then pass 0xff as the parameter.
Hi Paul,
as per mii info command my phy id is 0x18
what paramter should i pass in above function
thanks & regards
Not much of a response. After more analysis, I found that the 'Phy not found' message is generated in the function get_phy_device_by_mask() which is shown below. Maybe someone has some experience with this code. I cannot determine why the function search_for_existing_phy() does not return a valid value since the Phy device is present and addressable. I have verified that the address is a 7 which is the Phy device address. I cannot find where the array phymap[addr] is being initialized? Am I possibly missing some device initialization function that needs to be done before this code is called?
static struct phy_device *search_for_existing_phy(struct mii_dev *bus,
unsigned phy_mask, phy_interface_t interface)
{
/* If we have one, return the existing device, with new interface */
while (phy_mask) {
int addr = ffs(phy_mask) - 1;
if (bus->phymap[addr]) {
bus->phymap[addr]->interface = interface;
return bus->phymap[addr];
}
phy_mask &= ~(1 << addr);
}
return NULL;
}
static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus,
unsigned phy_mask, phy_interface_t interface)
{
int i;
struct phy_device *phydev;
phydev = search_for_existing_phy(bus, phy_mask, interface);
if (phydev)
return phydev;
/* Try Standard (ie Clause 22) access */
/* Otherwise we have to try Clause 45 */
for (i = 0; i < 5; i++) {
phydev = create_phy_by_mask(bus, phy_mask,
i ? i : MDIO_DEVAD_NONE, interface);
if (IS_ERR(phydev))
return NULL;
if (phydev)
return phydev;
}
printf("Phy not found\n");
return phy_device_create(bus, ffs(phy_mask) - 1, 0xffffffff, interface);
}
HI, Paul
Did you solve this problem?
Yes I did. The following code in my board specific file was not scanning the appropriate phy addr
/* scan phy 4,5,6,7 */
phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII);
The second variable passed to the function phy_find_by_mask() needed to include address 7 which is the MSB of the mask. If you want to scan all addresses from 0-7, then pass 0xff as the parameter.
imx6q with PHY chip AR8035, u-boot of L4.1.15-2.0.0 display error:
Net: Board Net Initialization Failed
according to the method, it works well now, thanks so much.
HI Paul
I believe it may be useful to look at micrel drivers at
Micrel KSZ8091 drivers for i.MX6 platform. Any leads appreciated.
[PATCH 3/3] ARM: i.MX6: add ethernet phy fixup for KSZ9031
Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
These patches are for Linux drivers. I am having issues with u-boot access to the PHY.