Commit 2b7fadba authored by Benoit Rat's avatar Benoit Rat Committed by Alessandro Rubini

libswitchhw: return version as integer to ensure comparison

parent 40deb0eb
......@@ -217,7 +217,7 @@ int shw_init_fans()
TRACE(TRACE_INFO, "Configuring PWMs for fans (desired temperature = %.1f degC)...", DESIRED_TEMPERATURE);
//Set the type of PWM
if(shw_get_hw_ver()<3.3) is_cpu_pwn=1;
if(shw_get_hw_ver()<330) is_cpu_pwn=1;
else is_cpu_pwn=0;
if(is_cpu_pwn)
......
......@@ -102,7 +102,7 @@ int shw_i2c_io_scan(uint8_t *dev_map)
}
float shw_get_hw_ver()
int shw_get_hw_ver()
{
uint8_t ret;
struct i2c_bus *bus= &i2c_io_bus;
......@@ -114,9 +114,9 @@ float shw_get_hw_ver()
ret= wrswhw_pca9554_get_input(bus,I2C_SCB_VER_ADDR);
switch((ret >> 1) & 0x7)
{
case 0: return 3.3;
case 1: return 3.4; //version is not available
case 2: return 3.41;
case 0: return 330;
case 1: return 340; //version is not available
case 2: return 341;
default:
TRACE(TRACE_FATAL,"Unknown HW version (0x%x), check the DIP switch under the SCB",(ret >> 1) & 0x7);
return -1;
......@@ -127,7 +127,7 @@ float shw_get_hw_ver()
}
else
{
return 3.2;
return 320;
}
}
......
......@@ -25,7 +25,7 @@ int shw_i2c_io_scan(uint8_t *dev_map);
uint8_t shw_i2c_read(const *i2c_bus, uint8_t addr);
uint8_t shw_i2c_write(const *i2c_bus, uint8_t addr, uint8_t value, uint8_t mask);
float shw_get_hw_ver();
int shw_get_hw_ver();
uint8_t shw_get_fpga_type();
#endif //I2C_SFP_H
......@@ -69,8 +69,7 @@ const shw_io_t _all_shw_io[NUM_SHW_IO_ID];
int shw_io_init()
{
float ver;
int ret;
int ret, ver;
//Remove const for writing
shw_io_t* all_shw_io=(shw_io_t*)_all_shw_io;
......@@ -86,7 +85,7 @@ int shw_io_init()
ver=shw_get_hw_ver();
//Finally assigned the input/ouput according to version number.
if(ver<3.3)
if(ver<330)
{
IOARR_SET_GPIO(shw_io_reset_n);
IOARR_SET_GPIO(shw_io_box_fan_en);
......@@ -96,6 +95,7 @@ int shw_io_init()
IOARR_SET_GPIO(shw_io_led_cpu2);
IOARR_SET_GPIO(shw_io_arm_boot_sel);
IOARR_SET_GPIO(shw_io_arm_gen_but);
TRACE(TRACE_INFO, "version=%f %d %d %d",ver, ver>=3.3f, ver<3.3f, ver==3.3f);
}
else
{
......@@ -234,11 +234,13 @@ int shw_io_write(shw_io_id_t id, uint32_t value)
const char *get_shw_info(const char cmd)
{
static char str_hwver[10];
int tmp;
switch(cmd)
{
case 'p':
snprintf(str_hwver,10,"%g",shw_get_hw_ver()); //generate a non harmful warning with our compiler
tmp = shw_get_hw_ver();
snprintf(str_hwver,10,"%d.%d",tmp/100,tmp%100);
return str_hwver;
case 'f':
return (shw_get_fpga_type()==SHW_FPGA_LX240T)?"LX240T":"LX130T";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment