Skip to content

Commit 60b2a66

Browse files
committed
add minor version to info command
Added the minor version number to the info command through reading the GAS address for Firmware Version. Add additional version info to the HW Revision section.
1 parent 3bb6ce6 commit 60b2a66

File tree

10 files changed

+56
-1
lines changed

10 files changed

+56
-1
lines changed

cli/main.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ static int print_dev_info(struct switchtec_dev *dev)
191191
char version[32];
192192
enum switchtec_boot_phase phase;
193193
enum switchtec_rev hw_rev;
194+
char * minor_ver;
194195

195196
device_id = switchtec_device_id(dev);
196197

@@ -203,11 +204,26 @@ static int print_dev_info(struct switchtec_dev *dev)
203204
switchtec_perror("dev info");
204205
return ret;
205206
}
207+
ret = switchtec_get_device_info(dev, &phase, NULL, &hw_rev);
208+
if (ret) {
209+
switchtec_perror("dev info");
210+
return ret;
211+
}
212+
if (switchtec_is_gen5(dev)) {
213+
switchtec_get_device_minor_ver(dev, &minor_ver);
214+
if (ret) {
215+
switchtec_perror("minor ver");
216+
return ret;
217+
}
218+
}
219+
else {
220+
minor_ver = "";
221+
}
206222

207223
printf("%s (%s):\n", switchtec_name(dev),
208224
switchtec_phase_id_str(phase));
209225
printf(" Generation: %s\n", switchtec_gen_str(dev));
210-
printf(" HW Revision: %s\n", switchtec_rev_str(hw_rev));
226+
printf(" HW Revision: %s%s\n", switchtec_rev_str(hw_rev), minor_ver);
211227
printf(" Variant: %s\n",
212228
device_id ? switchtec_variant_str(dev) : "N/A");
213229
if (device_id)

inc/switchtec/switchtec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ int switchtec_list(struct switchtec_device_info **devlist);
358358
void switchtec_list_free(struct switchtec_device_info *devlist);
359359
int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf,
360360
size_t buflen);
361+
int switchtec_get_device_minor_ver(struct switchtec_dev *dev, char ** res);
361362
int switchtec_cmd(struct switchtec_dev *dev, uint32_t cmd,
362363
const void *payload, size_t payload_len, void *resp,
363364
size_t resp_len);

lib/platform/gasops.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,32 @@ int gasop_get_fw_version(struct switchtec_dev *dev, char *buf,
188188
return 0;
189189
}
190190

191+
int gasop_get_device_minor_ver(struct switchtec_dev *dev, char ** res)
192+
{
193+
void __gas * addr;
194+
int offset = 0x2004;
195+
gasptr_t map;
196+
size_t map_size;
197+
uint32_t gas_result;
198+
char result[5];
199+
200+
uint8_t minor;
201+
map = switchtec_gas_map(dev, 0, &map_size);
202+
if (map == SWITCHTEC_MAP_FAILED) {
203+
switchtec_perror("gas_map");
204+
return -1;
205+
}
206+
addr = map;
207+
gas_result = __gas_read32(dev, addr + offset);
208+
minor = (gas_result >> 0x10) & 0xFF;
209+
snprintf(result, 5, ".%d", minor);
210+
*res = result;
211+
212+
switchtec_gas_unmap(dev, map);
213+
214+
return 0;
215+
}
216+
191217
int gasop_pff_to_port(struct switchtec_dev *dev, int pff,
192218
int *partition, int *port)
193219
{

lib/platform/gasops.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ int gasop_cmd(struct switchtec_dev *dev, uint32_t cmd,
3636
int gasop_get_device_id(struct switchtec_dev *dev);
3737
int gasop_get_fw_version(struct switchtec_dev *dev, char *buf,
3838
size_t buflen);
39+
int gasop_get_device_minor_ver(struct switchtec_dev *dev, char ** res);
3940
int gasop_pff_to_port(struct switchtec_dev *dev, int pff,
4041
int *partition, int *port);
4142
int gasop_port_to_pff(struct switchtec_dev *dev, int partition,

lib/platform/linux-eth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ static const struct switchtec_ops eth_ops = {
524524
.cmd = eth_cmd,
525525
.get_device_id = gasop_get_device_id,
526526
.get_fw_version = gasop_get_fw_version,
527+
.get_device_minor_ver = gasop_get_device_minor_ver,
527528
.pff_to_port = gasop_pff_to_port,
528529
.port_to_pff = gasop_port_to_pff,
529530
.flash_part = gasop_flash_part,

lib/platform/linux-i2c.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ static const struct switchtec_ops i2c_ops = {
623623
.cmd = gasop_cmd,
624624
.get_device_id = gasop_get_device_id,
625625
.get_fw_version = gasop_get_fw_version,
626+
.get_device_minor_ver = gasop_get_device_minor_ver,
626627
.pff_to_port = gasop_pff_to_port,
627628
.port_to_pff = gasop_port_to_pff,
628629
.flash_part = gasop_flash_part,

lib/platform/linux-uart.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ static const struct switchtec_ops uart_ops = {
439439
.cmd = gasop_cmd,
440440
.get_device_id = gasop_get_device_id,
441441
.get_fw_version = gasop_get_fw_version,
442+
.get_device_minor_ver = gasop_get_device_minor_ver,
442443
.pff_to_port = gasop_pff_to_port,
443444
.port_to_pff = gasop_port_to_pff,
444445
.flash_part = gasop_flash_part,

lib/platform/linux.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,7 @@ static const struct switchtec_ops linux_ops = {
971971
.close = linux_close,
972972
.get_device_id = linux_get_device_id,
973973
.get_fw_version = linux_get_fw_version,
974+
.get_device_minor_ver = gasop_get_device_minor_ver,
974975
.cmd = linux_cmd,
975976
.get_devices = linux_get_devices,
976977
.pff_to_port = linux_pff_to_port,

lib/platform/platform.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf,
150150
return 0;
151151
}
152152

153+
int switchtec_get_device_minor_ver(struct switchtec_dev *dev, char ** res)
154+
{
155+
int ret;
156+
ret = dev->ops->get_device_minor_ver(dev, res);
157+
return ret;
158+
}
153159
/**
154160
* @brief Execute an MRPC command
155161
* @ingroup Device

lib/switchtec_priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct switchtec_ops {
9393
int (*get_device_id)(struct switchtec_dev *dev);
9494
int (*get_fw_version)(struct switchtec_dev *dev, char *buf,
9595
size_t buflen);
96+
int (*get_device_minor_ver)(struct switchtec_dev *dev, char ** res);
9697
int (*cmd)(struct switchtec_dev *dev, uint32_t cmd,
9798
const void *payload, size_t payload_len, void *resp,
9899
size_t resp_len);

0 commit comments

Comments
 (0)