Browse Source

3A82H: Add the reference board support.

Change-Id: Ibed94cfe86588ad11022218889ae2eac0aa965e0
master
lixuefeng 8 years ago
parent
commit
2e12b66bc0
  1. 3898
      Targets/Bonito3a82h/Bonito/loongson3C_ddr3_leveling.S
  2. 27
      Targets/Bonito3a82h/Bonito/loongson3_def.h
  3. 24
      Targets/Bonito3a82h/Bonito/loongson_mc2_param.S
  4. 17
      Targets/Bonito3a82h/Bonito/start.S
  5. 37
      Targets/Bonito3a82h/Bonito/tgt_machdep.c
  6. 5
      Targets/Bonito3a82h/conf/Bonito.3a82h
  7. 3
      Targets/Bonito3a82h/conf/files.Bonito3a82h
  8. 198
      Targets/Bonito3a82h/dev/gmac.h
  9. 130
      Targets/Bonito3a82h/dev/pwm_fan.c
  10. 597
      Targets/Bonito3a82h/dev/signal_test.c
  11. 21
      Targets/Bonito3a82h/pci/ls2h_pci.c
  12. 14
      pmon/dev/flash.c
  13. 2
      sys/dev/gmac/synopGMAC_Dev.h
  14. 7
      sys/dev/gmac/synopGMAC_network_interface.c

3898
Targets/Bonito3a82h/Bonito/loongson3C_ddr3_leveling.S

File diff suppressed because it is too large

27
Targets/Bonito3a82h/Bonito/loongson3_def.h

@ -60,22 +60,25 @@ sw v1, 4(v0); \
nop; \
nop;
/*for 3a2000_2h refer board*/
/* WatchDog Close for chip MAX6369*/
#define WatchDog_Close \
li v0, 0xbbef0000;\
li v1, 0x00;\
sw v1, 0x30(v0);\
GPIO_CLEAR_OUTPUT(0x1<<5); \
GPIO_SET_OUTPUT(0x1<<3|0x1<<4); \
GPIO_CLEAR_OUTPUT(0x1<<13); \
/* WatchDog Enable for LS2H chip */
/* WatchDog Enable for chip MAX6369*/
#define WatchDog_Enable \
li v0, 0xbbef0000;\
li v1, 0x02;\
sw v1, 0x30(v0);\
li v1, 0x1fffffff;\
sw v1, 0x38(v0);\
li v1, 0x01;\
sw v1, 0x34(v0);\
GPIO_SET_OUTPUT(0x1<<14); \
GPIO_SET_OUTPUT(0x1<<5); \
GPIO_CLEAR_OUTPUT(0x1<<4); \
GPIO_SET_OUTPUT(0x1<<3); \
GPIO_CLEAR_OUTPUT(0x1<<14); \
li v1,0x100;\
78:; \
subu v1,1; \
bnez v1,78b; \
nop; \
#define CONFIG_CACHE_64K_4WAY 1

24
Targets/Bonito3a82h/Bonito/loongson_mc2_param.S

