2 * Copyright (C) 2014 Gateworks Corporation
3 * Author: Tim Harvey <tharvey@gateworks.com>
5 * SPDX-License-Identifier: GPL-2.0+
12 #include "ventana_eeprom.h"
14 /* read ventana EEPROM, check for validity, and return baseboard type */
16 read_eeprom(int bus, struct ventana_board_info *info)
22 unsigned char *buf = (unsigned char *)info;
24 memset(info, 0, sizeof(*info));
27 * On a board with a missing/depleted backup battery for GSC, the
28 * board may be ready to probe the GSC before its firmware is
29 * running. We will wait here indefinately for the GSC/EEPROM.
32 if (0 == i2c_set_bus_num(bus) &&
33 0 == i2c_probe(GSC_EEPROM_ADDR))
38 /* read eeprom config section */
39 if (gsc_i2c_read(GSC_EEPROM_ADDR, 0x00, 1, buf, sizeof(*info))) {
40 puts("EEPROM: Failed to read EEPROM\n");
46 if (info->model[0] != 'G' || info->model[1] != 'W') {
47 puts("EEPROM: Invalid Model in EEPROM\n");
52 /* validate checksum */
53 for (chksum = 0, i = 0; i < sizeof(*info)-2; i++)
55 if ((info->chksum[0] != chksum>>8) ||
56 (info->chksum[1] != (chksum&0xff))) {
57 puts("EEPROM: Failed EEPROM checksum\n");
62 /* original GW5400-A prototype */
63 baseboard = info->model[3];
64 if (strncasecmp((const char *)info->model, "GW5400-A", 8) == 0)
68 case '0': /* original GW5400-A prototype */
84 printf("EEPROM: Unknown model in EEPROM: %s\n", info->model);