nb/intel/sandybridge: Rewrite get_FRQ

The code is just clamping the frequency index to a valid range. Do it
with a helper function. Also, add a CPUID check, as Sandy Bridge will
eventually use this code.

Change-Id: I4c7aa5f7615c6edb1ab62fb004abb126df9d284b
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/39787
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
This commit is contained in:
Angel Pons
2020-03-23 22:38:08 +01:00
committed by Patrick Georgi
parent 2a0a02f98f
commit a6c8b4becb
2 changed files with 40 additions and 16 deletions

View File

@@ -0,0 +1,22 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef COMMONLIB_CLAMP_H
#define COMMONLIB_CLAMP_H
#include <stdint.h>
/*
* Clamp a value, so that it is between a lower and an upper bound.
*/
static inline u32 clamp_u32(const u32 min, const u32 val, const u32 max)
{
if (val > max)
return max;
if (val < min)
return min;
return val;
}
#endif /* COMMONLIB_CLAMP_H */