first and last commit

This commit is contained in:
Chris Nutter committed 2023-07-08 13:03:17 -07:00
commit 1bf4efd552
2612 files changed
+636500

No files matched your search

+213
View File
@@ -0,0 +1,213 @@
/*
* Copyright (C) 2013-2015 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#ifndef __DCS_H
#define __DCS_H
#include <sys/types.h>
/* DRAM Control Subsystem (DCS) */
#define DCS_MAX_FREQUENCY_SLOTS 4
#define DCS_NUM_FREQCHNGCTLREGS 6
#define DCS_FREQ(n) (1 << n)
#define EXEC(_instructions) do { _instructions ; } while(0)
#define __abs(x) (((x) < 0) ? -(x) : (x))
typedef enum {
DCS_BOOT_COLDBOOT,
DCS_BOOT_RESUME, // "Classic Resume" is (AOP_DDR | AOP_AWAKE)
DCS_BOOT_AOP_DDR,
DCS_BOOT_AOP_AWAKE,
} dcs_boottype_t;
typedef enum {
MR_READ,
MR_WRITE,
MR_MPC
} dcs_mrcmd_op_t;
struct dcs_per_freq {
uint32_t clk_period;
uint32_t freqchngctl[DCS_NUM_FREQCHNGCTLREGS];
uint32_t freqchngtim;
uint32_t lat;
uint32_t phyrdwrtim;
uint32_t caspch;
uint32_t act;
uint32_t autoref;
uint32_t selfref;
uint32_t pdn;
uint32_t derate;
uint32_t lat2;
uint32_t tat;
uint32_t mifqmaxctrl;
uint32_t nondqdspd;
uint32_t nondqds;
uint32_t cavref;
uint32_t odt_enable;
uint32_t dqds;
uint32_t dqdqsds;
uint32_t dqvref;
uint32_t cadficaltiming;
uint32_t dqdficaltiming;
uint32_t rddqcalwindow;
uint32_t wrdqcalwindow;
uint32_t caoutdllscl;
uint32_t dqsindllscl;
uint32_t rdcapcfg;
uint32_t autoref2;
};
typedef struct dcs_config_params {
uint32_t flags;
uint32_t supported_freqs;
uint32_t num_freqchngctl_regs;
uint32_t spllctrl_vco_1;
uint32_t spllctrl_vco_2;
uint32_t wrdqcalvrefcodecontrol;
uint32_t rddqcalvrefcodecontrol;
uint32_t rwcfg;
uint32_t phyupdatetimers;
uint32_t dllupdtctrl;
uint32_t dllupdtctrl1;
uint32_t pdn1;
uint32_t modereg;
uint32_t modereg1;
uint32_t autoref_params;
uint32_t autoref_params2;
uint32_t pdn;
uint32_t rnkcfg;
uint32_t cackcswkds;
uint32_t dqspdres;
uint32_t casdllupdatectrl;
uint32_t dqsdllupdatectrl;
uint32_t rdsdllctrl_step2;
uint32_t wrdqdqssdllctrl_step2;
uint32_t cawrlvlsdllcode;
uint32_t dlllocktim;
uint32_t dficaltiming;
uint32_t rdwrdqcaltiming_f0;
uint32_t rdwrdqcalseglen_f0;
uint32_t rdwrdqcaltiming_f1;
uint32_t rdwrdqcalseglen_f1;
uint32_t rdwrdqcaltiming_f3;
uint32_t rdwrdqcaltimingctrl1;
uint32_t rdwrdqcaltimingctrl2;
uint32_t rddqcalpatprbs4i;
uint32_t wrdqcalpatprbs4i;
uint32_t maxrddqssdllmulfactor;
uint32_t maxwrdqssdllmulfactor;
uint32_t dllupdtintvl;
uint32_t dcccontrol;
uint32_t dcccal;
uint32_t cbdrivestr;
uint32_t cbioctl;
uint32_t ckdrivestr;
uint32_t ckioctl;
uint32_t b0drivestr;
uint32_t b0ioctl;
uint32_t b0odt;
uint32_t b0odtctrl;
uint64_t b0dyniselasrtime;
uint64_t b0dynisel;
uint64_t b1dynisel;
uint32_t b1drivestr;
uint32_t b1ioctl;
uint32_t b1odt;
uint32_t b1odtctrl;
uint32_t dqs0drivestr;
uint32_t dqs0ioctl;
uint32_t dqs0odt;
uint32_t dqs0odtctrl;
uint32_t dqs0zdetbiasen;
uint32_t dqs1drivestr;
uint32_t dqs1ioctl;
uint32_t dqs1odt;
uint32_t dqs1odtctrl;
uint32_t dqs1zdetbiasen;
uint32_t zcalfsm0;
uint32_t zcalfsm1;
uint32_t spare0;
uint32_t hwrddqcaltvref;
uint32_t hwwrdqcaltvref;
uint32_t arefparam;
uint32_t odtszqc;
uint32_t longsr;
uint32_t freqchngctl_step3;
uint32_t mr3cmd;
uint32_t mr13cmd;
uint32_t addrcfg;
uint32_t aiuprtbaddr;
uint32_t chnldec;
uint32_t arefparam2;
uint32_t mr13cmd_step7;
uint32_t mr3cmd_step7;
uint32_t mr22cmd;
uint32_t mr11cmd;
uint32_t mr13cmd_step9;
uint32_t freqchngctl_step9;
uint32_t dqs0wkpupd;
uint32_t dqs1wkpupd;
uint32_t mr13cmd_step11;
uint32_t mr2cmd_step11;
uint32_t mr1cmd_step11;
uint32_t mr3cmd_step11;
uint32_t mr22cmd_step11;
uint32_t mr11cmd_step11;
uint32_t mr12cmd_step11;
uint32_t mr14cmd_step11;
uint32_t mr13cmd_step13;
uint32_t mr13cmd_step15;
uint32_t freqchngctl_step15;
uint32_t rdsdllctrl_step15;
uint32_t odtszqc2;
uint32_t qbren_step16;
uint32_t qbrparam;
uint32_t qbren;
uint32_t mccgen;
uint32_t caampclk;
uint32_t dqampclk;
uint32_t pwrmngten;
uint32_t odtszqc3;
struct dcs_per_freq freq[DCS_MAX_FREQUENCY_SLOTS];
} dcs_config_params_t;
typedef struct dcs_tunable {
volatile uintptr_t reg;
uint32_t mask;
uint32_t value;
} dcs_tunable_t;
struct dcs_memory_device_info {
uint32_t vendor_id;
uint32_t rev_id;
uint32_t rev_id2;
uint32_t type;
uint32_t width; // Device width in Bytes
uint32_t density; // Device density in MBytes
};
// to write the same value to the register in all channels
void dcs_reg_write_all_chan(uintptr_t reg_addr, uint32_t reg_value);
bool dcs_reg_is_outside_dcs_block(uintptr_t reg_addr);
void dcs_mrcmd(dcs_mrcmd_op_t op, uint8_t channels, uint8_t ranks, int32_t reg, uintptr_t val);
void dcs_enable_slow_boot (bool enable);
void dcs_enable_autorefresh(void);
uint64_t dcs_get_memory_size(void);
const struct dcs_memory_device_info *dcs_get_memory_device_info(void);
volatile uint32_t *dcs_save_calibration_results(volatile uint32_t *save_region, uint32_t freq);
void dcs_restore_calibration_results(volatile uint32_t *save_region);
void dcs_lock_down_mcc(void);
int32_t dcs_init(dcs_boottype_t boot_type);
#endif /* ! __DCS_H */
@@ -0,0 +1,233 @@
/*
* Copyright (C) 2013-2014 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#ifndef _DCS_CAL_H
#define _DCS_CAL_H
#define AMP_FREQUENCY_SLOTS (4)
/* _t: type, DQ0, DQ1, or CA */
/* _c: channel, 0 or 1 */
#define AMP_CA (0)
#define AMP_DQ0 (1)
#define AMP_DQ1 (2)
#define rAMP_AMPEN(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x000)
#define rAMP_AMPCLK(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x004)
#define rAMP_AMPINIT(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x008)
#define rAMP_AMPVER(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x00C)
#define rAMP_IMPCODE(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x080)
#define rAMP_IMPOVRRD(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x084)
#define rAMP_IMPAUTOCAL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x088)
#define rAMP_IMPCALPHYUPDT(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x08C)
#define rAMP_IMPCALCMD(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x090)
#define rAMP_DRAMSIGDLY(_t,_c,_n) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x094 + ((_n) * 4))
#define rAMP_NONDQDS(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + AMP_CA_SPACING + 0x098)
#define rAMP_DQDQSDS(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x09C)
#define rAMP_DIFFMODE_FREQ(_t,_c,_f) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x0A0 + ((_f) * 4))
#define rAMP_DQFLTCTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x0B0)
#define rAMP_DQSPDENALWYSON(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x110)
#define rAMP_DQSPDRES(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x114)
#define rAMP_RDFIFOPTRSTS(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x118)
#define rAMP_CALDQMSK(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x11C)
#define rAMP_DQTRNCFG(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x124 - ((_t >> 1) * 0x10))
#define rAMP_DQTRNCMD(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x128 - ((_t >> 1) * 0x10))
#define rAMP_DQTRNSTS(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x12C - ((_t >> 1) * 0x10))
#define rAMP_DLLEN(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x180)
#define rAMP_MDLLOVRRD(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x188 + ((_t >> 1) * 4))
#define rAMP_DLLLOCKTIM(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x198)
#define rAMP_DLLLOCKCTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x19C)
#define rAMP_DLLUPDTINTVL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x1A0)
#define rAMP_DLLUPDTCTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x1A4)
#define rAMP_DLLSTS(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x1A8)
#define rAMP_DQSINDLLSCL_FREQ(_t,_c,_f) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x1C0 + ((_f) * 4))
#define rAMP_CAOUTDLLSCL_FREQ(_c,_f) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + AMP_CA_SPACING + 0x1C0 + ((_f) * 4))
// <rdar://problem/13919568>
#define rAMP_TESTMODE(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x200 + ((_t >> 1) * 0x180))
#define rAMP_CKEDESKEW_CTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + AMP_CA_SPACING + 0x52C)
#define rAMP_DQWRLVLDLYCHAINCTRL(_t,_c,_b) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x704 + ((_b)*0x04))
#define rAMP_DQWRLVLRUN(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x714)
#define rAMP_DQWRLVLDATA(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x718)
#define rAMP_CACALMASK(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x804)
#define rAMP_CACALCABYTESEL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x808)
#define rAMP_CACALCAMAP0(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x80C)
#define rAMP_CACALCAMAP1(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x810)
#define rAMP_CACALCAMAP2(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x814)
//#define rAMP_CACALRUN(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x838 + ((_t >> 1) * 0xEC))
// CP : Maui Change
//#define rAMP_CACALRESULT(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x83C)
#define rAMP_CAPHYUPDTREQ(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + AMP_CA_SPACING + 0xB00)
#define rAMP_CAPHYUPDTSTATUS(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + AMP_CA_SPACING + 0xB04)
#define rAMP_DLLUPDTCMD(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x18C)
// Some bit definitions
// CP : Maui Change
#define CACALRUN_CACALMODE 1
#define rAMP_CACACALVREF(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x908)
#define rAMP_CACALBITSELECT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x918)
#define CS_TRAINING 0
#define CA_TRAINING 1
#define CS_FINE_TRAINING 2
#define RUN_DLL_UPDT 0
#define CACALRUN_RUNCACALENTRY (1 << 0)
#define CACALRUN_RUNCACALCS (1 << 4)
#define CACALRUN_RUNCACALCA (1 << 8)
#define CACALRUN_RUNCACALEXIT (1 << 12)
#define CACALRUN_RUNCACALVREF (1 << 16)
#define rAMP_CACALRESULT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x91C)
#define rAMP_CACALRUN(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x924)
#define rAMP_CACALCTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x900)
#define rAMP_CACALCTRL2(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x904)
#define rAMP_CACALCTRL3(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x928)
#define rAMP_CACALPAT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x90C)
#define rAMP_CASDLLCTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x700)
#define rAMP_CASDLLCODE(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x704)
#define rAMP_CKSDLLCTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x710)
#define rAMP_CKSDLLCODE(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x714)
#define rAMP_CSSDLLCTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x708)
#define rAMP_CSSDLLCODE(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x70C)
#define rAMP_AMPCACALENTRYCMD(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x910)
#define rAMP_AMPCACALEXITCMD(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x914)
#define rAMP_MDLLCODE(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x194)
#define rAMP_CKDESKEW_CTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x51C)
#define rAMP_CADESKEW_CTRL(_c,_d) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x500 + ((_d)*4))
#define rAMP_CSDESKEW_CTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x518)
#define rAMP_RDWRDQCALLOOPCNT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE20)
#define rAMP_RUNRDDQCAL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE58)
#define rAMP_CALPATCFG(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x110)
#define rAMP_DQSDLLCTRL_RD(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x608)
#define rAMP_DQSDLLCODE_RD(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x60C)
#define rAMP_RDDQDESKEW_CTRL(_b,_c,_d) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x428 + ((_d)*4))
#define rAMP_RDDQSDESKEW_CTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x448)
#define rAMP_RDDMDESKEW_CTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x44C)
#define rAMP_DQCALCTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x900)
#define rAMP_DQCALRUN(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE58)
#define rAMP_DQCALRESULT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE5C)
#define rAMP_RDCLKDLYSEL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x618)
#define rAMP_RDDQCALPAT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE2C)
#define rAMP_RdWrDqCalTiming_f0(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE00)
#define rAMP_RdWrDqCalTiming_f1(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE08)
#define rAMP_RdWrDqCalTiming_f2(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE10)
#define rAMP_RdWrDqCalTiming_f3(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE18)
#define rAMP_RdWrDqCalTimingCtrl2(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE28)
#define rAMP_RDDQCALVREF_f0(_t, _c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0xB00)
#define rAMP_RDDQCALVREF_f1(_t, _c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0xB04)
#define rAMP_CAWRLVLSDLLCODE(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x800)
#define rAMP_CAWRLVLENTRYCMD(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xB00)
#define rAMP_CAWRLVLEXITCMD(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xB04)
#define rAMP_CAWRLVLTIM(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xB08)
#define rAMP_CARUNWRLVL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xB0C)
#define rAMP_CAWRLVLRESULT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xB10)
#define rAMP_AMPSDQIOCFG_DQFLTCTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0xA4)
#define rAMP_DQWRLVLSDLLCODE(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x704)
#define rAMCX_DRAMCFG_FREQCHNGMRWCNT(_c) (DCS_BASE_ADDR + ((_c)*DCS_SPACING) + 0x44C)
#define rAMCX_DRAMCFG_FREQCHNGCTL0_FREQ0(_c) (DCS_BASE_ADDR + ((_c)*DCS_SPACING) + 0x450)
#define rAMCX_DRAMCFG_FREQCHNGCTL1_FREQ0(_c) (DCS_BASE_ADDR + ((_c)*DCS_SPACING) + 0x454)
#define rAMCX_DRAMCFG_FREQCHNGCTL0_FREQ1(_c) (DCS_BASE_ADDR + ((_c)*DCS_SPACING) + 0x468)
#define rAMCX_DRAMCFG_FREQCHNGCTL1_FREQ1(_c) (DCS_BASE_ADDR + ((_c)*DCS_SPACING) + 0x46C)
#define RUNDESKEWUPD (1 << 8)
#define rAMP_WRDQCALPAT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE30)
#define rAMP_WRDQSDQ_SDLLCTRL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x600)
#define rAMP_WRDQSDQ_SDLLCODE(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x604)
#define rAMP_WRDQ_CAL_RUN(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE60)
#define rAMP_WRDQ_CAL_RESULT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE64)
#define rAMP_WRDQCALVREF(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x908)
#define rAMP_WRDQDESKEW_CTRL(_b,_c,_t) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x400 + ((_t)*4))
#define rAMP_WRDQSDESKEW_CTRL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x420)
#define rAMP_WRDMDESKEW_CTRL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x424)
#define rAMP_CAMDLL_VTSCL_REFCNTL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x1D4)
#define rAMP_RDMDLL_VTSCL_REFCNTL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x1D8)
#define rAMP_WRMDLL_VTSCL_REFCNTL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x1D8)
#define rAMP_RDCAPCFG_FREQ(_c, _b, _f) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x100 + ((_f) * 4))
#define rAMP_DQSPDENALWAYSON(_c, _b) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x110)
#if DCS_REG_VERSION == 2
#define rAMPH_CFGH_DQS0_WKPUPD(_c) (AMP_H_BASE_ADDR + ((_c)*AMP_SPACING)+ 0x0C8)
#define rAMPH_CFGH_DQS1_WKPUPD(_c) (AMP_H_BASE_ADDR + ((_c)*AMP_SPACING)+ 0x138)
#define F0_IDLE_ACTIVE_MASK 0xFFFEFFF7
#define F0_IDLE_ACTIVE_OFFSET 16
#define F1_IDLE_ACTIVE_MASK 0xFFFDFFF7
#define F1_IDLE_ACTIVE_OFFSET 17
#define F1_PDPWK_OFFSET 3
#define DESKEW_CODE_MASK 0x3F
#endif // #if DCS_REG_VERSION == 2
#define RUNWRLVLENTRY_OFFSET 0
#define RUNWRLVLDQ_OFFSET 1
#define RUNWRLVLEXIT_OFFSET 3
#define RUNWRLVLLOOPCNT_OFFSET 8
#define RUNWRLVLMASK_OFFSET 16
#define RUNWRLVL_SDLLUPDOVR 8
#define RUNWRLVL_SDLLUPDWRRES 9
#define WRLVL_SDLLCODE_MASK 0xFFFFFF00
#define WRLVLMAX_SDLLCODE_MASK 0xFF00FFFF
#define WRLVL_SDLLCODE_OFFSET 0
#define WRLVLMAX_SDLLCODE_OFFSET 16
#define DQS_IDLE_ACTIVE_MASK 0xFFFFFFEF
#define DQS_IDLE_ACTIVE_OFFSET 4
#define WRLVL_RESULT 0
#define WRLVL_CNT0_OFFSET 8
#define WRLVL_CNT1_OFFSET 16
#define SDLLOFFSET 16
#define RUN_SDLLUPDOVR 1
#define RUN_SDLLUPDWRRES 2
#define WR_DQ_SDLL_OFFSET 16
#define WR_DQS_SDLL_OFFSET 24
#define WR_SDLLUPDOVR 1
#define WR_SDLLUPDWRRES 2
#define WR_ALL_BITS_PASS 0xFFFF
#define WR_ALL_BITS_FAIL 0x0
#define WR_CALIB_RUN 0
#define WR_DQS_SDLL_CODE_OFFSET 8
#define VT_SCL_REF_MASK 0x3FF
#define VT_SCL_REF_BITS 10
#define VT_SCL_OVR_OFFSET 16
#define VT_SCL_REF_UPD_OFFSET 28
#define DQS_PDEN_OFFSET 24
#define DQS_PDEN_MASK 0xFEFFFFFF
#define DQSPDEN_ALWAYSON_OFFSET 0
#define DQSPDEN_ALWAYSON_MASK 0x1
#define MAX_SDLL_OFFSET
#define TESTMODE_FORCECKELOW (1 << 8)
#define SIGN_BIT_POS (6)
#define AMP_MAX_RANKS_PER_CHAN (2)
#endif /* _DCS_CAL_H */
@@ -0,0 +1,291 @@
/*
* Copyright (C) 2013-2015 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#ifndef _DCS_CAL_H
#define _DCS_CAL_H
#define AMP_FREQUENCY_SLOTS (4)
/* _t: type, DQ0, DQ1, or CA */
/* _c: channel, 0 or 1 */
#define AMP_CA (0)
#define AMP_DQ0 (1)
#define AMP_DQ1 (2)
#define rAMP_AMPEN(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x000)
#define rAMP_AMPCLK(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x004)
#define rAMP_AMPINIT(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x008)
#define rAMP_AMPVER(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x00C)
#define rAMP_IMPCODE(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x080)
#define rAMP_IMPOVRRD(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x084)
#define rAMP_IMPAUTOCAL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x088)
#define rAMP_IMPCALPHYUPDT(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x08C)
#define rAMP_IMPCALCMD(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x090)
#define rAMP_DRAMSIGDLY(_t,_c,_n) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x094 + ((_n) * 4))
#define rAMP_NONDQDS(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + AMP_CA_SPACING + 0x098)
#define rAMP_DQDQSDS(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x09C)
#define rAMP_DIFFMODE_FREQ(_t,_c,_f) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x0A0 + ((_f) * 4))
#define rAMP_DQFLTCTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x0B0)
#define rAMP_DQSPDENALWYSON(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x110)
#define rAMP_DQSPDRES(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x114)
#define rAMP_RDFIFOPTRSTS(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x118)
#define rAMP_CALDQMSK(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x11C)
#define rAMP_DQTRNCFG(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x124 - ((_t >> 1) * 0x10))
#define rAMP_DQTRNCMD(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x128 - ((_t >> 1) * 0x10))
#define rAMP_DQTRNSTS(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x12C - ((_t >> 1) * 0x10))
#define rAMP_DLLEN(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x180)
#define rAMP_MDLLOVRRD(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x188 + ((_t >> 1) * 4))
#define rAMP_DLLLOCKTIM(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x198)
#define rAMP_DLLLOCKCTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x19C)
#define rAMP_DLLUPDTINTVL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x1A0)
#define rAMP_DLLUPDTCTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x1A4)
#define rAMP_DLLSTS(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x1A8)
#define rAMP_DQSINDLLSCL_FREQ(_t,_c,_f) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x1C0 + ((_f) * 4))
#define rAMP_CAOUTDLLSCL_FREQ(_c,_f) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + AMP_CA_SPACING + 0x1C0 + ((_f) * 4))
// <rdar://problem/13919568>
#define rAMP_TESTMODE(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x200 + ((_t >> 1) * 0x180))
#define rAMP_CKEDESKEW_CTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + AMP_CA_SPACING + 0x52C)
#define rAMP_DQWRLVLDLYCHAINCTRL(_t,_c,_b) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x704 + ((_b)*0x04))
#define rAMP_DQWRLVLRUN(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x714)
#define rAMP_DQWRLVLDATA(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x718)
#define rAMP_CACALMASK(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x804)
#define rAMP_CACALCABYTESEL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x808)
#define rAMP_CACALCAMAP0(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x80C)
#define rAMP_CACALCAMAP1(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x810)
#define rAMP_CACALCAMAP2(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x814)
//#define rAMP_CACALRUN(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x838 + ((_t >> 1) * 0xEC))
// CP : Maui Change
//#define rAMP_CACALRESULT(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x83C)
#define rAMP_CAPHYUPDTREQ(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + AMP_CA_SPACING + 0xB00)
#define rAMP_CAPHYUPDTSTATUS(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + AMP_CA_SPACING + 0xB04)
#define rAMP_DLLUPDTCMD(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x18C)
// Some bit definitions
// CP : Maui Change
#define CACALRUN_CACALMODE 1
#define rAMP_CACACALVREF(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x908)
#define rAMP_CACALBITSELECT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x918)
#define CS_TRAINING 0
#define CA_TRAINING 1
#define CS_FINE_TRAINING 2
#define RUN_DLL_UPDT 0
#define CACALRUN_RUNCACALENTRY (1 << 0)
#define CACALRUN_RUNCACALCS (1 << 4)
#define CACALRUN_RUNCACALCA (1 << 8)
#define CACALRUN_RUNCACALEXIT (1 << 12)
#define CACALRUN_RUNCACALVREF (1 << 16)
#define rAMP_CACALRESULT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x91C)
#define rAMP_CACALRUN(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x924)
#define rAMP_CACALCTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x900)
#define rAMP_CACALCTRL2(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x904)
#define rAMP_CACALCTRL3(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x928)
#define rAMP_CACALPAT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x90C)
#define rAMP_CASDLLCTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x700)
#define rAMP_CASDLLCODE(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x704)
#define rAMP_CKSDLLCTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x710)
#define rAMP_CKSDLLCODE(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x714)
#define rAMP_CSSDLLCTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x708)
#define rAMP_CSSDLLCODE(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x70C)
#define rAMP_AMPCACALENTRYCMD(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x910)
#define rAMP_AMPCACALEXITCMD(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x914)
#define rAMP_MDLLCODE(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t)*AMP_DQ_SPACING) + 0x194)
#define rAMP_CKDESKEW_CTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x51C)
#define rAMP_CADESKEW_CTRL(_c,_d) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x500 + ((_d)*4))
#define rAMP_CSDESKEW_CTRL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x518)
#define rAMP_RDWRDQCALLOOPCNT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE20)
#define rAMP_RUNRDDQCAL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE58)
#define rAMP_CALPATCFG(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x110)
#define rAMP_DQSDLLCTRL_RD(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x608)
#define rAMP_DQSDLLCODE_RD(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x60C)
#define rAMP_RDDQDESKEW_CTRL(_b,_c,_d) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x428 + ((_d)*4))
#define rAMP_RDDQSDESKEW_CTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x448)
#define rAMP_RDDMDESKEW_CTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x44C)
#define rAMP_DQCALCTRL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x900)
#define rAMP_DQCALRUN(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE58)
#define rAMP_DQCALRESULT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE5C)
#define rAMP_RDCLKDLYSEL(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x618)
#define rAMP_RDDQCALPAT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE2C)
#define rAMP_RdWrDqCalTiming_f0(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE00)
#define rAMP_RdWrDqCalTiming_f1(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE08)
#define rAMP_RdWrDqCalTiming_f2(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE10)
#define rAMP_RdWrDqCalTiming_f3(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE18)
#define rAMP_RdWrDqCalTimingCtrl2(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE28)
#define rAMP_RDDQCALVREF_f0(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xD10)
#define rAMP_RDDQCALVREF_f1(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xD14)
#define rAMP_DQCAL_BURSTLEN_MODE(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xF10)
#define rAMP_CAWRLVLSDLLCODE(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x800)
#define rAMP_CAWRLVLENTRYCMD(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xB00)
#define rAMP_CAWRLVLEXITCMD(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xB04)
#define rAMP_CAWRLVLTIM(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xB08)
#define rAMP_CARUNWRLVL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xB0C)
#define rAMP_CAWRLVLRESULT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xB10)
#define rAMPH_CFGH_DQS0_WKPUPD(_c) (AMP_H_BASE_ADDR + ((_c)*AMP_SPACING)+ 0x0C8)
#define rAMPH_CFGH_DQS1_WKPUPD(_c) (AMP_H_BASE_ADDR + ((_c)*AMP_SPACING)+ 0x138)
#define rAMPH_CFGH_CABIST_BISTRDFIFOCTRL(_c) (AMP_H_BASE_ADDR + ((_c)*AMP_SPACING)+ 0x164)
#define rAMP_CACALPATSEED_0(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x92C)
#define rAMP_CACALPATSEED_1(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x930)
#define rAMP_DQWRLVLSDLLCODE(_t,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_t + 1)*AMP_DQ_SPACING) + 0x704)
#define rAMCX_DRAMCFG_FREQCHNGMRWCNT(_c) (DCS_BASE_ADDR + ((_c)*DCS_SPACING) + 0x44C)
#define rAMCX_DRAMCFG_FREQCHNGCTL0_FREQ0(_c) (DCS_BASE_ADDR + ((_c)*DCS_SPACING) + 0x450)
#define rAMCX_DRAMCFG_FREQCHNGCTL1_FREQ0(_c) (DCS_BASE_ADDR + ((_c)*DCS_SPACING) + 0x454)
#define rAMCX_DRAMCFG_FREQCHNGCTL0_FREQ1(_c) (DCS_BASE_ADDR + ((_c)*DCS_SPACING) + 0x468)
#define rAMCX_DRAMCFG_FREQCHNGCTL1_FREQ1(_c) (DCS_BASE_ADDR + ((_c)*DCS_SPACING) + 0x46C)
#define RUNDESKEWUPD (1 << 8)
#define rAMP_WRDQCALPAT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE30)
#define rAMP_WRDQSDQ_SDLLCTRL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x600)
#define rAMP_WRDQSDQ_SDLLCODE(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x604)
#define rAMP_WRDQ_CAL_RUN(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE60)
#define rAMP_WRDQ_CAL_RESULT(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xE64)
#define rAMP_WRDQCALVREF(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x908)
#define rAMP_WRDQDESKEW_CTRL(_b,_c,_t) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x400 + ((_t)*4))
#define rAMP_WRDQSDESKEW_CTRL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x420)
#define rAMP_WRDMDESKEW_CTRL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x424)
#define rAMP_CAMDLL_VTSCL_REFCNTL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x1D4)
#define rAMP_RDMDLL_VTSCL_REFCNTL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x1D8)
#define rAMP_WRMDLL_VTSCL_REFCNTL(_b,_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x1D8)
#define rAMP_RDCAPCFG_FREQ(_c, _b, _f) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x100 + ((_f) * 4))
#define rAMP_DQSPDENALWAYSON(_c, _b) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + ((_b + 1)*AMP_DQ_SPACING) + 0x110)
#define rAMP_CALPATPRBS7_0(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xEA0)
#define rAMP_CALPATPRBS7_1(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xEA4)
#define rAMP_CALPATPRBS7_2(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xEA8)
#define rAMP_CALPATPRBS7_3(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xEAC)
#define rAMP_CACALPATSEED_0(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x92C)
#define rAMP_CACALPATSEED_1(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x930)
#define rAMP_WRDQCALPATSEED_B0_0(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xEB4)
#define rAMP_WRDQCALPATSEED_B0_1(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xEB8)
#define rAMP_WRDQCALPATSEED_B0_2(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xEBC)
#define rAMP_WRDQCALPATSEED_B1_0(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xEC0)
#define rAMP_WRDQCALPATSEED_B1_1(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xEC4)
#define rAMP_WRDQCALPATSEED_B1_2(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xEC8)
#define rAMP_WRDQCAL_NC_CONVERSION_THRESHOLD_F0(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xED0)
#define rAMP_WRDQCAL_NC_CONVERSION_THRESHOLD_F1(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xED4)
#define rAMP_WRDQCALVREFCODECONTROL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xF20)
#define rAMP_WRDQCALVREFCODESTATUS(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xF24)
#define rAMP_RDDQCALVREFCODECONTROL(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xF18)
#define rAMP_RDDQCALVREFCODESTATUS(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0xF1C)
#define rAMP_CA_IMPCALCMD(_c) (AMP_BASE_ADDR + ((_c)*AMP_SPACING) + 0x094)
#define RUNIMPCAL_OFFSET 0
#define RUNIMPCAL_MASK 0xFFFFFFFE
#define RUNWRLVLENTRY_OFFSET 0
#define RUNWRLVLDQ_OFFSET 1
#define RUNWRLVLEXIT_OFFSET 3
#define RUNWRLVLLOOPCNT_OFFSET 8
#define RUNWRLVLMASK_OFFSET 16
#define RUNWRLVL_SDLLUPDOVR 8
#define RUNWRLVL_SDLLUPDWRRES 9
#define WRLVL_SDLLCODE_MASK 0xFFFFFF00
#define WRLVLMAX_SDLLCODE_MASK 0xFF00FFFF
#define WRLVL_SDLLCODE_OFFSET 0
#define WRLVLMAX_SDLLCODE_OFFSET 16
#define DQS_IDLE_ACTIVE_MASK 0xFFFFFFEF
#define DQS_IDLE_ACTIVE_OFFSET 4
#define RUNRDDQCAL_WRFIFO_MASK 0xFFFFEFFF
#define RUNRDDQCAL_WRFIFO_OFFSET 12
#define HALF_CLK_OVRVAL_MASK 0xFFFFF3FF
#define HALF_CLK_OVRVAL_OFFSET 10
#define NC_THRESHOLD0_OFFSET 0
#define NC_THRESHOLD1_OFFSET 8
#define NC_THRESHOLD_MASK 0x3F
#define WRLVL_RESULT 0
#define WRDQ_VREF_F1_OFFSET 8
#define WRDQ_VREF_F0_OFFSET 0
#define WRDQ_VREF_F1_MASK 0xFFFF00FF
#define WRDQ_VREF_F0_MASK 0xFFFFFF00
#define RDDQ_VREF_F1_OFFSET 8
#define RDDQ_VREF_F0_OFFSET 0
#define RDDQ_VREF_F1_MASK 0xFFFF00FF
#define RDDQ_VREF_F0_MASK 0xFFFFFF00
#define WRLVL_CNT0_OFFSET 8
#define WRLVL_CNT1_OFFSET 16
#define SDLLOFFSET 16
#define RUN_SDLLUPDOVR 1
#define RUN_SDLLUPDWRRES 2
#define WR_DQ_SDLL_OFFSET 16
#define WR_DQS_SDLL_OFFSET 24
#define WR_SDLLUPDOVR 1
#define WR_SDLLUPDWRRES 2
#define WR_ALL_BITS_PASS 0xFFFF
#define WR_ALL_BITS_FAIL 0x0
#define WR_CALIB_RUN 0
#define WR_DQS_SDLL_CODE_OFFSET 8
#define VT_SCL_REF_MASK 0x3FF
#define VT_SCL_REF_BITS 10
#define VT_SCL_OVR_OFFSET 16
#define VT_SCL_REF_UPD_OFFSET 28
#define DQS_PDEN_OFFSET 24
#define DQS_PDEN_MASK 0xFEFFFFFF
#define DQSPDEN_ALWAYSON_OFFSET 0
#define DQSPDEN_ALWAYSON_MASK 0x1
#define DESKEW_CODE_MASK 0x3F
#define RDDQCAL_BURSTLEN_MODE_MASK 0xFFFFFFFE
#define RDDQCAL_BURSTLEN_MODE_OFFSET 0
#define F0_IDLE_ACTIVE_MASK 0xFFFEFFFF
#define F0_IDLE_ACTIVE_OFFSET 16
#define F1_IDLE_ACTIVE_MASK 0xFFFDFFFF
#define F1_IDLE_ACTIVE_OFFSET 17
#define F3_IDLE_ACTIVE_MASK 0xFFF7FFFF
#define F3_IDLE_ACTIVE_OFFSET 19
#define F0_WEAK_PD_MASK 0xFFFFFFFD
#define F0_WEAK_PD_OFFSET 1
#define F1_WEAK_PD_MASK 0xFFFFFFF7
#define F1_WEAK_PD_OFFSET 3
#define F3_WEAK_PD_MASK 0xFFFFFF7F
#define F3_WEAK_PD_OFFSET 7
#define CACAL_DQS_PULSE_CNT_OFFSET 16
#define CACAL_DQS_PULSE_WIDTH_OFFSET 20
#define BIST_RDFIFO_RESET_MASK 0xFFFFFFFD
#define BIST_RDFIFO_RESET_OFFSET 1
#define MAX_SDLL_OFFSET
#define TESTMODE_FORCECKELOW (1 << 8)
#define SIGN_BIT_POS (6)
#define AMP_MAX_RANKS_PER_CHAN (2)
#endif /* _DCS_CAL_H */
@@ -0,0 +1,271 @@
/*
* Copyright (C) 2012-2015 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#ifndef __DCS_CALIBRATION_H
#define __DCS_CALIBRATION_H
#ifdef ENV_IBOOT
// Calibration registers
#if DCS_REG_VERSION < 3
#include <drivers/dcs/dcs_cal.h>
#else
#include <drivers/dcs/dcs_cal_v2.h>
#endif
#endif
// Chip rev definitions for non-iBoot environments
#ifndef ENV_IBOOT
#define CHIP_REVISION_A0 0x00
#define CHIP_REVISION_A1 0x01
#define CHIP_REVISION_B0 0x10
#define CHIP_REVISION_B1 0x11
#define CHIP_REVISION_C0 0x20
#define CHIP_REVISION_C1 0x21
#endif
#define AMP_DQ_PER_CHAN 2
#define AMP_MAX_PATTERNS 8
#define CALIB_SAVE 0
#define CALIB_RESTORE 1
#define CALIB_PMU_BYTES 400
// 1 CASDLL (8 bits), 1 CKSDLL (8 bits), 1 CSSDLL (8 bits), 6 CA bit deskews (6 bits * 6), CK/CS deskew (6 bits * 2), 3 WrLvl SDLLs (8 bits * 3)
// WRDQ SDLLs (2 * 8 bits), WRDQS SDLLs (2 * 8 bits), WR DQ deskew (2 * 8 * 6 bits), WR DQS deskew ( 2 * 6 bits), WR DM deskew (2 * 6 bits)
// 3 WrLvl SDLLs (8 bits * 3) after WRDQ calibration
// RD SDLLs (2 * 8 bits), RD deskew (2 * 8 * 6 bits), RD DMI deskew (2 * 6 bits)
// Optimal Vref for CA, RD & WR for bins 0 & 1 (3 * 2 * 6 bits)
// VT scaling refence codes for CA, RD and WR for both DQ splits ( 3 * 2 * 10 bits)
// Total bits per channel = 24 +36 + 12 + 24 + 16 + 16 + 96 + 12 + 12 + 24 + 16 + 96 + 12 + 36 + 60 = 492 bits
// TODO: Recalculate this (somehow! --> better: sizeof(struct) )
#define CALIB_NUM_BYTES_TO_SAVE (DCS_NUM_CHANNELS * (62))
// CP Changed
#define CA_NUM_BITS 6
#define CA_ALL_BITS ((1 << CA_NUM_BITS) - 1)
#if DCS_REG_VERSION < 3
#define CA_NUM_VREF_F0 10
#define RDDQ_NUM_VREF_F0 10
#define CA_NUM_VREF_F1 21
#define RDDQ_NUM_VREF_F1 26
#define CA_NUM_VREF_MAX ((CA_NUM_VREF_F0 > CA_NUM_VREF_F1) ? CA_NUM_VREF_F0 : CA_NUM_VREF_F1)
#define RDDQ_NUM_VREF_MAX ((RDDQ_NUM_VREF_F0 > RDDQ_NUM_VREF_F1) ? RDDQ_NUM_VREF_F0 : RDDQ_NUM_VREF_F1)
#else
#define CA_NUM_VREF 10
#define RDDQ_NUM_VREF 10
#endif // #if DCS_REG_VERSION < 3
#define WRDQ_NUM_VREF 10
#define CA_NUM_PATTERNS 64
// <rdar://problem/13821643>
#define DELIMIT_POS_ADJ_CASDLL 6
#define DELIMIT_POS_ADJ_WRDQSDLL 6
#define MR_READ 0
#define MR_WRITE 1
#define MR0 0x0
#define MR2 0x02
#define MR5 0x05
#define MR12 0x0C
#define MR13 0x0D
#define MR14 0x0E
#define MR15 0x0F
#define MR20 0x14
#define MR32 0x20
#define MR40 0x28
#define MR41 0x29
#define MR42 0x2A
#define MR48 0x30
#define MIN_ENDPT 0
#define MAX_ENDPT 1
#if DCS_REG_VERSION == 1
#define MAX_DESKEW_PROGRAMMED 31
#define MAX_SDLL_VAL 203
#else
#define MAX_DESKEW_PROGRAMMED 55
#if DCS_REG_VERSION == 2
#define MAX_SDLL_VAL 248
#else
#define MAX_SDLL_VAL 204
#endif // #if DCS_REG_VERSION == 2
#endif // #if DCS_REG_VERSION == 1
#define MIN_SDLL_VAL 0
#define FINER_STEP_SZ 1
#define COARSE_STEP_SZ 4
#define SOLID_PASS_DETECT 8
#define SOLID_PASS_ZONE_DETECT 4
#define SOLID_FAIL 2
#define DLLVAL_BITS 0xFF
#define DESKEW_CTRL_BITS 0x3F
#define SDLL_NUM_BITS 8
#define DESKEW_NUM_BITS 6
#define CA_WRDQ_VREF_CTRL_BITS 0x7F
#define CA_WRDQ_VREF_NUM_BITS 7
#define RDDQ_VREF_CTRL_BITS 0xFF
#define RDDQ_VREF_NUM_BITS 8
#define RD_LATENCY_ENCODE 26
#define MAX_DQWRLVL_CODE 127
#define DQ_NUM_PATTERNS 128
// The number of bytes below is consecutive for a given ch, rnk, bank, and row (interleaving starts after these bytes)
//#define DQ_CONSECUTIVE_BYTES_PER_CHRNK 256
#define DQ_BYTES_PER_COL 4 // That makes for 64 consecutive columns (or words)
// the bank and row numbers where patterns will be written
#define DQ_ROW 0
#define DQ_BANK 0
#define DQ_ADDR_RANK_BIT 16 // RIBI2 addressing for dual rank devices
// Calibration operation selection
#define SELECT_CACAL 0x1
#define SELECT_WRLVLCAL 0x2
#define SELECT_RDDQCAL 0x4
#define SELECT_WRDQCAL 0x8
#define SELECT_CAL_ALL 0xF
// This defintion is put here for non-iBoot compilation environments
#ifndef __abs
#define __abs(x) (((x) < 0) ? -(x) : (x))
#endif
#if DCS_REG_VERSION < 2
#define DQ_MAX_DESKEW_PER_BIT 47
#else
#define DQ_MAX_DESKEW_PER_BIT 55
#endif
// maximum possible loops in the hw
#define RDDQ_LOOPCNT 16
#define DQ_NUM_BYTES 2
#define DQ_NUM_BYTES_PER_DQ 1
#define DQ_NUM_BITS_PER_BYTE 8
#define DQ_TOTAL_BITS (DQ_NUM_BYTES * DQ_NUM_BITS_PER_BYTE)
#define DMI_TOTAL_BITS 2
#define DMI_NUM_BITS_PER_BYTE 1
#if DCS_REG_VERSION == 2
#define MAX_CAWRLVL_CODE 52
#else
#define MAX_CAWRLVL_CODE 47
#endif // #if DCS_REG_VERSION == 2
#define CLK_PERIOD_NUMER (1000000)
#define CLK_PERIOD_OF(_freq_in_mhz) (CLK_PERIOD_NUMER / (_freq_in_mhz))
#define CLK_PERIOD_1600 CLK_PERIOD_OF(1600) // 625
#define CLK_PERIOD_1200 CLK_PERIOD_OF(1200) // 833
#define CLK_PERIOD_800 CLK_PERIOD_OF(800) // 1250
void calibration_ca_rddq_wrlvl(bool resume);
void calibration_wrdq_rddq(bool resume);
void calibration_save_restore_ca_wrlvl_regs(uint32_t save_or_restore, uint32_t channels, bool freq_bin);
void calibration_dump_results(uint32_t operations, bool dump_passing_window);
struct amp_calibration_params {
uint32_t chip_id;
uint32_t chip_rev;
uint32_t num_channels;
uint32_t num_channels_runCalib;
uint32_t num_ranks;
uint32_t clk_period_bin0;
uint32_t clk_period_bin1;
#if DCS_REG_VERSION < 3
uint32_t ca_num_vref_f0;
uint32_t rddq_num_vref_f0;
uint32_t ca_num_vref_f1;
uint32_t rddq_num_vref_f1;
#else
uint32_t ca_num_vref;
uint32_t rddq_num_vref;
#endif // #if DCS_REG_VERSION < 3
uint32_t wrdq_num_vref;
bool wrdq_apply_NC_algorithm;
#if DCS_REG_VERSION < 3
uint32_t ca_vref_values_f0[CA_NUM_VREF_F0];
uint32_t rddq_vref_values_f0[RDDQ_NUM_VREF_F0];
uint32_t ca_vref_values_f1[CA_NUM_VREF_F1];
uint32_t rddq_vref_values_f1[RDDQ_NUM_VREF_F1];
#else
uint32_t ca_vref_values[CA_NUM_VREF];
uint32_t rddq_vref_values[RDDQ_NUM_VREF];
#endif
uint32_t wrdq_vref_values[WRDQ_NUM_VREF];
bool resume;
bool disable_coarse_cs_training;
uint32_t opt_vref_mode; // Use CoM or "Widest Span" method?
uint32_t cacalib_hw_loops;
uint32_t cacalib_sw_loops;
uint32_t cacalib_dqs_pulse_cnt;
uint32_t cacalib_dqs_pulse_width;
uint32_t rddq_cal_loopcnt;
uint32_t wrdq_cal_loopcnt;
uint32_t rddq_legacy_mode;
uint32_t wrdq_legacy_mode;
uint32_t cacal_bit_sel[8];
uint32_t cacal_rd_byte_sel;
uint32_t ca_prbs4_pattern;
uint32_t prbs7_pattern_0;
uint32_t prbs7_pattern_1;
uint32_t prbs7_pattern_2;
uint32_t prbs7_pattern_3;
uint32_t ca_prbs_seed_bit[CA_NUM_BITS];
uint32_t wrdq_prbs_seed[DQ_NUM_BYTES][DQ_NUM_BITS_PER_BYTE + DMI_NUM_BITS_PER_BYTE];
uint32_t ca_invert_mask;
uint32_t CsStopCycleCnt;
uint32_t CsActiveCycleCnt;
uint32_t tADR, tMRD, tCAENT, tVREF_LONG, tCKELCK, tCKCKEH, tDSTrain;
uint32_t tWLO;
uint32_t tWLMRD;
uint32_t tWLDQSEN;
uint32_t tDQSCKE;
uint32_t tCKEHCMD;
uint32_t WrLvlDqsPulseCnt;
int freq_bin;
int RL;
int WL;
// SEG specific flags
bool dv_params_valid; // DV flag
bool dv_randomize; // flag to be used by DV to randomize some register values for DV purposes
uint32_t dbg_calib_mode; // flag to be used by SEG to skip calibration operations for debug purposes
};
#define DCS_CAL_OPT_VREF_MODE_WIDEST 0
#define DCS_CAL_OPT_VREF_MODE_COM 1
////////////////////////////////////////////////////////////////////////////////////////////////////////
// API Functions
////////////////////////////////////////////////////////////////////////////////////////////////////////
struct amp_calibration_params *calibration_cfg_params_init(int bootMode, int numChans, int numRanksPerChn);
void calibrate_ca(void);
void calibrate_wrlvl(void);
void calibrate_wrdq(void);
void calibrate_rddq(void);
////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif /* ! __DCS_CALIBRATION_H */
////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,331 @@
/*
* Copyright (C) 2014-2015 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#ifndef __DCS_INIT_LIB_H
#define __DCS_INIT_LIB_H
/* DRAM Control Subsystem (DCS) Initialization Library API Definitions */
//================================================================================
// Build (Environment) Type: iBoot, SiVal, DV, PE-RTOS
//================================================================================
#define DCS_BUILD_ENV_IBOOT (0)
#define DCS_BUILD_ENV_SIVAL (1)
#define DCS_BUILD_ENV_DV (2)
#define DCS_BUILD_ENV_PERTOS (3)
#define izIBOOT (DCS_BUILD_ENV_TYPE == DCS_BUILD_ENV_IBOOT)
#define izSIVAL (DCS_BUILD_ENV_TYPE == DCS_BUILD_ENV_SIVAL)
#define izDV (DCS_BUILD_ENV_TYPE == DCS_BUILD_ENV_DV)
#define izPERTOS (DCS_BUILD_ENV_TYPE == DCS_BUILD_ENV_PERTOS)
//================================================================================
// Target Type: SoC, FPGA, Palladium
//================================================================================
#define DCS_TARGET_SOC (0)
#define DCS_TARGET_FPGA (1)
#define DCS_TARGET_PALLADIUM (2)
#define izSOC (DCS_TARGET_TYPE == DCS_TARGET_SOC)
#define izFPGA (DCS_TARGET_TYPE == DCS_TARGET_FPGA)
#define izPAL (DCS_TARGET_TYPE == DCS_TARGET_PALLADIUM)
//================================================================================
// What Build Environment?
#ifndef DCS_BUILD_ENV_TYPE
#define DCS_BUILD_ENV_TYPE DCS_BUILD_ENV_IBOOT
#endif
//================================================================================
#if izIBOOT
//================================================================================
#define AMP_H_BASE_ADDR AMPH_BASE_ADDR
#include <sys/types.h>
#include <debug.h>
#include <drivers/dcs/dcs_regs.h>
#include <drivers/dcs/dcs.h>
#include <drivers/dcs/dcs_calibration.h>
#include <drivers/dram.h>
#include <drivers/miu.h>
#include <lib/env.h>
#include <platform.h>
#include <platform/soc/hwclocks.h>
#include <platform/chipid.h>
#include <platform/memmap.h>
#include <platform/timer.h>
#include <sys.h>
#include <string.h>
#define delay_for_us(_us_delay) spin(_us_delay)
extern int debug_level_dcs;
#define do_printf(x...) dprintf(debug_level_dcs, x)
#define dcs_panic(x...) \
EXEC( \
debug_level_dcs = DEBUG_CRITICAL; \
dcs_cfg.debugBitz |= DCS_DBG_CAL; \
calibration_dump_results(SELECT_CAL_ALL, true); \
panic(x); \
)
#if SUPPORT_FPGA
#define DCS_TARGET_TYPE DCS_TARGET_FPGA
#endif
// iBoot gets these definitions via the make command line
// Maximum channels/ranks supported by the target
//#define DCS_NUM_CHANNELS 4
//#define DCS_NUM_RANKS 1
// iBoot gets this definition via the make command line
#ifdef AMP_CALIBRATION_SKIP
#define DCS_DO_CALIBRATION 0
#else
#define DCS_DO_CALIBRATION 1
#endif
//================================================================================
#elif izSIVAL
//================================================================================
#include "drivers/dcs/dcs_sival.h"
//================================================================================
#elif izDV
//================================================================================
//================================================================================
#elif izPERTOS
//================================================================================
//================================================================================
#else // other than iBoot (examples: SiVal, DV, etc.)
//================================================================================
// iBoot has a special version of a tight SpinLoop with Timeout
// Other build environments may use the following simple definition (no Timeout),
// or else provide their own by modifying this definition
#define SPIN_W_TMO_WHILE(__expr) while(__expr)
// iBoot defines this function to delay for N microseconds
// Other build environments may use the following degenerate definition (no delay),
// or else provide their own by modifying this definition
#define delay_for_us(_us_delay) EXEC(;)
// iBoot defines this function to optionally print out debug messages
// Other build environments may use the following simple definition (printf),
// or else provide their own by modifying this definition
#define do_printf(x...) printf(x)
// iBoot defines this function to halt execution and terminate because of a fatal error
// Other build environments may use the following similar definition (panic),
// or else provide their own by modifying this definition
#define dcs_panic(x...) \
EXEC( \
debug_level_dcs = DEBUG_CRITICAL; \
dcs_cfg.debugBitz |= DCS_DBG_CAL; \
calibration_dump_results(SELECT_CAL_ALL, true); \
panic(x); \
)
// iBoot derives this definition from other definitions provided via the make command line
// Other build environments may explicitly define the target type here,
// or use any other desired method
//#define DCS_TARGET_TYPE DCS_TARGET_SOC
//#define DCS_TARGET_TYPE DCS_TARGET_FPGA
//#define DCS_TARGET_TYPE DCS_TARGET_PALLADIUM
// Maximum channels/ranks supported by the target
#define DCS_NUM_CHANNELS 4
#define DCS_NUM_RANKS 1
#define DCS_DO_CALIBRATION 1 // ZERO to Skip Calibration
//================================================================================
#endif
//================================================================================
#ifndef DCS_TARGET_TYPE
#define DCS_TARGET_TYPE DCS_TARGET_SOC
#endif
typedef uint32_t dcs_buildtype_t;
typedef uint32_t dcs_target_t;
#define CACAL_MAX_SWLOOPS 1
//================================================================================
// Config Sturcture
//================================================================================
typedef struct {
bool valid;
dcs_boottype_t boot_type;
uint32_t chipID; // Supported ChipID values listed below
uint32_t chipRev; // A0, B0, B1, etc.
uint32_t num_dcs; // Number of DCS Blocks for this Chip
uint32_t num_rank; // Number of Ranks for the DRAM
uint32_t debugBitz; // Bit Field to control various debug behaviors
uint32_t variantBitz; // Bit Field to control variant behavior (workaround, per RADAR)
} dcs_config_t;
// Supported Chip Revision Codes
#define DCS_CHIP_REV_A0 0x00
#define DCS_CHIP_REV_A1 0x01
#define DCS_CHIP_REV_A2 0x02
#define DCS_CHIP_REV_B0 0x10
#define DCS_CHIP_REV_B1 0x11
#define DCS_CHIP_REV_B2 0x12
#define DCS_CHIP_REV_C0 0x20
#define DCS_CHIP_REV_C1 0x21
#define DCS_CHIP_REV_C2 0x22
//================================================================================
#define BIT_N(_N) (1 << (_N))
// Defined debug Bitz
#define DCS_DBG_NONE 0x00000000
#define DCS_DBG_REG_ACCESS BIT_N(0)
#define DCS_DBG_CHAN_DETAIL BIT_N(1)
#define DCS_DBG_SPIN BIT_N(2)
#define DCS_DBG_MR_READ BIT_N(3)
#define DCS_DBG_MILESTONE BIT_N(4)
#define DCS_DBG_CAL BIT_N(5)
#define DCS_DBG_CAL_MILESTONE BIT_N(6)
#define DCS_DBG_FREQ BIT_N(7)
#define DCS_DBG_OVERVIEW BIT_N(8)
#define DCS_DBG_ASSESS_CONFIG BIT_N(9)
#define DCS_DBG_DEFAULT (DCS_DBG_OVERVIEW | DCS_DBG_ASSESS_CONFIG)
// Defined variant Bitz
#define DCS_VARIANT_NONE 0x00000000
#define DCS_VARIANT_SKIP_MCC BIT_N(0)
#define DCS_VARIANT_VREF_USES_WIDEST BIT_N(1) // Use Widest-Eye Algorithm for Optimal Vref
#define DCS_NONVAL (0xF82BDEAD)
//================================================================================
extern dcs_config_t dcs_cfg;
// extern dcs_config_params_t dcs_params;
#define izColdBoot (dcs_cfg.boot_type == DCS_BOOT_COLDBOOT)
#define izResume (dcs_cfg.boot_type == DCS_BOOT_RESUME)
#define izAOP_DDR (dcs_cfg.boot_type == DCS_BOOT_AOP_DDR)
#define izAOP_Awake (dcs_cfg.boot_type == DCS_BOOT_AOP_AWAKE)
//================================================================================
#define ifbit_printf(_b, _f, x...) EXEC(if ((_b) & (_f)) do_printf(x))
#define dbgprintf(_b, x...) ifbit_printf(_b, dcs_cfg.debugBitz, x)
//================================================================================
// These are used by the Calibration Functions ... provided by dcs_init_lib
// Save SRAM space in iBoot by removing calibration debug printfs
#if izIBOOT
#define shim_printf(x...) do { } while(0)
#else
#define shim_printf(x...) dbgprintf(DCS_DBG_CAL, x)
#endif
#define shim_panic(x...) dcs_panic(x)
#define shim_mrcmd_to_ch_rnk(x...) dcs_mrcmd_to_ch_rnk(x)
//================================================================================
// Callouts Required by this Library.
// Must be Provided externally (build environment, platform, target, etc.)
//================================================================================
void dcs_dram_workarounds(dcs_boottype_t boot_type);
void dcs_dram_workarounds_step12(void);
void dcs_init_config_params(dcs_config_params_t *use_dcs_params, dcs_target_t targtype);
const dcs_tunable_t *dcs_init_tunable_table(uint32_t *table_len);
void dcs_change_freq(uint32_t freq_bin);
void dcs_store_memory_calibration(void *cal_values, uint32_t cal_size);
void dcs_load_memory_calibration(void *cal_values, uint32_t cal_size);
//================================================================================
// These are used by the Calibration Functions ... must be provided by build environment
#define shim_change_freq(_bin) dcs_change_freq(_bin)
#define shim_store_memory_calibration dcs_store_memory_calibration
#define shim_load_memory_calibration dcs_load_memory_calibration
//================================================================================
// API Functions provided by this Library and available for use
//================================================================================
bool dcs_init_config(dcs_boottype_t boot_type, uint32_t chipID, uint32_t chipRev,
uint32_t num_dcs, uint32_t num_rank);
uint32_t dcs_init_debug_enable(uint32_t bit);
uint32_t dcs_init_debug_disable(uint32_t bit);
uint32_t dcs_init_variant_enable(uint32_t bit);
uint32_t dcs_init_variant_disable(uint32_t bit);
dcs_config_params_t *dcs_init_param_table(void);
void dcs_mrcmd_to_ch_rnk(dcs_mrcmd_op_t op, uint8_t channel, uint8_t rank, int reg, uintptr_t val);
void dcs_mrcmd(dcs_mrcmd_op_t op, uint8_t channels, uint8_t ranks, int reg, uintptr_t val);
void dcs_spin(uint32_t duration_us, char *reason);
void dcs_enable_autorefresh(void);
void dcs_init_apply_tunables(void);
// Step 0: AMC Prolog
void dcs_init_Prolog(void);
// Step 1: AMC Initial Configuration
void dcs_init_AMC_Initial_Config(void);
// Step 2: AMP Initial Configuration
void dcs_init_AMP_Initial_Config(void);
// Step 3: Self-Refresh Exit
void dcs_init_Self_Refresh_Exit_a(void);
void dcs_init_Self_Refresh_Exit_b(void);
// Step 4: DRAM Reset, ZQ Calibration & Configuration (cold boot only)
void dcs_init_ZQ_Cal_Cfg(void);
// Step 5a: AddrConfig Configuration
void dcs_init_AddrCfg_Cfg(void);
void dcs_init_TotalSize_Cfg(uint32_t total_size_Mbytes);
// Step 6: Switch from boot-clock speed to normal operation speed
void dcs_init_Reenable_AMC_Scheduler(void);
// Step 7: Setup registers for CA calibration for bucket 1
void dcs_init_CA_Cal_Setup_Freq1(void);
// Step 8: AMP Dynamic CA Vref Timing Calibration at Vmin 800MHz
void dcs_init_CA_Cal_Freq1(void);
// Step 9: Setup registers for DQ calibration for bucket 1
void dcs_init_DQ_Cal_Setup_Freq1_a(void);
void dcs_init_DQ_Cal_Setup_Freq1_b(void);
// Step 10: PHY write DQ calibration
void dcs_init_wrdq_skew(void);
void dcs_init_post_wrlvl(void);
// Step 11: Setup registers for CA calibration for bucket 0
void dcs_init_CA_Cal_Setup_Freq0(void);
// Step 12: AMP Dynamic CA Timing Calibration
// NO PROVIDED FUNCTION
// Step 13: Setup registers for DQ calibration for bucket 0
void dcs_init_DQ_Cal_Setup_Freq0_a(void);
void dcs_init_DQ_Cal_Setup_Freq0_b(void);
// Step 14: AMP Dynamic DQ Calibration
// NO PROVIDED FUNCTION
// Step 15: Setup Registers for Boot
void dcs_init_Reg_for_Boot(void);
// Step 16: Enable Other Features
void dcs_init_MoreFeatures(void);
// Step 17: Enable Fast Critical Word Forwarding Feature
void dcs_init_Fast_Critical_Word_Forwarding(void);
// Step 18: Enable Power- and Clock-Gating Features; Config MCC and Global Timers
void dcs_init_Gating_Global_Timers(void);
// Step 19: ODTS read & set interval for periodic MR4 on-die Temp sensor reading
void dcs_init_ODTS(void);
// <rdar://problem/23244578> Elba: Samsung DRAM workaround: disable hw zqcal
bool shim_apply_samsung_workaround(void);
void dcs_reg_write(uintptr_t reg_addr, uint32_t reg_value);
void dcs_reg_poll(uintptr_t reg_addr, uint32_t mask_value, uint32_t required_value);
void dcs_reg_write_all_chan(uintptr_t reg_addr, uint32_t reg_value);
void dcs_reg_poll_all_chan(uintptr_t reg_addr, uint32_t mask_value, uint32_t required_value);
#endif /* ! __DCS_INIT_LIB_H */
@@ -0,0 +1,676 @@
/*
* Copyright (C) 2013-2015 Apple Inc. All rights reserved.
*
* This document is the property of Apple Inc.
* It is considered confidential and proprietary.
*
* This document may not be reproduced or transmitted in any form,
* in whole or in part, without the express written permission of
* Apple Inc.
*/
#ifndef _DCS_S8000_H
#define _DCS_S8000_H
#include <drivers/dcs/dcs.h>
#include <platform.h>
#include <platform/soc/hwregbase.h>
#include <sys/types.h>
/*
* DCS_REG_VERSION mapping used in iBoot for various platforms
* Maui: 1
* s8003: 2
* Elba: 3
* Cayman: 4
*
* SoCs with "dcsh" block to have bit 4 set
* M8: 0x10
*/
#ifndef DCS_REG_VERSION
#define DCS_REG_VERSION (1)
#endif
#ifndef NUM_AMCCS
#define NUM_AMCCS (1)
#endif
/* Macro to read a register in a particular DCS channel */
#define DCS_REG_ACCESS(reg) (*(volatile uint32_t *)(reg))
#define DCS_REG_READ_CH(_c,reg) DCS_REG_ACCESS((reg) + ((_c)*DCS_SPACING))
// Used by Calibration Code
#define CSR_READ(addr) DCS_REG_ACCESS(addr)
#define CSR_WRITE(addr, val) EXEC(DCS_REG_ACCESS(addr) = val)
#define KAY (1024)
#define MEG (KAY*KAY)
#define DCS_FREQUENCY_SLOTS (4)
#if DCS_REG_VERSION >= 0x10
// PIOWRAP registers
#define rAMC_PIO_ACCESS_CFG (PIO_BASE_ADDR + 0x02C)
// AMCSYS registers
#define rAMC_AMCEN (AMC_BASE_ADDR + 0x000)
#define rAMC_CLKGATE (AMC_BASE_ADDR + 0x004)
#define rAMC_AIUPRT_RD_CWF (AMC_BASE_ADDR + 0x084)
#define rAMC_AIUPRT_RD_GEN (AMC_BASE_ADDR + 0x088)
#define rAMC_AIUPRTBADDR (AMC_BASE_ADDR + 0x0A0)
#define rAMC_AIUCHNLDEC (AMC_BASE_ADDR + 0x0A4)
#define rAMC_AIUADDRBANKHASH(_n) (AMC_BASE_ADDR + (_n * 4) + 0x0B0)
#define rAMC_AIUCHNLCRD (AMC_BASE_ADDR + 0x100)
#define rAMC_AIUCHNLTM (AMC_BASE_ADDR + 0x104)
#define rAMC_AIURDBRSTLEN (AMC_BASE_ADDR + 0x108)
#define rAMC_AIURDMAXCRD (AMC_BASE_ADDR + 0x10C)
#define rAMC_AIURDMINCRD (AMC_BASE_ADDR + 0x110)
#define rAMC_AIURDREFL (AMC_BASE_ADDR + 0x114)
#define rAMC_AIUWRBRSTLEN (AMC_BASE_ADDR + 0x118)
#define rAMC_AIUWRMAXCRD (AMC_BASE_ADDR + 0x11C)
#define rAMC_AIUWRMINCRD (AMC_BASE_ADDR + 0x120)
#define rAMC_AIUWRREFL (AMC_BASE_ADDR + 0x124)
#define rAMC_AIUCPUSPCREQ (AMC_BASE_ADDR + 0x128)
#define rAMC_AIUGRXSPCREQ (AMC_BASE_ADDR + 0x12C)
#define rAMC_AIUNRTSPCREQ (AMC_BASE_ADDR + 0x130)
#define rAMC_AIURLTSPCREQ (AMC_BASE_ADDR + 0x134)
#define rAMC_AIUWPQSCH (AMC_BASE_ADDR + 0x138)
#define rAMC_AIUTHOTLEN (AMC_BASE_ADDR + 0x13C)
#define rAMC_AIUTHOTLCPUPARAM (AMC_BASE_ADDR + 0x140)
#define rAMC_AIUTHOTLRLTPARAM (AMC_BASE_ADDR + 0x144)
#define rAMC_AIUTHOTLNRTPARAM (AMC_BASE_ADDR + 0x148)
#define rAMC_AIUTHOTLGRXPARAM (AMC_BASE_ADDR + 0x14C)
#define rAMC_AIUPUSHEN (AMC_BASE_ADDR + 0x150)
#define rAMC_AIUTHOTLCPUPARAM2 (AMC_BASE_ADDR + 0x154)
#define rAMC_AIUTHOTLRLTPARAM2 (AMC_BASE_ADDR + 0x158)
#define rAMC_AIUTHOTLNRTPARAM2 (AMC_BASE_ADDR + 0x15C)
#define rAMC_AIUTHOTLGRXPARAM2 (AMC_BASE_ADDR + 0x160)
#define rAMC_AIULLTSCHCTL (AMC_BASE_ADDR + 0x164)
#define rAMC_AIURDMAXCRD2 (AMC_BASE_ADDR + 0x168)
#define rAMC_AIURDMINCRD2 (AMC_BASE_ADDR + 0x16C)
#define rAMC_AIURDREFL2 (AMC_BASE_ADDR + 0x170)
#define rAMC_AIUWRMAXCRD2 (AMC_BASE_ADDR + 0x174)
#define rAMC_AIUWRMINCRD2 (AMC_BASE_ADDR + 0x178)
#define rAMC_AIUWRREFL2 (AMC_BASE_ADDR + 0x17C)
#define rAMC_AIUMEDSPCREQ (AMC_BASE_ADDR + 0x180)
#define rAMC_AIUTHOTLMEDPARAM (AMC_BASE_ADDR + 0x184)
#define rAMC_AIUTHOTLMEDPARAM2 (AMC_BASE_ADDR + 0x188)
#define rAMC_QBREN (AMC_BASE_ADDR + 0x200)
#define rAMC_PSQRQCTL0 (AMC_BASE_ADDR + 0x208)
#define rAMC_PSQRQCTL1 (AMC_BASE_ADDR + 0x20C)
#define rAMC_PSQRQTIMER(_n) (AMC_BASE_ADDR + (_n * 4) + 0x210)
#define rAMC_PSQRQBRST (AMC_BASE_ADDR + 0x21C)
#define rAMC_PSQRQSCHCRD (AMC_BASE_ADDR + 0x220)
#define rAMC_PSQWQCTL1 (AMC_BASE_ADDR + 0x228)
#define rAMC_PSQWQBRST (AMC_BASE_ADDR + 0x230)
#define rAMC_PSQWQSCHCRD (AMC_BASE_ADDR + 0x234)
#define rAMC_MCUQOS (AMC_BASE_ADDR + 0x238)
#define rAMC_MCUQOSLLT (AMC_BASE_ADDR + 0x23C)
#define rAMC_ADDRMAPMODE (AMC_BASE_ADDR + 0x400)
#define rAMC_ADDRCFG (AMC_BASE_ADDR + 0x404)
#define rAMC_PWRMNGTPARAM (AMC_BASE_ADDR + 0x408)
// AMCSYS_AON
#define rAMC_IDLE2BCG_CONTROL (AMC_BASE_ADDR + 0x8014)
// DCSH_AON
#define rDCS_AON_IDLE2BCG_CONTROL (DCS_BASE_ADDR + DCSH_AON_SPACING + 0x004)
#endif // #if DCS_REG_VERSION >= 0x10
#if NUM_AMCCS == 2
/* AMCC0 registers */
#define rAMCC_MCCCHNLDEC_ADDR (AMCC_BASE_ADDR(0) + 0x4A4)
#define rAMCC_MCUCHNHASH_ADDR (AMCC_BASE_ADDR(0) + 0x4A8)
#define rAMCC_DRAMACCCTRL_ADDR (AMCC_BASE_ADDR(0) + 0x4B8)
#define rAMCC_ADDRCFG_ADDR (AMCC_BASE_ADDR(0) + 0x4CC)
#define rAMCC_MCC0QPROPCTRL_ADDR (AMCC_BASE_ADDR(0) + 0x648)
#define rAMCC_MCC1QPROPCTRL_ADDR (AMCC_BASE_ADDR(0) + 0x64C)
#define rAMCC_MCCGEN_ADDR (AMCC_BASE_ADDR(0) + 0x780)
#define rAMCC_MCCCFG_TAG_RD_DIS_ADDR (AMCC_BASE_ADDR(0) + 0x794)
#define rAMCC_MCCPWRONWAYCNTSTATUS_ADDR (AMCC_BASE_ADDR(0) + 0x79C)
#define rAMCC_MCCCHNLDEC DCS_REG_ACCESS(rAMCC_MCCCHNLDEC_ADDR)
#define rAMCC_DRAMACCCTRL DCS_REG_ACCESS(rAMCC_DRAMACCCTRL_ADDR)
#define rAMCC_ADDRCFG DCS_REG_ACCESS(rAMCC_ADDRCFG_ADDR)
#define rAMCC_MCC0QPROPCTRL DCS_REG_ACCESS(rAMCC_MCC0QPROPCTRL_ADDR)
#define rAMCC_MCC1QPROPCTRL DCS_REG_ACCESS(rAMCC_MCC1QPROPCTRL_ADDR)
#define rAMCC_MCCGEN DCS_REG_ACCESS(rAMCC_MCCGEN_ADDR)
#define rAMCC_MCCCFG_TAG_RD_DIS DCS_REG_ACCESS(rAMCC_MCCCFG_TAG_RD_DIS_ADDR)
#define rAMCC_MCCPWRONWAYCNTSTATUS DCS_REG_ACCESS(rAMCC_MCCPWRONWAYCNTSTATUS_ADDR)
/* AMCC1 registers */
#define rAMCC1_MCCCHNLDEC_ADDR (AMCC_BASE_ADDR(1) + 0x4A4)
#define rAMCC1_MCUCHNHASH_ADDR (AMCC_BASE_ADDR(1) + 0x4A8)
#define rAMCC1_DRAMACCCTRL_ADDR (AMCC_BASE_ADDR(1) + 0x4B8)
#define rAMCC1_ADDRCFG_ADDR (AMCC_BASE_ADDR(1) + 0x4CC)
#define rAMCC1_MCC0QPROPCTRL_ADDR (AMCC_BASE_ADDR(1) + 0x648)
#define rAMCC1_MCC1QPROPCTRL_ADDR (AMCC_BASE_ADDR(1) + 0x64C)
#define rAMCC1_MCCGEN_ADDR (AMCC_BASE_ADDR(1) + 0x780)
#define rAMCC1_MCCCFG_TAG_RD_DIS_ADDR (AMCC_BASE_ADDR(1) + 0x794)
#define rAMCC1_MCCPWRONWAYCNTSTATUS_ADDR (AMCC_BASE_ADDR(1) + 0x79C)
#define rAMCC1_MCCCHNLDEC DCS_REG_ACCESS(rAMCC1_MCCCHNLDEC_ADDR)
#define rAMCC1_DRAMACCCTRL DCS_REG_ACCESS(rAMCC1_DRAMACCCTRL_ADDR)
#define rAMCC1_ADDRCFG DCS_REG_ACCESS(rAMCC1_ADDRCFG_ADDR)
#define rAMCC1_MCC0QPROPCTRL DCS_REG_ACCESS(rAMCC1_MCC0QPROPCTRL_ADDR)
#define rAMCC1_MCC1QPROPCTRL DCS_REG_ACCESS(rAMCC1_MCC1QPROPCTRL_ADDR)
#define rAMCC1_MCCGEN DCS_REG_ACCESS(rAMCC1_MCCGEN_ADDR)
#define rAMCC1_MCCCFG_TAG_RD_DIS DCS_REG_ACCESS(rAMCC1_MCCCFG_TAG_RD_DIS_ADDR)
#define rAMCC1_MCCPWRONWAYCNTSTATUS DCS_REG_ACCESS(rAMCC1_MCCPWRONWAYCNTSTATUS_ADDR)
#elif NUM_AMCCS == 1
/* AMCC registers */
#define rAMCC_MCCCHNLDEC_ADDR (AMCC_BASE_ADDR(0) + 0x4A4)
#define rAMCC_DRAMACCCTRL_ADDR (AMCC_BASE_ADDR(0) + 0x4B4)
#define rAMCC_ADDRCFG_ADDR (AMCC_BASE_ADDR(0) + 0x4C8)
#define rAMCC_MCC0QPROPCTRL_ADDR (AMCC_BASE_ADDR(0) + 0x648)
#define rAMCC_MCC1QPROPCTRL_ADDR (AMCC_BASE_ADDR(0) + 0x64C)
#define rAMCC_MCCGEN_ADDR (AMCC_BASE_ADDR(0) + 0x780)
#define rAMCC_MCCCFG_TAG_RD_DIS_ADDR (AMCC_BASE_ADDR(0) + 0x794)
#define rAMCC_MCCPWRONWAYCNTSTATUS_ADDR (AMCC_BASE_ADDR(0) + 0x79C)
#define rAMCC_MCCCHNLDEC DCS_REG_ACCESS(rAMCC_MCCCHNLDEC_ADDR)
#define rAMCC_DRAMACCCTRL DCS_REG_ACCESS(rAMCC_DRAMACCCTRL_ADDR)
#define rAMCC_ADDRCFG DCS_REG_ACCESS(rAMCC_ADDRCFG_ADDR)
#define rAMCC_MCC0QPROPCTRL DCS_REG_ACCESS(rAMCC_MCC0QPROPCTRL_ADDR)
#define rAMCC_MCC1QPROPCTRL DCS_REG_ACCESS(rAMCC_MCC1QPROPCTRL_ADDR)
#define rAMCC_MCCGEN DCS_REG_ACCESS(rAMCC_MCCGEN_ADDR)
#define rAMCC_MCCCFG_TAG_RD_DIS DCS_REG_ACCESS(rAMCC_MCCCFG_TAG_RD_DIS_ADDR)
#define rAMCC_MCCPWRONWAYCNTSTATUS DCS_REG_ACCESS(rAMCC_MCCPWRONWAYCNTSTATUS_ADDR)
#endif // #if NUM_AMCCS == 2
#define AMCC_MCCCFG_TAG_RD_DIS_ADDR(i) (AMCC_BASE_ADDR(i) + 0x794)
#define AMCC_MCCGEN_MCC_RAM_EN (1 << 1)
#define AMCC_MCCGEN_MCC_RAM_EN_LOCK (1 << 16)
#define DCS_NUM_MEG_IN_DRAM_BLK (128)
/* MCU registers */
#define rDCS_MCU_AMCCTRL (DCS_BASE_ADDR + 0x000)
#define rDCS_MCU_CLKGATE (DCS_BASE_ADDR + 0x004)
#define rDCS_MCU_AMCCLKPWRGATE (DCS_BASE_ADDR + 0x010)
#define rDCS_MCU_AMCCLKPWRGATE2 (DCS_BASE_ADDR + 0x014)
#if DCS_REG_VERSION >= 0x10
#define rDCS_MCU_IDLE_EXTEND_CONTROL (DCS_BASE_ADDR + 0x018)
#define rDCS_MCU_DIV_CLK_SELECT (DCS_BASE_ADDR + 0x020)
#endif
#define rDCS_MCU_OPIDLETMR (DCS_BASE_ADDR + 0x180)
#define rDCS_MCU_OPTMRADJEN (DCS_BASE_ADDR + 0x184)
#define rDCS_MCU_OPTMRADJPARAM (DCS_BASE_ADDR + 0x188)
#define rDCS_MCU_MIFNRTAGE (DCS_BASE_ADDR + 0x18C)
#define rDCS_MCU_MIFRTAGE (DCS_BASE_ADDR + 0x190)
#define rDCS_MCU_MIFPCAGE (DCS_BASE_ADDR + 0x194)
#define rDCS_MCU_QBREN (DCS_BASE_ADDR + 0x198)
#define rDCS_MCU_QBRPARAM (DCS_BASE_ADDR + 0x19C)
#if DCS_REG_VERSION >= 0x10
#define rDCS_MCU_QBRPARAM2 (DCS_BASE_ADDR + 0x1A0)
#endif
#define rDCS_MCU_PSQRQCTL0 (DCS_BASE_ADDR + 0x1A4)
#define rDCS_MCU_PSQCPU0LLT_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 0xC) + 0x1A8)
#define rDCS_MCU_PSQCPU1LLT_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 0xC) + 0x1AC)
#define rDCS_MCU_PSQSOCLLT_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 0xC) + 0x1B0)
#define rDCS_MCU_PSQRQTIMER0 (DCS_BASE_ADDR + 0x1D8)
#define rDCS_MCU_PSQRQTIMER1 (DCS_BASE_ADDR + 0x1DC)
#define rDCS_MCU_PSQRQBRST (DCS_BASE_ADDR + 0x1E0)
#define rDCS_MCU_PSQRQSCHCRD (DCS_BASE_ADDR + 0x1E4)
#define rDCS_MCU_PSQWQ_CTL(_n) (DCS_BASE_ADDR + ((_n) * 4) + 0x1E8)
#define rDCS_MCU_PSQWQCTL0 rDCS_MCU_PSQWQ_CTL(0)
#define rDCS_MCU_PSQWQCTL1 rDCS_MCU_PSQWQ_CTL(1)
#define rDCS_MCU_PSQWQCTL2 rDCS_MCU_PSQWQ_CTL(2)
#define rDCS_MCU_PSQWQTHR (DCS_BASE_ADDR + 0x1F4)
#define rDCS_MCU_PSQWQBRST (DCS_BASE_ADDR + 0x1F8)
#define rDCS_MCU_PSQWQSCHCRD (DCS_BASE_ADDR + 0x1FC)
#define rDCS_MCU_QOSLLT (DCS_BASE_ADDR + 0x200)
#define rDCS_MCU_SBQOSUPGCTL (DCS_BASE_ADDR + 0x204)
#define rDCS_MCU_SBQOSUPGISPAIDS (DCS_BASE_ADDR + 0x208)
#define rDCS_MCU_PHYRDWRTIM_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x280)
#define rDCS_MCU_PHYUPDATETIMERS (DCS_BASE_ADDR + 0x300)
#if (DCS_REG_VERSION >= 4 && DCS_REG_VERSION < 0x10)
#define rDCS_MCU_LAT_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x340)
#define rDCS_MCU_CASPCH_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x350)
#define rDCS_MCU_ACT_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x360)
#define rDCS_MCU_AUTOREF_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x370)
#define rDCS_MCU_SELFREF_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x380)
#define rDCS_MCU_PDN (DCS_BASE_ADDR + 0x390)
#define rDCS_MCU_MODEREG (DCS_BASE_ADDR + 0x394)
#define rDCS_MCU_DERATE_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x398)
#define rDCS_MCU_TAT_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x3A8)
#define rDCS_MCU_AUTOREF_PARAMS (DCS_BASE_ADDR + 0x3BC)
#define rDCS_MCU_PDN1 (DCS_BASE_ADDR + 0x3C0)
#define rDCS_MCU_MODEREG1 (DCS_BASE_ADDR + 0x3C4)
#define rDCS_MCU_PDN_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x3C8)
#else
#define rDCS_MCU_LAT_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x380)
#define rDCS_MCU_CASPCH_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x390)
#define rDCS_MCU_ACT_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x3A0)
#define rDCS_MCU_AUTOREF_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x3B0)
#define rDCS_MCU_SELFREF_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x3C0)
#define rDCS_MCU_PDN (DCS_BASE_ADDR + 0x3D0)
#define rDCS_MCU_MODEREG (DCS_BASE_ADDR + 0x3D4)
#define rDCS_MCU_DERATE_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x3D8)
#define rDCS_MCU_TAT_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x3E8)
#define rDCS_MCU_AUTOREF_PARAMS (DCS_BASE_ADDR + 0x3FC)
#endif
#define rDCS_MCU_RWCFG (DCS_BASE_ADDR + 0x400)
#define rDCS_MCU_RNKCFG (DCS_BASE_ADDR + 0x404)
#define rDCS_MCU_AREFEN_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x408)
#define rDCS_MCU_AREFPARAM (DCS_BASE_ADDR + 0x418)
#if (DCS_REG_VERSION >= 4 && DCS_REG_VERSION < 0x10)
#define rDCS_MCU_LONGSR (DCS_BASE_ADDR + 0x420)
#define rDCS_MCU_ODTSZQC (DCS_BASE_ADDR + 0x424)
#define rDCS_MCU_PWRMNGTEN (DCS_BASE_ADDR + 0x428)
#define rDCS_MCU_PWRMNGTPARAM_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x42C)
#define rDCS_MCU_MCPHYUPDTPARAM (DCS_BASE_ADDR + 0x440)
#define rDCS_MCU_READLEVELING (DCS_BASE_ADDR + 0x444)
#define rDCS_MCU_FREQCHNGCTL (DCS_BASE_ADDR + 0x450)
#define rDCS_MCU_FREQCHNGCTL_FREQ(_n,_f) (DCS_BASE_ADDR + ((_n) * 4) + ((_f) * 0x18) + 0x454)
#define rDCS_MCU_FREQCHNGTIM_FREQ(_n) (DCS_BASE_ADDR + ((_n) * 4) + 0x4B4)
#define rDCS_MCU_LS3B_QUIES_CTRL (DCS_BASE_ADDR + 0x838)
#else
#define rDCS_MCU_LONGSR (DCS_BASE_ADDR + 0x41C)
#define rDCS_MCU_ODTSZQC (DCS_BASE_ADDR + 0x420)
#define rDCS_MCU_PWRMNGTEN (DCS_BASE_ADDR + 0x424)
#define rDCS_MCU_PWRMNGTPARAM_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x428)
#define rDCS_MCU_MCPHYUPDTPARAM (DCS_BASE_ADDR + 0x43C)
#define rDCS_MCU_READLEVELING (DCS_BASE_ADDR + 0x440)
#define rDCS_MCU_FREQCHNGCTL (DCS_BASE_ADDR + 0x44C)
#define rDCS_MCU_ROWHAM_CTL(_n) (DCS_BASE_ADDR + ((_n) * 4) + 0x4B0)
#define rDCS_MCU_FREQCHNGCTL_FREQ(_n,_f) (DCS_BASE_ADDR + ((_n) * 4) + ((_f) * 0x18) + 0x450)
#if DCS_REG_VERSION < 3
#define rDCS_MCU_FREQCHNGTIM_FREQ(_n) (DCS_BASE_ADDR + ((_n) * 4) + 0x4C0)
#else
#define rDCS_MCU_FREQCHNGTIM_FREQ(_n) (DCS_BASE_ADDR + ((_n) * 4) + 0x4C4)
#endif // #if DCS_REG_VERSION < 3
#endif // #if (DCS_REG_VERSION >= 4 && DCS_REG_VERSION < 0x10)
#define rDCS_MCU_MRINITCMD_0 (DCS_BASE_ADDR + 0x500)
#define rDCS_MCU_MRINITSTS_0 (DCS_BASE_ADDR + 0x504)
#define rDCS_MCU_INTSTS_0 (DCS_BASE_ADDR + 0x708)
#define rDCS_MCU_MIFQMAXCTRL_FREQ(_f) (DCS_BASE_ADDR + ((_f) * 4) + 0x780)
#define rDCS_MCU_MRINITCMD(_c) DCS_REG_READ_CH(_c,rDCS_MCU_MRINITCMD_0)
#define rDCS_MCU_MRINITSTS(_c) DCS_REG_READ_CH(_c,rDCS_MCU_MRINITSTS_0)
#define rDCS_MCU_INTSTS(_c) DCS_REG_READ_CH(_c,rDCS_MCU_INTSTS_0)
#define MRCMD_POLL_BIT (0x100)
#define MRCMD_RANK_SHIFT (13)
#define MRCMD_CMDTYPE_SHIFT (8)
#define MRCMD_REG_SHIFT (16)
#define MRCMD_DATA_SHIFT (24)
#define MRCMD_TYPE(_h) (((_h) & 0xFF) << MRCMD_CMDTYPE_SHIFT)
#define MRCMD_TYPE_READ MRCMD_TYPE(0x11)
#define MRCMD_TYPE_WRITE MRCMD_TYPE(0x01)
#define MRCMD_TYPE_MPC MRCMD_TYPE(0x41)
/* SPLLCTRL registers */
#define rDCS_SPLLCTRL_MODEREG (DCS_BASE_ADDR + SPLLCTRL_SPACING + 0x000)
#define rDCS_SPLLCTRL_CHARGEPUMP (DCS_BASE_ADDR + SPLLCTRL_SPACING + 0x01C)
#define rDCS_SPLLCTRL_VCO (DCS_BASE_ADDR + SPLLCTRL_SPACING + 0x020)
#define rDCS_SPLLCTRL_LDO (DCS_BASE_ADDR + SPLLCTRL_SPACING + 0x024)
#define rDCS_SPLLCTRL_SPLLPWRDNCFG (DCS_BASE_ADDR + SPLLCTRL_SPACING + 0x05C)
#define rDCS_SPLLCTRL_SPLLDIVCFG (DCS_BASE_ADDR + SPLLCTRL_SPACING + 0x060)
#if DCS_REG_VERSION >= 2
#define rDCS_SPLLCTRL_MDLLPWRDNCFG(_n) (DCS_BASE_ADDR + SPLLCTRL_SPACING + ((_n) * 4) + 0x064)
#endif
#if DCS_REG_VERSION >= 0x10
#define rDCS_SPLLCTRL_RECONFIGSWRESETTRIGGER (DCS_BASE_ADDR + SPLLCTRL_SPACING + 0x074)
#define rDCS_SPLLCTRL_RECONFIGSWRESETCONTROL (DCS_BASE_ADDR + SPLLCTRL_SPACING + 0x078)
#endif
/* AMP registers */
/* _t: type, DQ0, DQ1, or CA */
/* _c: channel, 0 or 1 */
#define AMP_CA (0)
#define AMP_DQ0 (1)
#define AMP_DQ1 (2)
#define DCS_AMP_NUM_PHYS (3)
#define AMP_IFF(__t,_t,_off) (((__t) == (_t))? _off:0)
#define rDCS_AMP_AMPEN(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x000)
#define rDCS_AMP_AMPCLK(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x004)
#define rDCS_AMP_AMPINIT(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x008)
#define rDCS_AMP_DRAM_RESETN(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x00C) // Only for AMPCA
#define rDCS_AMP_AMPVER(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + AMP_IFF(_t,0,4) + 0x00C)
// for AMPCA Only
#define rDCS_AMP_IMPCODE (AMP_BASE_ADDR + 0x080)
#if (DCS_REG_VERSION >= 4 && DCS_REG_VERSION < 0x10)
#define rDCS_AMP_IMPAUTOCAL (AMP_BASE_ADDR + 0x084)
#define rDCS_AMP_IMPCALCONTROL (AMP_BASE_ADDR + 0x088)
#define rDCS_AMP_IMPCALPHYUPDT (AMP_BASE_ADDR + 0x08C)
#define rDCS_AMP_IMPCALCMD (AMP_BASE_ADDR + 0x090)
#else
#define rDCS_AMP_IMPOVRRD (AMP_BASE_ADDR + 0x084)
#define rDCS_AMP_IMPAUTOCAL (AMP_BASE_ADDR + 0x088)
#define rDCS_AMP_IMPCALCONTROL (AMP_BASE_ADDR + 0x08C)
#define rDCS_AMP_IMPCALPHYUPDT (AMP_BASE_ADDR + 0x090)
#define rDCS_AMP_IMPCALCMD (AMP_BASE_ADDR + 0x094)
#define rDCS_AMP_NONDQDSPD_F(_f) (AMP_BASE_ADDR + 0x09C + ((_f) * 4))
#define rDCS_AMP_NONDQDS_F(_f) (AMP_BASE_ADDR + 0x0AC + ((_f) * 4))
#define rDCS_AMP_CACKCSWKPD_F(_f) (AMP_BASE_ADDR + 0x0BC + ((_f) * 4))
#define rDCS_AMP_CACKCSWKDS (AMP_BASE_ADDR + 0x0CC)
#define rDCS_AMP_BISTRXMODE (AMP_BASE_ADDR + 0x0D4)
#endif
#if (DCS_REG_VERSION == 3 || DCS_REG_VERSION >= 0x10)
#define rDCS_AMP_DCCCONTROL (AMP_BASE_ADDR + 0x0DC)
#define rDCS_AMP_DCCTIMER (AMP_BASE_ADDR + 0x0E0)
#define rDCS_AMP_IMPCALCONTROL2 (AMP_BASE_ADDR + 0x0E8)
#if DCS_REG_VERSION >= 0x10
#define rDCS_AMP_IMPCALCONTROL3 (AMP_BASE_ADDR + 0x0EC)
#endif // #if DCS_REG_VERSION >= 0x10
#elif (DCS_REG_VERSION >= 4 && DCS_REG_VERSION < 0x10)
#define rDCS_AMP_DCCCONTROL (AMP_BASE_ADDR + 0x098)
#define rDCS_AMP_DCCTIMER (AMP_BASE_ADDR + 0x09C)
#endif
// For AMPDQn
#define rDCS_AMP_DRAMSIGDLY(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x080 + AMP_IFF(_t,0,0x18))
#define rDCS_AMP_DQDQSDS_F(_t,_f) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x084 + ((_f) * 4))
#define rDCS_AMP_DIFFMODE_FREQ(_t,_f) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x094 + ((_f) * 4))
#define rDCS_AMP_DQFLTCTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x0A4) // For AMPDQn only
#define rDCS_AMP_DCC(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x0A8 + AMP_IFF(_t,0,0x28))
#if DCS_REG_VERSION < 4
#define rDCS_AMP_DQDS_F(_t,_f) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x0AC + ((_f) * 4))
#endif
#define rDCS_AMP_RDCAPCFG_FREQ(_t,_f) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x100 + ((_f) * 4))
#define rDCS_AMP_DQSPDENALWYSON(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x110)
#define rDCS_AMP_DQSPDRES(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x114)
#define rDCS_AMP_RDFIFOPTRSTS(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x118)
#define rDCS_AMP_CALDQMSK(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x11C)
#define rDCS_AMP_CALPATCFG(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x120 - AMP_IFF(_t,0,0x10))
#define rDCS_AMP_DQTRNCFG(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x124 - AMP_IFF(_t,0,0x10))
#define rDCS_AMP_DQTRNCMD(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x128 - AMP_IFF(_t,0,0x10))
#define rDCS_AMP_DQTRNSTS(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x12C - AMP_IFF(_t,0,0x10))
#define rDCS_AMP_DLLEN(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x180)
#define rDCS_AMP_MDLLFREQBINDIS(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x184)
#define rDCS_AMP_MDLLFREQSCALE(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x188)
#define rDCS_AMP_DLLUPDTCMD(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x18C)
#define rDCS_AMP_MDLLOVRRD(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x190 + AMP_IFF(_t,0,4))
#define rDCS_AMP_MDLLCODE(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x194 - AMP_IFF(_t,0,4))
#define rDCS_AMP_DLLLOCKTIM(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x198)
#define rDCS_AMP_DLLLOCKCTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x19C)
#if (DCS_REG_VERSION >= 4 && DCS_REG_VERSION < 0x10)
#define rDCS_AMP_DLLUPDTINTVL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1A0 - AMP_IFF(_t,0,4))
#define rDCS_AMP_DLLUPDTCTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1A4 - AMP_IFF(_t,0,4))
#define rDCS_AMP_CAOUTDLLSCL_FREQ(_f) (AMP_BASE_ADDR + 0x1A4 + ((_f) * 4)) // For AMPCA Only
#define rDCS_AMP_MDLLCODE_CAP_CNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1BC)
#define rDCS_AMP_MDLL_VTSCALE_CNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1C0)
#define rDCS_AMP_CAMDLL_VTSCALE_REFCNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1C4)
#define rDCS_AMP_RDMDLL_VTSCALE_REFCNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1C8)
#define rDCS_AMP_WRMDLL_VTSCALE_REFCNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1CC)
#define rDCS_AMP_CA_VTSCALE_FACTOR_STAT(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1D0)
#define rDCS_AMP_RD_VTSCALE_FACTOR_STAT(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1D4)
#define rDCS_AMP_WR_VTSCALE_FACTOR_STAT(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1D8)
#else
#define rDCS_AMP_DLLUPDTINTVL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1A0)
#define rDCS_AMP_DLLUPDTCTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1A4)
#define rDCS_AMP_DQSINDLLSCL_FREQ(_t,_f) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1BC + ((_f) * 4))
#define rDCS_AMP_CAOUTDLLSCL_FREQ(_f) (AMP_BASE_ADDR + 0x1C0 + ((_f) * 4)) // For AMPCA Only
#define rDCS_AMP_MDLLCODE_CAP_CNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1CC)
#define rDCS_AMP_MDLL_VTSCALE_CNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1D0)
#define rDCS_AMP_CAMDLL_VTSCALE_REFCNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1D4)
#define rDCS_AMP_RDMDLL_VTSCALE_REFCNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1D8)
#define rDCS_AMP_WRMDLL_VTSCALE_REFCNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1DC)
#define rDCS_AMP_CA_VTSCALE_FACTOR_STAT(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1E0)
#define rDCS_AMP_RD_VTSCALE_FACTOR_STAT(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1E4)
#define rDCS_AMP_WR_VTSCALE_FACTOR_STAT(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x1E8)
#endif
#define rDCS_AMP_TESTMODE(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x200 + AMP_IFF(_t,0,0x180))
// For AMPDQn Only
#define rDCS_AMP_WRDQDESKEW_CTRL(_t,_d) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x400 + ((_d) * 4))
#define rDCS_AMP_WRDQSDESKEW_CTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x420)
#define rDCS_AMP_WRDMDESKEW_CTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x424)
#define rDCS_AMP_RDDQDESKEW_CTRL(_t,_d) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x428 + ((_d) * 4))
#define rDCS_AMP_RDDQSDESKEW_CTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x448)
#define rDCS_AMP_RDDMDESKEW_CTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x44C)
#define rDCS_AMP_WRDQDQSSDLLCTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x600)
#define rDCS_AMP_WRDQDQSSDLLCODE(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x604)
#define rDCS_AMP_RDSDLLCTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x608)
#define rDCS_AMP_RDSDLLCODE(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x60C)
#define rDCS_AMP_RDCAPSDLLCTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x610)
#define rDCS_AMP_RDCAPSDLLCODE(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x614)
#define rDCS_AMP_RDDQSDLL_DLYSEL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x618)
#define rDCS_AMP_SDLL_UPDATE_CNTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x61c + AMP_IFF(_t,0,0xFC))
#define rDCS_AMP_DQSDQ_SKEWCTL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x620)
#define rDCS_AMP_DQSDQ_SKEW(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x624)
#define rDCS_AMP_SDLL_UPDATE_DEFER_EN(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x628 + AMP_IFF(_t,0,0xF4))
#define rDCS_AMP_WRLVL_DLYCHAIN_CTRL(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x700)
#define rDCS_AMP_WRLVL_SDLL_CODE0(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0x704)
// For AMPCA Only
#define rDCS_AMP_CADESKEW_CTRL(_d) (AMP_BASE_ADDR + 0x500 + ((_d) * 4))
#define rDCS_AMP_CSDESKEW_CTRL (AMP_BASE_ADDR + 0x518)
#define rDCS_AMP_CKDESKEW_CTRL (AMP_BASE_ADDR + 0x51C)
#define rDCS_AMP_CASDLLCTRL (AMP_BASE_ADDR + 0x700)
#define rDCS_AMP_CASDLLCODE (AMP_BASE_ADDR + 0x704)
#define rDCS_AMP_CSSDLLCTRL (AMP_BASE_ADDR + 0x708)
#define rDCS_AMP_CSSDLLCODE (AMP_BASE_ADDR + 0x70C)
#define rDCS_AMP_CKSDLLCTRL (AMP_BASE_ADDR + 0x710)
#define rDCS_AMP_CKSDLLCODE (AMP_BASE_ADDR + 0x714)
// Some bit definitions
#define RUNSDLLUPDWRRESULT (1 << 2)
#define SDLLOVRVAL_MASK (0x00FF0000)
#define WRLVLRUNUPDWRRESULT (1 << 9)
#define WRLVLSDLLCODE_MASK (0x000000FF)
#define RUNDESKEWUPD (1 << 8)
#define DESKEWCODE_MASK (0x0000003F)
#define VREFSEL_MASK (0x000000FF)
#define DQSVREFSEL_MASK (0x00FF0000)
#define VTSCALEREFUPDATE (1 << 28)
#define VTSCALEREFSTATUS_MASK (0x000003FF)
#define VTSCALEREFSTATUS_SHIFT (0)
#define VTSCALEREFOVERRIDEVAL_MASK (0x03FF0000)
#define VTSCALEREFOVERRIDEVAL_SHIFT (16)
// #define rDCS_AMP_SDLL_UPDATE_CNTL rDCS_AMP_SDLL_UPDATE_CNTL(0) // 0x718
// #define rDCS_AMP_SDLL_UPDATE_DEFER_EN rDCS_AMP_SDLL_UPDATE_DEFER_EN(0) // 0x71C
#define rDCS_AMP_MCCPWRONWAYCNTCTRL (AMP_BASE_ADDR + 0x798)
#define rDCS_AMP_MCCPWRONWAYCNTSTAT (AMP_BASE_ADDR + 0x79c)
#define rDCS_AMP_MCCALCHINT (AMP_BASE_ADDR + 0x7c8)
#define rDCS_AMP_CAWRLVLSDLLCODE (AMP_BASE_ADDR + 0x800)
#define rDCS_AMP_ODTENABLE_F(_f) (AMP_BASE_ADDR + 0xD00 + ((_f) * 4))
#if (DCS_REG_VERSION >= 4 && DCS_REG_VERSION < 0x10)
#define rDCS_AMP_VREF_F(_t,_f) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0xB00 + AMP_IFF(_t,0,0x200) + ((_f) * 4))
#else
#define rDCS_AMP_VREF_F(_t,_f) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0xB00 + AMP_IFF(_t,0,0x210) + ((_f) * 4))
#endif
#define rDCS_AMPDQ_RDDQSMULFACTOR(_t) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0xD00)
#define rDCS_AMPDQ_DFICALTIMING_F(_t,_f) (AMP_BASE_ADDR + ((_t)*AMP_DQ_SPACING) + 0xD80 + ((_f) * 4))
#define rDCS_AMP_RDWRDQCALTIMING_F(_f) (AMP_BASE_ADDR + 0xE00 + ((_f) * 8))
#define rDCS_AMP_RDWRDQCALSEGLEN_F(_f) (AMP_BASE_ADDR + 0xE04 + ((_f) * 8))
#define rDCS_AMP_HWRDWRDQCALTIMINGCTRL(_n) (AMP_BASE_ADDR + 0xE20 + ((_n) * 4))
#define rDCS_AMP_HWRDDQCALPATPRBS4I (AMP_BASE_ADDR + 0xE2C)
#define rDCS_AMP_HWWRDQCALPATPRBS4I (AMP_BASE_ADDR + 0xE30)
#define rDCS_AMP_HWRDWRDQCALFULLSCANEN (AMP_BASE_ADDR + 0xE34)
#define rDCS_AMP_RDDQCALWINDOW_F(_f) (AMP_BASE_ADDR + 0xE38 + ((_f) * 8))
#define rDCS_AMP_WRDQCALWINDOW_F(_f) (AMP_BASE_ADDR + 0xE3C + ((_f) * 8))
#define rDCS_AMP_DFICALTIMING (AMP_BASE_ADDR + 0xE74)
#define rDCS_AMP_MAXWRDQ_SDLL_MULFACTOR (AMP_BASE_ADDR + 0xE78)
#define rDCS_AMP_MAXRDDQS_SDLL_MULFACTOR (AMP_BASE_ADDR + 0xE7C)
#define rDCS_AMP_MAXWRDQS_SDLL_MULFACTOR (AMP_BASE_ADDR + 0xE80)
#define rDCS_AMPCA_DFICALTIMING_F(_f) (AMP_BASE_ADDR + 0xF80 + ((_f - 1) * 4))
#define rDCS_AMPCA_DFICALTIMING_RDDQCAL2 (AMP_BASE_ADDR + 0xF90 )
#if DCS_REG_VERSION >= 3
#define rDCS_AMP_HWWRDQCALPATPRBS7(_n) (AMP_BASE_ADDR + 0xEA0 + ((_n) * 4))
#define rDCS_AMP_HWWRDQCALPATINVERTMASK (AMP_BASE_ADDR + 0xEB0)
#define rDCS_AMP_HWWRDQCALDYNHALFCLKDLYCTRL (AMP_BASE_ADDR + 0xECC)
#define rDCS_AMP_HWRDDQCALVREFCONTROL (AMP_BASE_ADDR + 0xED8)
#define rDCS_AMP_HWRDDQCALTVREF (AMP_BASE_ADDR + 0xEDC)
#define rDCS_AMP_HWRDDQCALVREFOFFSETCONTROL(_n) (AMP_BASE_ADDR + 0xEE0 + ((_n - 1) * 4))
#define rDCS_AMP_HWWRDQCALVREFCONTROL (AMP_BASE_ADDR + 0xEE8)
#define rDCS_AMP_HWWRDQCALTVREF (AMP_BASE_ADDR + 0xEEC)
#define rDCS_AMP_HWWRDQCALVREFOFFSETCONTROL(_n) (AMP_BASE_ADDR + 0xEF0 + ((_n - 1) * 4))
#define rDCS_AMP_DQCALBURSTLENMODE (AMP_BASE_ADDR + 0xF10)
#define rDCS_AMP_RDDQCALVREFCODECONTROL (AMP_BASE_ADDR + 0xF18)
#define rDCS_AMP_RDDQCALVREFCODESTATUS (AMP_BASE_ADDR + 0xF1C)
#define rDCS_AMP_WRDQCALVREFCODECONTROL (AMP_BASE_ADDR + 0xF20)
#define rDCS_AMP_WRDQCALVREFCODESTATUS (AMP_BASE_ADDR + 0xF24)
#endif
#if DCS_REG_VERSION >= 2
// AMPH
#define rDCS_AMPH_ZCAL_FSM(_n) (AMPH_BASE_ADDR + (_n * 4) + 0x008)
#define rDCS_AMPH_DBG_REG0 (AMPH_BASE_ADDR + 0x024)
#define rDCS_AMPH_CB_DRIVESTR (AMPH_BASE_ADDR + 0x028)
#define rDCS_AMPH_CB_IMPCTL (AMPH_BASE_ADDR + 0x02C)
#define rDCS_AMPH_CB_WKPUPD (AMPH_BASE_ADDR + 0x030)
#define rDCS_AMPH_CB_IOCTL (AMPH_BASE_ADDR + 0x044)
#define rDCS_AMPH_CK_DRIVESTR (AMPH_BASE_ADDR + 0x050)
#define rDCS_AMPH_CK_WKPUPD (AMPH_BASE_ADDR + 0x058)
#define rDCS_AMPH_CK_IOCTL (AMPH_BASE_ADDR + 0x060)
#define rDCS_AMPH_CK_ZDETBIASEN (AMPH_BASE_ADDR + 0x068)
#define rDCS_AMPH_B0_DRIVESTR (AMPH_BASE_ADDR + 0x078)
#define rDCS_AMPH_B0_IMPCTL (AMPH_BASE_ADDR + 0x07C)
#define rDCS_AMPH_B0_WKPUPD (AMPH_BASE_ADDR + 0x080)
#define rDCS_AMPH_B0_DYN_ISEL (AMPH_BASE_ADDR + 0x098)
#define rDCS_AMPH_B0_DYN_ISEL_ASRTIME (AMPH_BASE_ADDR + 0x09C)
#define rDCS_AMPH_B0_IOCTL (AMPH_BASE_ADDR + 0x0A0)
#define rDCS_AMPH_B0_ODT (AMPH_BASE_ADDR + 0x0B0)
#define rDCS_AMPH_B0_ODTCTRL (AMPH_BASE_ADDR + 0x0B4)
#define rDCS_AMPH_DQS0_DRIVESTR (AMPH_BASE_ADDR + 0x0C0)
#define rDCS_AMPH_DQS0_IMPCTL (AMPH_BASE_ADDR + 0x0C4)
#define rDCS_AMPH_DQS0_WKPUPD (AMPH_BASE_ADDR + 0x0C8)
#define rDCS_AMPH_DQS0_DCD_IOCTL (AMPH_BASE_ADDR + 0x0CC)
#define rDCS_AMPH_DQS0_IOCTL (AMPH_BASE_ADDR + 0x0D0)
#define rDCS_AMPH_DQS0_ODT (AMPH_BASE_ADDR + 0x0D8)
#define rDCS_AMPH_DQS0_ZDETBIASEN (AMPH_BASE_ADDR + 0x0DC)
#define rDCS_AMPH_DQS0_ODTCTRL (AMPH_BASE_ADDR + 0x0E0)
#define rDCS_AMPH_B1_DRIVESTR (AMPH_BASE_ADDR + 0x0E8)
#define rDCS_AMPH_B1_IMPCTL (AMPH_BASE_ADDR + 0x0EC)
#define rDCS_AMPH_B1_WKPUPD (AMPH_BASE_ADDR + 0x0F0)
#define rDCS_AMPH_B1_DYN_ISEL (AMPH_BASE_ADDR + 0x108)
#define rDCS_AMPH_B1_IOCTL (AMPH_BASE_ADDR + 0x10C)
#define rDCS_AMPH_B1_ODT (AMPH_BASE_ADDR + 0x11C)
#define rDCS_AMPH_B1_ODTCTRL (AMPH_BASE_ADDR + 0x120)
#define rDCS_AMPH_DQS1_DRIVESTR (AMPH_BASE_ADDR + 0x130)
#define rDCS_AMPH_DQS1_IMPCTL (AMPH_BASE_ADDR + 0x134)
#define rDCS_AMPH_DQS1_WKPUPD (AMPH_BASE_ADDR + 0x138)
#define rDCS_AMPH_DQS1_DCD_IOCTL (AMPH_BASE_ADDR + 0x13C)
#define rDCS_AMPH_DQS1_IOCTL (AMPH_BASE_ADDR + 0x140)
#define rDCS_AMPH_DQS1_ODT (AMPH_BASE_ADDR + 0x148)
#define rDCS_AMPH_DQS1_ODTCTRL (AMPH_BASE_ADDR + 0x14C)
#define rDCS_AMPH_DQS1_ZDETBIASEN (AMPH_BASE_ADDR + 0x150)
#define rDCS_AMPH_DCC_CAL (AMPH_BASE_ADDR + 0x290)
#define rDCS_AMPH_SPARE(_n) (AMPH_BASE_ADDR + (_n * 4) + 0x2FC)
#define rDCS_AMPH_DCC_BYPCA (AMPH_BASE_ADDR + 0x29C)
#define rDCS_AMPH_DCC_BYPCK (AMPH_BASE_ADDR + 0x2A0)
#define rDCS_AMPH_DCC_BYPCS (AMPH_BASE_ADDR + 0x2A4)
#define rDCS_AMPH_DCC_BYPB0 (AMPH_BASE_ADDR + 0x2A8)
#define rDCS_AMPH_DCC_BYPDQS0 (AMPH_BASE_ADDR + 0x2AC)
#define rDCS_AMPH_DCC_BYPB1 (AMPH_BASE_ADDR + 0x2B0)
#define rDCS_AMPH_DCC_BYPDQS1 (AMPH_BASE_ADDR + 0x2B4)
#else
#define rDCS_AMPH_SLC_REG(_n) (AMPH_BASE_ADDR + (_n * 4) + 0x080)
#endif // #if DCS_REG_VERSION >= 2
#define AMP_MAX_RANKS_PER_CHAN (2)
#define DQ_NUM_BITS_PER_BYTE 8
// Global Timer Registers
#define rGLBTIMER_MDLLTIMER (GLBTIMER_BASE_ADDR + 0x000)
#define rGLBTIMER_MDLLVOLTRAMPTIMER (GLBTIMER_BASE_ADDR + 0x004)
#define rGLBTIMER_CTRLUPDMASKTIMER (GLBTIMER_BASE_ADDR + 0x008)
#define rGLBTIMER_IDTTIMER (GLBTIMER_BASE_ADDR + 0x00c)
#define rGLBTIMER_RDCALTIMER (GLBTIMER_BASE_ADDR + 0x010)
#define rGLBTIMER_WRCALTIMER (GLBTIMER_BASE_ADDR + 0x014)
#define rGLBTIMER_ZQCTIMER (GLBTIMER_BASE_ADDR + 0x018)
#if DCS_REG_VERSION >= 0x10
#define rGLBTIMER_FREQCHNG_ACTIVE (GLBTIMER_BASE_ADDR + 0x094)
#endif
#if DCS_REG_VERSION >= 3
#define rGLBTIMER_DCCTIMER (GLBTIMER_BASE_ADDR + 0x01c)
#define rGLBTIMER_PERCAL_FREQCHNGTIMER (GLBTIMER_BASE_ADDR + 0x020)
#define rGLBTIMER_VOLTRAMPTIMER (GLBTIMER_BASE_ADDR + 0x024)
#define rGLBTIMER_IMPCALTIMER (GLBTIMER_BASE_ADDR + 0x028)
#define rGLBTIMER_PERWRCALCFG (GLBTIMER_BASE_ADDR + 0x02c)
#define rGLBTIMER_PERRDCALCFG (GLBTIMER_BASE_ADDR + 0x030)
#define rGLBTIMER_VOLTRAMPCFG (GLBTIMER_BASE_ADDR + 0x034)
#define rGLBTIMER_FREQCHNGCFG (GLBTIMER_BASE_ADDR + 0x038)
#define rGLBTIMER_PMGRWAKEUPCFG (GLBTIMER_BASE_ADDR + 0x03c)
#define rGLBTIMER_FREQBIN3CALCFG (GLBTIMER_BASE_ADDR + 0x040)
#define rGLBTIMER_CHEN (GLBTIMER_BASE_ADDR + 0x044)
#define rGLBTIMER_CAL2PREFREQCHNGDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x048)
#define rGLBTIMER_PREFREQ2ALLBANKDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x050)
#define rGLBTIMER_PREFREQCHNG2FREQCHNGDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x058)
#define rGLBTIMER_FREQCHNG2PSTCALDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x060)
#define rGLBTIMER_VOLTRAMP2ALLBANKDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x068)
#define rGLBTIMER_ALLBANK2PMGRACKDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x070)
#define rGLBTIMER_PRECALWAITPERIOD (GLBTIMER_BASE_ADDR + 0x078)
#define rGLBTIMER_CALSEG2ALLBANK(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x07C)
#define rGLBTIMER_ALLBANK2CALSEG(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x084)
#define rGLBTIMER_VREFCNTRL (GLBTIMER_BASE_ADDR + 0x08C)
#define rGLBTIMER_PERVREFCALCFG (GLBTIMER_BASE_ADDR + 0x090)
#else
#define rGLBTIMER_PERCAL_FREQCHNGTIMER (GLBTIMER_BASE_ADDR + 0x01c)
#define rGLBTIMER_VOLTRAMPTIMER (GLBTIMER_BASE_ADDR + 0x020)
#define rGLBTIMER_IMPCALTIMER (GLBTIMER_BASE_ADDR + 0x024)
#define rGLBTIMER_PERWRCALCFG (GLBTIMER_BASE_ADDR + 0x028)
#define rGLBTIMER_PERRDCALCFG (GLBTIMER_BASE_ADDR + 0x02c)
#define rGLBTIMER_VOLTRAMPCFG (GLBTIMER_BASE_ADDR + 0x030)
#define rGLBTIMER_FREQCHNGCFG (GLBTIMER_BASE_ADDR + 0x034)
#define rGLBTIMER_PMGRWAKEUPCFG (GLBTIMER_BASE_ADDR + 0x038)
#define rGLBTIMER_FREQBIN3CALCFG (GLBTIMER_BASE_ADDR + 0x03c)
#define rGLBTIMER_CHEN (GLBTIMER_BASE_ADDR + 0x040)
#define rGLBTIMER_CAL2PREFREQCHNGDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x044)
#define rGLBTIMER_PREFREQ2ALLBANKDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x04C)
#define rGLBTIMER_PREFREQCHNG2FREQCHNGDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x054)
#define rGLBTIMER_FREQCHNG2PSTCALDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x05C)
#define rGLBTIMER_VOLTRAMP2ALLBANKDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x064)
#define rGLBTIMER_ALLBANK2PMGRACKDLY(_n) (GLBTIMER_BASE_ADDR + ((_n) * 4) + 0x06C)
#endif // #if DCS_REG_VERSION >= 3
#endif /* _DCS_S8000_H */