Browse Source

1. Update DDR training code.

2. Merge save_ddrparam for 3A and 3B to one file.
3. Update Non-training DDR parameters for 3A780e.

Targets: Bonito3aserver/Bonito3a780e
master
Chen Xinke 13 years ago
committed by wanghongmei
parent
commit
8ee169f773
  1. 18
      Targets/Bonito3a780e/Bonito/detect_node_dimm.S
  2. 8
      Targets/Bonito3a780e/Bonito/loongson3a_ddr3_param.S
  3. 18
      Targets/Bonito3a780e/Bonito/start.S
  4. 1
      Targets/Bonito3a780e/conf/Bonito.3a780e
  5. 18
      Targets/Bonito3aserver/Bonito/detect_node_dimm.S
  6. 1
      Targets/Bonito3aserver/conf/Bonito.3aserver
  7. 176
      pmon/arch/mips/mm/ARB_level.S
  8. 39
      pmon/arch/mips/mm/ddr_config.S
  9. 8
      pmon/arch/mips/mm/ddr_param_define.h
  10. 103
      pmon/cmds/save_ddrparam.c

18
Targets/Bonito3a780e/Bonito/detect_node_dimm.S

@ -43,15 +43,25 @@ LEAF(PROBE_NODE_DIMM)
PRINTSTR("\r\nOpen SMBUS controller\r\n");
/* Open the SMBUS controller */
dli a1, 0x90000efdfe00a090 ; #b:d:f:r=0:14:0:90 set tmp config address
#ifdef MULTI_I2C_BUS
GET_I2C_NODE_ID_a2
dsll a2, a2, 44
or a1, a1, a2
#endif
li a0, SMBUS_IO_BASE_VALUE | 0x1
sw a0, 0x0(a1);
/* enable the host controller */
dli a1, 0x90000efdfe00a0d0 ; #b:d:f:r=0:14:0:d2 bit0=1
lw a0, 0x0(a1);
li a2, 0x10000;
or a0, a2
sw a0, 0x0(a1);
#ifdef MULTI_I2C_BUS
GET_I2C_NODE_ID_a2
dsll a2, a2, 44
or a1, a1, a2
#endif
lw a0, 0x0(a1)
li a2, 0x10000
or a0, a0, a2
sw a0, 0x0(a1)
#endif
#if 0 //for debug, give the SPD device id directly.
//scan the devices and display DIMM SPD values when the first device is detected.

8
Targets/Bonito3a780e/Bonito/loongson3a_ddr3_param.S

@ -1,3 +1,9 @@
ddr2_reg_data:
ddr2_reg_data_mc1:
ddr2_RDIMM_reg_data:
ddr2_RDIMM_reg_data_mc1:
/*DDR3 PARAMETER */
//#define REGDIMM_5
ddr3_reg_data:
@ -560,3 +566,5 @@ MC1_DDR3_CTL_b30 : .dword 0x00000c2d00000000
//00000000000000000000110000101101 tdfi_wrlvl_resp(RW) 00000000000000000000000000000000 tdfi_wrlvl_max(RW)
#endif
ddr3_RDIMM_reg_data:
ddr3_RDIMM_reg_data_mc1:

18
Targets/Bonito3a780e/Bonito/start.S

@ -1258,7 +1258,7 @@ gs_2f_v3_ddr2_cfg:
#define DISABLE_DIMM_ECC
#define PRINT_MSG
#ifndef ARB_LEVEL
#define FIX_DDR_PARAM
//#define FIX_DDR_PARAM
#endif
//#define DEBUG_DDR
//#define DEBUG_DDR_MT
@ -3008,28 +3008,22 @@ nvram_offs:
.global ddr2_leveled_mark
.global ddr2_reg_data_mc0_leveled
.global ddr2_reg_data_mc1_leveled
#ifdef MULTI_CHIP
.global n1_ddr2_reg_data_mc0_leveled
.global n1_ddr2_reg_data_mc1_leveled
#endif
#endif
.align 5
#ifndef ARB_LEVEL
#include "loongson3a_ddr3_param.S"
#else
#include "loongson3A3_ddr_param.S"
#ifdef MULTI_NODE_DDR_PARAM
#include "loongson3A3_ddr_param_c1.S"
#endif
#ifdef ARB_LEVEL
#include "loongson3A3_ddr_param.lvled.S"
#ifdef MULTI_CHIP
#include "loongson3A3_ddr_param_c1.lvled.S"
#endif
.align 12
ddr2_leveled_mark:
.dword 0x0
.align 12
#include "loongson3A3_ddr_param.lvled.S"
#else
#ifdef FIX_DDR_PARAM
#include "loongson3A3_ddr_param.fix.S"