@ -21,12 +21,12 @@ MC0_DDR3_CTRL_0x010: .dword 0x0000000000000000
//XXXX pm_dll_value_8(RD) XXXX pm_dll_value_7 (RD) XXXX pm_dll_value_6(RD) XXXX pm_dll_value_5(RD)
//MC0_DDR3_CTRL_0x018: .dword 0x5252525216100000
//MC0_DDR3_CTRL_0x018: .dword 0x4040404016100000
MC0_DDR3_CTRL_0x018: .dword 0x3030303016100000
//MC0_DDR3_CTRL_0x018: .dword 0x2525252516100000
//MC0_DDR3_CTRL_0x018: .dword 0x3030303016100000
MC0_DDR3_CTRL_0x018: .dword 0x2020202016100000
//_00000000 pm_dll_ck_3 _00000000 pm_dll_ck_2 _00000000 pm_dll_ck_1 _00000000 pm_dll_ck_0 _00000000 pm_dll_increment _00000000 pm_dll_start_point _0000000_0 pm_dll_bypass _0000000_0 pm_init_start
MC0_DDR3_CTRL_0x020: .dword 0x0201000201000000
//0000_0000 pm_dq_oe_end_0 0000_0000 pm_dq_oe_begin_0 000000_00 pm_dq_stop_edge_0 000000_00 pm_dq_start_edge_0 0000000_0 pm_rddata_delay_0 0000000_0 pm_rddqs_lt_half_0 0000000_0 pm_wrdqs_lt_half_0 0000000_0 pm_wrdq_lt_half_0
MC0_DDR3_CTRL_0x028: .dword 0x0303000002010100
MC0_DDR3_CTRL_0x028: .dword 0x0303000002000103
//0000_0000 pm_rd_oe_end_0 0000_0000 pm_rd_oe_begin_0 000000_00 pm_rd_stop_edge_0 000000_00 pm_rd_start_edge_0 0000_0000 pm_dqs_oe_end_0 0000_0000 pm_dqs_oe_begin_0 000000_00 pm_dqs_stop_edge_0 000000_00 pm_dqs_start_edge_0
MC0_DDR3_CTRL_0x030: .dword 0x0000000003020202
//hXXXXXX (RD) 0000000_0 pm_wrdq_clkdelay_0 0000_0000 pm_odt_oe_end_0 0000_0000 pm_odt_oe_begin_0 000000_00 pm_odt_stop_edge_0 000000_00 pm_odt_start_edge_0
@ -34,7 +34,7 @@ MC0_DDR3_CTRL_0x038: .dword 0x0000002020056500
//hXXXXXX (RD) _00000000 pm_dll_rddqs_n_0 _00000000 pm_dll_rddqs_p_0 _00000000 pm_dll_wrdqs_0 _00000000 pm_dll_wrdata_0 _00000000 pm_dll_gate_0
MC0_DDR3_CTRL_0x040: .dword 0x0201000201000000
//0000_0000 pm_dq_oe_end_1 0000_0000 pm_dq_oe_begin_1 000000_00 pm_dq_stop_edge_1 000000_00 pm_dq_start_edge_1 0000000_0 pm_rddata_delay_1 0000000_0 pm_rddqs_lt_half_1 0000000_0 pm_wrdqs_lt_half_1 0000000_0 pm_wrdq_lt_half_1
MC0_DDR3_CTRL_0x048: .dword 0x0303000002010100
MC0_DDR3_CTRL_0x048: .dword 0x0303000002000103
//0000_0000 pm_rd_oe_end_1 0000_0000 pm_rd_oe_begin_1 000000_00 pm_rd_stop_edge_1 000000_00 pm_rd_start_edge_1 0000_0000 pm_dqs_oe_end_1 0000_0000 pm_dqs_oe_begin_1 000000_00 pm_dqs_stop_edge_1 000000_00 pm_dqs_start_edge_1
MC0_DDR3_CTRL_0x050: .dword 0x0000000003020202
//hXXXXXX (RD) 0000000_0 pm_wrdq_clkdelay_1 0000_0000 pm_odt_oe_end_1 0000_0000 pm_odt_oe_begin_1 000000_00 pm_odt_stop_edge_1 000000_00 pm_odt_start_edge_1
@ -42,7 +42,7 @@ MC0_DDR3_CTRL_0x058: .dword 0x0000002020056500
//hXXXXXX (RD) _00000000 pm_dll_rddqs_n_1 _00000000 pm_dll_rddqs_p_1 _00000000 pm_dll_wrdqs_1 _00000000 pm_dll_wrdata_1 _00000000 pm_dll_gate_1
MC0_DDR3_CTRL_0x060: .dword 0x0201000201000000
//0000_0000 pm_dq_oe_end_2 0000_0000 pm_dq_oe_begin_2 000000_00 pm_dq_stop_edge_2 000000_00 pm_dq_start_edge_2 0000000_0 pm_rddata_delay_2 0000000_0 pm_rddqs_lt_half_2 0000000_0 pm_wrdqs_lt_half_2 0000000_0 pm_wrdq_lt_half_2
MC0_DDR3_CTRL_0x068: .dword 0x0303000002010100
MC0_DDR3_CTRL_0x068: .dword 0x0303000002000103
//0000_0000 pm_rd_oe_end_2 0000_0000 pm_rd_oe_begin_2 000000_00 pm_rd_stop_edge_2 000000_00 pm_rd_start_edge_2 0000_0000 pm_dqs_oe_end_2 0000_0000 pm_dqs_oe_begin_2 000000_00 pm_dqs_stop_edge_2 000000_00 pm_dqs_start_edge_2
MC0_DDR3_CTRL_0x070: .dword 0x0000000003020202
//hXXXXXX (RD) 0000000_0 pm_wrdq_clkdelay_2 0000_0000 pm_odt_oe_end_2 0000_0000 pm_odt_oe_begin_2 000000_00 pm_odt_stop_edge_2 000000_00 pm_odt_start_edge_2
@ -50,7 +50,7 @@ MC0_DDR3_CTRL_0x078: .dword 0x0000002020056500
//hXXXXXX (RD) _00000000 pm_dll_rddqs_n_2 _00000000 pm_dll_rddqs_p_2 _00000000 pm_dll_wrdqs_2 _00000000 pm_dll_wrdata_2 _00000000 pm_dll_gate_2
MC0_DDR3_CTRL_0x080: .dword 0x0201000201000000
//0000_0000 pm_dq_oe_end_3 0000_0000 pm_dq_oe_begin_3 000000_00 pm_dq_stop_edge_3 000000_00 pm_dq_start_edge_3 0000000_0 pm_rddata_delay_3 0000000_0 pm_rddqs_lt_half_3 0000000_0 pm_wrdqs_lt_half_3 0000000_0 pm_wrdq_lt_half_3
MC0_DDR3_CTRL_0x088: .dword 0x0303000002010100
MC0_DDR3_CTRL_0x088: .dword 0x0303000002000103
//0000_0000 pm_rd_oe_end_3 0000_0000 pm_rd_oe_begin_3 000000_00 pm_rd_stop_edge_3 000000_00 pm_rd_start_edge_3 0000_0000 pm_dqs_oe_end_3 0000_0000 pm_dqs_oe_begin_3 000000_00 pm_dqs_stop_edge_3 000000_00 pm_dqs_start_edge_3
MC0_DDR3_CTRL_0x090: .dword 0x0000000003020202
//hXXXXXX (RD) 0000000_0 pm_wrdq_clkdelay_3 0000_0000 pm_odt_oe_end_3 0000_0000 pm_odt_oe_begin_3 000000_00 pm_odt_stop_edge_3 000000_00 pm_odt_start_edge_3
@ -58,7 +58,7 @@ MC0_DDR3_CTRL_0x098: .dword 0x0000002020056500
//hXXXXXX (RD) _00000000 pm_dll_rddqs_n_3 _00000000 pm_dll_rddqs_p_3 _00000000 pm_dll_wrdqs_3 _00000000 pm_dll_wrdata_3 _00000000 pm_dll_gate_3
MC0_DDR3_CTRL_0x0a0: .dword 0x0201000201000000
//0000_0000 pm_dq_oe_end_4 0000_0000 pm_dq_oe_begin_4 000000_00 pm_dq_stop_edge_4 000000_00 pm_dq_start_edge_4 0000000_0 pm_rddata_delay_4 0000000_0 pm_rddqs_lt_half_4 0000000_0 pm_wrdqs_lt_half_4 0000000_0 pm_wrdq_lt_half_4
MC0_DDR3_CTRL_0x0a8: .dword 0x0303000002010100
MC0_DDR3_CTRL_0x0a8: .dword 0x0303000002000103
//0000_0000 pm_rd_oe_end_4 0000_0000 pm_rd_oe_begin_4 000000_00 pm_rd_stop_edge_4 000000_00 pm_rd_start_edge_4 0000_0000 pm_dqs_oe_end_4 0000_0000 pm_dqs_oe_begin_4 000000_00 pm_dqs_stop_edge_4 000000_00 pm_dqs_start_edge_4
MC0_DDR3_CTRL_0x0b0: .dword 0x0000000003020202
//hXXXXXX (RD) 0000000_0 pm_wrdq_clkdelay_4 0000_0000 pm_odt_oe_end_4 0000_0000 pm_odt_oe_begin_4 000000_00 pm_odt_stop_edge_4 000000_00 pm_odt_start_edge_4
@ -66,7 +66,7 @@ MC0_DDR3_CTRL_0x0b8: .dword 0x0000002020056500
//hXXXXXX (RD) _00000000 pm_dll_rddqs_n_4 _00000000 pm_dll_rddqs_p_4 _00000000 pm_dll_wrdqs_4 _00000000 pm_dll_wrdata_4 _00000000 pm_dll_gate_4
MC0_DDR3_CTRL_0x0c0: .dword 0x0201000201000000
//0000_0000 pm_dq_oe_end_5 0000_0000 pm_dq_oe_begin_5 000000_00 pm_dq_stop_edge_5 000000_00 pm_dq_start_edge_5 0000000_0 pm_rddata_delay_5 0000000_0 pm_rddqs_lt_half_5 0000000_0 pm_wrdqs_lt_half_5 0000000_0 pm_wrdq_lt_half_5
MC0_DDR3_CTRL_0x0c8: .dword 0x0303000002010100
MC0_DDR3_CTRL_0x0c8: .dword 0x0303000002000103
//0000_0000 pm_rd_oe_end_5 0000_0000 pm_rd_oe_begin_5 000000_00 pm_rd_stop_edge_5 000000_00 pm_rd_start_edge_5 0000_0000 pm_dqs_oe_end_5 0000_0000 pm_dqs_oe_begin_5 000000_00 pm_dqs_stop_edge_5 000000_00 pm_dqs_start_edge_5
MC0_DDR3_CTRL_0x0d0: .dword 0x0000000003020202
//hXXXXXX (RD) 0000000_0 pm_wrdq_clkdelay_5 0000_0000 pm_odt_oe_end_5 0000_0000 pm_odt_oe_begin_5 000000_00 pm_odt_stop_edge_5 000000_00 pm_odt_start_edge_5
@ -74,7 +74,7 @@ MC0_DDR3_CTRL_0x0d8: .dword 0x0000002020056500
//hXXXXXX (RD) _00000000 pm_dll_rddqs_n_5 _00000000 pm_dll_rddqs_p_5 _00000000 pm_dll_wrdqs_5 _00000000 pm_dll_wrdata_5 _00000000 pm_dll_gate_5
MC0_DDR3_CTRL_0x0e0: .dword 0x0201000201000000
//0000_0000 pm_dq_oe_end_6 0000_0000 pm_dq_oe_begin_6 000000_00 pm_dq_stop_edge_6 000000_00 pm_dq_start_edge_6 0000000_0 pm_rddata_delay_6 0000000_0 pm_rddqs_lt_half_6 0000000_0 pm_wrdqs_lt_half_6 0000000_0 pm_wrdq_lt_half_6
MC0_DDR3_CTRL_0x0e8: .dword 0x0303000002010100
MC0_DDR3_CTRL_0x0e8: .dword 0x0303000002000103
//0000_0000 pm_rd_oe_end_6 0000_0000 pm_rd_oe_begin_6 000000_00 pm_rd_stop_edge_6 000000_00 pm_rd_start_edge_6 0000_0000 pm_dqs_oe_end_6 0000_0000 pm_dqs_oe_begin_6 000000_00 pm_dqs_stop_edge_6 000000_00 pm_dqs_start_edge_6
MC0_DDR3_CTRL_0x0f0: .dword 0x0000000003020202
//hXXXXXX (RD) 0000000_0 pm_wrdq_clkdelay_6 0000_0000 pm_odt_oe_end_6 0000_0000 pm_odt_oe_begin_6 000000_00 pm_odt_stop_edge_6 000000_00 pm_odt_start_edge_6
@ -82,7 +82,7 @@ MC0_DDR3_CTRL_0x0f8: .dword 0x0000002020056500
//hXXXXXX (RD) _00000000 pm_dll_rddqs_n_6 _00000000 pm_dll_rddqs_p_6 _00000000 pm_dll_wrdqs_6 _00000000 pm_dll_wrdata_6 _00000000 pm_dll_gate_6
MC0_DDR3_CTRL_0x100: .dword 0x0201000201000000
//0000_0000 pm_dq_oe_end_7 0000_0000 pm_dq_oe_begin_7 000000_00 pm_dq_stop_edge_7 000000_00 pm_dq_start_edge_7 0000000_0 pm_rddata_delay_7 0000000_0 pm_rddqs_lt_half_7 0000000_0 pm_wrdqs_lt_half_7 0000000_0 pm_wrdq_lt_half_7
MC0_DDR3_CTRL_0x108: .dword 0x0303000002010100
MC0_DDR3_CTRL_0x108: .dword 0x0303000002000103
//0000_0000 pm_rd_oe_end_7 0000_0000 pm_rd_oe_begin_7 000000_00 pm_rd_stop_edge_7 000000_00 pm_rd_start_edge_7 0000_0000 pm_dqs_oe_end_7 0000_0000 pm_dqs_oe_begin_7 000000_00 pm_dqs_stop_edge_7 000000_00 pm_dqs_start_edge_7
MC0_DDR3_CTRL_0x110: .dword 0x0000000003020202
//hXXXXXX (RD) 0000000_0 pm_wrdq_clkdelay_7 0000_0000 pm_odt_oe_end_7 0000_0000 pm_odt_oe_begin_7 000000_00 pm_odt_stop_edge_7 000000_00 pm_odt_start_edge_7
@ -90,7 +90,7 @@ MC0_DDR3_CTRL_0x118: .dword 0x0000002020056500
//hXXXXXX (RD) _00000000 pm_dll_rddqs_n_7 _00000000 pm_dll_rddqs_p_7 _00000000 pm_dll_wrdqs_7 _00000000 pm_dll_wrdata_7 _00000000 pm_dll_gate_7
MC0_DDR3_CTRL_0x120: .dword 0x0201000201000000
//0000_0000 pm_dq_oe_end_8 0000_0000 pm_dq_oe_begin_8 000000_00 pm_dq_stop_edge_8 000000_00 pm_dq_start_edge_8 0000000_0 pm_rddata_delay_8 0000000_0 pm_rddqs_lt_half_8 0000000_0 pm_wrdqs_lt_half_8 0000000_0 pm_wrdq_lt_half_8
MC0_DDR3_CTRL_0x128: .dword 0x0303000002010100
MC0_DDR3_CTRL_0x128: .dword 0x0303000002000103
//0000_0000 pm_rd_oe_end_8 0000_0000 pm_rd_oe_begin_8 000000_00 pm_rd_stop_edge_8 000000_00 pm_rd_start_edge_8 0000_0000 pm_dqs_oe_end_8 0000_0000 pm_dqs_oe_begin_8 000000_00 pm_dqs_stop_edge_8 000000_00 pm_dqs_start_edge_8
MC0_DDR3_CTRL_0x130: .dword 0x0000000003020202
//hXXXXXX (RD) 0000000_0 pm_wrdq_clkdelay_8 0000_0000 pm_odt_oe_end_8 0000_0000 pm_odt_oe_begin_8 000000_00 pm_odt_stop_edge_8 000000_00 pm_odt_start_edge_8
@ -134,7 +134,7 @@ MC0_DDR3_CTRL_0x1b8: .dword 0x0000001000060d30
//_00000000_00000000 pm_mr_3_cs_3 _00000000_00000000 pm_mr_2_cs_3 _00000000_00000000 pm_mr_1_cs_3 _00000000_00000000 pm_mr_0_cs_3
MC0_DDR3_CTRL_0x1c0: .dword 0x3030c80c03042005
//_00000000 pm_tRESET _00000000 pm_tCKE _00000000 pm_tXPR _00000000 pm_tMOD _00000000 pm_tZQCL _00000000 pm_tZQ_CMD _00000000 pm_tWLDQSEN 000_00000 pm_tRDDATA
MC0_DDR3_CTRL_0x1c8: .dword 0x11070707154a4080
MC0_DDR3_CTRL_0x1c8: .dword 0x1107070715704080
//00_000000 pm_tFAW 0000_0000 pm_tRRD 0000_0000 pm_tRCD _00000000 pm_tRP _00000000 pm_tREF _00000000 pm_tRFC _00000000 pm_tZQCS _00000000 pm_tZQperiod
MC0_DDR3_CTRL_0x1d0: .dword 0x0a02090402000019
//0000_0000 pm_tODTL _00000000 pm_tXSRD 0000_0000 pm_tPHY_RDLAT 000_00000 pm_tPHY_WRLAT 000000_00_00000000_00000000 pm_tRAS_max 00_000000 pm_tRAS_min

