+// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2013 Gateworks Corporation
*
* Author: Tim Harvey <tharvey@gateworks.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
-#include <asm/errno.h>
+#include <common.h>
+#include <command.h>
+#include <log.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
#include <common.h>
#include <i2c.h>
#include <linux/ctype.h>
+#include "ventana_eeprom.h"
#include "gsc.h"
/*
puts("fRD\n");
} else {
ui = buf[0] | (buf[1]<<8) | (buf[2]<<16);
+ if (size == 2 && ui > 0x8000)
+ ui -= 0xffff;
if (ui == 0xffffff)
puts("invalid\n");
else
int gsc_info(int verbose)
{
- const char *model = getenv("model");
unsigned char buf[16];
i2c_set_bus_num(0);
gsc_i2c_write(GSC_SC_ADDR, GSC_SC_STATUS, 1,
&buf[GSC_SC_STATUS], 1);
}
+ if (!gsc_i2c_read(GSC_HWMON_ADDR, GSC_HWMON_TEMP, 1, buf, 2)) {
+ int ui = buf[0] | buf[1]<<8;
+ if (ui > 0x8000)
+ ui -= 0xffff;
+ printf(" board temp at %dC", ui / 10);
+ }
puts("\n");
if (!verbose)
return CMD_RET_SUCCESS;
read_hwmon("VDD_HIGH", GSC_HWMON_VDD_HIGH, 3);
read_hwmon("VDD_DDR", GSC_HWMON_VDD_DDR, 3);
read_hwmon("VDD_5P0", GSC_HWMON_VDD_5P0, 3);
- read_hwmon("VDD_2P5", GSC_HWMON_VDD_2P5, 3);
+ if (strncasecmp((const char*) ventana_info.model, "GW553", 5))
+ read_hwmon("VDD_2P5", GSC_HWMON_VDD_2P5, 3);
read_hwmon("VDD_1P8", GSC_HWMON_VDD_1P8, 3);
read_hwmon("VDD_IO2", GSC_HWMON_VDD_IO2, 3);
- switch (model[3]) {
+ switch (ventana_info.model[3]) {
case '1': /* GW51xx */
read_hwmon("VDD_IO3", GSC_HWMON_VDD_IO4, 3); /* -C rev */
break;
break;
case '5': /* GW55xx */
break;
+ case '6': /* GW560x */
+ read_hwmon("VDD_IO4", GSC_HWMON_VDD_IO4, 3);
+ read_hwmon("VDD_GPS", GSC_HWMON_VDD_IO3, 3);
+ break;
+ case '9': /* GW590x */
+ read_hwmon("AMONBMON", GSC_HWMON_VDD_IO3, 3);
+ read_hwmon("BAT_VOLT", GSC_HWMON_VDD_EXT, 3);
+ read_hwmon("BAT_TEMP", GSC_HWMON_VDD_IO4, 2);
}
return 0;
}
-#ifdef CONFIG_CMD_GSC
-static int do_gsc_wd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+/*
+ * The Gateworks System Controller implements a boot
+ * watchdog (always enabled) as a workaround for IMX6 boot related
+ * errata such as:
+ * ERR005768 - no fix scheduled
+ * ERR006282 - fixed in silicon r1.2
+ * ERR007117 - fixed in silicon r1.3
+ * ERR007220 - fixed in silicon r1.3
+ * ERR007926 - no fix scheduled
+ * see http://cache.freescale.com/files/32bit/doc/errata/IMX6DQCE.pdf
+ *
+ * Disable the boot watchdog
+ */
+int gsc_boot_wd_disable(void)
+{
+ u8 reg;
+
+ i2c_set_bus_num(CONFIG_I2C_GSC);
+ if (!gsc_i2c_read(GSC_SC_ADDR, GSC_SC_CTRL1, 1, ®, 1)) {
+ reg |= (1 << GSC_SC_CTRL1_WDDIS);
+ if (!gsc_i2c_write(GSC_SC_ADDR, GSC_SC_CTRL1, 1, ®, 1))
+ return 0;
+ }
+ puts("Error: could not disable GSC Watchdog\n");
+ return 1;
+}
+
+#if defined(CONFIG_CMD_GSC) && !defined(CONFIG_SPL_BUILD)
+static int do_gsc_sleep(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ unsigned char reg;
+ unsigned long secs = 0;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ secs = simple_strtoul(argv[1], NULL, 10);
+ printf("GSC Sleeping for %ld seconds\n", secs);
+
+ i2c_set_bus_num(0);
+ reg = (secs >> 24) & 0xff;
+ if (gsc_i2c_write(GSC_SC_ADDR, 9, 1, ®, 1))
+ goto error;
+ reg = (secs >> 16) & 0xff;
+ if (gsc_i2c_write(GSC_SC_ADDR, 8, 1, ®, 1))
+ goto error;
+ reg = (secs >> 8) & 0xff;
+ if (gsc_i2c_write(GSC_SC_ADDR, 7, 1, ®, 1))
+ goto error;
+ reg = secs & 0xff;
+ if (gsc_i2c_write(GSC_SC_ADDR, 6, 1, ®, 1))
+ goto error;
+ if (gsc_i2c_read(GSC_SC_ADDR, GSC_SC_CTRL1, 1, ®, 1))
+ goto error;
+ reg |= (1 << 2);
+ if (gsc_i2c_write(GSC_SC_ADDR, GSC_SC_CTRL1, 1, ®, 1))
+ goto error;
+ reg &= ~(1 << 2);
+ reg |= 0x3;
+ if (gsc_i2c_write(GSC_SC_ADDR, GSC_SC_CTRL1, 1, ®, 1))
+ goto error;
+
+ return CMD_RET_SUCCESS;
+
+error:
+ printf("i2c error\n");
+ return CMD_RET_FAILURE;
+}
+
+static int do_gsc_wd(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
{
unsigned char reg;
return CMD_RET_SUCCESS;
}
-static int do_gsc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_gsc(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
if (argc < 2)
return gsc_info(1);
if (strcasecmp(argv[1], "wd") == 0)
return do_gsc_wd(cmdtp, flag, --argc, ++argv);
+ else if (strcasecmp(argv[1], "sleep") == 0)
+ return do_gsc_sleep(cmdtp, flag, --argc, ++argv);
return CMD_RET_USAGE;
}
U_BOOT_CMD(
gsc, 4, 1, do_gsc, "GSC configuration",
- "[wd enable [30|60]]|[wd disable]\n"
+ "[wd enable [30|60]]|[wd disable]|[sleep <secs>]\n"
);
#endif /* CONFIG_CMD_GSC */