coreboot/src/soc
Julius Werner 5132570845 timer: Add wait_us/wait_ms helper macros to wait for conditions
A very common pattern in drivers is that we need to wait for a condition
to become true (e.g. for a lock bit in a PLL status register to become
set), but we still want to have a maximum timeout before we treat it as
an error. coreboot uses the stopwatch API for this, but it's still a
little verbose for the most simple cases. This patch introduces two new
helper macros that wrap this common application of the stopwatch API in
a single line: wait_ms(XXX, YYY) waits for up to XXX milliseconds to see
if the C condition 'if (YYY)' becomes true. The return value is 0 on
failure (i.e. timeout expires without the condition becoming true) and
the amount of elapsed time on success, so it can be used both in a
boolean context and to log the amount of time waited.

Replace the custom version used in an MTK ADC driver with this new
generic version.

Change-Id: I6de38ee00673c46332ae92b8a11099485de5327a
Signed-off-by: Tristan Shieh <tristan.shieh@mediatek.com>
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/29315
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2018-11-07 06:17:37 +00:00
..
amd soc/amd/common: Fix function formating 2018-11-06 13:59:15 +00:00
broadcom src: Add missing include <stdint.h> 2018-11-01 11:25:07 +00:00
cavium src: Add missing include <stdint.h> 2018-11-01 11:25:07 +00:00
imgtec soc/imgtech/pistachio: Convert to board_reset() 2018-10-22 08:34:33 +00:00
intel src/soc/intel/braswell/romstage/romstage.c: Perform RTC init in romstage 2018-11-05 09:06:55 +00:00
mediatek timer: Add wait_us/wait_ms helper macros to wait for conditions 2018-11-07 06:17:37 +00:00
nvidia src: Add missing include <stdint.h> 2018-11-01 11:25:07 +00:00
qualcomm src: Add missing include <stdint.h> 2018-11-01 11:25:07 +00:00
rockchip src: Add missing include <stdint.h> 2018-10-30 09:41:08 +00:00
samsung src: Remove unneeded whitespace 2018-10-23 15:52:09 +00:00
sifive riscv: add support smp_pause / smp_resume 2018-11-05 09:03:40 +00:00
ucb riscv: add support smp_pause / smp_resume 2018-11-05 09:03:40 +00:00