| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <drivers/vpd/vpd.h> |
| 5 |
#include <stdint.h> |
| 6 |
#include <string.h> |
| 7 |
#include <types.h> |
| 8 |
#include "dsm_calib.h" |
| 9 |
|
| 10 |
#define DSM_BUF_LEN 128 |
| 11 |
#define DSM_PREFIX "dsm_calib_" |
| 12 |
|
| 13 |
enum cb_err get_dsm_calibration_from_key(const char *key, uint64_t *value) |
| 14 |
{ |
| 15 |
static char buf[DSM_BUF_LEN]; |
| 16 |
char *ret; |
| 17 |
long value_from_vpd; |
| 18 |
|
| 19 |
if (strncmp(key, DSM_PREFIX, strlen(DSM_PREFIX))) { |
| 20 |
printk(BIOS_ERR, "got invalid dsm_calib key: %s\n", key); |
| 21 |
return CB_ERR; |
| 22 |
} |
| 23 |
|
| 24 |
ret = vpd_gets(key, buf, DSM_BUF_LEN, VPD_RO); |
| 25 |
if (!ret) { |
| 26 |
printk(BIOS_ERR, "failed to find key in VPD: %s\n", key); |
| 27 |
return CB_ERR; |
| 28 |
} |
| 29 |
|
| 30 |
value_from_vpd = atol(buf); |
| 31 |
if (value_from_vpd <= 0) { |
| 32 |
printk(BIOS_ERR, "got invalid dsm_calib from VPD: %ld\n", value_from_vpd); |
| 33 |
return CB_ERR; |
| 34 |
} |
| 35 |
|
| 36 |
*value = value_from_vpd; |
| 37 |
|
| 38 |
return CB_SUCCESS; |
| 39 |
} |