summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Zeh <werner.zeh@siemens.com>2017-07-05 15:52:52 +0200
committerWerner Zeh <werner.zeh@siemens.com>2017-07-11 14:00:11 +0000
commit2db7922cca8663eb464e63599f4c9de17f6ba2c8 (patch)
treec0e79520b27390d171a5b8d9c4a2e80bb25d9162
parent55ea013842b50177bc48fae8159a77596bd3a6d9 (diff)
downloadcoreboot-2db7922cca8663eb464e63599f4c9de17f6ba2c8.tar.xz
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 <werner.zeh@siemens.com> Reviewed-on: https://review.coreboot.org/20471 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Mario Scheithauer <mario.scheithauer@siemens.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
-rw-r--r--src/drivers/siemens/nc_fpga/nc_fpga.c9
-rw-r--r--src/drivers/siemens/nc_fpga/nc_fpga.h2
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;