Commit 4f6e7f3afe588d36bb9bc16942c04b942d5af46b

Authored by Eric Lee
1 parent f5086a1062

Read Revision Number from EEPROM

Showing 2 changed files with 79 additions and 1 deletions Side-by-side Diff

board/embedian/smarcfimx6/smarcfimx6.c
... ... @@ -84,6 +84,48 @@
84 84  
85 85 #define OUTPUT_40OHM (PAD_CTL_SPEED_MED|PAD_CTL_DSE_40ohm)
86 86  
  87 +/*
  88 + * Read header information from EEPROM into global structure.
  89 + */
  90 +static int read_eeprom(struct smarcfimx6_id *header)
  91 +{
  92 + /* Check if baseboard eeprom is available */
  93 + if (i2c_probe(CONFIG_SYS_I2C_EEPROM_ADDR)) {
  94 + puts("Could not probe the EEPROM; something fundamentally "
  95 + "wrong on the I2C bus.\n");
  96 + return -ENODEV;
  97 + }
  98 +
  99 + /* read the eeprom using i2c */
  100 + if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 2, (uchar *)header,
  101 + sizeof(struct smarcfimx6_id))) {
  102 + puts("Could not read the EEPROM; something fundamentally"
  103 + " wrong on the I2C bus.\n");
  104 + return -EIO;
  105 + }
  106 +
  107 + if (header->magic != 0xEE3355AA) {
  108 + /*
  109 + * read the eeprom using i2c again,
  110 + * but use only a 1 byte address
  111 + */
  112 + if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, 1, (uchar *)header,
  113 + sizeof(struct smarcfimx6_id))) {
  114 + puts("Could not read the EEPROM; something "
  115 + "fundamentally wrong on the I2C bus.\n");
  116 + return -EIO;
  117 + }
  118 +
  119 + if (header->magic != 0xEE3355AA) {
  120 + printf("Incorrect magic number (0x%x) in EEPROM\n",
  121 + header->magic);
  122 + return -EINVAL;
  123 + }
  124 + }
  125 +
  126 + return 0;
  127 +}
  128 +
87 129 /*I2C1 I2C_PM*/
88 130 struct i2c_pads_info i2c_pad_info1 = {
89 131 .scl = {
90 132  
... ... @@ -1237,8 +1279,29 @@
1237 1279  
1238 1280 int checkboard(void)
1239 1281 {
1240   - puts("Board: SMARC-FiMX6 Rev.00A0\n");
  1282 + struct smarcfimx6_id header;
  1283 +
  1284 + if (read_eeprom(&header) < 0)
  1285 + puts("Could not get board ID.\n");
  1286 +
  1287 + if (revision_is_00a0(&header)) {
  1288 + puts("Board: SMARC-FiMX6 Rev.00A0\n");
  1289 +
  1290 + return 0;
  1291 + } else if (revision_is_00b0(&header)) {
  1292 + puts("Board: SMARC-FiMX6 Rev.00B0\n");
  1293 +
  1294 + return 0;
  1295 + } else if (revision_is_00c0(&header)) {
  1296 + puts("Board: SMARC-FiMX6 Rev.00C0\n");
  1297 +
  1298 + return 0;
  1299 + } else {
  1300 + puts("Board: SMARC-FiMX6, Cannot find Revision number from EEPROM\n");
  1301 +
1241 1302 return 0;
  1303 + }
  1304 +
1242 1305 }
1243 1306  
1244 1307 #ifdef CONFIG_FASTBOOT
board/embedian/smarcfimx6/smarcfimx6.h
... ... @@ -84,6 +84,21 @@
84 84 return !strncmp(header->name, "SMCMXQ2G", HDR_NAME_LEN);
85 85 }
86 86  
  87 +static inline int revision_is_00a0(struct smarcfimx6_id *header)
  88 +{
  89 + return !strncmp(header->version, "00A0", 4);
  90 +}
  91 +
  92 +static inline int revision_is_00b0(struct smarcfimx6_id *header)
  93 +{
  94 + return !strncmp(header->version, "00B0", 4);
  95 +}
  96 +
  97 +static inline int revision_is_00c0(struct smarcfimx6_id *header)
  98 +{
  99 + return !strncmp(header->version, "00C0", 4);
  100 +}
  101 +
87 102 /*
88 103 * Read ethernet MAC address from EEPROM for SMARC-FiMX6DVEVM compatible boards.
89 104 * Returns 1 if found, 0 otherwise.