1
Targets/Bonito3a780e/conf/Bonito.3a780e

@ -21,7 +21,6 @@ option TARGETNAME="\"Bonito\""
# Platform options
#
option loongson3A3
option LSMCD3_2
#option ARB_LEVEL
option DDR3_DIMM

18
Targets/Bonito3aserver/Bonito/detect_node_dimm.S

@ -43,15 +43,25 @@ LEAF(PROBE_NODE_DIMM)
PRINTSTR("\r\nOpen SMBUS controller\r\n");
/* Open the SMBUS controller */
dli a1, 0x90000efdfe00a090 ; #b:d:f:r=0:14:0:90 set tmp config address
#ifdef MULTI_I2C_BUS
GET_I2C_NODE_ID_a2
dsll a2, a2, 44
or a1, a1, a2
#endif
li a0, SMBUS_IO_BASE_VALUE | 0x1
sw a0, 0x0(a1);
/* enable the host controller */
dli a1, 0x90000efdfe00a0d0 ; #b:d:f:r=0:14:0:d2 bit0=1
lw a0, 0x0(a1);
li a2, 0x10000;
or a0, a2
sw a0, 0x0(a1);
#ifdef MULTI_I2C_BUS
GET_I2C_NODE_ID_a2
dsll a2, a2, 44
or a1, a1, a2
#endif
lw a0, 0x0(a1)
li a2, 0x10000
or a0, a0, a2
sw a0, 0x0(a1)
#endif
#if 0 //for debug, give the SPD device id directly.
//scan the devices and display DIMM SPD values when the first device is detected.

1
Targets/Bonito3aserver/conf/Bonito.3aserver

@ -21,7 +21,6 @@ option TARGETNAME="\"Bonito\""
# Platform options
#
option loongson3A3
option LSMCD3_2 #for LS3A/3B
#option ARB_LEVEL #use software MC leveling
option DDR3_DIMM #board use DDR3 memory, use: USE_SB_I2C, else use USE_GPIO_I2C and MULTI_I2C_BUS

176
pmon/arch/mips/mm/ARB_level.S

