Commit 9b04f2d1b8460105c66214531d245d67c1fec7e5
1 parent
03aa8dd14b
Exists in
smarc-imx-l5.0.0_1.0.0-ga
Read Revision Number from EEPROM
Showing 2 changed files with 80 additions and 2 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 = { |
... | ... | @@ -1238,8 +1280,29 @@ |
1238 | 1280 | |
1239 | 1281 | int checkboard(void) |
1240 | 1282 | { |
1241 | - puts("Board: SMARC-FiMX6 Rev.00A0\n"); | |
1242 | - return 0; | |
1283 | + struct smarcfimx6_id header; | |
1284 | + | |
1285 | + if (read_eeprom(&header) < 0) | |
1286 | + puts("Could not get board ID.\n"); | |
1287 | + | |
1288 | + if (revision_is_00a0(&header)) { | |
1289 | + puts("Board: SMARC-FiMX6 Rev.00A0\n"); | |
1290 | + | |
1291 | + return 0; | |
1292 | + } else if (revision_is_00b0(&header)) { | |
1293 | + puts("Board: SMARC-FiMX6 Rev.00B0\n"); | |
1294 | + | |
1295 | + return 0; | |
1296 | + } else if (revision_is_00c0(&header)) { | |
1297 | + puts("Board: SMARC-FiMX6 Rev.00C0\n"); | |
1298 | + | |
1299 | + return 0; | |
1300 | + } else { | |
1301 | + puts("Board: SMARC-FiMX6, Cannot find Revision number from EEPROM\n"); | |
1302 | + | |
1303 | + return 0; | |
1304 | + } | |
1305 | + | |
1243 | 1306 | } |
1244 | 1307 | |
1245 | 1308 | #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. |