summaryrefslogtreecommitdiff
path: root/udelay.c
Commit message (Collapse)AuthorAgeFilesLines
* Reinitialize the delay loop upon recalibration.hailfinger2010-04-091-1/+2
| | | | | | | | | | Fix an unescaped % in a format specifier. Signed-off-by: Urja Rannikko <urjaman@gmail.com> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@992 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* The current delay loop calculation is still from revision 1 of flashrom,hailfinger2010-03-311-13/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and since then it had a logic bug which caused all delays to be twice as long as intended. Fix the delay duration. Protect against delay loop overflows. Detect a non-working delay loop. Change the delay loop itself to ensure clever compiler optimizers won't eliminate it (as happens with clang/llvm in the current code). Some people suggested machine-specific asm, but the empty asm statement with the loop counter as register/memory input has the benefit of being perfectly cross-platform and working in gcc and clang. If time goes backwards (catastrophical NTP time difference, manual time change), timing measurements were shot because the new-old time subtraction yielded negative numbers which weren't handled correctly because the variable is unsigned. Work around that issue (a fix is mathematically impossible). If time goes forward too fast, pick the biggest possible timing measurement with a guaranteed overflow avoidance for all timing calculations. Check four times if the calculated timing is at most 10% too fast. This addresses OS scheduler interactions, e.g. being scheduled out during measurement which inflates measurements. If the timing looks like garbage, recalculate the timer values up to four times before giving up. Avoid division by zero in rare cases where timing measurements for a 250 ms delay returned 0 us elapsed. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Maciej Pijanka <maciej.pijanka@gmail.com> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@990 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* The delay loop is probably one of the oldest pieces of code in flashrom.hailfinger2010-03-271-13/+29
| | | | | | | | | | | Clean up code duplication and measure timing of 10/100/1000/10000 us delays. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Maciej Pijanka <maciej.pijanka@gmail.com> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@986 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* internal.c was always compiled in because it hosted the functionhailfinger2009-12-241-0/+13
| | | | | | | | | | | | | internal_delay(). Move that function to udelay.c and compile internal.c only if really needed. physmap.c is only needed if the programmer is internal or a PCI card. Make its compilation conditional. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Idwer Vollering <vidwer@gmail.com> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@822 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Add external programmer delay functions so external programmers canhailfinger2009-06-051-2/+2
| | | | | | | | | | | handle the delay on their own if needed. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Urja Rannikko <urjaman@gmail.com> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@578 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Drop unused/duplicated #includes and some dead code (trivial).uwe2009-05-161-1/+0
| | | | | | | | | | | Build-tested on 32bit x86. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@521 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 4117uwe2009-04-151-1/+1
| | | | | | | | | | | Some coding style and consistency fixes (trivial). Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@429 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 3669uwe2008-10-181-1/+1
| | | | | | | | | | | Coding-style fixes for flashrom, partly indent-aided (trivial). Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@326 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 3569stuge2008-09-071-1/+7
| | | | | | | | | | flashrom: Debug print actual time base calculated by myusec_calibrate_delay() Signed-off-by: Peter Stuge <peter@stuge.se> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@314 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 2873uwe2007-10-171-1/+1
| | | | | | | | | | | Some cosmetic cleanups in the flashrom code and output. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@151 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 2847uwe2007-10-101-1/+1
| | | | | | | | | | | Revert my last cleanup patch. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@143 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 2846uwe2007-10-101-1/+1
| | | | | | | | | | | Cosmetic changes to make the flashrom output more consistent (trivial). Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@142 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 2768uwe2007-09-091-1/+1
| | | | | | | | | | | Add '(C)' where it's missing (for consistency reasons). Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@136 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 2767uwe2007-09-091-0/+20
| | | | | | | | | | | | | | | | | | | Add missing license header to udelay.c. I'm self-ack'ing this, as the origin of the code in udelay.c (and thus the license and copyright owner) is pretty clear. The code which is now in udelay.c was split out from flash_rom.c in r1428, and flash_rom.c, in turn, has been around since the beginning and had a 'Copyright 2000 Silicon Integrated System Corporation' line as well as the usual GPLv2-or-later license header. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@135 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 2746uwe2007-08-231-1/+1
| | | | | | | | | | | Drop a bunch of useless header files, merge them into flash.h. Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@128 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 2585stepan2007-04-061-2/+4
| | | | | | | | | | | | | | | | Trivial (cosmetic) cleanup: * Only open /dev/mem once and do it early. * Drop extern for function prototypes. * Minimize ts5300 impact in probe_flash() This cleanup will making ICH7 SPI support quite some easier. Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@100 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 2577uwe2007-04-011-2/+2
| | | | | | | | | | | Coding style fixes (trivial). Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@97 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 2111ollie2005-11-261-2/+3
| | | | | | flasrom update from Stefan, resovle issue 21 git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@34 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 1457ollie2004-03-201-6/+5
| | | | | | | consolidate more jedec standard code git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@15 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 1434ollie2004-03-181-3/+0
| | | | | | | fixed 32bit v.s. 64bit long int arithematics git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@8 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 1433ollie2004-03-171-3/+1
| | | | | | | | | removed spd_dump.c, it has nothing to do with flashing flash parts. use standard product ID exit method for w49f002u move udelay stuff into its own file git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@7 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
* Original v2 revision: 1428ollie2004-03-171-0/+43
move utility functions into new source files git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@6 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1