From: York Sun Date: Thu, 28 Jul 2011 14:41:56 -0700 Subject: [U-Boot] [PATCHv2] fsl_ddr: Don't use full 64-bit divides on32-bit PowerPC In-Reply-To: <012D4984-FEC4-4C55-B74D-940D426F1694@boeing.com> References: <1298478920-22044-1-git-send-email-Kyle.D.Moffett@boeing.com> <1300134142.23720.52.camel@oslab-l1> <012D4984-FEC4-4C55-B74D-940D426F1694@boeing.com> Message-ID: <1311889316.2842.3.camel@oslab-l1> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Kyle, On Mon, 2011-03-14 at 16:35 -0500, Moffett, Kyle D wrote: > On Mar 14, 2011, at 16:22, York Sun wrote: > > On Wed, 2011-02-23 at 11:35 -0500, Kyle Moffett wrote: > >> + * Now divide by 5^12 and track the 32-bit remainder, then divide > >> + * by 2*(2^12) using shifts (and updating the remainder). > >> + */ > >> + clks_rem = do_div(clks, UL_5pow12); > >> + clks_rem <<= 13; > > > > Shouldn't this be clks_rem >>= 13 ? > >> > >> + clks_rem |= clks & (UL_2pow13-1); > >> + clks >>= 13; > >> + > >> + /* If we had a remainder, then round up */ > >> + if (clks_rem) > >> clks++; > >> - } I found a problem with the round up. Please try picos_to_mclk(mclk_to_picos(3)) You will notice the result is round up. I am sure it is unexpected. York