Stefan Reinauer has uploaded this change for review. ( https://review.coreboot.org/c/em100/+/36834 )
Change subject: Add support for reading hardware version ......................................................................
Add support for reading hardware version
The hardware version of an EM100Pro / EM100Pro-G2 is stored in the built-in SPI flash of the chip. So far we are making no use of the hardware version, but in the future this can be used to differentiate between hardware and protocol differences.
Signed-off-by: Stefan Reinauer stefan.reinauer@coreboot.org Change-Id: I2232d9d6caabf33ae9777d28378c1cdd83da1446 --- M em100.c M em100.h 2 files changed, 10 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/em100 refs/changes/34/36834/1
diff --git a/em100.c b/em100.c index 1548450..fea2eda 100644 --- a/em100.c +++ b/em100.c @@ -196,15 +196,16 @@ }
/** - * get_serialno: fetch device's serial number + * get_device_info: fetch device's serial number and hardware version * @param em100: initialized em100 device structure */ -static int get_serialno(struct em100 *em100) +static int get_device_info(struct em100 *em100) { unsigned char data[256]; if (read_spi_flash_page(em100, 0x1fff00, data)) { em100->serialno = (data[5] << 24) | (data[4] << 16) | \ (data[3] << 8) | data[2]; + em100->hwversion = data[1]; return 1; } return 0; @@ -249,7 +250,9 @@ printf("Error: Could not write SPI flash.\n"); return 0; } - get_serialno(em100); + + /* Re-read serial number */ + get_device_info(em100); if (em100->serialno != 0xffffffff) printf("New serial number: DP%06d\n", em100->serialno); else @@ -334,8 +337,8 @@ return 0; }
- if (!get_serialno(em100)) { - printf("Failed to fetch serial number.\n"); + if (!get_device_info(em100)) { + printf("Failed to fetch serial number and hardware version.\n"); return 0; }
@@ -755,6 +758,7 @@ printf("FPGA version: %d.%02d\n", em100.fpga >> 8, em100.fpga & 0xff); } + printf("Hardware version: %u\n", em100.hwversion);
if (em100.serialno != 0xffffffff) printf("Serial number: DP%06d\n", em100.serialno); diff --git a/em100.h b/em100.h index 6a58e70..7d12dd6 100644 --- a/em100.h +++ b/em100.h @@ -26,6 +26,7 @@ uint16_t mcu; uint16_t fpga; uint32_t serialno; + uint8_t hwversion; };
#define BULK_SEND_TIMEOUT 5000 /* sentinel value */