github.com/f-secure-foundry/tamago@v0.0.0-20220307101044-d73fcdd7f11b/board/f-secure/usbarmory/mark-two/usbarmory.go (about) 1 // USB armory Mk II support for tamago/arm 2 // https://github.com/f-secure-foundry/tamago 3 // 4 // Copyright (c) F-Secure Corporation 5 // https://foundry.f-secure.com 6 // 7 // Use of this source code is governed by the license 8 // that can be found in the LICENSE file. 9 10 // Package usbarmory provides hardware initialization, automatically on import, 11 // for the USB armory Mk II single board computer. 12 // 13 // This package is only meant to be used with `GOOS=tamago GOARCH=arm` as 14 // supported by the TamaGo framework for bare metal Go on ARM SoCs, see 15 // https://github.com/f-secure-foundry/tamago. 16 package usbarmory 17 18 import ( 19 "github.com/f-secure-foundry/tamago/internal/reg" 20 "github.com/f-secure-foundry/tamago/soc/imx6" 21 _ "github.com/f-secure-foundry/tamago/soc/imx6/imx6ul" 22 23 _ "unsafe" 24 ) 25 26 const OCOTP_MAC0 = 0x021bc620 27 28 const ( 29 REV_BETA = iota 30 REV_GAMMA 31 ) 32 33 // Model returns the USB armory model name, to further detect SoC variants 34 // imx6.Model() can be used. 35 func Model() (model string) { 36 // F-Secure burns model information in the MSB of OTP fuses bank 4 word 2. 37 mac0 := reg.Read(OCOTP_MAC0) 38 39 switch mac0 >> 24 { 40 case REV_GAMMA: 41 return "UA-MKII-γ" 42 default: 43 return "UA-MKII-β" 44 } 45 } 46 47 // Init takes care of the lower level SoC initialization triggered early in 48 // runtime setup. 49 // 50 //go:linkname Init runtime.hwinit 51 func Init() { 52 // initialize SoC 53 imx6.Init() 54 55 // initialize serial console 56 imx6.UART2.Init() 57 }