Changeset 891fa3e in rtems


Ignore:
Timestamp:
Jun 28, 2016, 8:47:15 AM (3 years ago)
Author:
Alexander Krutwig <alexander.krutwig@…>
Branches:
master
Children:
297d4372
Parents:
9bb3ce39
git-author:
Alexander Krutwig <alexander.krutwig@…> (06/28/16 08:47:15)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/29/16 08:38:19)
Message:

bsp/atsam: Add support for TCM

Location:
c/src/lib/libbsp/arm/atsam
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/atsam/include/bsp.h

    r9bb3ce39 r891fa3e  
    6060} if_atsam_config;
    6161
     62extern char atsam_memory_dtcm_begin[];
     63extern char atsam_memory_dtcm_end[];
     64extern char atsam_memory_dtcm_size[];
     65
     66extern char atsam_memory_intflash_begin[];
     67extern char atsam_memory_intflash_end[];
     68extern char atsam_memory_intflash_size[];
     69
     70extern char atsam_memory_intsram_begin[];
     71extern char atsam_memory_intsram_end[];
     72extern char atsam_memory_intsram_size[];
     73
     74extern char atsam_memory_itcm_begin[];
     75extern char atsam_memory_itcm_end[];
     76extern char atsam_memory_itcm_size[];
     77
     78extern char atsam_memory_nocache_begin[];
     79extern char atsam_memory_nocache_end[];
     80extern char atsam_memory_nocache_size[];
     81
     82extern char atsam_memory_qspiflash_begin[];
     83extern char atsam_memory_qspiflash_end[];
     84extern char atsam_memory_qspiflash_size[];
     85
     86extern char atsam_memory_sdram_begin[];
     87extern char atsam_memory_sdram_end[];
     88extern char atsam_memory_sdram_size[];
     89
    6290/** @} */
    6391
  • c/src/lib/libbsp/arm/atsam/libraries/libboard/source/board_lowlevel.c

    r9bb3ce39 r891fa3e  
    169169            END_Addr:-    0x2045FFFFUL
    170170        ******************************************************/
     171#ifndef __rtems__
    171172        /* SRAM memory region */
    172173        dwRegionBaseAddr =
     
    182183
    183184        MPU_SetRegion(dwRegionBaseAddr, dwRegionAttr);
     185#endif /* __rtems__ */
    184186
    185187#ifdef MPU_HAS_NOCACHE_REGION
  • c/src/lib/libbsp/arm/atsam/libraries/libchip/include/mpu.h

    r9bb3ce39 r891fa3e  
    3030#ifndef _MPU_H_
    3131#define _MPU_H_
     32#ifdef __rtems__
     33#include <bsp.h>
     34#endif /* __rtems__ */
    3235
    3336/*----------------------------------------------------------------------------
     
    126129
    127130/* Regions should be a 2^(N+1)  where 4 < N < 31 */
     131#ifdef __rtems__
     132#define SRAM_FIRST_START_ADDRESS            ((uintptr_t) atsam_memory_sdram_begin)
     133#define SRAM_FIRST_END_ADDRESS              ((uintptr_t) atsam_memory_sdram_end - 1)
     134#else /* __rtems__ */
    128135#define SRAM_FIRST_START_ADDRESS            (SRAM_START_ADDRESS)
    129136#define SRAM_FIRST_END_ADDRESS              (SRAM_FIRST_START_ADDRESS + 0x3FFFF)        // (2^18) 256 KB
     137#endif /* __rtems__ */
    130138
    131139#if defined MPU_HAS_NOCACHE_REGION
     140#ifdef __rtems__
     141        #define SRAM_NOCACHE_START_ADDRESS          ((uintptr_t) atsam_memory_nocache_begin)
     142        #define SRAM_NOCACHE_END_ADDRESS            ((uintptr_t) atsam_memory_nocache_end - 1)
     143#else /* __rtems__ */
    132144        #define SRAM_SECOND_START_ADDRESS           (SRAM_FIRST_END_ADDRESS+1)
    133145        #define SRAM_SECOND_END_ADDRESS             (SRAM_END_ADDRESS - NOCACHE_SRAM_REGION_SIZE)              // (2^17) 128 - 0x1000 KB
    134146        #define SRAM_NOCACHE_START_ADDRESS          (SRAM_SECOND_END_ADDRESS + 1)
    135147        #define SRAM_NOCACHE_END_ADDRESS            (SRAM_END_ADDRESS)
     148#endif /* __rtems__ */
    136149#else
     150#ifndef __rtems__
    137151        #define SRAM_SECOND_START_ADDRESS           (SRAM_FIRST_END_ADDRESS + 1)
    138152        #define SRAM_SECOND_END_ADDRESS             (SRAM_END_ADDRESS)                          // (2^17) 128 KB
     153#endif /* __rtems__ */
    139154#endif
    140155/************** Peripherals memory region macros ********/
  • c/src/lib/libbsp/arm/atsam/startup/bspstarthooks.c

    r9bb3ce39 r891fa3e  
    2121#include <include/board_memories.h>
    2222
     23#define SIZE_0K 0
     24#define SIZE_32K (32 * 1024)
     25#define SIZE_64K (64 * 1024)
     26#define SIZE_128K (128 * 1024)
     27
     28#define ITCMCR_SZ_0K 0x0
     29#define ITCMCR_SZ_32K 0x6
     30#define ITCMCR_SZ_64K 0x7
     31#define ITCMCR_SZ_128K 0x8
     32
     33static BSP_START_TEXT_SECTION void efc_send_command(uint32_t eefc)
     34{
     35  EFC->EEFC_FCR = eefc | EEFC_FCR_FKEY_PASSWD;
     36}
     37
     38static BSP_START_TEXT_SECTION void tcm_enable(void)
     39{
     40  SCB->ITCMCR |= SCB_ITCMCR_EN_Msk;
     41  SCB->DTCMCR |= SCB_DTCMCR_EN_Msk;
     42}
     43
     44static BSP_START_TEXT_SECTION void tcm_disable(void)
     45{
     46  SCB->ITCMCR &= ~SCB_ITCMCR_EN_Msk;
     47  SCB->DTCMCR &= ~SCB_DTCMCR_EN_Msk;
     48}
     49
     50static BSP_START_TEXT_SECTION bool tcm_setup_and_check_if_do_efc_config(
     51  uintptr_t tcm_size,
     52  uint32_t itcmcr_sz
     53)
     54{
     55  if (tcm_size == SIZE_0K && itcmcr_sz == ITCMCR_SZ_0K) {
     56    tcm_disable();
     57    return false;
     58  } else if (tcm_size == SIZE_32K && itcmcr_sz == ITCMCR_SZ_32K) {
     59    tcm_enable();
     60    return false;
     61  } else if (tcm_size == SIZE_64K && itcmcr_sz == ITCMCR_SZ_64K) {
     62    tcm_enable();
     63    return false;
     64  } else if (tcm_size == SIZE_128K && itcmcr_sz == ITCMCR_SZ_128K) {
     65    tcm_enable();
     66    return false;
     67  } else {
     68    return true;
     69  }
     70}
     71
    2372void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
    2473{
     74  uintptr_t tcm_size;
     75  uint32_t itcmcr_sz;
     76
    2577  system_init_flash(BOARD_MCK);
    2678  SystemInit();
     
    4294
    4395  _SetupMemoryRegion();
     96
     97  /* Configure tightly coupled memory interfaces */
     98
     99  tcm_size = (uintptr_t) atsam_memory_itcm_size;
     100  itcmcr_sz = (SCB->ITCMCR & SCB_ITCMCR_SZ_Msk) >> SCB_ITCMCR_SZ_Pos;
     101
     102  if (tcm_setup_and_check_if_do_efc_config(tcm_size, itcmcr_sz)) {
     103    if (tcm_size == SIZE_128K) {
     104      efc_send_command(EEFC_FCR_FCMD_SGPB | EEFC_FCR_FARG(7));
     105      efc_send_command(EEFC_FCR_FCMD_SGPB | EEFC_FCR_FARG(8));
     106      tcm_enable();
     107    } else if (tcm_size == SIZE_64K) {
     108      efc_send_command(EEFC_FCR_FCMD_CGPB | EEFC_FCR_FARG(7));
     109      efc_send_command(EEFC_FCR_FCMD_SGPB | EEFC_FCR_FARG(8));
     110      tcm_enable();
     111    } else if (tcm_size == SIZE_32K) {
     112      efc_send_command(EEFC_FCR_FCMD_SGPB | EEFC_FCR_FARG(7));
     113      efc_send_command(EEFC_FCR_FCMD_CGPB | EEFC_FCR_FARG(8));
     114      tcm_enable();
     115    } else {
     116      efc_send_command(EEFC_FCR_FCMD_CGPB | EEFC_FCR_FARG(7));
     117      efc_send_command(EEFC_FCR_FCMD_CGPB | EEFC_FCR_FARG(8));
     118      tcm_disable();
     119    }
     120  }
    44121}
    45122
  • c/src/lib/libbsp/arm/atsam/startup/linkcmds.memory.in

    r9bb3ce39 r891fa3e  
    88        QSPIFLASH  : ORIGIN = 0x80000000, LENGTH = @ATSAM_MEMORY_QSPIFLASH_SIZE@
    99}
     10
     11atsam_memory_itcm_begin = ORIGIN (ITCM);
     12atsam_memory_itcm_end = ORIGIN (ITCM) + LENGTH (ITCM);
     13atsam_memory_itcm_size = LENGTH (ITCM);
     14
     15atsam_memory_intflash_begin = ORIGIN (INTFLASH);
     16atsam_memory_intflash_end = ORIGIN (INTFLASH) + LENGTH (INTFLASH);
     17atsam_memory_intflash_size = LENGTH (INTFLASH);
     18
     19atsam_memory_dtcm_begin = ORIGIN (DTCM);
     20atsam_memory_dtcm_end = ORIGIN (DTCM) + LENGTH (DTCM);
     21atsam_memory_dtcm_size = LENGTH (DTCM);
     22
     23atsam_memory_intsram_begin = ORIGIN (INTSRAM);
     24atsam_memory_intsram_end = ORIGIN (INTSRAM) + LENGTH (INTSRAM);
     25atsam_memory_intsram_size = LENGTH (INTSRAM);
     26
     27atsam_memory_nocache_begin = ORIGIN (NOCACHE);
     28atsam_memory_nocache_end = ORIGIN (NOCACHE) + LENGTH (NOCACHE);
     29atsam_memory_nocache_size = LENGTH (NOCACHE);
     30
     31atsam_memory_sdram_begin = ORIGIN (SDRAM);
     32atsam_memory_sdram_end = ORIGIN (SDRAM) + LENGTH (SDRAM);
     33atsam_memory_sdram_size = LENGTH (SDRAM);
     34
     35atsam_memory_qspiflash_begin = ORIGIN (QSPIFLASH);
     36atsam_memory_qspiflash_end = ORIGIN (QSPIFLASH) + LENGTH (QSPIFLASH);
     37atsam_memory_qspiflash_size = LENGTH (QSPIFLASH);
Note: See TracChangeset for help on using the changeset viewer.