From: Wolfgang Denk Date: Tue, 21 Sep 2010 09:13:10 +0200 Subject: [U-Boot] RFC: get_ticks() + get_tbclk() In-Reply-To: <4C98536C.6010003@emk-elektronik.de> References: <4C98482F.7040508@emk-elektronik.de> <201009210208.55367.vapier@gentoo.org> <4C98536C.6010003@emk-elektronik.de> Message-ID: <20100921071310.30201157D71@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Reinhard Meyer, In message <4C98536C.6010003@emk-elektronik.de> you wrote: > > For me it seems useful to keep both functions and have ticks > increment at a hardware-convenient rate. > If the hardware timer can be prescaled to increment at 1000 Hz that > is fine, but I see no immediate need for that. If the hardware cannot > be prescaled, and software would need to do a 64 bit multiply/divide > on each timer read, that would really be overkill. Just FYI: the origin of these functions is (like usual) in the implementation for the Power Architecture. There we have a 64 bit timebase register (split into two 32 bit registers, the upper half in tbu and the lower half in tbl). The timebase register gets incremented at a pretty high rate, usually every 4 or 16 system clocks). get_ticks() just returns the content of the 64 bit timebase register. [See also wait_ticks(0 which delays for a number of ticks, cf. "arch/powerpc/lib/ticks.S"] get_tbclk() just returns the timebase clock (usually derived froom the system clock; see for exmaple "arch/powerpc/cpu/mpc5xxx/cpu.c": tbclk = (gd->bus_clk + 3L) / 4L; ). Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de They weren't that important. They were merely at the top. The people who really run organizations are usually found several levels down, where it's still possible to get things done. - Terry Pratchett, _Small Gods_