Skip to content

Commit f6567a5

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 f6567a5

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

cli/main.c

Lines changed: 16 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,25 @@ 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+
} else {
219+
minor_ver = "";
220+
}
206221

207222
printf("%s (%s):\n", switchtec_name(dev),
208223
switchtec_phase_id_str(phase));
209224
printf(" Generation: %s\n", switchtec_gen_str(dev));
210-
printf(" HW Revision: %s\n", switchtec_rev_str(hw_rev));
225+
printf(" HW Revision: %s%s\n", switchtec_rev_str(hw_rev), minor_ver);
211226
printf(" Variant: %s\n",
212227
device_id ? switchtec_variant_str(dev) : "N/A");
213228
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/platform.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,20 @@ 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+
uint32_t addr = 0x2004;
156+
uint32_t gas_result;
157+
char result[5];
158+
uint8_t minor;
159+
160+
gas_result = __gas_read32(dev, &addr);
161+
minor = (gas_result >> 0x10) & 0xFF;
162+
snprintf(result, 5, ".%d", minor);
163+
*res = result;
164+
165+
return 0;
166+
}
153167
/**
154168
* @brief Execute an MRPC command
155169
* @ingroup Device

0 commit comments

Comments
 (0)