-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk1.go
70 lines (61 loc) · 1.41 KB
/
mk1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright © 2020 Platina Systems, Inc. All rights reserved.
// Use of this source code is governed by the GPL-2 license described in the
// LICENSE file.
// +build mk1
package main
import (
"github.com/platinasystems/goes/external/log"
"github.com/platinasystems/ioport"
)
const packageName = "goes-boot-platina-mk1"
const recoveryUrl = "https://platina.io/goes/goes-boot-platina-mk1.cpio.xz"
func disableBootdog() (err error) {
c1, err := ioport.Inb(0x604)
if err != nil {
log.Printf("err", "Error reading CPLD Ctrl-1: %s", err)
c1 = 0 // Assume register read as zero
}
s1, err := ioport.Inb(0x602)
if err != nil {
log.Printf("err", "Error reading CPLD Status-1: %s", err)
s1 = 0 // Assume register read as zero
}
qspiBoot := 0
qspiSel := 0
if s1&0x80 != 0 {
qspiBoot = 1
}
if c1&0x80 != 0 {
qspiSel = 1
}
if qspiBoot == qspiSel {
log.Printf("alert", "Booted from QSPI%d", qspiBoot)
} else {
log.Printf("alert", "Booted from QSPI%d (QSPI%d was selected)",
qspiBoot, qspiSel)
}
if c1&0x3 != 0 {
en := ""
if c1&0x1 != 0 {
en = "WDT_RCVRY_EN"
}
if c1&0x2 != 0 {
if en != "" {
en = en + " and "
}
en = en + "WDT_DOG_EN"
}
log.Printf("alert", "CPLD watchdog status: %s", en)
c1 &= 0x7c
if qspiBoot != 0 {
c1 |= 0x80
}
err = ioport.Outb(0x604, c1)
if err != nil {
log.Printf("alert",
"Error disabling WDT in CPLD Ctrl-1: %s",
err)
}
}
return
}