github.com/f-secure-foundry/tamago@v0.0.0-20220307101044-d73fcdd7f11b/board/nxp/mx6ullevk/pmic.go (about)

     1  // MCIMX6ULL-EVK 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 mx6ullevk
    11  
    12  import (
    13  	"github.com/f-secure-foundry/tamago/bits"
    14  	"github.com/f-secure-foundry/tamago/internal/reg"
    15  	"github.com/f-secure-foundry/tamago/soc/imx6"
    16  )
    17  
    18  // On the MCIMX6ULL-EVK the SoC LCD_RESET output signal, which is tied to the
    19  // global watchdog, is connected to power reset logic
    20  // (p4081, Table 59-1. WDOG External Signals, IMX6ULLRM).
    21  const (
    22  	IOMUXC_SW_MUX_CTL_PAD_LCD_RESET = 0x020e0114
    23  	IOMUXC_SW_PAD_CTL_PAD_LCD_RESET = 0x020e03a0
    24  
    25  	WDOG1_WDOG_ANY_MODE = 4
    26  )
    27  
    28  func init() {
    29  	var ctl uint32
    30  
    31  	bits.Set(&ctl, imx6.SW_PAD_CTL_HYS)
    32  	bits.Set(&ctl, imx6.SW_PAD_CTL_PUE)
    33  	bits.Set(&ctl, imx6.SW_PAD_CTL_PKE)
    34  
    35  	bits.SetN(&ctl, imx6.SW_PAD_CTL_PUS, 0b11, imx6.SW_PAD_CTL_PUS_PULL_UP_22K)
    36  	bits.SetN(&ctl, imx6.SW_PAD_CTL_SPEED, 0b11, imx6.SW_PAD_CTL_SPEED_50MHZ)
    37  	bits.SetN(&ctl, imx6.SW_PAD_CTL_DSE, 0b111, imx6.SW_PAD_CTL_DSE_2_R0_6)
    38  
    39  	p, err := imx6.NewPad(IOMUXC_SW_MUX_CTL_PAD_LCD_RESET,
    40  		IOMUXC_SW_PAD_CTL_PAD_LCD_RESET,
    41  		0)
    42  
    43  	if err != nil {
    44  		panic(err)
    45  	}
    46  
    47  	p.Mode(WDOG1_WDOG_ANY_MODE)
    48  	p.Ctl(ctl)
    49  }
    50  
    51  // Reset deasserts the global watchdog signal which causes the MCIMX6ULL-EVK
    52  // board to power cycle (cold reset).
    53  func Reset() {
    54  	reg.Clear16(imx6.WDOG1_WCR, imx6.WCR_WDA)
    55  }