
-----Original Message----- From: u-boot-bounces@lists.denx.de [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Wolfgang Denk Sent: Monday, March 15, 2010 9:38 PM To: Siddarth Gore Cc: u-boot@lists.denx.de; Ashish Karkare; Prabhanjan Sarnaik Subject: Re: [U-Boot] [PATCH] Marvell GuruPlug Board Support
...snip...
+#ifdef CONFIG_RESET_PHY_R +void mv_phy_88e1121_init(char *name) +{
- u16 reg;
- u16 devadr;
- if (miiphy_set_current_dev(name))
return;
- /* command to read PHY dev address */
- if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
printf("Err..%s could not read PHY dev address\n",
__FUNCTION__);
return;
- }
- /*
* Enable RGMII delay on Tx and Rx for CPU port
* Ref: sec 4.7.2 of chip datasheet
*/
- miiphy_write(name, devadr, MV88E1121_PGADR_REG, 2);
- miiphy_read(name, devadr, MV88E1121_MAC_CTRL2_REG, ®);
- reg |= (MV88E1121_RGMII_RXTM_CTRL | MV88E1121_RGMII_TXTM_CTRL);
- miiphy_write(name, devadr, MV88E1121_MAC_CTRL2_REG, reg);
- miiphy_write(name, devadr, MV88E1121_PGADR_REG, 0);
- /* reset the phy */
- if (miiphy_read (name, devadr, PHY_BMCR, ®) != 0) {
printf("Err..(%s) PHY status read failed\n",
__FUNCTION__);
return;
- }
- if (miiphy_write (name, devadr, PHY_BMCR, reg | 0x8000) != 0) {
printf("Err..(%s) PHY reset failed\n", __FUNCTION__);
return;
- }
- printf("88E1121 Initialized on %s\n", name);
+}
We have pretty much identical code already in mv_phy_88e1116_init() [in "board/Marvell/rd6281a/rd6281a.c"], in reset_phy() [in "board/Marvell/openrd_base/openrd_base.c"], in reset_phy(0 [in "board/Marvell/sheevaplug/sheevaplug.c"] and I don't know where else.
I object against adding more and more copies of the same code. Please factor out the common part into a single implementation, and call this everwhere where such code is used. Thanks.
Hi Wolfgang
I agree with you. Pls have a look at old reference http://lists.denx.de/pipermail/u-boot/2009-June/053621.html
I would be keen to do this cleanup. Can someone make new PHY framework available, If not I will be glad to provide Drivers for Marvell PHYs.
Regards.. Prafulla . .