Subject: Re: Fwd: micrel: ksz8051 badly detected as ksz8031

From: Angelo Dureghello <[email-masked]>
Date: Tue, 14 Oct 2014 21:33:24 +0200

Hi Florian,

> On 10/14/2014 10:24 AM, Angelo Dureghello wrote:
>> Dear,
>>
>> have to apologize for the confusion, previous patch is not the proper fix,
>> since it is not solving completely the issue.
>>
>> And also, i mainly misunderstood the issue.
>>
>> The issue i am experiencing is :
>>
>> https://lkml.org/lkml/2013/9/18/259
>>
>> Mainly, i have Micrel chip marked KSZ8051(RNL), but the product Id in the
>> silicon is KSZ8031 and linux detects it as KSZ8031.
>> The attmept to mdio boot override register kill the Micrel functionality.
> Ok, so basically your bootloader does something that Linux does, and
> once Linux boots, it will reset the PHY to put it in a known state. If
> you can snoop the MDIO read/writes done in your bootloader environment,
> that might help narrow down the issue.
>
Bootloader is u-boot and seems it uses generic PHY setup, and so it works.

Linux at boot detects the phy and does a soft_reset. If the detection 
sets the
driver as for KSZ8031, ethernet/link will not work, becouse micrel.c uses
the incorrect config_init function, attempts to write to the bootstrap
override register, that can't be written for KSZ8051, and so puts the micrel
chip in a broken state.

The guy in this link (https://lkml.org/lkml/2013/9/18/259) seems are 
discussing a
better solution.

I patched my linux as below, but this is a fast fixup for me:

diff -rupN drivers/net/phy/phy_device.c 
../linux-3.17/drivers/net/phy/phy_device.c
--- drivers/net/phy/phy_device.c        2014-10-14 21:05:56.191117190 +0200
+++ ../linux-3.17/drivers/net/phy/phy_device.c  2014-10-05 
21:23:04.000000000 +0200
@@ -310,19 +310,6 @@ static int get_phy_id(struct mii_bus *bu

         *phy_id |= (phy_reg & 0xffff);

-       /*
-        * Angelo - Barix
-        * Micrel produced chips marked KSZ8051 but with KSZ8031 id code
-        * in the silicon. After getting crazy to understand why in 
recent kernel
-        * the ethenret was not workeing, i find it out.
-        *
-        * From the schematic, we assume to use KSZ8051
-        * I hardcode the fix here for ipam390.
-        */
-#if CONFIG_MACH_BARIX_IPAM390
-       if (*phy_id == 0x00221556) *phy_id = 0x00221550;
-#endif
-
         return 0;
  }

Regards
angelo