@ -30,7 +30,7 @@ algrithm:
//#define DEBUG_ARB_LEVEL
//#define ARB_LEVEL_INTERVAL
#define ARB_LEVEL_PAD
//#define ARB_LEVEL_PAD
#define CLEAR_HALF_CLK_SHIFT
#define LOG2_STEP 2 //log2 of TM step interval, remember to small WINDOW_ZERO_NUM when we use larger STEP
@ -664,30 +664,32 @@ boundary sign: contain at least WINDOW_ZERO_NUM consecutive 0(TM success)
dsrl a0, a0, 1
dli a1, 0x7f7f7f7f7f7f7f7f
and a0, a0, a1
#ifdef DDR3_DIMM
//special deal with wrlvl_dqs
#ifdef DDR3_DIMM //special deal with wrlvl_dqs when use DDR3 DIMM
dli a1, 0x5
bne t6, a1, 8f
bne t6, a1, 88f
nop
GET_DIMM_TYPE
bnez a1, 88f
nop
ld a1, GD_MIN(t8)
ld a3, GD_MAX(t8)
//Byte 1~0
//refer byte 1 MIN
//refer byte 1
dsrl a2, a1, 8
and a2, a2, 0x7f
bnez a2, 1f
nop
//min==0
dsrl v0, a0, 2 //mid_value / 4
dli a2, 0x7f7f //byte1~0, mid_value/4
dli a2, 0x7f7f
and v0, v0, a2
dli a2, 0xffff
not a2, a2
and a0, a0, a2
or a0, a0, v0
1:
2:
//Byte 3~2
//refer byte 3
dsrl a2, a1, 24
and a2, a2, 0x7f
bnez a2, 1f
@ -702,6 +704,7 @@ boundary sign: contain at least WINDOW_ZERO_NUM consecutive 0(TM success)
or a0, a0, v0
1:
//Byte 5~4
//refer byte 5
dsrl a2, a3, 40
and a2, a2, 0x7f
dli v0, 0x58
@ -728,7 +731,7 @@ boundary sign: contain at least WINDOW_ZERO_NUM consecutive 0(TM success)
dsrl a2, a3, 56
and a2, a2, 0x7f
dli v0, 0x58
blt a2, v0, 2f
blt a2, v0, 1f
nop
//MAX reach boundary, use (MAX+MID)/2
daddu v0, a3, a0
@ -739,9 +742,74 @@ boundary sign: contain at least WINDOW_ZERO_NUM consecutive 0(TM success)
not v1, v1
and a0, a0, v1
or a0, a0, v0
2:
1:
b 88f
nop
4:
ld a1, GD_MIN(t8)
ld a3, GD_MAX(t8)
//Byte 1~0
//refer byte 0 MIN
dsrl a2, a1, 0
and a2, a2, 0x7f
bnez a2, 1f
nop
//min==0
dsrl v0, a0, 0 //mid_value / 1
dli a2, 0x7f7f
and v0, v0, a2
dli a2, 0xffff
not a2, a2
and a0, a0, a2
or a0, a0, v0
1:
//Byte 3~2
//refer byte 2 MIN
dsrl a2, a1, 16
and a2, a2, 0x7f
bnez a2, 1f
nop
//MIN==0
dsrl v0, a0, 1 //mid_value / 2
dli a2, 0x7f7f0000
and v0, v0, a2
dli a2, 0xffff0000
not a2, a2
and a0, a0, a2
or a0, a0, v0
1:
//Byte 5~4
//refer byte 5 MIN
dsrl a2, a1, 40
and a2, a2, 0x7f
bnez a2, 1f
nop
//MIN==0
dsrl v0, a0, 1 //mid_value / 2
dli a2, 0x7f7f00000000
and v0, v0, a2
dli a2, 0xffff00000000
not a2, a2
and a0, a0, a2
or a0, a0, v0
1:
//Byte 7~6
//refer byte 7 MIN
dsrl a2, a1, 56
and a2, a2, 0x7f
bnez a2, 1f
nop
//MIN==0
dsrl v0, a0, 0 //mid_value / 1
dli a2, 0x7f7f000000000000
and v0, v0, a2
dli a2, 0xffff000000000000
not a2, a2
and a0, a0, a2
or a0, a0, v0
1:
8:
88:
#endif
sd a0, GD_MID(t8)
One_Level_Caled_1:
@ -782,6 +850,8 @@ One_Level_Caled_1:
beq t6, a0, ARB_level_PAD_ready
nop
//process level result
bnez t9, 1f //level fail
nop
ld a1, GD_MAX(t8)
ld a0, GD_MIN(t8)
dsubu a1, a1, a0
@ -1505,30 +1575,32 @@ boundary sign: contain at least WINDOW_ZERO_NUM consecutive 0(TM success)
and a0, a0, a1
2:
#endif
#ifdef DDR3_DIMM
//special deal with wrlvl_dqs
#ifdef DDR3_DIMM //special deal with wrlvl_dqs when use DDR3 DIMM
dli a1, 0x5
bne t6, a1, 8f
bne t6, a1, 88f
nop
GET_DIMM_TYPE
bnez a1, 88f
nop
ld a1, GD_MIN(t8)
ld a3, GD_MAX(t8)
//Byte 1~0
//refer byte 1 MIN
//refer byte 1
dsrl a2, a1, 8
and a2, a2, 0x7f
bnez a2, 1f
nop
//min==0
dsrl v0, a0, 2 //mid_value / 4
dli a2, 0x7f7f //byte1~0, mid_value/4
dli a2, 0x7f7f
and v0, v0, a2
dli a2, 0xffff
not a2, a2
and a0, a0, a2
or a0, a0, v0
1:
2:
//Byte 3~2
//refer byte 3
dsrl a2, a1, 24
and a2, a2, 0x7f
bnez a2, 1f
@ -1543,6 +1615,7 @@ boundary sign: contain at least WINDOW_ZERO_NUM consecutive 0(TM success)
or a0, a0, v0
1:
//Byte 5~4
//refer byte 5
dsrl a2, a3, 40
and a2, a2, 0x7f
dli v0, 0x58
@ -1569,7 +1642,7 @@ boundary sign: contain at least WINDOW_ZERO_NUM consecutive 0(TM success)
dsrl a2, a3, 56
and a2, a2, 0x7f
dli v0, 0x58
blt a2, v0, 2f
blt a2, v0, 1f
nop
//MAX reach boundary, use (MAX+MID)/2
daddu v0, a3, a0
@ -1580,9 +1653,74 @@ boundary sign: contain at least WINDOW_ZERO_NUM consecutive 0(TM success)
not v1, v1
and a0, a0, v1
or a0, a0, v0
2:
1:
b 88f
nop
4:
ld a1, GD_MIN(t8)
ld a3, GD_MAX(t8)
//Byte 1~0
//refer byte 0 MIN
dsrl a2, a1, 0
and a2, a2, 0x7f
bnez a2, 1f
nop
//min==0
dsrl v0, a0, 0 //mid_value / 1
dli a2, 0x7f7f
and v0, v0, a2
dli a2, 0xffff
not a2, a2
and a0, a0, a2
or a0, a0, v0
1:
//Byte 3~2
//refer byte 2 MIN
dsrl a2, a1, 16
and a2, a2, 0x7f
bnez a2, 1f
nop
//MIN==0
dsrl v0, a0, 1 //mid_value / 2
dli a2, 0x7f7f0000
and v0, v0, a2
dli a2, 0xffff0000
not a2, a2
and a0, a0, a2
or a0, a0, v0
1:
//Byte 5~4
//refer byte 5 MIN
dsrl a2, a1, 40
and a2, a2, 0x7f
bnez a2, 1f
nop
//MIN==0
dsrl v0, a0, 1 //mid_value / 2
dli a2, 0x7f7f00000000
and v0, v0, a2
dli a2, 0xffff00000000
not a2, a2
and a0, a0, a2
or a0, a0, v0
1:
//Byte 7~6
//refer byte 7 MIN
dsrl a2, a1, 56
and a2, a2, 0x7f
bnez a2, 1f
nop
//MIN==0
dsrl v0, a0, 0 //mid_value / 1
dli a2, 0x7f7f000000000000
and v0, v0, a2
dli a2, 0xffff000000000000
not a2, a2
and a0, a0, a2
or a0, a0, v0
1:
8:
88:
#endif
#if 0
//add some offset for wrlvl_dq