17
Targets/Bonito3a82h/Bonito/start.S

@ -104,6 +104,11 @@ stack = start - 0x4000 /* Place PMON stack below PMON start in RAM */
/* WatchDog chip MAX6369 disable work */
WatchDog_Close
/* spi speedup */
li t0, 0xbfe00220
li t1, 0x07
sb t1, 0x4(t0)
bal locate /* Get current execute address */
nop
@ -360,9 +365,9 @@ gs_2f_v3_ddr2_cfg:
//#define DDR_LOOPC 48 //400MHz
//#define DDR_LOOPC 28 //466MHz
//#define DDR_LOOPC 60 //500MHz
//#define DDR_LOOPC 32 //533MHz
#define DDR_LOOPC 64 //533MHz
//#define DDR_LOOPC 34 //566MHz
#define DDR_LOOPC 72 //600MHz
//#define DDR_LOOPC 72 //600MHz
//#define DDR_LOOPC 38 //633MHz
#define DDR_REFC 1
//#define DDR_DIV 8
@ -564,9 +569,9 @@ after_ht:
TTYDBG("NODE 0 MEMORY CONFIG BEGIN\r\n")
#ifdef AUTO_DDR_CONFIG
dli s1, 0x32170000 //set use MC1 or MC0 or MC1/0 and give All device id
dli s1, 0x36170000 //set use MC1 or MC0 or MC1/0 and give All device id
#else
dli s1, 0xc3e30200c3e30204
dli s1, 0xc2e30400c2e30400
#endif
#include "ddr_dir/loongson3a2h_ddr_config.S"
@ -574,7 +579,7 @@ after_ht:
/*judge the node0 whether have memory*/
and a0, msize, 0xff
//beqz a0, beep_on
beqz a0, beep_on
nop
/* test memory */
@ -1287,7 +1292,7 @@ watchdog_enable:
#######################################
#include "ddr_dir/ls3A8_ddr_config.S"
#ifdef DDR3_DIMM
#include "ddr_dir/loongson3C_ddr3_leveling.S"
#include "loongson3C_ddr3_leveling.S"
#endif
#ifdef ARB_LEVEL
#include "ddr_dir/ARB_level_new.S"

37
Targets/Bonito3a82h/Bonito/tgt_machdep.c

@ -295,10 +295,13 @@ initmips(unsigned long long raw_memsz)
/*
* Probe clock frequencys so delays will work properly.
*/
delay(0x200000);
delay(0x200000);
delay(0x200000);
for (i = 0;i < 3;i++)
{
delay(0x200000);
delay(0x200000);
}
ls2h_pcibios_init();
tgt_cpufreq();
SBD_DISPLAY("DONE",0);
/*
@ -332,6 +335,7 @@ initmips(unsigned long long raw_memsz)
* Launch!
*/
//_pci_conf_write(_pci_make_tag(0,0,0),0x90,0xff800000);
main();
}
@ -379,13 +383,16 @@ tgt_devconfig()
#endif
#endif
outl(LS2H_GPIO_CFG_REG, 0xf << 24);
#if 1
board_ver_num = LS3A2H_BOARD_2_2;
#else
board_ver_num = (inl(LS2H_GPIO_IN_REG) >> 8) & 0xf;
#endif
if(board_ver_num == LS3A2H_BOARD_2_2) { // new 3A2H Board: lpc interface mount on 2H, old board lpc mount on 3A
superio_base = 0xbbf00000;
} else if(board_ver_num == LS3A2H_BOARD_OLD) {
superio_base = 0xbff00000;
}
_pci_devinit(1); /* PCI device initialization */
#if (NMOD_X86EMU_INT10 > 0)||(NMOD_X86EMU >0)
#ifdef PCIE_GRAPHIC_CARD
@ -608,6 +615,8 @@ extern void cs5536_pci_fixup(void);
#ifdef PCIE_GRAPHIC_CARD
extern int ls2h_pcibios_init(void);
#endif
extern int ls2h_pcibios_init(void);
extern int gmac_w18(void);
@ -652,8 +661,16 @@ tgt_poweroff()
void
tgt_reboot(void)
{
volatile char * hard_reset_reg = 0xbbef0030;
unsigned int GPIO_DATA_REG = 0xbfe0011c;
unsigned int GPIO_EN_REG = 0xbfe00120;
#define ls_readl(x) (* (volatile unsigned int*)(x))
ls_readl(GPIO_DATA_REG) &= (~0x38);
ls_readl(GPIO_EN_REG) &= (~(1 << 13));
ls_readl(GPIO_DATA_REG) |= (1 << 13);
/* volatile char * hard_reset_reg = 0xbbef0030;
* hard_reset_reg = ( * hard_reset_reg) | 0x01; // watch dog hardreset
*/
}
@ -1569,9 +1586,7 @@ struct efi_memory_map_loongson * init_memory_map()
#ifndef UMA_VIDEO_RAM
EMAP_ENTRY(i, 0, SYSTEM_RAM_LOW, 0x00200000, 0x0ee);
#else
/*add UMA_VIDEO_RAM area to reserved 0x60 MB memory for GPU */
EMAP_ENTRY(i, 0, SYSTEM_RAM_LOW, 0x00200000, 0x0ee - 0x60);
EMAP_ENTRY(i, 0, UMA_VIDEO_RAM, (0xee - 0x60 + 2) << 20, 0x60);
EMAP_ENTRY(i, 0, SYSTEM_RAM_LOW, 0x00200000, 0x0ee);
#endif
/* for entry with mem_size < 1M, we set bit31 to 1 to indicate
@ -1579,7 +1594,13 @@ struct efi_memory_map_loongson * init_memory_map()
EMAP_ENTRY(i, 0, SMBIOS_TABLE, (SMBIOS_PHYSICAL_ADDRESS & 0x0fffffff),
(SMBIOS_SIZE_LIMIT | 0x80000000));
#ifndef UMA_VIDEO_RAM
EMAP_ENTRY(i, 0, SYSTEM_RAM_HIGH, 0x110000000, size >> 20);
#else
/*add UMA_VIDEO_RAM area to reserved 0x100 MB memory for GPU vram*/
EMAP_ENTRY(i, 0, UMA_VIDEO_RAM, 0x110000000, 0x100);
EMAP_ENTRY(i, 0, SYSTEM_RAM_HIGH, 0x120000000, (size >> 20) - 0x100);
#endif
emap->vers = 1;
emap->nr_map = i;

