diff mbox

[U-Boot] Which entry in drivers/net/phy/realtek.c matches my device?

Message ID 20160321170721.GC4751@excalibur.cnev.de
State Not Applicable
Headers show

Commit Message

Karsten Merker March 21, 2016, 5:07 p.m. UTC
On Mon, Mar 21, 2016 at 05:11:41PM +0100, Karsten Merker wrote:
> On Sun, Mar 20, 2016 at 08:52:05AM +0100, Michael Haas wrote:
> > Hello all,
> > 
> > I'd like to add some device-specific hacks to realtek.c. I'm using the
> > Olimex A20-OlinuXino-Lime2 which uses the RTL8211CL PHY.
> > 
> > Which of the various phy_driver structs is responsible for that device?
> > I presume it's keyed off the .uid, but I'm not sure how to find the ID
> > of the specific PHY used on my device.
> 
> I have just looked at u-boot's drivers/net/phy/realtek.c and am a
> bit confused regarding the PHY IDs when comparing the code to the
> Linux kernel's drivers/net/phy/realtek.c.
> 
> On my Lime2 and my A20-SOM-EVB, the RTL8211CL provides a PHY ID of
> 0x001cc912:
> 
> Lime2:       eth0: PHY ID 001cc912 at 1 IRQ POLL (stmmac-0:01) active
> A20-SOM-EVB: eth0: PHY ID 001cc912 at 1 IRQ POLL (stmmac-0:01) active
> 
> According to the Linux sources, 0x001cc912 is the PHY ID of the
> RTL8211B, so that would mean that the RTL8211B and RTL8211C share
> the same PHY ID.  I have googled around a bit and that seems to
> be indeed the case.  This is insofar interesting as the PHY IDs
> of the various RTL8211 variants count up otherwhise while there
> is a hole in the numbering scheme where the RTL8211C would fit
> in:
> 
>   RTL8211B: 0x001cc912
> 
>   RTL8211D: 0x001cc914
>   RTL8211E: 0x001cc915
>   RTL8211F: 0x001cc916
> 
> The u-boot drivers/net/phy/realtek.c doesn't have 0x001cc912 as
> the PHY ID for the RTL8211B, but instead has 0x1cc910.  The mask
> bits cover the whole ID, so it looks like the 0x001cc912 from our
> RTL8211CL wouldn't match in u-boot at all?

I have run some tests which have confirmed that this is indeed
the case.  The PHY ID of the RTL8211CL in the A20-OlinuXino-Lime2
doesn't cause a match in the Realtek PHY driver in u-boot.  With
the following patch, the PHY gets at least recognized by the
realtek phy driver.


Regards,
Karsten
diff mbox

Patch

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 259a87f..b5354a8 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -231,6 +231,17 @@  static struct phy_driver RTL8211B_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
+/* Support for RTL8211C PHY */
+static struct phy_driver RTL8211C_driver = {
+	.name = "RealTek RTL8211C",
+	.uid = 0x1cc912,
+	.mask = 0xffffff,
+	.features = PHY_GBIT_FEATURES,
+	.config = &rtl8211x_config,
+	.startup = &rtl8211x_startup,
+	.shutdown = &genphy_shutdown,
+};
+
 /* Support for RTL8211E-VB-CG, RTL8211E-VL-CG and RTL8211EG-VB-CG PHYs */
 static struct phy_driver RTL8211E_driver = {
 	.name = "RealTek RTL8211E",
@@ -267,6 +278,7 @@  static struct phy_driver RTL8211F_driver = {
 int phy_realtek_init(void)
 {
 	phy_register(&RTL8211B_driver);
+	phy_register(&RTL8211C_driver);
 	phy_register(&RTL8211E_driver);
 	phy_register(&RTL8211F_driver);
 	phy_register(&RTL8211DN_driver);