From 96bb22511f82a8a50667b24afeb6067e276d0429 Mon Sep 17 00:00:00 2001 From: Matt Mets Date: Sat, 30 Nov 2024 19:03:59 +0100 Subject: [PATCH] Correct the reset registers, and separate rp2040 from rp2350 --- src/machine/machine_rp2.go | 9 ++------- src/machine/machine_rp2350_resets.go | 15 +++++++-------- src/machine/machine_rp2_2040.go | 6 ++++++ src/machine/machine_rp2_2350.go | 7 +++++++ 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/machine/machine_rp2.go b/src/machine/machine_rp2.go index 6b3b97e8c0..855f25c866 100644 --- a/src/machine/machine_rp2.go +++ b/src/machine/machine_rp2.go @@ -45,12 +45,7 @@ func machineInit() { // except for QSPI pads and the XIP IO bank, as this is fatal if running from flash // and the PLLs, as this is fatal if clock muxing has not been reset on this boot // and USB, syscfg, as this disturbs USB-to-SWD on core 1 - bits := ^uint32(rp.RESETS_RESET_IO_QSPI | - rp.RESETS_RESET_PADS_QSPI | - rp.RESETS_RESET_PLL_USB | - rp.RESETS_RESET_USBCTRL | - rp.RESETS_RESET_SYSCFG | - rp.RESETS_RESET_PLL_SYS) + bits := ^uint32(initDontReset) resetBlock(bits) // Remove reset from peripherals which are clocked only by clkSys and @@ -58,7 +53,7 @@ func machineInit() { bits = ^uint32(initUnreset) unresetBlockWait(bits) -// clocks.init() + //clocks.init() // Peripheral clocks should now all be running unresetBlockWait(RESETS_RESET_Msk) diff --git a/src/machine/machine_rp2350_resets.go b/src/machine/machine_rp2350_resets.go index c224cb754d..596912741a 100644 --- a/src/machine/machine_rp2350_resets.go +++ b/src/machine/machine_rp2350_resets.go @@ -11,11 +11,10 @@ import ( // RESETS_RESET_Msk is bitmask to reset all peripherals // // TODO: This field is not available in the device file. -const RESETS_RESET_Msk = 0x01ffffff +const RESETS_RESET_Msk = 0x1fffffff type resetsType struct { - frceOn volatile.Register32 - frceOff volatile.Register32 + reset volatile.Register32 wdSel volatile.Register32 resetDone volatile.Register32 } @@ -25,20 +24,20 @@ var resets = (*resetsType)(unsafe.Pointer(rp.RESETS)) // resetBlock resets hardware blocks specified // by the bit pattern in bits. func resetBlock(bits uint32) { -// resets.frceOff.Set(bits) + resets.reset.SetBits(bits) } // unresetBlock brings hardware blocks specified by the // bit pattern in bits out of reset. func unresetBlock(bits uint32) { -// resets.frceOn.Set(bits) + resets.reset.ClearBits(bits) } // unresetBlockWait brings specified hardware blocks // specified by the bit pattern in bits // out of reset and wait for completion. func unresetBlockWait(bits uint32) { -// unresetBlock(bits) -// for !resets.resetDone.HasBits(bits) { -// } + unresetBlock(bits) + for !resets.resetDone.HasBits(bits) { + } } diff --git a/src/machine/machine_rp2_2040.go b/src/machine/machine_rp2_2040.go index f42a23c7ee..d3f4903b8f 100644 --- a/src/machine/machine_rp2_2040.go +++ b/src/machine/machine_rp2_2040.go @@ -11,6 +11,12 @@ const ( _NUMBANK0_GPIOS = 30 _NUMBANK0_IRQS = 4 rp2350ExtraReg = 0 + initDontReset = rp.RESETS_RESET_IO_QSPI | + rp.RESETS_RESET_PADS_QSPI | + rp.RESETS_RESET_PLL_USB | + rp.RESETS_RESET_USBCTRL | + rp.RESETS_RESET_SYSCFG | + rp.RESETS_RESET_PLL_SYS initUnreset = rp.RESETS_RESET_ADC | rp.RESETS_RESET_RTC | rp.RESETS_RESET_SPI0 | diff --git a/src/machine/machine_rp2_2350.go b/src/machine/machine_rp2_2350.go index a9d61f817c..ee5638df75 100644 --- a/src/machine/machine_rp2_2350.go +++ b/src/machine/machine_rp2_2350.go @@ -16,6 +16,13 @@ const ( xoscFreq = 12 // Pico 2 Crystal oscillator Abracon ABM8-272-T3 frequency in MHz rp2350ExtraReg = 1 notimpl = "rp2350: not implemented" + initDontReset = + rp.RESETS_RESET_USBCTRL | + rp.RESETS_RESET_SYSCFG | + rp.RESETS_RESET_PLL_USB | + rp.RESETS_RESET_PLL_SYS | + rp.RESETS_RESET_PADS_QSPI | + rp.RESETS_RESET_IO_QSPI initUnreset = rp.RESETS_RESET_ADC | rp.RESETS_RESET_SPI0 | rp.RESETS_RESET_SPI1 |