#!/bin/bash

# ============================================================
# Copyright (c) Lightos_
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# ============================================================

BASE=0x7001B000

REGISTERS="
EMC_INTSTATUS_0 0x0
EMC_INTMASK_0 0x4
EMC_DBG_0 0x8
EMC_CFG_0 0xc
EMC_ADR_CFG_0 0x10
EMC_REFCTRL_0 0x20
EMC_PIN_0 0x24
EMC_TIMING_CONTROL_0 0x28
EMC_RC_0 0x2c
EMC_RFC_0 0x30
EMC_RAS_0 0x34
EMC_RP_0 0x38
EMC_R2W_0 0x3c
EMC_W2R_0 0x40
EMC_R2P_0 0x44
EMC_W2P_0 0x48
EMC_RD_RCD_0 0x4c
EMC_WR_RCD_0 0x50
EMC_RRD_0 0x54
EMC_REXT_0 0x58
EMC_WDV_0 0x5c
EMC_QUSE_0 0x60
EMC_QRST_0 0x64
EMC_QSAFE_0 0x68
EMC_RDV_0 0x6c
EMC_REFRESH_0 0x70
EMC_BURST_REFRESH_NUM_0 0x74
EMC_PDEX2WR_0 0x78
EMC_PDEX2RD_0 0x7c
EMC_PCHG2PDEN_0 0x80
EMC_ACT2PDEN_0 0x84
EMC_AR2PDEN_0 0x88
EMC_RW2PDEN_0 0x8c
EMC_TXSR_0 0x90
EMC_TCKE_0 0x94
EMC_TFAW_0 0x98
EMC_TRPAB_0 0x9c
EMC_TCLKSTABLE_0 0xa0
EMC_TCLKSTOP_0 0xa4
EMC_TREFBW_0 0xa8
EMC_TPPD_0 0xac
EMC_ODT_WRITE_0 0xb0
EMC_PDEX2MRR_0 0xb4
EMC_WEXT_0 0xb8
EMC_RFC_SLR_0 0xc0
EMC_MRS_WA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604
EMC_PMACRO_QUSE_DDLL_RANK0_2_0 0x608
EMC_PMACRO_QUSE_DDLL_RANK0_3_0 0x60c
EMC_PMACRO_QUSE_DDLL_RANK0_4_0 0x610
EMC_PMACRO_QUSE_DDLL_RANK0_5_0 0x614
EMC_PMACRO_QUSE_DDLL_RANK1_0_0 0x620
EMC_PMACRO_QUSE_DDLL_RANK1_1_0 0x624
EMC_PMACRO_QUSE_DDLL_RANK1_2_0 0x628
EMC_PMACRO_QUSE_DDLL_RANK1_3_0 0x62c
EMC_PMACRO_QUSE_DDLL_RANK1_4_0 0x630
EMC_PMACRO_QUSE_DDLL_RANK1_5_0 0x634
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_0_0 0x640
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_1_0 0x644
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_2_0 0x648
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_3_0 0x64c
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_4_0 0x650
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK0_5_0 0x654
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_0_0 0x660
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_1_0 0x664
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_2_0 0x668
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_3_0 0x66c
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_4_0 0x670
EMC_PMACRO_OB_DDLL_LONG_DQ_RANK1_5_0 0x674
EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_0_0 0x680
EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_1_0 0x684
EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_2_0 0x688
EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_3_0 0x68c
EMC_PMACRO_OB_DDLL_LONG_DQS_RANK0_4_0 0x690
EMC_PMACRO_OB_DDLL_LONG_DQ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CAL_CAL_0 0xce0
EMC_PMACRO_DDLL_OFFSET_0 0xce4
EMC_PMACRO_DDLL_PERIODIC_OFFSET_0 0xce8
EMC_PMACRO_VTTGEN_CTRL_2_0 0xcf0
EMC_PMACRO_IB_RXRT_0 0xcf4
EMC_PMACRO_TRAINING_CTRL_0_0 0xcf8
EMC_PMACRO_TRAINING_CTRL_1_0 0xcfc
EMC_TRAINING_CMD_0 0xe00
EMC_TRAINING_CTRL_0 0xe04
EMC_TRAINING_STATUS_0 0xe08
EMC_TRAINING_QUSE_CORS_CTRL_0 0xe0c
EMC_TRAINING_QUSE_FINE_CTRL_0 0xe10
EMC_TRAINING_QUSE_CTRL_MISC_0 0xe14
EMC_TRAINING_WRITE_FINE_CTRL_0 0xe18
EMC_TRAINING_WRITE_CTRL_MISC_0 0xe1c
EMC_TRAINING_WRITE_VREF_CTRL_0 0xe20
EMC_TRAINING_READ_FINE_CTRL_0 0xe24
EMC_TRAINING_READ_CTRL_MISC_0 0xe28
EMC_TRAINING_READ_VREF_CTRL_0 0xe2c
EMC_TRAINING_CA_FINE_CTRL_0 0xe30
EMC_TRAINING_CA_CTRL_MISC_0 0xe34
EMC_TRAINING_CA_CTRL_MISC1_0 0xe38
EMC_TRAINING_CA_VREF_CTRL_0 0xe3c
EMC_TRAINING_CA_TADR_CTRL_0 0xe40
EMC_TRAINING_SETTLE_0 0xe44
EMC_TRAINING_DEBUG_CTRL_0 0xe48
EMC_TRAINING_MPC_0 0x5ec
EMC_TRAINING_PATRAM_CTRL_0 0xe60
EMC_TRAINING_PATRAM_DQ_0 0xe64
EMC_TRAINING_PATRAM_DMI_0 0xe68
EMC_TRAINING_VREF_SETTLE_0 0xe6c
EMC_TRAINING_OPT_CA_VREF_0 0xec0
EMC_TRAINING_OPT_DQ_OB_VREF_0 0xec4
EMC_TRAINING_QUSE_VREF_CTRL_0 0xed0
"

echo "Dumping EMC registers from BASE=$BASE"
echo "-----------------------------------"

# Read two tokens at a time (name + offset)
set -- $REGISTERS
while [ $# -gt 0 ]; do
    name=$1
    offset=$2
    addr=$(printf "0x%X" $((BASE + offset)))
    val=$(busybox devmem "$addr")
    echo "$name = $val"
    shift 2
done
