diff --git a/post/src/post.c b/post/src/post.c
index c6d91140906b310e78c2fc232d76634c3c1e568a..2902574a9e300f90fe1b792bdcd07d7a0c7b9b53 100644 (file)
--- a/post/src/post.c
+++ b/post/src/post.c
return test_passed;
}
+void
+post_hex_to_string
+(
+ uint32_t hex,
+ uint32_t nibbles,
+ char *msg
+)
+{
+ int32_t i;
+ uint8_t nibble;
+
+ for (i = (nibbles-1); i >= 0; i--)
+ {
+ nibble = hex & 0xf;
+ if (nibble <= 0x9)
+ {
+ nibble += '0';
+ }
+ else
+ {
+ nibble += ('A' - 0xa);
+ }
+
+ msg[i] = nibble;
+ hex = hex >> 4;
+ }
+ msg[nibbles] = 0;
+}
+
+Bool
+post_serial_num_isvalid
+(
+ char c
+)
+{
+ if (
+ ((c >= '0') && (c <= '9')) ||
+ ((c >= 'a') && (c <= 'z')) ||
+ ((c >= 'A') && (c <= 'Z'))
+ )
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+/******************************************************************************
+ * Function: post_write_serial_no
+ ******************************************************************************/
+void
+post_write_serial_no
+(
+ void
+)
+{
+ uint32_t i, j;
+ uint8_t msg[20], msg2[2];
+ PLATFORM_DEVICE_info *p_device;
+
+ /* Check if user key in the passcode "ti" to enter board serial number */
+ if (platform_uart_read(msg, POST_UART_READ_TIMEOUT) != Platform_EOK)
+ {
+ return;
+ }
+ if (msg[0] != 't')
+ {
+ return;
+ }
+
+ if (platform_uart_read(msg, POST_UART_READ_TIMEOUT) != Platform_EOK)
+ {
+ return;
+ }
+ if (msg[0] != 'i')
+ {
+ return;
+ }
+
+ /* Passcode verified, prompt the user to enter serial number */
+ p_device = platform_device_open(PLATFORM_DEVID_EEPROM50, 0);
+ if (p_device == NULL)
+ {
+ return;
+ }
+
+ post_write_uart("\r\n\r\nPlease enter the 10 digit serial number for this board, and then press ENTER key:\r\n\r\n");
+
+ i = 0;
+ msg2[1] = 0;
+ while (TRUE)
+ {
+ if (platform_uart_read(&msg[i], POST_UART_READ_TIMEOUT) != Platform_EOK)
+ {
+ platform_device_close(p_device->handle);
+ post_write_uart("\r\n\r\nSerial number input time out!");
+ return;
+ }
+
+ if (msg[i] == '\r')
+ {
+ break;
+ }
+ if ((i < POST_MAX_SN_SIZE) && post_serial_num_isvalid(msg[i]))
+ {
+ msg2[0] = msg[i];
+ post_write_uart((char *)msg2);
+ i++;
+ }
+ }
+
+ if (i < POST_MAX_SN_SIZE)
+ {
+ for (j = i; j < POST_MAX_SN_SIZE; j++)
+ {
+ msg[j] = 0xff;
+ }
+ }
+
+ if(platform_device_write(p_device->handle, POST_SERIAL_NUM_ADDR, msg, 16) == Platform_EOK)
+ {
+ post_write_uart("\r\n\r\nSerial number programmed to EEPROM successfully! ");
+ }
+ else
+ {
+ post_write_uart("\r\n\r\nFailed to program the serial number to EEPROM!");
+ }
+ platform_device_close(p_device->handle);
+
+}
+
/******************************************************************************
* Function: main function for POST
******************************************************************************/
int32_t i;
char msg[9];
uint8_t mac_addr[6];
+ platform_info info;
+ uint32_t sa_enable;
/* Turn on all the platform initialize flags */
memset(&init_config, 0, sizeof(platform_init_config));
memset(&init_flags, 0x01, sizeof(platform_init_flags));
-#ifdef _EVMC6670L_
- init_flags.phy = 0;
-#endif
-
/* Initialize the platform */
if (platform_init(&init_flags, &init_config) != Platform_EOK)
{
platform_uart_set_baudrate(POST_UART_BAUDRATE);
if (test_id != POST_TEST_PLL_INIT)
{
- if (post_write_uart(POST_DEVICE) != TRUE)
+ if (post_write_uart("\r\n\r\n") != TRUE)
{
post_display_led_error(POST_TEST_UART); /* Never return from this function */
}
+
+ platform_get_info(&info);
+
+ /* Display the board name */
+ post_write_uart(info.board_name);
+
+ /* Display the POST version */
post_write_uart(POST_EVM_VERSION_MSG);
post_write_uart(post_version);
- /*post_write_uart("\r\n\r\nPOST booting from I2C 0x50 ... ");*/
+ post_hex_to_string(info.board_rev, 4, msg);
+ post_write_uart("\r\n\r\nFPGA Version: ");
+ post_write_uart(msg);
+
+ if (info.serial_nbr[0] != 0)
+ {
+ post_write_uart("\r\n\r\nBoard Serial Number: ");
+ post_write_uart(info.serial_nbr);
+ }
+ /* Display the EFUSE MAC address */
platform_get_macaddr(PLATFORM_MAC_TYPE_EFUSE, mac_addr);
- msg[2] = ' ';
- msg[3] = 0;
post_write_uart("\r\n\r\nEFUSE MAC ID is: ");
for (i = 0; i < 6; i++)
{
- msg[0] = (char)(mac_addr[i]>>4);
- if (msg[0] < 0xa)
- {
- msg[0] += '0';
- }
- else
- {
- msg[0] = msg[0] - 0xa + 'A';
- }
- msg[1] = (char)(mac_addr[i]&0xf);
- if (msg[1] < 0xa)
- {
- msg[1] += '0';
- }
- else
- {
- msg[1] = msg[1] - 0xa + 'A';
- }
+ post_hex_to_string(info.emac.efuse_mac_address[i], 2, msg);
+ msg[2] = ' ';
+ msg[3] = 0;
post_write_uart(msg);
}
+
+ sa_enable = *(volatile uint32_t *)0x20c0000;
+ sa_enable &= 0x1;
+
+ if (sa_enable)
+ {
+ post_write_uart("\r\n\r\nSA is enabled on this board.");
+ }
+ else
+ {
+ post_write_uart("\r\n\r\nSA is disabled on this board.");
+ }
+
+ /* Read the PLL Reset Type Status register and display on UART */
+ reset_type = PLL_CTRL_REG_RSTYPE;
+ post_hex_to_string(reset_type, 8, msg);
+ post_write_uart("\r\n\r\nPLL Reset Type Status Register: 0x");
+ post_write_uart(msg);
}
/* Display test in progress UART/LED status or init error */
post_display_status(POST_TEST_COMPLETE, TRUE);
- /* Read the PLL Reset Type Status register and display on UART */
- reset_type = PLL_CTRL_REG_RSTYPE;
- for (i = 7; i >= 0; i--)
- {
- msg[i] = (char)(reset_type & 0xf) + '0';
- reset_type = reset_type >> 4;
- }
- msg[8] = 0;
- post_write_uart("\r\n\r\nPLL Reset Type Status Register: 0x");
- post_write_uart(msg);
+ post_write_serial_no();
}