Werner Zeh has uploaded this change for review. ( https://review.coreboot.org/20471
Change subject: siemens/nc_fpga: Modify macro FPGA_SET_PARAM to avoid hwilib errors ......................................................................
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 in increased to 8 as the FPGA now supports more.
Change-Id: I0c697106783158420708a973c3cff2be90fa4fce --- M src/drivers/siemens/nc_fpga/nc_fpga.c M src/drivers/siemens/nc_fpga/nc_fpga.h 2 files changed, 5 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/71/20471/1
diff --git a/src/drivers/siemens/nc_fpga/nc_fpga.c b/src/drivers/siemens/nc_fpga/nc_fpga.c index 8fb25bc..15b3ad3 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 @@ /* 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 a5a7ab8..0a0b0c6 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;