From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.29]) by ozlabs.org (Postfix) with ESMTP id 40BD6DDFBA for ; Fri, 1 May 2009 01:33:33 +1000 (EST) Received: by yx-out-2324.google.com with SMTP id 8so1044202yxb.39 for ; Thu, 30 Apr 2009 08:33:31 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <625fc13d0904200529l152b8d75g33c3f940de1b2920@mail.gmail.com> <1240388476.17445.10.camel@pasglop> Date: Thu, 30 Apr 2009 11:33:31 -0400 Message-ID: Subject: Re: Porting the ibm_newemac driver to use phylib (and other PHY/MAC questions) From: Kyle Moffett To: Grant Likely Content-Type: text/plain; charset=UTF-8 Cc: linuxppc-dev@ozlabs.org, "Linux-Kernel@Vger. Kernel. Org" , netdev List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Thu, Apr 30, 2009 at 11:11 AM, Grant Likely wrote: > Just a heads up Kyle; there are changes queued in the netdev tree > which add OF helpers for MDIO bus drivers and MAC drivers. =C2=A0See here= : > > http://git.kernel.org/?p=3Dlinux/kernel/git/davem/net-next-2.6.git;a=3Dco= mmit;h=3D8bc487d150b939e69830c39322df4ee486efe381 > > and here is an example of a driver change: > > http://git.kernel.org/?p=3Dlinux/kernel/git/davem/net-next-2.6.git;a=3Dco= mmit;h=3D1dd2d06c0459a2f1bffc56765e3cc57427818867 Hmm, very interesting! Thanks! Although I'm not sure that those OF helpers are entirely usable for the emac driver at the moment, as the device trees for the existing boards simply don't have PHYs present in them. Most of the ibm_newemac board device-trees just have one of: "phy-address =3D <4>", "phy-mask =3D <0xffff0000>", or nothing at all (for autodetection). I will probably need to leave in support for the old PHY mask parsing to preserve backwards compatibility. My main concern at the moment is cleaning up the driver's general PHY handling. I got started on this whole mess when I was trying to write some hackish PHY drivers for a weird custom board I've got here. I couldn't figure out why the hell all my PHY register changes in the phy_ops->init function kept getting cleared, until I noticed 2 things: The emac_reset_phy() function gets called occasionally and does not call the ->init() function again afterwards. The genmii_setup_forced() function (in the EMAC driver) unconditionally ORs the BCMR_RESET flag into the MII_BCMR register. Both of those meant that any early setup I did for my PHY was getting completely cleared on a regular basis, with no decent way for me to patch it back up again. Cheers, Kyle Moffett