From 2db7922cca8663eb464e63599f4c9de17f6ba2c8 Mon Sep 17 00:00:00 2001 From: Werner Zeh Date: Wed, 5 Jul 2017 15:52:52 +0200 Subject: siemens/nc_fpga: Modify macro FPGA_SET_PARAM to avoid hwilib errors The macro FPGA_SET_PARAM was introduced to make the setting of different FPGA registers with the appropriate values from hwinfo more transparent. The hwilib takes care about the size of the provided buffer where the requested value should be stored in. The fields in hwinfo have not always the same size as the matching registers in the FPGA. So to avoid errors resulting in a too small buffer when calling hwilib_get_field() the buffer is now fixed to 32 bit and will be casted to the destination type when the value is written into the FPGA register. Changing the field size in hwilib would be the wrong way as the defined lengths are specified this way to be expandable in the future. In addition the number of maximum supported temperature sensors is increased to 8 as the FPGA now supports more. Change-Id: I0c697106783158420708a973c3cff2be90fa4fce Signed-off-by: Werner Zeh Reviewed-on: https://review.coreboot.org/20471 Tested-by: build bot (Jenkins) Reviewed-by: Mario Scheithauer Reviewed-by: Paul Menzel Reviewed-by: Patrick Georgi --- src/drivers/siemens/nc_fpga/nc_fpga.c | 9 ++++----- src/drivers/siemens/nc_fpga/nc_fpga.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/drivers/siemens/nc_fpga/nc_fpga.c b/src/drivers/siemens/nc_fpga/nc_fpga.c index 8fb25bc7d2..15b3ad338d 100644 --- a/src/drivers/siemens/nc_fpga/nc_fpga.c +++ b/src/drivers/siemens/nc_fpga/nc_fpga.c @@ -26,10 +26,9 @@ #define FPGA_SET_PARAM(src, dst) \ { \ - typeof(dst) var; \ - size_t len = sizeof(var); \ - if (hwilib_get_field(src, (uint8_t *)&var, len) == len) \ - dst = (typeof(dst))(var); \ + uint32_t var; \ + if (hwilib_get_field(src, (uint8_t *)&var, sizeof(var))) \ + dst = *((typeof(dst) *)var); \ } static void init_temp_mon (void *base_adr) @@ -41,7 +40,7 @@ static void init_temp_mon (void *base_adr) /* Program sensor delay first. */ FPGA_SET_PARAM(FANSensorDelay, ctrl->sensordelay); /* Program correction curve for every used sensor. */ - if (hwilib_get_field(FANSensorNum, &num, sizeof(num) != sizeof(num)) || + if ((hwilib_get_field(FANSensorNum, &num, 1) != 1) || (num == 0) || (num > MAX_NUM_SENSORS)) return; for (i = 0; i < num; i ++) { diff --git a/src/drivers/siemens/nc_fpga/nc_fpga.h b/src/drivers/siemens/nc_fpga/nc_fpga.h index a5a7ab8faf..0a0b0c6ed0 100644 --- a/src/drivers/siemens/nc_fpga/nc_fpga.h +++ b/src/drivers/siemens/nc_fpga/nc_fpga.h @@ -28,7 +28,7 @@ #define NC_BL_PWM_OFFSET 0x8C #define NC_FANMON_CTRL_OFFSET 0x400 -#define MAX_NUM_SENSORS 4 +#define MAX_NUM_SENSORS 8 typedef struct { uint16_t rmin; -- cgit v1.2.3