39
pmon/arch/mips/mm/ddr_config.S

@ -10,7 +10,6 @@
0: MC0
1: MC1
**********************************/
//#define MULTI_NODE_DDR_PARAM
#define CONFIG_BASE 0x900000000ff00000
.global ddr2_config
@ -244,6 +243,8 @@ ddr2_config:
dli a1, 0x0101040401010404
or a2, a2, a1
sd a2, ODT_MAP_CS_ADDR(t8)
1: //1 DIMM
#if 1
//if its DDR3_DIMM, enable dynamic ODT and reset ODT value
GET_SDRAM_TYPE
dli a2, 0x3
@ -273,31 +274,7 @@ ddr2_config:
dsll a1, a1, MR2_DATA_3_OFFSET
or a2, a2, a1
sd a2, MR2_DATA_3_ADDR(t8)
1: //1 DIMM
#if 0
//check 1 rank or 2 ranks populated by xor CS[0] and CS[2]
GET_MC_CS_MAP
dsrl a2, a1, 2
xor a2, a1, a2
and v0, a2, 0x1
beqz v0, 1f
nop
//1 DIMM, check its SR DIMM or DR DIMM
//here a2[1:0] store the valid CS
and v0, a2, 0x3
dsrl v0, v0, 1
beqz v0, 2f
nop
//Dual Rank DIMM
dli a2, 0x0408010200000000
sd a2, ODT_MAP_CS_ADDR(t8)
2: //1 SR DIMM, use the default setting
b 8f
nop
1: //2 DIMM
8:
1:
#endif
//set data bus width
ld a2, REDUC_ADDR(t8)
@ -1065,6 +1042,13 @@ t5: value
sync
//wait initialization complete
//delay
dli v0, 0x100
1:
bnez v0, 1b
daddi v0, v0, -1
nop
daddiu v0, t8, 0x960
1:
ld a1, 0x0(v0)
@ -1212,6 +1196,7 @@ Fix_ddr_param:
blt t6, a1, Fix_ddr_param
nop
8:
move t2, t5
//ARB_Write_Leveled_param.S will disable DDR register space
@ -1372,7 +1357,7 @@ Fix_ddr_param:
//init mem to all 0
dli t1, 0x9800001000000000
GET_NODE_ID_a0
or t1, t1, a0
or t1, t1, a0
GET_MC0_MEMSIZE
beqz t3, 1f
nop