5
Targets/Bonito3a82h/conf/Bonito.3a82h

@ -44,9 +44,10 @@ option SHUTDOWN_MASK=0x0000
option INTERFACE_3A780E # option for bios memu
option LOONGSON_3A2H
option LOONGSON_3A8
option BOOT_PARAM
option PCIE_GRAPHIC_CARD
#option PCIE_GRAPHIC_CARD
#
# Uart serial baud rate selection
@ -182,7 +183,7 @@ pcibr0 at mainbus0
#pcibr1 at mainbus0
pcibr2 at mainbus0 #For the port1 device register
pcibr4 at mainbus0 #For the port2 device register
pcibr6 at mainbus0 #For the port3 device register
#pcibr6 at mainbus0 #For the port3 device register
pci* at pcibr?
ppb* at pci? dev ? function ? # PCI-PCI bridges
pci* at ppb? bus ?

3
Targets/Bonito3a82h/conf/files.Bonito3a82h

@ -30,6 +30,9 @@ file Targets/Bonito3a82h/dev/nand_myops.c nand needs-flag
#dc
file Targets/Bonito3a82h/dev/dc.c
file Targets/Bonito3a82h/dev/signal_test.c
file Targets/Bonito3a82h/dev/pwm_fan.c
#i2c
file sys/dev/i2c.c
file Targets/Bonito3a82h/dev/eeprom.c

198
Targets/Bonito3a82h/dev/gmac.h

@ -0,0 +1,198 @@
#ifndef _GMAC_H_
#define _GMAC_H_
#define u16 unsigned short
#if 0
#define GMAC0_MAC_REG_ADDR 0xffffffffbbe10000
#define GMAC0_DMA_REG_ADDR 0xffffffffbbe11000
#define GMAC1_MAC_REG_ADDR 0xffffffffbbe18000
#define GMAC1_DMA_REG_ADDR 0xffffffffbbe19000
#define GMAC0_RX_DESC_BASE 0x9000000000060000
#define GMAC1_RX_DESC_BASE 0x9000000000060200
#define GMAC0_RX_DESC_BASE_PHY 0x60000
#define GMAC0_RDES0_VALUE 0x80000000
#define GMAC0_RDES1_VALUE 0x4110
#define GMAC0_RDES1_END_VALUE 0x8100
#define GMAC0_TX_DESC_BASE 0x9000000000040000
#define GMAC1_TX_DESC_BASE 0x9000000000040200
#define GMAC0_TX_DESC_BASE_PHY 0x40000
#else
#define GMAC0_MAC_REG_ADDR 0xffffffffbbe10000
#define GMAC0_DMA_REG_ADDR 0xffffffffbbe11000
#define GMAC1_MAC_REG_ADDR 0xffffffffbbe18000
#define GMAC1_DMA_REG_ADDR 0xffffffffbbe19000
#define GMAC0_RX_DESC_BASE 0xa0060000
#define GMAC1_RX_DESC_BASE 0xa0060200
#define GMAC0_RX_DESC_BASE_PHY 0x60000
#define GMAC0_RDES0_VALUE 0x80000000
#define GMAC0_RDES1_VALUE 0x4110
#define GMAC0_RDES1_END_VALUE 0x8100
#define GMAC0_TX_DESC_BASE 0xa0040000
#define GMAC1_TX_DESC_BASE 0xa0040200
#define GMAC0_TX_DESC_BASE_PHY 0x40000
#endif
#define GMAC0_TDES0_VALUE 0xb0100000
#define GMAC0_TDES0_VALUE_END 0xb0200000
#define GMAC0_TDES1_VALUE 0x100
#define DmaBusMode_SWR 0x1
#define DmaBusMode_PBL 0X400
#define GmacConfig_DM (1 << 11)
#define GmacConfig_IFG 0xc000
#define GmacFrameFilter_RA (1 << 31)
#define GmacConfig_RE (1 << 2)
#define GmacConfig_TE (1 << 3)
#define DmaControl_SR (1 << 1)
#define DmaControl_ST (1 << 13)
#define DmaControl_TSF (1 << 21)
#define DmaControl_RSF (1 << 25)
#define SGMII_STATUS 0xd8
#define SGMII_STATUS_LINK_STATUS (1 << 3)
/*RTL8211E REG*/
#define PHY_BMCR 0x0
#define PHY_BMCR_LOOPBACK (1 << 14)
#define PHY_BMCR_SPEED (0X2000)
#define PHY_BMCR_DUPLEX (1 << 8)
#define PHY_PHYSR 0x11
#define PHY_PHYSR_LINK_STATUS (1 << 10)
#define TX_BUF_SIZE 0xc00
#define ls_readl(x) (*(volatile u32*)(x))
#define DEFAULT_DELAY_VARIABLE 10
#define DEFAULT_LOOP_VARIABLE 10000
#define SYNOP_PHY_LOOPBACK 1
/* Error Codes */
#define ESYNOPGMACNOERR 0
#define ESYNOPGMACNOMEM 1
#define ESYNOPGMACPHYERR 2
#define ESYNOPGMACBUSY 3
enum GmacRegisters
{
GmacConfig = 0x0000, /* Mac config Register */
GmacFrameFilter = 0x0004, /* Mac frame filtering controls */
GmacHashHigh = 0x0008, /* Multi-cast hash table high */
GmacHashLow = 0x000C, /* Multi-cast hash table low */
GmacGmiiAddr = 0x0010, /* GMII address Register(ext. Phy) */
GmacGmiiData = 0x0014, /* GMII data Register(ext. Phy) */
GmacFlowControl = 0x0018, /* Flow control Register */
GmacVlan = 0x001C, /* VLAN tag Register (IEEE 802.1Q) */
GmacVersion = 0x0020, /* GMAC Core Version Register */
GmacWakeupAddr = 0x0028, /* GMAC wake-up frame filter adrress reg */
GmacPmtCtrlStatus = 0x002C, /* PMT control and status register */
GmacInterruptStatus = 0x0038, /* Mac Interrupt ststus register */
GmacInterruptMask = 0x003C, /* Mac Interrupt Mask register */
GmacAddr0High = 0x0040, /* Mac address0 high Register */
GmacAddr0Low = 0x0044, /* Mac address0 low Register */
GmacAddr1High = 0x0048, /* Mac address1 high Register */
GmacAddr1Low = 0x004C, /* Mac address1 low Register */
GmacAddr2High = 0x0050, /* Mac address2 high Register */
GmacAddr2Low = 0x0054, /* Mac address2 low Register */
GmacAddr3High = 0x0058, /* Mac address3 high Register */
GmacAddr3Low = 0x005C, /* Mac address3 low Register */
GmacAddr4High = 0x0060, /* Mac address4 high Register */
GmacAddr4Low = 0x0064, /* Mac address4 low Register */
GmacAddr5High = 0x0068, /* Mac address5 high Register */
GmacAddr5Low = 0x006C, /* Mac address5 low Register */
GmacAddr6High = 0x0070, /* Mac address6 high Register */
GmacAddr6Low = 0x0074, /* Mac address6 low Register */
GmacAddr7High = 0x0078, /* Mac address7 high Register */
GmacAddr7Low = 0x007C, /* Mac address7 low Register */
GmacAddr8High = 0x0080, /* Mac address8 high Register */
GmacAddr8Low = 0x0084, /* Mac address8 low Register */
GmacAddr9High = 0x0088, /* Mac address9 high Register */
GmacAddr9Low = 0x008C, /* Mac address9 low Register */
GmacAddr10High = 0x0090, /* Mac address10 high Register */
GmacAddr10Low = 0x0094, /* Mac address10 low Register */
GmacAddr11High = 0x0098, /* Mac address11 high Register */
GmacAddr11Low = 0x009C, /* Mac address11 low Register */
GmacAddr12High = 0x00A0, /* Mac address12 high Register */
GmacAddr12Low = 0x00A4, /* Mac address12 low Register */
GmacAddr13High = 0x00A8, /* Mac address13 high Register */
GmacAddr13Low = 0x00AC, /* Mac address13 low Register */
GmacAddr14High = 0x00B0, /* Mac address14 high Register */
GmacAddr14Low = 0x00B4, /* Mac address14 low Register */
GmacAddr15High = 0x00B8, /* Mac address15 high Register */
GmacAddr15Low = 0x00BC, /* Mac address15 low Register */
/*Time Stamp Register Map*/
GmacTSControl = 0x0700, /* Controls the Timestamp update logic : only when IEEE 1588 time stamping is enabled in corekit */
GmacTSSubSecIncr = 0x0704, /* 8 bit value by which sub second register is incremented : only when IEEE 1588 time stamping without external timestamp input */
GmacTSHigh = 0x0708, /* 32 bit seconds(MS) : only when IEEE 1588 time stamping without external timestamp input */
GmacTSLow = 0x070C, /* 32 bit nano seconds(MS) : only when IEEE 1588 time stamping without external timestamp input */
GmacTSHighUpdate = 0x0710, /* 32 bit seconds(MS) to be written/added/subtracted : only when IEEE 1588 time stamping without external timestamp input */
GmacTSLowUpdate = 0x0714, /* 32 bit nano seconds(MS) to be writeen/added/subtracted : only when IEEE 1588 time stamping without external timestamp input */
GmacTSAddend = 0x0718, /* Used by Software to readjust the clock frequency linearly : only when IEEE 1588 time stamping without external timestamp input */
GmacTSTargetTimeHigh = 0x071C, /* 32 bit seconds(MS) to be compared with system time : only when IEEE 1588 time stamping without external timestamp input */
GmacTSTargetTimeLow = 0x0720, /* 32 bit nano seconds(MS) to be compared with system time : only when IEEE 1588 time stamping without external timestamp input */
GmacTSHighWord = 0x0724, /* Time Stamp Higher Word Register (Version 2 only); only lower 16 bits are valid */
//GmacTSHighWordUpdate = 0x072C, /* Time Stamp Higher Word Update Register (Version 2 only); only lower 16 bits are valid */
GmacTSStatus = 0x0728, /* Time Stamp Status Register */
};
/**********************************************************
* GMAC DMA registers
* For Pci based system address is BARx + GmaDmaBase
* For any other system translation is done accordingly
**********************************************************/
enum DmaRegisters
{
DmaBusMode = 0x0000, /* CSR0 - Bus Mode Register */
DmaTxPollDemand = 0x0004, /* CSR1 - Transmit Poll Demand Register */
DmaRxPollDemand = 0x0008, /* CSR2 - Receive Poll Demand Register */
DmaRxBaseAddr = 0x000C, /* CSR3 - Receive Descriptor list base address */
DmaTxBaseAddr = 0x0010, /* CSR4 - Transmit Descriptor list base address */
DmaStatus = 0x0014, /* CSR5 - Dma status Register */
DmaControl = 0x0018, /* CSR6 - Dma Operation Mode Register */
DmaInterrupt = 0x001C, /* CSR7 - Interrupt enable */
DmaMissedFr = 0x0020, /* CSR8 - Missed Frame & Buffer overflow Counter */
DmaTxCurrDesc = 0x0048, /* - Current host Tx Desc Register */
DmaRxCurrDesc = 0x004C, /* - Current host Rx Desc Register */
DmaTxCurrAddr = 0x0050, /* CSR20 - Current host transmit buffer address */
DmaRxCurrAddr = 0x0054, /* CSR21 - Current host receive buffer address */
};
enum GmacGmiiAddrReg
{
GmiiDevMask = 0x0000F800, /* (PA)GMII device address 15:11 RW 0x00 */
GmiiDevShift = 11,
GmiiRegMask = 0x000007C0, /* (GR)GMII register in selected Phy 10:6 RW 0x00 */
GmiiRegShift = 6,
GmiiCsrClkMask = 0x0000001C, /*CSR Clock bit Mask 4:2 */
GmiiCsrClk5 = 0x00000014, /* (CR)CSR Clock Range 250-300 MHz 4:2 RW 000 */
GmiiCsrClk4 = 0x00000010, /* 150-250 MHz */
GmiiCsrClk3 = 0x0000000C, /* 35-60 MHz */
GmiiCsrClk2 = 0x00000008, /* 20-35 MHz */
GmiiCsrClk1 = 0x00000004, /* 100-150 MHz */
GmiiCsrClk0 = 0x00000000, /* 60-100 MHz */
GmiiWrite = 0x00000002, /* (GW)Write to register 1 RW */
GmiiRead = 0x00000000, /* Read from register 0 */
GmiiBusy = 0x00000001, /* (GB)GMII interface is busy 0 RW 0 */
};
#endif /*_GMAC_H_*/

