From deccab5a1b90df299b7b194bfef9da046f8f319b Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 12 Jan 2018 17:11:05 -0800 Subject: mpm: Add EEPROM utilities for N310 Actually-written-by: Moritz Fischer --- mpm/tools/fan-limits.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 mpm/tools/fan-limits.c (limited to 'mpm/tools/fan-limits.c') diff --git a/mpm/tools/fan-limits.c b/mpm/tools/fan-limits.c new file mode 100644 index 000000000..4000d5832 --- /dev/null +++ b/mpm/tools/fan-limits.c @@ -0,0 +1,47 @@ +// +// Copyright 2017 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: GPL-3.0 +// + +#include "eeprom.h" +#include +#include + +void usage(char *argv[]) +{ + printf("-- Usage -- \n"); + printf("%s fan0_min fan0_max fan1_min fan1_max\n\n", argv[0]); + printf("Example:\n"); + printf("$ %s 3800 13000 3800 1300\n", argv[0]); +} + +int main(int argc, char *argv[]) +{ + struct usrp_sulfur_eeprom *ep; + uint8_t fan0_max, fan0_min, fan1_max, fan1_min; + uint32_t new_flags = 0; + + if (argc != 5) { + usage(argv); + return EXIT_FAILURE; + } + + fan0_min = atoi(argv[1]) / 100; + fan0_max = atoi(argv[2]) / 100; + fan1_min = atoi(argv[3]) / 100; + fan1_max = atoi(argv[4]) / 100; + + printf("Writing: %d/%d/%d/%d\n", fan0_min, fan0_max, fan1_min, fan1_max); + + ep = usrp_sulfur_eeprom_from_file(NVMEM_PATH_MB); + ep->mcu_flags[0] = 0; + ep->mcu_flags[1] = htonl(fan1_max << 24 | fan1_min << 16 | fan0_max << 8 | fan0_min); + usrp_sulfur_eeprom_recrc(ep); + usrp_sulfur_eeprom_to_i2c(ep, "/dev/i2c-2"); + + + free(ep); + + return 0; +} -- cgit v1.2.3