github.com/usbarmory/tamago@v0.0.0-20240508072735-8612bbe1e454/board/nxp/mx6ullevk/pmic.go (about)

     1  // MCIMX6ULL-EVK support for tamago/arm
     2  // https://github.com/usbarmory/tamago
     3  //
     4  // Copyright (c) WithSecure Corporation
     5  // https://foundry.withsecure.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/usbarmory/tamago/bits"
    14  	"github.com/usbarmory/tamago/soc/nxp/imx6ul"
    15  	"github.com/usbarmory/tamago/soc/nxp/iomuxc"
    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, iomuxc.SW_PAD_CTL_HYS)
    32  	bits.Set(&ctl, iomuxc.SW_PAD_CTL_PUE)
    33  	bits.Set(&ctl, iomuxc.SW_PAD_CTL_PKE)
    34  
    35  	bits.SetN(&ctl, iomuxc.SW_PAD_CTL_PUS, 0b11, iomuxc.SW_PAD_CTL_PUS_PULL_UP_22K)
    36  	bits.SetN(&ctl, iomuxc.SW_PAD_CTL_SPEED, 0b11, iomuxc.SW_PAD_CTL_SPEED_50MHZ)
    37  	bits.SetN(&ctl, iomuxc.SW_PAD_CTL_DSE, 0b111, iomuxc.SW_PAD_CTL_DSE_2_R0_6)
    38  
    39  	p := iomuxc.Pad{
    40  		Mux: IOMUXC_SW_MUX_CTL_PAD_LCD_RESET,
    41  		Pad: IOMUXC_SW_PAD_CTL_PAD_LCD_RESET,
    42  	}
    43  
    44  	p.Mode(WDOG1_WDOG_ANY_MODE)
    45  	p.Ctl(ctl)
    46  }
    47  
    48  // Reset asserts the global watchdog signal which causes the MCIMX6ULL-EVK
    49  // board to power cycle (cold reset).
    50  func Reset() {
    51  	imx6ul.WDOG1.Reset()
    52  }