source: rtems/c/src/lib/libbsp/arm/tms570/hwinit/tms570_selftest_par_std.c @ b2ed712

Last change on this file since b2ed712 was 29430a3, checked in by Pavel Pisa <pisa@…>, on Sep 22, 2016 at 7:50:59 AM

arm/tms570: include hardware initialization and selftest based on Ti HalCoGen? generated files.

The configuration is specific for TMS570LS3137 based HDK.
Pins configuration can be easily changed in

rtems/c/src/lib/libbsp/arm/tms570/hwinit/init_pinmux.c

file.

The list tms570_selftest_par_list in the file

rtems/c/src/lib/libbsp/arm/tms570/hwinit/bspstarthooks-hwinit.c

specifies peripherals which health status is examined
by parity self-test at BSP start-up. It can be easily
modified for other TMS570 family members variants same
as the selection of other tests in bspstarthooks-hwinit.c.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/**
2 * @file tms570_selftest_par_std.c
3 *
4 * @ingroup tms570
5 *
6 * @brief Generic parity based protection logic check applicable to HETx, HTUx, ADC, DMA and VIM.
7 */
8/*
9 * Copyright (c) 2016 Pavel Pisa <pisa@cmp.felk.cvut.cz>
10 *
11 * Czech Technical University in Prague
12 * Zikova 1903/4
13 * 166 36 Praha 6
14 * Czech Republic
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 *
20 * Algorithms are based on Ti manuals and Ti HalCoGen generated
21 * code.
22 */
23
24#include <stdint.h>
25#include <stddef.h>
26#include <bsp/tms570.h>
27#include "tms570_selftest.h"
28#include "tms570_selftest_parity.h"
29
30/**
31 * @brief run test to check that parity protection works for modules with common setup structure.
32 *
33 * @param[in] desc module registers addresses end ESM channels descriptor
34 *
35 * @return Void, in the case of error invokes bsp_selftest_fail_notification()
36 *
37 * The descriptor provides address of the module registers and address
38 * of internal RAM memory and corresponding parity area test access window.
39 * This test function is usable for HETx, HTUx, ADC, DMA and VIM TMS570
40 * peripherals.
41 */
42void tms570_selftest_par_check_std( const tms570_selftest_par_desc_t *desc )
43{
44  volatile uint32_t test_read_data;
45  uint32_t          par_cr_bak = *desc->par_cr_reg;
46  int               perr;
47
48  /* Set TEST mode and enable parity checking */
49  *desc->par_cr_reg = desc->par_cr_test | TMS570_SELFTEST_PAR_CR_KEY;
50
51  /* flip parity bit */
52  *desc->par_loc ^= desc->par_xor;
53
54  /* Disable TEST mode */
55  *desc->par_cr_reg = TMS570_SELFTEST_PAR_CR_KEY;
56
57  /* read to cause parity error */
58  test_read_data = *desc->ram_loc;
59  (void) test_read_data;
60
61  /* check if ESM channel is flagged */
62  perr = tms570_esm_channel_sr_get( desc->esm_prim_grp, desc->esm_prim_chan );
63
64  if ( desc->esm_sec_grp )
65    perr |= tms570_esm_channel_sr_get( desc->esm_sec_grp, desc->esm_sec_chan );
66
67  if ( !perr ) {
68    /* RAM parity error was not flagged to ESM. */
69    bsp_selftest_fail_notification( desc->fail_code );
70  } else {
71    /* If periperal has it own parity status register, clear it */
72    if ( desc->par_st_reg != NULL )
73      *desc->par_st_reg = desc->par_st_clear;
74
75    /* clear ESM flag */
76    tms570_esm_channel_sr_clear( desc->esm_prim_grp, desc->esm_prim_chan );
77
78    if ( desc->esm_sec_grp )
79      tms570_esm_channel_sr_clear( desc->esm_sec_grp, desc->esm_sec_chan );
80
81    /* Set TEST mode and enable parity checking */
82    *desc->par_cr_reg = desc->par_cr_test | TMS570_SELFTEST_PAR_CR_KEY;
83
84    /* Revert back to correct data by flipping parity location */
85    *desc->par_loc ^= desc->par_xor;
86  }
87
88  /* Restore Parity comtrol register */
89  *desc->par_cr_reg = par_cr_bak;
90}
Note: See TracBrowser for help on using the repository browser.