Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:03

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSBSPsARMLPC24XX
0007  *
0008  * @brief BSP start configuration.
0009  */
0010 
0011 /*
0012  * Copyright (C) 2011, 2012 embedded brains GmbH & Co. KG
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifndef LIBBSP_ARM_LPC24XX_START_CONFIG_H
0037 #define LIBBSP_ARM_LPC24XX_START_CONFIG_H
0038 
0039 #include <rtems/score/armv7m.h>
0040 
0041 #include <bsp.h>
0042 #include <bsp/io.h>
0043 #include <bsp/start.h>
0044 #include <bsp/lpc-emc.h>
0045 
0046 #ifdef __cplusplus
0047 extern "C" {
0048 #endif /* __cplusplus */
0049 
0050 /**
0051  * @brief Pico seconds @a ps to clock ticks for clock frequency @a f.
0052  */
0053 #define LPC24XX_PS_TO_CLK(ps, f) \
0054   (((((uint64_t) (ps)) * ((uint64_t) (f))) + 1000000000000ULL - 1ULL) \
0055     / 1000000000000ULL)
0056 
0057 /**
0058  * @brief Pico seconds @a ps to EMCCLK clock ticks adjusted by @a m.
0059  */
0060 #define LPC24XX_PS_TO_EMCCLK(ps, m) \
0061   (LPC24XX_PS_TO_CLK(ps, LPC24XX_EMCCLK) > (m) ? \
0062     LPC24XX_PS_TO_CLK(ps, LPC24XX_EMCCLK) - (m) : 0)
0063 
0064 typedef struct {
0065   uint32_t refresh;
0066   uint32_t readconfig;
0067   uint32_t trp;
0068   uint32_t tras;
0069   uint32_t tsrex;
0070   uint32_t tapr;
0071   uint32_t tdal;
0072   uint32_t twr;
0073   uint32_t trc;
0074   uint32_t trfc;
0075   uint32_t txsr;
0076   uint32_t trrd;
0077   uint32_t tmrd;
0078   uint32_t emcdlyctl;
0079 } lpc24xx_emc_dynamic_config;
0080 
0081 typedef struct {
0082   volatile lpc_emc_dynamic *chip_select;
0083   uint32_t address;
0084   uint32_t config;
0085   uint32_t rascas;
0086   uint32_t mode;
0087 } lpc24xx_emc_dynamic_chip_config;
0088 
0089 typedef struct {
0090   volatile lpc_emc_static *chip_select;
0091   struct {
0092     uint32_t config;
0093     uint32_t waitwen;
0094     uint32_t waitoen;
0095     uint32_t waitrd;
0096     uint32_t waitpage;
0097     uint32_t waitwr;
0098     uint32_t waitrun;
0099   } config;
0100 } lpc24xx_emc_static_chip_config;
0101 
0102 extern BSP_START_DATA_SECTION const lpc24xx_pin_range
0103   lpc24xx_start_config_pinsel [];
0104 
0105 extern BSP_START_DATA_SECTION const lpc24xx_emc_dynamic_config
0106   lpc24xx_start_config_emc_dynamic [];
0107 
0108 extern BSP_START_DATA_SECTION const lpc24xx_emc_dynamic_chip_config
0109   lpc24xx_start_config_emc_dynamic_chip [];
0110 
0111 extern BSP_START_DATA_SECTION const size_t
0112   lpc24xx_start_config_emc_dynamic_chip_count;
0113 
0114 extern BSP_START_DATA_SECTION const lpc24xx_emc_static_chip_config
0115   lpc24xx_start_config_emc_static_chip [];
0116 
0117 extern BSP_START_DATA_SECTION const size_t
0118   lpc24xx_start_config_emc_static_chip_count;
0119 
0120 #ifdef ARM_MULTILIB_ARCH_V7M
0121 
0122 extern BSP_START_DATA_SECTION const ARMV7M_MPU_Region
0123   lpc24xx_start_config_mpu_region [];
0124 
0125 extern BSP_START_DATA_SECTION const size_t
0126   lpc24xx_start_config_mpu_region_count;
0127 
0128 #endif /* ARM_MULTILIB_ARCH_V7M */
0129 
0130 #ifdef __cplusplus
0131 }
0132 #endif /* __cplusplus */
0133 
0134 #endif /* LIBBSP_ARM_LPC24XX_START_CONFIG_H */