- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# /space/home/slher/rel/Beken/v6_4_5/macsw/plf/refip/src/driver/la/la.c

Go to the documentation of this file.

    00001
    00019 /*
    00020  * INCLUDE FILES
    00021  ****************************************************************************************
    00022  */
    00023 #include <string.h>
    00024
    00025 #include "rwnx_config.h"
    00026 #include "dbg_assert.h"
    00027 #include "boot.h"
    00028
    00029 #include "rxl_cntrl.h"
    00030 #include "txl_cntrl.h"
    00031
    00032 #include "reg_la.h"
    00033 #include "reg_mac_core.h"
    00034 #include "reg_sysctrl.h"
    00035 #include "dma.h"
    00036 #include "la.h"
    00037 #include "la_shared.h"
    00038 #include "la_mem.h"
    00039
    00040 #include "dbg.h"
    00041 #include "co_utils.h"
    00042
    00043
    00044 /*
    00045  * FUNCTIONS DEFINITIONS
    00046  ****************************************************************************************
    00047  */
    00048 void la_get_conf(struct la_conf_tag *conf)
    00049 {
    00050     int i = 0;
    00051
    00052     conf->conf[i++] = la_sampling_mask0_get();
    00053     conf->conf[i++] = la_sampling_mask1_get();
    00054     conf->conf[i++] = la_sampling_mask2_get();
    00055     conf->conf[i++] = la_trigger_mask0_get();
    00056     conf->conf[i++] = la_trigger_mask1_get();
    00057     conf->conf[i++] = la_trigger_mask2_get();
    00058     conf->conf[i++] = la_trigger_value0_get();
    00059     conf->conf[i++] = la_trigger_value1_get();
    00060     conf->conf[i++] = la_trigger_value2_get();
    00061     conf->conf[i++] = la_version_get();
    00062
    00063     conf->trace_len = (la_writeaddr_getf() + 1) * sizeof_b(struct la_mem_format);
    00064     conf->diag_conf = sysctrl_diag_conf1_get();
    00065 }
    00066
    00085 static void la_dump_trace_timestamp_and_stop(void)
    00086 {
    00087     uint32_t conf[2];
    00088     uint32_t mask[4];
    00089
    00090     if ((la_version_get() & LA_LA_VERSION_MASK) < 0x050000)
    00091     {
    00092         la_stop();
    00093         return;
    00094     }
    00095
    00096     // Mask all LA signals
    00097     mask[0] = la_sampling_mask0_get();
    00098     la_sampling_mask0_set(0);
    00099     mask[1] = la_sampling_mask1_get();
    00100     la_sampling_mask1_set(0);
    00101     mask[2] = la_sampling_mask2_get();
    00102     la_sampling_mask2_set(0);
    00103     mask[3] = la_sampling_mask3_get();
    00104     la_sampling_mask3_set(0);
    00105
    00106     // Force Software diags on diag0/1 and diag4/5 banks
    00107     conf[0] = sysctrl_diag_conf0_get();
    00108     sysctrl_diag_conf0_pack(0x1f, 1, 0x1e, 1);
    00109     conf[1] = sysctrl_diag_conf2_get();
    00110     sysctrl_diag_conf2_pack(0x1f, 1, 0x1e, 1);
    00111
    00112     // Trace FW trace counter via SW diags
    00113     nxmac_sw_clear_profiling_clear(0xFFFFFFFF);
    00114     la_sampling_mask0_set(0xFFFFFFFF);
    00115     la_sampling_mask2_set(0xFFFFFFFF);
    00116     nxmac_sw_set_profiling_set(hal_machw_time());
    00117     nxmac_sw_clear_profiling_clear(0xFFFFFFFF);
    00118
    00119     // Stop LA
    00120     la_stop();
    00121
    00122     // restore LA config
    00123     sysctrl_diag_conf0_set(conf[0]);
    00124     sysctrl_diag_conf2_set(conf[1]);
    00125     la_sampling_mask0_set(mask[0]);
    00126     la_sampling_mask1_set(mask[1]);
    00127     la_sampling_mask2_set(mask[2]);
    00128     la_sampling_mask3_set(mask[3]);
    00129 }
    00130
    00131 void la_dump_trace(struct dbg_debug_dump_tag *dbg_dump)
    00132 {
    00133     uint32_t dst = CPU2HW(&dbg_dump->la_mem[0]);
    00134     struct dma_desc *dma_desc = (struct dma_desc *) &(la_shared_env.dma_desc);
    00135     int remaining, curr_line;
    00136
    00137     la_dump_trace_timestamp_and_stop();
    00138     remaining = la_writeaddr_getf() + 1;
    00139     curr_line = (la_firstsample_get() + 1) % LA_MEM_LINE_COUNT;
    00140
    00141     while (remaining > 0)
    00142     {
    00143         int i;
    00144         int line_count = LA_SHARED_LINE_COUNT;
    00145
    00146         if (remaining <= line_count)
    00147             line_count = remaining;
    00148
    00149         for (i = 0; i < line_count; i++)
    00150         {
    00151             la_shared_env.la_buf[i] = la_mem_mac[curr_line];
    00152
    00153             curr_line = (curr_line + 1) % LA_MEM_LINE_COUNT;
    00154         }
    00155         dma_desc->src = CPU2HW(la_shared_env.la_buf);
    00156
    00157         // Only one DMA transfer will be needed to send the complete MSG.
    00158         dma_desc->dest = dst;
    00159         dma_desc->length = line_count * sizeof_b(struct la_mem_format);
    00160         dma_desc->ctrl = (IPC_DMA_LLI_IRQ_EN |
    00161                           (IPC_DMA_LLI_DBG_DUMP << IPC_DMA_LLI_IRQ_POS));
    00162
    00163         // Push the DMA descriptor in the DMA engine
    00164         dma_push(dma_desc, dma_desc, IPC_DMA_CHANNEL_CTRL_RX);
    00165
    00166         // Poll for the DMA to be finished
    00167         dma_lli_poll(IPC_DMA_LLI_DBG_DUMP + DMA_LLI_IRQ_LSB);
    00168
    00169         // acknowledge the interrupt
    00170         dma_int_ack_clear(CO_BIT(IPC_DMA_LLI_DBG_DUMP + DMA_LLI_IRQ_LSB));
    00171
    00172         // Update the DMA transfer parameters
    00173         remaining -= line_count;
    00174         dst += dma_desc->length;
    00175     }
    00176 }
    00177
    00178 void la_init(void)
    00179 {
    00180     if ((la_version_get() & 0xFFFFFF) < 0x50000)
    00181     {
    00182         // Set the sampling mask
    00183         // SW Traces
    00184         la_sampling_mask0_set(0xFFFFFFFF);
    00185         // HW Traces
    00186         la_sampling_mask1_set(0xFFFFFFFF);
    00187         // MACPHY Traces
    00188         la_sampling_mask2_set(0x300300FF);
    00189     }
    00190     else
    00191     {
    00192         // Set the sampling mask
    00193         // SW Traces
    00194         la_sampling_mask0_set(0x0000CFFF);
    00195         // HW Traces
    00196         la_sampling_mask1_set(0xFFFFFFFF);
    00197         // MACPHY Traces
    00198         la_sampling_mask2_set(0xFFFFFFFF);
    00199         // MACPHY Traces
    00200         la_sampling_mask3_set(0xFFFFFFFF);
    00201     }
    00202     // Set trigger level
    00203     la_trigger_point_set(0x100);
    00204
    00205     // Start the logic analyzer
    00206     la_start();
    00207 }
    00208
    00209 void la_start(void)
    00210 {
    00211     // Start the logic analyzer
    00212     la_cntrl_set(LA_START_BIT);
    00213 }
    00214
    00215 void la_stop(void)
    00216 {
    00217     // Stop the logic analyzer
    00218     la_cntrl_set(LA_STOP_BIT);
    00219 }
    00220
    00222