From: Scott Wood Date: Mon, 21 Sep 2009 12:33:50 -0500 Subject: [U-Boot] [PATCH] Add MII bus implementation for FCC ports (using bitbanging) In-Reply-To: <1253374777-27742-2-git-send-email-luigi.mantellini@gmail.com> References: <1253374777-27742-1-git-send-email-luigi.mantellini@gmail.com> <1253374777-27742-2-git-send-email-luigi.mantellini@gmail.com> Message-ID: <20090921173350.GA31532@b07421-ec1.am.freescale.net> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Sat, Sep 19, 2009 at 05:39:37PM +0200, Luigi 'Comio' Mantellini wrote: > +/***************************************************************************** > + * > + * Utility to send the preamble, address, and register (common to read > + * and write). > + */ > +static void mpc85xx_miiphy_pre (struct ether_fcc_info_s *info, char read, unsigned char addr, unsigned char reg) > +{ > + int j; /* counter */ > + > + int mdio = info->mdiopin; > + int mdc = info->mdcpin; > + > + /* > + * Send a 32 bit preamble ('1's) with an extra '1' bit for good measure. > + * The IEEE spec says this is a PHY optional requirement. The AMD > + * 79C874 requires one after power up and one after a MII communications > + * error. This means that we are doing more preambles than we need, > + * but it is safer and will be much more robust. > + */ > + > + mpc85xx_mdio_active(mdio); > + mpc85xx_mdc_active(mdc); > + mpc85xx_mdio_set(mdio, 1); > + > + for (j = 0; j < 32; j++) { > + mpc85xx_mdc_set(mdc, 0); > + mpc85xx_udelay(1); > + mpc85xx_mdc_set(mdc, 1); > + mpc85xx_udelay(1); > + } > + > + /* send the start bit (01) and the read opcode (10) or write (10) */ > + mpc85xx_mdc_set(mdc, 0); > + mpc85xx_mdio_set(mdio, 0); > + mpc85xx_udelay(1); > + mpc85xx_mdc_set(mdc, 1); > + mpc85xx_udelay(1); > + mpc85xx_mdc_set(mdc, 0); > + mpc85xx_mdio_set(mdio, 1); > + mpc85xx_udelay(1); Please do not duplicate this. Use the existing code in drivers/net/phy/miiphybb.c, refactoring it if necessary. Also, please attribute and preserve copyrights when you copy large chunks of code. -Scott