8
pmon/arch/mips/mm/ddr_param_define.h

@ -3,6 +3,14 @@
Author: Chen Xinke
v0.1
*******************************/
#ifdef loongson3A3
#define LSMCD3_2
#else
#ifdef LS3B
#define LSMCD3_2
#endif
#endif
#define DDR_MC_CONFIG_BASE 0x900000000ff00000
#define MC_CONFIG_REG_BASE_ADDR 0x900000000ff00000
#ifdef LSMCD3_2

103
pmon/cmds/save_ddrparam.c

@ -83,10 +83,22 @@ u64 __raw_writeq_sp(u64 addr, u64 val)
extern char _start;
extern char ddr2_leveled_mark;
#ifndef LS3B
extern char ddr2_reg_data_mc0_leveled, ddr2_reg_data_mc1_leveled;
#ifdef MULTI_CHIP
extern char n1_ddr2_reg_data_mc0_leveled, n1_ddr2_reg_data_mc1_leveled;
#endif
#else
extern char ddr2_reg_data_leveled;
#ifdef MULTI_CHIP
extern char n1_ddr2_reg_data_leveled;
#endif
#ifdef DUAL_3B
extern char n2_ddr2_reg_data_leveled;
extern char n3_ddr2_reg_data_leveled;
#endif
#endif
//#define DEBUG
#ifdef DEBUG
@ -94,7 +106,7 @@ extern int do_cmd(char *);
extern void dump_l2xbar(int node);
#endif
#ifdef loongson3A3
#ifdef LSMCD3_2
#define DDR_PARAM_NUM 180
#else
#define DDR_PARAM_NUM 152
@ -190,6 +202,7 @@ int read_ddr_param(u64 node_id_shift44, int mc_selector, unsigned long long * b
//do_cmd("showwindows");
//dump_l2xbar(1);
#ifndef LS3B
// step 1. Change The Primest window for MC0 or MC1 register space
enable_ddrcfgwindow(node_id_shift44, mc_selector, buf);
@ -198,7 +211,7 @@ int read_ddr_param(u64 node_id_shift44, int mc_selector, unsigned long long * b
// step 2. Enabel access to MC0 or MC1 register space
enable_ddrconfig(node_id_shift44);
#endif
// step 3. Read out ddr config register to buffer
printf("\nNow Read out DDR parameter from DDR MC%d controler after DDR training\n", mc_selector);
for ( i = DDR_PARAM_NUM - 1; i >= 0; i--) // NOTICE HERE: it means system has DDR_PARAM_NUM double words
@ -206,22 +219,26 @@ int read_ddr_param(u64 node_id_shift44, int mc_selector, unsigned long long * b
val[i] = ld((MC_CONFIG_ADDR | node_id_shift44) + (0x10 * i));
#ifdef DEBUG
printf("< CFGREG >:val[%d] = %016llx \n", i, val[i]);
printf("< CFGREG >:val[%03d] = %016llx \n", i, val[i]);
#endif
}
//clear param_start
val[3] &= 0xfffffeffffffffff;
#ifndef LS3B
// step 4. Disabel access to MC0 or MC1 register space
disable_ddrconfig(node_id_shift44);
// step 5. Restore The Primest window for accessing system memory
disable_ddrcfgwidow(node_id_shift44, mc_selector, buf);
#endif
printf("Read out DDR MC%d config Done.\n", mc_selector);
return 0;
}
#ifndef LS3B
void save_ddrparam(u64 node_id_shift44, int mc0_param_store_addr, int mc1_param_store_addr)
{
@ -234,7 +251,7 @@ void save_ddrparam(u64 node_id_shift44, int mc0_param_store_addr, int mc1_param_
#endif
#ifdef DEBUG
printf("node_id_shift44=0x%016llx\n", node_id_shift44);
printf("\nnode_id_shift44=0x%016llx\n", node_id_shift44);
#endif
/********************************************************/
/************************/ // End of flash
@ -313,7 +330,6 @@ void save_ddrparam(u64 node_id_shift44, int mc0_param_store_addr, int mc1_param_
}
// test : master
int save_board_ddrparam()
{
unsigned long long flag;
@ -331,6 +347,83 @@ int save_board_ddrparam()
}
return(1);
}
#else
void save_ddrparam(u64 node_id_shift44, int mc0_param_store_addr)
{
unsigned long long ddr_param_buf[DDR_PARAM_NUM + 1];
#ifdef DEBUG
int i;
unsigned long long tmp;
#endif
#ifdef DEBUG
printf("\nnode_id_shift44=0x%016llx\n", node_id_shift44);
#endif
/********************************************************/
/************************/ // End of flash
/* DDRPTOVF */ // End - 8 (byte) (1M-8)
/* -------------------- */ //
/* */ //
/* ....... */
/* ....... */
/* ....... */ // $ddr3_data
/* ....... */
/* */
/************************/ // Base of flash: offset 0x00
/********************************************************/
// step 1. Read out DDR controler register values and save them in buffers
// step 1.1 Read out DDR controler register from MC0 and save them in buffer0
read_ddr_param(node_id_shift44, MC0, ddr_param_buf);
//ddr_param_buf[DDR_PARAM_NUM] = 0x0;
// step 1.2 Program buffers of MC0 register into FLASH
tgt_flashprogram((int *)(0xbfc00000+(mc0_param_store_addr -(int)&_start)), DDR_PARAM_NUM*8, ddr_param_buf,TRUE);
#ifdef DEBUG
for(i = 0; i< DDR_PARAM_NUM; i++)
{
tmp = ld(0x900000001fc00000 + mc0_param_store_addr - (int)&_start + i * 8);
if(ddr_param_buf[i] != tmp)
{
printf("\nMiscompare:i=%d, val=%016llx", i, tmp);
}
else
printf("\nSame:i=%d, val=%016llx", i, tmp);
}
#endif
}
int save_board_ddrparam()
{
unsigned long long flag;
unsigned long long node_id;
if(ld(0x900000001fc00000 + (int) &ddr2_leveled_mark - (int)&_start) == 0)
{
node_id = 0;
save_ddrparam(node_id << 44, (int)&ddr2_reg_data_leveled);
#ifdef MULTI_CHIP
node_id = 1;
save_ddrparam(node_id << 44, (int)&n1_ddr2_reg_data_leveled);
#endif
#ifdef DUAL_3B
node_id = 2;
save_ddrparam(node_id << 44, (int)&n2_ddr2_reg_data_leveled);
node_id = 3;
save_ddrparam(node_id << 44, (int)&n3_ddr2_reg_data_leveled);
#endif
flag = 0x1;
tgt_flashprogram((int *)(0xbfc00000 + ((int)&ddr2_leveled_mark - (int)&_start)), 8, &flag, TRUE);
}
return(1);
}
#endif
int cmd_save_ddrparam(ac, av)
int ac;

Loading…
Cancel
Save