130
Targets/Bonito3a82h/dev/pwm_fan.c

@ -0,0 +1,130 @@
//cpu fan pwm1 output,pwm2 intput.
#include <stdio.h>
#include <pmon.h>
#define LS2H_PWM_REG_BASE 0xbbea0000 //2H 0x1fea0000
#define PWM_LOWBUF_OFFSET 0x4
#define PWM_FULLBUF_OFFSET 0x8
#define PWM_CTRL_OFFSET 0xc
#define PWM_CTRL_EN (1 << 0)
#define PWM_CTRL_CAPTE (1 << 8)
#define LS2H_GPIOCFG 0xbbd000c0 //2H gpiocfg
#define read_w(x) (*(volatile unsigned int*)(x))
#define write_w(x,val) (*(volatile unsigned int*)(x) = val)
//#define DEBUG
#ifdef DEBUG
#define dbg(format, arg...) printf(format, ## arg)
#else
#define dbg(format, arg...)
#endif
static int fan_speed(ac,av)
int ac;
char *av[];
{
unsigned int tmp, tmp1, tmp_speed, total_val = 0, i;
read_w(LS2H_GPIOCFG) |= ((0xf << 12) | (1 << 17));//pwm enable,pwm2 output
dbg("gpiocfg->%x\n", read_w(LS2H_GPIOCFG));
delay(0x400000);//wait for the pwm intput value valide.
for (i = 0;i < 20;i++) {
read_w(LS2H_PWM_REG_BASE + (0x10 * 2) + PWM_CTRL_OFFSET) |= (PWM_CTRL_CAPTE | PWM_CTRL_EN);
dbg("pwm2 ctrl->%x\n", read_w(LS2H_GPIOCFG));
speed_read:
tmp = read_w(LS2H_PWM_REG_BASE + (0x10 * 2) + PWM_LOWBUF_OFFSET);
dbg("tmp->%x\n", tmp);
tmp1 = read_w(LS2H_PWM_REG_BASE + (0x10 * 2) + PWM_FULLBUF_OFFSET);
dbg("tmp1->%x\n", tmp1);
if ((tmp > tmp1) || (tmp < 0x1000) || (tmp < 0x1000))
goto speed_read;
// tmp_speed = (1000000000 * 60)/((1000 / 125) * tmp1 * 2); //this code is overflow.
tmp_speed = (62500000 * 6)/(tmp1 / 10);
dbg("fan speed -> %d\n", tmp_speed);
total_val += tmp_speed;
}
dbg("total fan speed -> %d\n", total_val);
tmp_speed = total_val / 20;
if(ac == 1)
printf("fan speed -> %d\n", tmp_speed);
return tmp_speed;
}
static int fan_set(ac, av)
int ac;
char *av[];
{
unsigned int speed, tmp_speed, tmp_speed1, goal_speed, tmp_reg;
int i;
if (ac < 2) {
printf("parameter is error!\n");
return -1;
}
if (read_w(LS2H_PWM_REG_BASE + (0x10 * 1) + PWM_FULLBUF_OFFSET) == 0) {
read_w(LS2H_GPIOCFG) |= ((0xf << 12) | (1 << 17));//pwm enable
dbg("gpiocfg->%x\n", read_w(LS2H_GPIOCFG));
write_w(LS2H_PWM_REG_BASE + (0x10 * 1) + PWM_FULLBUF_OFFSET,0x1000);
write_w(LS2H_PWM_REG_BASE + (0x10 * 1) + PWM_LOWBUF_OFFSET,0x800);
write_w(LS2H_PWM_REG_BASE + (0x10 * 1) + PWM_CTRL_OFFSET,PWM_CTRL_EN);
}
goal_speed = atoi(av[1]);
printf("goal fan speed %d\n",goal_speed);
if ((goal_speed > 4700) && (goal_speed < 2200)) {
printf("goal speed can not complete!The fan speed is (2200 - 4600)\n");
return -2;
}
speed = fan_speed();
tmp_reg = read_w(LS2H_PWM_REG_BASE + (0x10 * 1) + PWM_LOWBUF_OFFSET);
if (goal_speed > speed){
for (i = tmp_reg;i > 0x80; i -= 0x40) {
dbg("value 0x%x\n",i);
write_w(LS2H_PWM_REG_BASE + (0x10 * 1) + PWM_LOWBUF_OFFSET, i);
speed = fan_speed();
if (speed > goal_speed) {
tmp_speed1 = speed - goal_speed;
dbg("tmp_speed1 %d tmp_speed %d\n",tmp_speed1,tmp_speed);
if(tmp_speed1 > tmp_speed)
write_w(LS2H_PWM_REG_BASE + (0x10 * 1) + PWM_LOWBUF_OFFSET, i + 0x40);
break;
}
tmp_speed = goal_speed - speed;
}
} else if (goal_speed < speed) {
for (i = tmp_reg;i < 0x1000; i += 0x40) {
dbg("2 value 0x%x\n",i);
write_w(LS2H_PWM_REG_BASE + (0x10 * 1) + PWM_LOWBUF_OFFSET, i);
speed = fan_speed();
if (speed < goal_speed) {
tmp_speed1 = goal_speed - speed;
dbg("2 tmp_speed1 %d tmp_speed %d\n",tmp_speed1,tmp_speed);
if(tmp_speed1 > tmp_speed)
write_w(LS2H_PWM_REG_BASE + (0x10 * 1) + PWM_LOWBUF_OFFSET, i - 0x40);
break;
}
tmp_speed = speed - goal_speed;
}
}
printf("ctual fan speed %d\n",fan_speed());
return 0;
}
static const Cmd Cmds[] =
{
{"Misc"},
{"fan_speed", "", 0, "3a2h fan speed test ", fan_speed, 1, 99, 0},
{"fan_set", "", 0, "3a2h set fan speed test ", fan_set, 1, 99, 0},
{0, 0}
};
static void init_cmd __P((void)) __attribute__ ((constructor));
void
init_cmd()
{
cmdlist_expand(Cmds, 1);
}

