aboutsummaryrefslogtreecommitdiff
path: root/board/keymile/common/qrio.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/keymile/common/qrio.c')
-rw-r--r--board/keymile/common/qrio.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/board/keymile/common/qrio.c b/board/keymile/common/qrio.c
index da516918af..5401bddf06 100644
--- a/board/keymile/common/qrio.c
+++ b/board/keymile/common/qrio.c
@@ -27,6 +27,32 @@ void show_qrio(void)
(id_rev >> 8) & 0xff, id_rev & 0xff);
}
+#define SLFTEST_OFF 0x06
+
+bool qrio_get_selftest_pin(void)
+{
+ u8 slftest;
+
+ void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE;
+
+ slftest = in_8(qrio_base + SLFTEST_OFF);
+
+ return (slftest & 1) > 0;
+}
+
+#define BPRTH_OFF 0x04
+
+bool qrio_get_pgy_pres_pin(void)
+{
+ u8 pgy_pres;
+
+ void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE;
+
+ pgy_pres = in_8(qrio_base + BPRTH_OFF);
+
+ return (pgy_pres & 0x80) > 0;
+}
+
int qrio_get_gpio(u8 port_off, u8 gpio_nr)
{
u32 gprt;
@@ -244,6 +270,44 @@ void qrio_uprstreq(u8 mode)
out_8(qrio_base + RSTCFG_OFF, rstcfg);
}
+/* Early bootcount memory area is avilable starting from QRIO3 Rev.2 */
+#define QRIO3_ID 0x71
+#define QRIO3_REV 0x02
+#define EBOOTCNT_OFF 0x28
+
+ulong early_bootcount_load(void)
+{
+ void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE;
+ u16 id_rev = in_be16(qrio_base + ID_REV_OFF);
+ u8 id = (id_rev >> 8) & 0xff;
+ u8 rev = id_rev & 0xff;
+ u32 ebootcount = 0;
+
+ if (id == QRIO3_ID && rev >= QRIO3_REV) {
+ ebootcount = in_be32(qrio_base + EBOOTCNT_OFF);
+ } else {
+ printf("QRIO: warning: early bootcount not supported, ");
+ printf("id = %u, rev = %u\n", id, rev);
+ }
+
+ return ebootcount;
+}
+
+void early_bootcount_store(ulong ebootcount)
+{
+ void __iomem *qrio_base = (void *)CONFIG_SYS_QRIO_BASE;
+ u16 id_rev = in_be16(qrio_base + ID_REV_OFF);
+ u8 id = (id_rev >> 8) & 0xff;
+ u8 rev = id_rev & 0xff;
+
+ if (id == QRIO3_ID && rev >= QRIO3_REV) {
+ out_be32(qrio_base + EBOOTCNT_OFF, ebootcount);
+ } else {
+ printf("QRIO: warning: early bootcount not supported, ");
+ printf("id = %u, rev = %u\n", id, rev);
+ }
+}
+
/* I2C deblocking uses the algorithm defined in board/keymile/common/common.c
* 2 dedicated QRIO GPIOs externally pull the SCL and SDA lines
* For I2C only the low state is activly driven and high state is pulled-up