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>
This commit is contained in:
Werner Zeh 2017-07-05 15:52:52 +02:00
parent 55ea013842
commit 2db7922cca
2 changed files with 5 additions and 6 deletions

View file

@ -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 ++) {

View file

@ -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;