597
Targets/Bonito3a82h/dev/signal_test.c

@ -0,0 +1,597 @@
/* $Id: fan.c,v 1.1.1.1 2006/09/14 01:59:08 xqch Exp $ */
/*
* Copyright (c) 2001 Opsycon AB (www.opsycon.se)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Opsycon AB, Sweden.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/device.h>
#include <sys/queue.h>
#include <pmon.h>
#include "gmac.h"
#define read32(x) (*(volatile unsigned int *)(x))
#define read8(x) (*(volatile unsigned char *)(x))
unsigned char
cmd_usbtest(ac, av)
int ac;
char *av[];
{
unsigned int base = 0xbbe00000;
int port,test_mode;
if (ac != 3){
printf("Usage:usbtest <port > <T> \n");
printf("port0: 0\n");
printf("port1: 1\n");
printf("port2: 2\n");
printf("port3: 3\n");
printf("port4: 4\n");
printf("port5: 5\n");
printf("<T> 1: J_STATE\n");
printf("<T> 2: K_STATE\n");
printf("<T> 3: SE0_NAK\n");
printf("<T> 4: Packet\n");
printf("<T> 5: FORCE_ENABLE\n");
printf("For example:usbtest 1 1 \n");
return 0;
}
port = atoi(av[1]);
test_mode = atoi(av[2]);
read32(0xbbe00010) = 0x2;
switch (port) {
case 0:
read32(base | 0x54) = ((test_mode << 16) | 0x3084);
break;
case 1:
read32(base | 0x58) = ((test_mode << 16) | 0x3084);
break;
case 2:
read32(base | 0x5c) = ((test_mode << 16) | 0x3084);
break;
case 3:
read32(base | 0x60) = ((test_mode << 16) | 0x3084);
break;
case 4:
read32(base | 0x64) = ((test_mode << 16) | 0x3084);
break;
case 5:
read32(base | 0x68) = ((test_mode << 16) | 0x3084);
break;
default:
printf("the port number is error!\n");
break;
}
if (test_mode == 5)
read8(0xbBe00010) = 0x1;
return(1);
}
cmd_satatest(ac, av)
int ac;
char *av[];
{
unsigned int port, gen;
unsigned int base;
int test_mode;
if (ac != 4){
printf("Usage:satatest <port > <gen> <test_mode>\n");
printf("port0: 0\n");
printf("port1: 1\n");
printf("gen1: 1\n");
printf("gen2: 2\n");
printf("test_mode: 0x0 SSOP( Simultaneous switching outputs pattern)\n");
printf("test_mode: 0x1 HTDP( High transition density pattern) \n");
printf("test_mode: 0x2 LTDP( Low transition density pattern) \n");
printf("test_mode: 0x3 LFSCP( Low frequency spectral component pattern)\n");
printf("test_mode: 0x4 COMP( Composite pattern) \n");
printf("test_mode: 0x5 LBP( Lone bit pattern) \n");
printf("test_mode: 0x6 MFTP( Mid frequency test pattern)\n");
printf("test_mode: 0x7 HFTP( High frequency test pattern)\n");
printf("test_mode: 0x8 LFTP( Low frequency test pattern)\n");
return 0;
}
port = atoi(av[1]);
gen = atoi(av[2]);
test_mode = atoi(av[3]);
base = (0xbbe38000 + port * 0x100);
// printf(" -> 0x%x\n", (gen == 1 ? 0x0 : 0x9));
if (gen == 1)
read8(base | 0x12) = 0x0;
else if (gen == 2)
read8(base | 0x12) = 0x9;
read8(base | 0x10) = 0x1;
read32(0xbbe300f4) = port * 0x10000;
read32(0xbbe300a4) = (0x10000 | test_mode);
return(1);
}
unsigned char
cmd_pcietest(ac, av)
int ac;
char *av[];
{
unsigned int port, gen;
unsigned int base,test_mode;
unsigned int pcie_clock_source;
if (ac < 2){
printf("if test gen1:pcietest <gen1>\n");
printf("if test gen2:pcietest <gen2> <gen2_test_mode> \n");
printf("gen1: 1\n");
printf("gen2: 2\n");
printf("gen2_test_mode: 1 ->0xf052, -3.5db De-emphasis \n");
printf("gen2_test_mode: 2 ->0xf012, -6db De-emphasis \n");
printf("gen2_test_mode: 3 ->0xf452, -3.5db De-emphasis, modified compliance \n");
printf("gen2_test_mode: 4 ->0xf412, -6db De-emphasis, modified compliance \n");
printf("gen2_test_mode: 5 ->0xfc12, -6db De-emphasis, modified compliance, compliance \n");
printf("gen2_test_mode: 6 ->0xfc52, -3.5db De-emphasis, modified compliance, compliance SOS \n");
printf("For example:pcietest 2 1 \n");
return 0;
}
gen = atoi(av[1]);
if (gen == 2) {
test_mode = atoi(av[2]);
read32(0xb811407c) = 0x533c42;// the low 4 bit must be 2.
}
base = 0xb8110000;
read32(base | 0x480c) = 0x2040f;
for (port = 0;port < 4;port++) {
read8(base | (port * 0x100) | 0x11) = 0x21;
read8(base | (port * 0x100) | 0x10) = 0xb;
}
if (gen == 2) {
for (port = 0;port < 4;port++)
read8(base | (port * 0x100) | 0x12) = 0xa;
}
read32(base | 0x8000) = 0xff204c;
if (gen == 0x1) {
read32(base | 0x40a0) = 0xfc51;
} else if (gen == 0x2){
switch (test_mode) {
case 1:
read32(base | 0x40a0) = 0xf052;
break;
case 2:
read32(base | 0x40a0) = 0xf012;
break;
case 3:
read32(base | 0x40a0) = 0xf452;
break;
case 4:
read32(base | 0x40a0) = 0xf412;
break;
case 5:
read32(base | 0x40a0) = 0xfc52;
break;
case 6:
read32(base | 0x40a0) = 0xfc12;
break;
default:
printf("The test mode is error!\n");
break;
}
printf("test_mode = 0x%lx\n",test_mode);
}
read32(base | 0x4708) = 0x7028004;
return(1);
}
#define u64 unsigned long
#define u32 unsigned int
#define u16 unsigned short
#define u8 unsigned char
#define GMAC0_MAC_REG_ADDR 0xffffffffbbe10000
#define GMAC0_DMA_REG_ADDR 0xffffffffbbe11000
#define GMAC1_MAC_REG_ADDR 0xffffffffbbe18000
#define GMAC1_DMA_REG_ADDR 0xffffffffbbe19000
#define PHY_REG20 20
#define PHY_REG0 0
#define PHY_REG16 16
#define PHY_LOOPBACK (1 << 14)
#define PHY_SPEED0 (1 << 13)
#define PHY_DUMPLEX_FULL (1 << 8)
#define PHY_SPEED1 (1 << 6)
#define PHY_MODE_100M (PHY_SPEED0 & ~PHY_SPEED1)
static u32 gmac_read(u64 base, u32 reg)
{
u64 addr;
u32 data;
addr = base + (u64)reg;
data = ls_readl(addr);
return data;
}
static void gmac_write(u64 base, u32 reg, u32 data)
{
u64 addr;
addr = base + (u64)reg;
ls_readl(addr) = data;
return;
}
static signed int gmac_phy_read(u64 base,u32 PhyBase, u32 reg, u16 * data )
{
u32 addr;
u32 loop_variable;
addr = ((PhyBase << GmiiDevShift) & GmiiDevMask) | ((reg << GmiiRegShift) & GmiiRegMask) | GmiiCsrClk3;
addr = addr | GmiiBusy ;
gmac_write(base,GmacGmiiAddr,addr);
for(loop_variable = 0; loop_variable < DEFAULT_LOOP_VARIABLE; loop_variable++){
if (!(gmac_read(base,GmacGmiiAddr) & GmiiBusy)){
break;
}
int i = DEFAULT_DELAY_VARIABLE;
while (i--);
}
if(loop_variable < DEFAULT_LOOP_VARIABLE)
* data = (u16)(gmac_read(base,GmacGmiiData) & 0xFFFF);
else{
tgt_printf("\rError::: PHY not responding Busy bit didnot get cleared !!!!!!\n");
return -ESYNOPGMACPHYERR;
}
return -ESYNOPGMACNOERR;
}
static signed int gmac_phy_write(u64 base, u32 PhyBase, u32 reg, u16 data)
{
u32 addr;
u32 loop_variable;
gmac_write(base,GmacGmiiData,data);
addr = ((PhyBase << GmiiDevShift) & GmiiDevMask) | ((reg << GmiiRegShift) & GmiiRegMask) | GmiiWrite | GmiiCsrClk3;
addr = addr | GmiiBusy ;
gmac_write(base,GmacGmiiAddr,addr);
for(loop_variable = 0; loop_variable < DEFAULT_LOOP_VARIABLE; loop_variable++){
if (!(gmac_read(base,GmacGmiiAddr) & GmiiBusy)){
break;
}
int i = DEFAULT_DELAY_VARIABLE;
while (i--);
}
if(loop_variable < DEFAULT_LOOP_VARIABLE){
return -ESYNOPGMACNOERR;
}
else{
tgt_printf("\rError::: PHY not responding Busy bit didnot get cleared !!!!!!\n");
return -ESYNOPGMACPHYERR;
}
}
unsigned char
cmd_lantest(ac, av)
int ac;
char *av[];
{
unsigned int base,test_mode,id;
unsigned short data;
u64 mac_base;
if (ac < 2){
printf("lantest: lantest <testmode>\n");
printf("testmode1: 1\n");
printf("testmode2: 2\n");
printf("testmode3: 3\n");
printf("testmode4: 4\n");
printf("For example:lantest 1 \n");
return 0;
}
test_mode = atoi(av[1]);
for (id = 0;id < 2;id++) {
if (id == 0)
mac_base = GMAC0_MAC_REG_ADDR;
else if (id == 1)
mac_base = GMAC1_MAC_REG_ADDR;
switch (test_mode) {
case 1:
gmac_phy_read(mac_base,16,9,&data);
printf("phy 9 register value = 0x%lx\n",data);
gmac_phy_read(mac_base,16,10,&data);
printf("phy 10 register value = 0x%lx\n",data);
gmac_phy_write(mac_base,16,9,(1 << 13));
gmac_phy_read(mac_base,16,9,&data);
printf("changed phy 9 register value = 0x%lx\n",data);
gmac_phy_read(mac_base,16,10,&data);
printf("changed phy 10 register value = 0x%lx\n",data);
break;
case 2:
gmac_phy_read(mac_base,16,9,&data);
printf("phy 9 register value = 0x%lx\n",data);
gmac_phy_read(mac_base,16,10,&data);
printf("phy 10 register value = 0x%lx\n",data);
gmac_phy_write(mac_base,16,9, (0x2 << 13));
gmac_phy_read(mac_base,16,9,&data);
printf("changed phy 9 register value = 0x%lx\n",data);
gmac_phy_read(mac_base,16,10,&data);
printf("changed phy 10 register value = 0x%lx\n",data);
break;
case 3:
gmac_phy_read(mac_base,16,9,&data);
printf("phy 9 register value = 0x%lx\n",data);
gmac_phy_read(mac_base,16,10,&data);
printf("phy 10 register value = 0x%lx\n",data);
gmac_phy_write(mac_base,16,9,(0x3 << 13));
gmac_phy_read(mac_base,16,9,&data);
printf("changed phy 9 register value = 0x%lx\n",data);
gmac_phy_read(mac_base,16,10,&data);
printf("changed phy 10 register value = 0x%lx\n",data);
break;
case 4:
gmac_phy_read(mac_base,16,9,&data);
printf("phy 9 register value = 0x%lx\n",data);
gmac_phy_read(mac_base,16,10,&data);
printf("phy 10 register value = 0x%lx\n",data);
gmac_phy_write(mac_base,16,9, (0x4 << 13));
gmac_phy_read(mac_base,16,9,&data);
printf("changed phy 9 register value = 0x%lx\n",data);
gmac_phy_read(mac_base,16,10,&data);
printf("changed phy 10 register value = 0x%lx\n",data);
break;
default:
printf("Test mode is error!\n");
break;
}
}
return(1);
}
int gmac_w18(void)
{
unsigned char offset;
unsigned char id;
unsigned long long mac_base;
unsigned short data;
for (id = 0;id < 2;id++) {
if (id == 0) {
mac_base = GMAC0_MAC_REG_ADDR;
} else if (id == 1){
mac_base = GMAC1_MAC_REG_ADDR;
}
/*
gmac_phy_read(mac_base,16,16,&data);
data |= 0x300;
gmac_phy_write(mac_base,16,16,data);
gmac_phy_read(mac_base,16,16,&data);
*/
gmac_phy_read(mac_base,16,19,&data);
data = 0x10;
gmac_phy_write(mac_base,16,18,data);
gmac_phy_read(mac_base,16,18,&data);
gmac_phy_read(mac_base,16,19,&data);
gmac_phy_read(mac_base,16,24,&data);
data = data | 0x800;
gmac_phy_write(mac_base,16,24,data);
gmac_phy_read(mac_base,16,27,&data);
data = data & (~(1 << 10));
gmac_phy_write(mac_base,16,27,data);
gmac_phy_read(mac_base,16,0,&data);
data = data | 0x8000;
gmac_phy_write(mac_base,16,0,data);
}
return 0;
}
int gmac_w(ac, av)
int ac;
char *av[];
{
unsigned char offset;
unsigned char id;
unsigned long long mac_base;
unsigned short data;
if (ac == 3) {
data = 0x1e1;
printf("data 0x%lx\n",data);
for (id = 0;id < 2;id++) {
if (id == 0) {
mac_base = GMAC0_MAC_REG_ADDR;
gmac_phy_write(mac_base,16,4,data);
gmac_phy_read(mac_base,16,4,&data);
printf("gmac0 4 0x%lx\n",data);
gmac_phy_read(mac_base,16,0x00,&data);
gmac_phy_write(mac_base,16,0x00,data);
} else if (id == 1){
data = 0xffff;
mac_base = GMAC1_MAC_REG_ADDR;
gmac_phy_write(mac_base,16,4,data);
gmac_phy_read(mac_base,16,4,&data);
printf("gmac1 4 0x%lx\n",data);
gmac_phy_read(mac_base,16,0x00,&data);
data = data | 0x8000;
gmac_phy_write(mac_base,16,0x00,data);
}
}
}
if (ac == 1) {
printf("data 0x%lx\n",data);
for (id = 0;id < 2;id++) {
if (id == 0) {
data = 0x10;
mac_base = GMAC0_MAC_REG_ADDR;
gmac_phy_write(mac_base,16,18,data);
gmac_phy_read(mac_base,16,18,&data);
printf("gmac0 4 0x%lx\n",data);
gmac_phy_read(mac_base,16,0,&data);
data = data | 0x8000;
gmac_phy_write(mac_base,16,0,data);
} else if (id == 1){
data = 0x10;
mac_base = GMAC1_MAC_REG_ADDR;
gmac_phy_write(mac_base,16,18,data);
gmac_phy_read(mac_base,16,18,&data);
printf("gmac1 4 0x%lx\n",data);
gmac_phy_read(mac_base,16,0,&data);
data = data | 0x8000;
gmac_phy_write(mac_base,16,0,data);
}
}
}
if (ac == 2) {
for (id = 0;id < 2;id++) {
if (id == 0)
mac_base = GMAC0_MAC_REG_ADDR;
else if (id == 1)
mac_base = GMAC1_MAC_REG_ADDR;
data = 0x40;
gmac_phy_write(mac_base,16,18,data);
gmac_phy_read(mac_base,16,0x00,&data);
data = data | 0x8000;
gmac_phy_write(mac_base,16,0x00,data);
}
}
return 0;
}
int gmacphy_write(ac, av)
int ac;
char *av[];
{
unsigned char offset;
if (ac != 3) {
printf("the parameters is error!\n");
printf("gmacphy_write <offset> <data>\n");
return -1;
}
offset = atoi(av[1]);
unsigned char id;
unsigned long long mac_base;
unsigned short data;
data = atoi(av[2]);
printf("data 0x%lx\n",data);
for (id = 0;id < 2;id++) {
if (id == 0)
mac_base = GMAC0_MAC_REG_ADDR;
else if (id == 1)
mac_base = GMAC1_MAC_REG_ADDR;
gmac_phy_write(mac_base,16,offset,data);
}
return 0;
}
int gmacphy_read(ac, av)
int ac;
char *av[];
{
unsigned char offset;
unsigned char id;
unsigned long long mac_base;
unsigned short data;
if (ac == 1) {
for (id = 0;id < 2;id++) {
if (id == 0)
mac_base = GMAC0_MAC_REG_ADDR;
else if (id == 1)
mac_base = GMAC1_MAC_REG_ADDR;
for (offset = 0;offset < 32;offset++) {
gmac_phy_read(mac_base,16,offset,&data);
printf("gmac%d reg(%d) %lx\n",id,offset,data);
}
}
return -1;
}
offset = atoi(av[1]);
for (id = 0;id < 2;id++) {
if (id == 0)
mac_base = GMAC0_MAC_REG_ADDR;
else if (id == 1)
mac_base = GMAC1_MAC_REG_ADDR;
gmac_phy_read(mac_base,16,offset,&data);
printf("gmac%d reg(%d) %lx\n",id,offset,data);
}
return 0;
}
/*
*
* Command table registration
* ==========================
*/
static const Cmd Cmds[] =
{
{"Misc"},
{"usbtest", "", 0, "3a2h usbtest : usbtest ", cmd_usbtest, 1, 99, 0},
{"gmacphy_read", "", 0, "read gmac phy reg", gmacphy_read, 1, 99, 0},
{"gmacphy_write", "", 0, "read gmac phy reg", gmacphy_write, 1, 99, 0},
{"gmac_w", "", 0, "read gmac phy reg", gmac_w, 1, 99, 0},
{"lantest", "", 0, "3a2h lantest : lantest ", cmd_lantest, 1, 99, 0},
{"pcietest", "", 0, "3a2h pcietest: pcietest ", cmd_pcietest, 1, 99, 0},
{"satatest", "", 0, "3a2h satatest: satatest ", cmd_satatest, 1, 99, 0},
{0, 0}
};
static void init_cmd __P((void)) __attribute__ ((constructor));
void
init_cmd()
{
cmdlist_expand(Cmds, 1);
}

