分支自 DSP/ADSP21569/DSP-21569

wanglei
2024-03-27 ec21e6d7b11751cba2501c690d0e16fcb0581d3c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*********************************************************************************
Copyright(c) 2019 Analog Devices, Inc. All Rights Reserved.
This software is proprietary and confidential. By using this software you agree
to the terms of the associated Analog Devices License Agreement.
*********************************************************************************/
 
/*****************************************************************************
 * ddr_sweep.h
 *****************************************************************************/
#ifndef DDR_SWEEP_H_
#define DDR_SWEEP_H_
 
#include <stdio.h>
#include <stdbool.h>
#include <sys/platform.h>
#include <stdlib.h>
#include <stdbool.h>
#include <ctype.h>
#include <stdint.h>
 
 
 
//#define __DEBUG_FILE__  /* output is directed to file __DEBUG_FILE_NAME__ */
#define __DEBUG_UART__  /* output is directed to the UART */
//#define __DEBUG_VIEW__  /* output is directed to the view console window */
 
#define DMC0_START_ADDRESS 0x80000000
 
 
 
/*************************************************************************************************************************
                                    Enum definitions
**************************************************************************************************************************/
//Use these to specifiy whether core/DMA access is required (e.g. for sweep test)
typedef enum ACCESS_TYPE
{
    CORE_ACCESS,
    DMA_ACCESS
} ATYPE;
 
//Use these to specify the word size (8/16/32/64 bits) requied e.g. for sweep test
typedef enum WORD_SIZE
{
    WORD_SIZE_8BITS  =1,
    WORD_SIZE_16BITS =2,
    WORD_SIZE_32BITS =4,
    WORD_SIZE_64BITS =8,
    WORD_SIZE_128BITS =16,
    WORD_SIZE_256BYTES = 32
} WSIZE;
 
//Use these to specify the data pattern in the sweep test
typedef enum PATTERN_TPYE
{
    ALL_ZEROS,
    ALL_ONES,
    ALL_A,
    ALL_5,
    ALL_BITS_TOGGLING,
    INCREMENTAL_VALUES,
    RANDOM_VALUES
 
} PATTERN;
 
//Use these to specify the memory type in the sweep test
enum MEM_TEST_TYPE
{
    MEMTEST_L1,
    MEMTEST_L2,
    MEMTEST_DDR2,
    MEMTEST_DDR3,
    MEMTEST_LPDDR,
};
 
#define BUFF_SIZE 256
 
/*************************************************************************************************************************
                                    MACROs
************************************************************************************************************************/
//This macro can be used to configure an MDMA stream by providing the source and destination DMA channel details
#define MDMA_CONFIG(S_MDMA_CHANNEL,S_CFG, S_ADDRSTART, S_MOD, S_COUNT,D_MDMA_CHANNEL,D_CFG, D_ADDRSTART, D_MOD, D_COUNT)\
        *pREG_DMA##S_MDMA_CHANNEL##_CFG = S_CFG;\
        *pREG_DMA##S_MDMA_CHANNEL##_ADDRSTART = S_ADDRSTART;\
        *pREG_DMA##S_MDMA_CHANNEL##_XCNT = S_COUNT;\
        *pREG_DMA##S_MDMA_CHANNEL##_XMOD = S_MOD;\
        *pREG_DMA##D_MDMA_CHANNEL##_CFG = D_CFG;\
        *pREG_DMA##D_MDMA_CHANNEL##_ADDRSTART = D_ADDRSTART;\
        *pREG_DMA##D_MDMA_CHANNEL##_XCNT = D_COUNT;\
        *pREG_DMA##D_MDMA_CHANNEL##_XMOD = D_MOD;\
        *pREG_DMA##D_MDMA_CHANNEL##_BWMCNT=0x7FFFFFFF;\
        *pREG_DMA##D_MDMA_CHANNEL##_CFG |= 0x1;\
        *pREG_DMA##S_MDMA_CHANNEL##_CFG |= 0x1;
 
//Macro to wait for DMA done
#define WAIT_FOR_DMADONE(DMA_CHANNEL)\
        while(!(*pREG_DMA##DMA_CHANNEL##_STAT & ENUM_DMA_STAT_IRQDONE));
 
//Macro to disable MDMA channels
#define DISABLE_MDMA(S_MDMA_CHANNEL, D_MDMA_CHANNEL)\
        *pREG_DMA##S_MDMA_CHANNEL##_CFG = 0;\
        *pREG_DMA##D_MDMA_CHANNEL##_CFG = 0;
 
 
 
 
/*************************************************************************************************************************
                                    Function Declarations
**************************************************************************************************************************/
uint32_t Memory_Sweep_Test_8Bits(uint8_t* uiMUTStartAdd, uint32_t uiCount, uint32_t uiAccessType, uint32_t uiDataPattern, uint8_t* uiSrcBuffAdd, uint8_t* uiDestBuffAdd, uint32_t uiBuffSize);
uint32_t Memory_Sweep_Test_16Bits(uint16_t* uiMUTStartAdd, uint32_t uiCount, uint32_t uiAccessType, uint32_t uiDataPattern, uint16_t* uiSrcBuffAdd, uint16_t* uiDestBuffAdd, uint32_t uiBuffSize);
uint32_t Memory_Sweep_Test_32Bits(uint32_t* uiMUTStartAdd, uint32_t uiCount, uint32_t uiAccessType, uint32_t uiDataPattern, uint32_t* uiSrcBuffAdd, uint32_t* uiDestBuffAdd, uint32_t uiBuffSize);
uint32_t Memory_Sweep_Test_64Bits(uint64_t* uiMUTStartAdd, uint32_t uiCount, uint32_t uiAccessType, uint32_t uiDataPattern, uint64_t* uiSrcBuffAdd, uint64_t* uiDestBuffAdd, uint32_t uiBuffSize);
uint32_t Memory_Sweep_Test(uint32_t uiMUTStartAdd, uint32_t uiCount);
 
 
#endif /* DDR_SWEEP_H_ */