21
Targets/Bonito3a82h/pci/ls2h_pci.c

@ -410,6 +410,24 @@ static void en_ref_clock(void)
| LS2H_CLK_CTRL3_BIT_PEREF_EN(3));
ls2h_writel(data, LS2H_CLK_CTRL3_REG);
}
static void ls2h_pcie_reset(void)
{
unsigned int data;
delay(100);
/* 2H PCIE sleep */
data = ls2h_readw(LS2H_CHIP_CFG1_REG);
data |= (1 << 18);
ls2h_writew(data, LS2H_CHIP_CFG1_REG);
delay(100);
/* 2H PCIE wakeup */
data = ls2h_readw(LS2H_CHIP_CFG1_REG);
data &= ~(1 << 18);
data |= (1 << 17);
ls2h_writew(data, LS2H_CHIP_CFG1_REG);
delay(100);
}
static int is_rc_mode(void)
{
@ -455,12 +473,11 @@ int ls2h_pcibios_init(void)
{
tgt_printf("arch_initcall:pcibios_init\n");
en_ref_clock();
ls2h_pcie_reset();
if (!is_rc_mode())
return 0;
ls2h_pcie_port_init(0);
#ifdef PCIE_GRAPHIC_CARD
if ( is_x4_mode() || is_pcie_vga_card() )
#else

14
pmon/dev/flash.c

@ -42,7 +42,7 @@
#include <flash.h>
#include <dev/pflash_tgt.h>
#ifdef LOONGSON_3A84W
#ifdef defined(LOONGSON_3A84W) || defined(LOONGSON_3A2H)
#include <Targets/Bonito3a84w/dev/spi_w.c>
#endif
@ -260,7 +260,7 @@ fl_find_map(void *base)
struct fl_device *
fl_devident(void *base, struct fl_map **m)
{
#ifdef LOONGSON_3A84W
#ifdef defined(LOONGSON_3A84W) || defined(LOONGSON_3A2H)
if (selected_lpc_spi()) {
return spi_fl_devident(base,m);
} else {
@ -335,7 +335,7 @@ fl_devident(void *base, struct fl_map **m)
outb((map->fl_map_base), 0x00);
return((struct fl_device *)NULL);
#ifdef LOONGSON_3A84W
#ifdef defined(LOONGSON_3A84W) || defined(LOONGSON_3A2H)
}
#endif
}
@ -348,7 +348,7 @@ fl_devident(void *base, struct fl_map **m)
int
fl_erase_device(void *base, int size, int verbose)
{
#ifdef LOONGSON_3A84W
#ifdef defined(LOONGSON_3A84W) || defined(LOONGSON_3A2H)
if (selected_lpc_spi()) {
return spi_fl_erase_device(base, size, verbose);
} else {
@ -485,7 +485,7 @@ fl_erase_device(void *base, int size, int verbose)
tgt_flashwrite_disable();
fl_write_protect_lock(map, dev, 0);/* Enable write protection of SST49LF040B/SST49LF008A */
return(ok);
#ifdef LOONGSON_3A84W
#ifdef defined(LOONGSON_3A84W) || defined(LOONGSON_3A2H)
}
#endif
}
@ -559,7 +559,7 @@ int fl_program(void *fl_base, void *data_base, int data_size, int verbose)
int
fl_program_device(void *fl_base, void *data_base, int data_size, int verbose)
{
#ifdef LOONGSON_3A84W
#ifdef defined(LOONGSON_3A84W) || defined(LOONGSON_3A2H)
if (selected_lpc_spi()) {
return spi_fl_program_device(fl_base, data_base, data_size, verbose);
} else {
@ -634,7 +634,7 @@ fl_program_device(void *fl_base, void *data_base, int data_size, int verbose)
tgt_flashwrite_disable();
fl_write_protect_lock(map, dev, 0);/* Enable write protection of SST49LF040B/SST49LF008A */
return(ok);
#ifdef LOONGSON_3A84W
#ifdef defined(LOONGSON_3A84W) || defined(LOONGSON_3A2H)
}
#endif
}

2
sys/dev/gmac/synopGMAC_Dev.h

@ -43,7 +43,7 @@ typedef unsigned long dma_addr_t;
*/
/*SynopGMAC can support up to 32 phys*/
#if defined(LOONGSON_2G5536)||defined(LOONGSON_2G1A) || defined(LOONGSON_2F1A)
#if defined(LOONGSON_2G5536)||defined(LOONGSON_2G1A) || defined(LOONGSON_2F1A) || (defined(LOONGSON_3A2H) && defined(LOONGSON_3A8))
#define DEFAULT_PHY_BASE PHY16
#else
#define DEFAULT_PHY_BASE PHY0 //We use First Phy

7
sys/dev/gmac/synopGMAC_network_interface.c

@ -1975,7 +1975,7 @@ void set_phy_manu(synopGMACdevice * gmacdev)
}
#endif
#if defined(LOONGSON_2G1A) || defined(LOONGSON_2F1A)
#if defined(LOONGSON_2G1A) || defined(LOONGSON_2F1A) || (defined(LOONGSON_3A2H) && defined(LOONGSON_3A8))
static int rtl88e1111_config_init(synopGMACdevice *gmacdev)
{
int retval, err;
@ -1994,7 +1994,7 @@ static int rtl88e1111_config_init(synopGMACdevice *gmacdev)
}
#endif
#if defined(LOONGSON_2G1A) || defined(LOONGSON_2F1A)
#if defined(LOONGSON_2G1A) || defined(LOONGSON_2F1A) || (defined(LOONGSON_3A2H) && defined(LOONGSON_3A8))
int init_phy(synopGMACdevice *gmacdev)
#else
int init_phy(struct synopGMACdevice *gmacdev)
@ -2013,6 +2013,9 @@ int init_phy(struct synopGMACdevice *gmacdev)
retval = rtl8211_config_init(gmacdev);
return retval;
}
#elif (defined(LOONGSON_3A2H) && defined(LOONGSON_3A8))
rtl88e1111_config_init(gmacdev);
return 0;
#else
retval = rtl8211_config_init(gmacdev);
return retval;

Loading…
Cancel
Save