From 1df25eee7c5e7143664a8cfc84019cbd3c5b4279 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 18 May 2015 11:59:53 -0600 Subject: [PATCH] Rename sam_fuses.h to samd_fuses.h; add saml_fused.h for the SAML21 --- .../samdl/chip/{sam_fuses.h => samd_fuses.h} | 13 +- arch/arm/src/samdl/chip/saml21_memorymap.h | 8 + arch/arm/src/samdl/chip/saml_fuses.h | 206 ++++++++++++++++++ arch/arm/src/samdl/sam_fuses.h | 91 ++++++++ arch/arm/src/samdl/samd_clockconfig.c | 2 +- 5 files changed, 314 insertions(+), 6 deletions(-) rename arch/arm/src/samdl/chip/{sam_fuses.h => samd_fuses.h} (97%) create mode 100644 arch/arm/src/samdl/chip/saml_fuses.h create mode 100644 arch/arm/src/samdl/sam_fuses.h diff --git a/arch/arm/src/samdl/chip/sam_fuses.h b/arch/arm/src/samdl/chip/samd_fuses.h similarity index 97% rename from arch/arm/src/samdl/chip/sam_fuses.h rename to arch/arm/src/samdl/chip/samd_fuses.h index b16ca1b122..f47cb22a35 100644 --- a/arch/arm/src/samdl/chip/sam_fuses.h +++ b/arch/arm/src/samdl/chip/samd_fuses.h @@ -1,7 +1,7 @@ /******************************************************************************************** - * arch/arm/src/samdl/chip/sam_fuses.h + * arch/arm/src/samdl/chip/samd_fuses.h * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * References: @@ -42,8 +42,8 @@ * ********************************************************************************************/ -#ifndef __ARCH_ARM_SRC_SAMDL_CHIP_SAM_NVMCTRL_H -#define __ARCH_ARM_SRC_SAMDL_CHIP_SAM_NVMCTRL_H +#ifndef __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_FUSES_H +#define __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_FUSES_H /******************************************************************************************** * Included Files @@ -53,6 +53,8 @@ #include "chip.h" +#ifdef CONFIG_ARCH_FAMILY_SAMD20 + /******************************************************************************************** * Pre-processor Definitions ********************************************************************************************/ @@ -255,4 +257,5 @@ * Public Functions ********************************************************************************************/ -#endif /* __ARCH_ARM_SRC_SAMDL_CHIP_SAM_NVMCTRL_H */ +#endif /* CONFIG_ARCH_FAMILY_SAMD20 */ +#endif /* __ARCH_ARM_SRC_SAMDL_CHIP_SAMD_FUSES_H */ diff --git a/arch/arm/src/samdl/chip/saml21_memorymap.h b/arch/arm/src/samdl/chip/saml21_memorymap.h index 9d46bfee23..b02f6d15b4 100644 --- a/arch/arm/src/samdl/chip/saml21_memorymap.h +++ b/arch/arm/src/samdl/chip/saml21_memorymap.h @@ -55,6 +55,7 @@ #define SAM_FLASH_BASE 0x00000000 /* Embedded FLASH memory space (<= 256KB) */ #define SAM_FLASHRWW_BASE 0x00400000 /* Embedded FLASH RWW memory space (<= 8KB) */ +#define SAM_NVM_BASE 0x00800000 /* Readable NVM content */ #define SAM_SRAM_BASE 0x20000000 /* Embedded SRAM memory space (<= 32KB) */ #define SAM_LPSRAM_BASE 0x30000000 /* Embedded low-power SRAM memory space (<= 8KB) */ #define SAM_AHBA_BASE 0x40000000 /* AHB-APB Bridge A (64KB) */ @@ -63,6 +64,13 @@ #define SAM_AHBD_BASE 0x43000000 /* AHB-APB Bridge D (64KB) */ #define SAM_AHBE_BASE 0x44000000 /* AHB-APB Bridge D (64KB) */ #define SAM_IOBUS_BASE 0x60000000 /* IOBUS (O.5KB) */ +#define SAM_SYSTEM_BASE 0x60000200 /* System */ + +/* Non-volatile memory */ + +#define SAM_NVMUSER_ROW 0x00804000 /* NVM user row */ +#define SAM_NVMCALIB_AREA 0x00806020 /* NVM software calibration area */ +#define SAM_NVM_SERIALNO 0x0080a00c /* Serial number */ /* AHB-APB Bridge A */ diff --git a/arch/arm/src/samdl/chip/saml_fuses.h b/arch/arm/src/samdl/chip/saml_fuses.h new file mode 100644 index 0000000000..65d419b5fb --- /dev/null +++ b/arch/arm/src/samdl/chip/saml_fuses.h @@ -0,0 +1,206 @@ +/******************************************************************************************** + * arch/arm/src/samdl/chip/sam_fuses.h + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * References: + * "Atmel SAM L21E / SAM L21G / SAM L21J Smart ARM-Based Microcontroller + * Datasheet", Atmel-42385C-SAML21_Datasheet_Preliminary-03/20/15 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_CHIP_SAML_FUSES_H +#define __ARCH_ARM_SRC_SAMDL_CHIP_SAML_FUSES_H + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include + +#include "chip.h" + +#ifdef CONFIG_ARCH_FAMILY_SAML21 + +/******************************************************************************************** + * Pre-processor Definitions + ********************************************************************************************/ +/* NVM Fuse addresses **********************************************************************/ + +/* NVM user row bits */ + +#define SAM_NVMUSER_ROW0 (SAM_NVMUSER_ROW + 0x0000) /* Bits 0-31 */ +#define SAM_NVMUSER_ROW1 (SAM_NVMUSER_ROW + 0x0004) /* Bits 32-63 */ + +/* NVM Software Calibration Area */ + +#defien SAM_NVMCALIB_AREA0 (SAM_NVMCALIB_AREA + 0x0000) /* Bits 0-31 */ +#defien SAM_NVMCALIB_AREA1 (SAM_NVMCALIB_AREA + 0x0000) /* Bits 32-63 */ +#defien SAM_NVMCALIB_AREA2 (SAM_NVMCALIB_AREA + 0x0000) /* Bits 64-95 */ +#defien SAM_NVMCALIB_AREA3 (SAM_NVMCALIB_AREA + 0x0000) /* Bits 96-127 */ + +/* Fuse bit-field definitions **************************************************************/ +/* NVM user row bits 0-31 */ + +#define SAM_FUSES_BOOTPROT_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_BOOTPROT_SHIFT (0) /* Bits 0-2: Bootloader Size */ +#define SAM_FUSES_BOOTPROT_MASK (7 << SAM_FUSES_BOOTPROT_SHIFT) +# define SAM_FUSES_BOOTPROT(n) ((uint32_t)(n) << SAM_FUSES_BOOTPROT_SHIFT) + +#define SAM_FUSES_EEPROM_SIZE_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_EEPROM_SIZE_SHIFT (4) /* Bits 4-6: EEPROM Size */ +#define SAM_FUSES_EEPROM_SIZE_MASK (7 << SAM_FUSES_EEPROM_SIZE_SHIFT) +# define SAM_FUSES_EEPROM_SIZE(n) ((uint32_t)(n) << SAM_FUSES_EEPROM_SIZE_SHIFT) + +#define SAM_FUSES_BOD33LEVEL_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_BOD33LEVEL_SHIFT (8) /* Bits 8-13: BOD33 Level */ +#define SAM_FUSES_BOD33LEVEL_MASK (0x3f << SAM_FUSES_BOD33LEVEL_SHIFT) +# define SAM_FUSES_BOD33LEVEL(n) (((uint32_t)n) << SAM_FUSES_BOD33LEVEL_SHIFT) + +#define SAM_FUSES_BOD33_DIS_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_BOD33_DIS_SHIFT (14) /* Bit 14: BOD33 Disable */ +#define SAM_FUSES_BOD33_DIS_MASK (1 << SAM_FUSES_BOD33_DIS_SHIFT) + +#define SAM_FUSES_BOD33_ACTION_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_BOD33_ACTION_SHIFT (15) /* Bits 15-16: BOD33 Action */ +#define SAM_FUSES_BOD33_ACTION_MASK (3 << SAM_FUSES_BOD33_ACTION_SHIFT) +# define SAM_FUSES_BOD33_ACTION(n) (((uint32_t)n) << SAM_FUSES_BOD33_ACTION_SHIFT) + +#define SAM_FUSES_BOD12LEVEL_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_BOD12LEVEL_SHIFT (17) /* Bits 17-22: BOD12 Level */ +#define SAM_FUSES_BOD12LEVEL_MASK (0x1f << SAM_FUSES_BOD12LEVEL_SHIFT) +# define SAM_FUSES_BOD12LEVEL(n) ((uint32_t)(n) << SAM_FUSES_BOD12LEVEL_SHIFT) + +#define SAM_FUSES_BOD12_DIS_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_BOD12_DIS_SHIFT (23) /* Bit 23: BOD12 Disable */ +#define SAM_FUSES_BOD12_DIS_MASK (1 << SAM_FUSES_BOD12_DIS_SHIFT) + +#define SAM_FUSES_BOD12_ACTION_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_BOD12_ACTION_SHIFT (24) /* Bits 24-25: BOD12 Action */ +#define SAM_FUSES_BOD12_ACTION_MASK (3 << SAM_FUSES_BOD12_ACTION_SHIFT) +# define SAM_FUSES_BOD12_ACTION(n) ((uint32_t)(n) << SAM_FUSES_BOD12_ACTION_SHIFT) + +#define SAM_FUSES_WDT_ENA_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_WDT_ENA_SHIFT (26) /* Bit 26: WDT Enable */ +#define SAM_FUSES_WDT_ENA_MASK (1 << SAM_FUSES_WDT_ENA_SHIFT) + +#define SAM_FUSES_WDT_ALWAYSON_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_WDT_ALWAYSON_SHIFT (27) /* Bit 27: WDT Always On */ +#define SAM_FUSES_WDT_ALWAYSON_MASK (1 << SAM_FUSES_WDT_ALWAYSON_SHIFT) + +#define SAM_FUSES_WDT_PER_ADDR SAM_NVMUSER_ROW0 +#define SAM_FUSES_WDT_PER_SHIFT (28) /* Bits 28-31: WDT Period */ +#define SAM_FUSES_WDT_PER_MASK (15 << SAM_FUSES_WDT_PER_SHIFT) +# define SAM_FUSES_WDT_PER(n) ((uint32_t)(n) << SAM_FUSES_WDT_PER_SHIFT) + +/* NVM user row bits 32-64 */ + +#define SAM_FUSES_WDT_WINDOW_ADDR SAM_NVMUSER_ROW1 +#define SAM_FUSES_WDT_WINDOW_SHIFT (0) /* Bits 32-35: WDT Window */ +#define SAM_FUSES_WDT_WINDOW_MASK (15 << SAM_FUSES_WDT_WINDOW_SHIFT) + +#define SAM_FUSES_WDT_EWOFFSET_ADDR SAM_NVMUSER_ROW1 +#define SAM_FUSES_WDT_EWOFFSET_SHIFT (4) /* Bits 36-39: WDT Early Warning Offset */ +#define SAM_FUSES_WDT_EWOFFSET_MASK (15 << SAM_FUSES_WDT_EWOFFSET_SHIFT) +# define SAM_FUSES_WDT_EWOFFSET(n) ((uint32_t)(n) << SAM_FUSES_WDT_EWOFFSET_SHIFT) + +#define SAM_FUSES_WDT_WEN_ADDR SAM_NVMUSER_ROW1 +#define SAM_FUSES_WDT_WEN_SHIFT (8) /* Bit 40: WDT Window Mode Enable */ +#define SAM_FUSES_WDT_WEN_MASK (1 << SAM_FUSES_WDT_WEN_SHIFT) + +#define SAM_FUSES_BOD33_HYST_ADDR SAM_NVMUSER_ROW1 +#define SAM_FUSES_BOD33_HYST_SHIFT (9) /* Bit 41: BOD33 Hysteresis */ +#define SAM_FUSES_BOD33_HYST_MASK (1 << SAM_FUSES_BOD33_HYST_SHIFT) + +#define SAM_FUSES_BOD12_HYST_ADDR SAM_NVMUSER_ROW1 +#define SAM_FUSES_BOD12_HYST_SHIFT (10) /* Bit 42: BOD12 Hysteresis */ +#define SAM_FUSES_BOD12_HYST_MASK (1 << SAM_FUSES_BOD12_HYST_SHIFT) + +#define SAM_FUSES_LOCK_ADDR SAM_NVMUSER_ROW1 +#define SAM_FUSES_LOCK_SHIFT (16) /* Bits 48-63: NVM Region Lock bits */ +#define SAM_FUSES_LOCK_MASK (0xffff << SAM_FUSES_LOCK_SHIFT) +# define SAM_FUSES_LOCK(n) ((uint32_t)(n) << SAM_FUSES_LOCK_SHIFT) + +/* NVM Software Calibration Area bits 0-31 */ + +#define SAM_FUSES_ADC_LINEARITY_ADDR SAM_NVMCALIB_AREA0 +#define SAM_FUSES_ADC_LINEARITY_SHIFT (0) /* Bits 0-2: ADC Linearity bits */ +#define SAM_FUSES_ADC_LINEARITY_MASK (7 << SAM_FUSES_ADC_LINEARITY_SHIFT) +# define SAM_FUSES_ADC_LINEARITY(n) ((uint32_t)(n) << SAM_FUSES_ADC_LINEARITY_SHIFT) + +#define SAM_FUSES_ADC_BIASCAL_ADDR SAM_NVMCALIB_AREA0 +#define SAM_FUSES_ADC_BIASCAL_SHIFT (3) /* Bits 3-5: ADC Bias Calibration */ +#define SAM_FUSES_ADC_BIASCAL_MASK (7 << SAM_FUSES_ADC_BIASCAL_SHIFT) +# define SAM_FUSES_ADC_BIASCAL(n) ((uint32_t)(n) << SAM_FUSES_ADC_BIASCAL_SHIFT) + +#define SAM_FUSES_OSC32KCAL_ADDR SAM_NVMCALIB_AREA0 +#define SAM_FUSES_OSC32KCAL_SHIFT (6) /* Bits 6-12: OSC32K Calibration */ +#define SAM_FUSES_OSC32KCAL_MASK (0x7f << SAM_FUSES_OSC32KCAL_SHIFT) +# define SAM_FUSES_OSC32KCAL(n) ((uint32_t)(n) << SAM_FUSES_OSC32KCAL_SHIFT) + +#define SAM_FUSES_USBTRANSN_ADDR SAM_NVMCALIB_AREA0 +#define SAM_FUSES_USBTRANSN_SHIFT (13) /* Bits 13-17: USB TRNSN Calibration */ +#define SAM_FUSES_USBTRANSN_MASK (31 << SAM_FUSES_USBTRANSN_SHIFT) +# define SAM_FUSES_USBTRANSN(n) ((uint32_t)(n) << SAM_FUSES_USBTRANSN_SHIFT) + +#define SAM_FUSES_USBTRANSP_ADDR SAM_NVMCALIB_AREA0 +#define SAM_FUSES_USBTRANSP_SHIFT (6) /* Bits 18-22: USB TRNSP Calibration */ +#define SAM_FUSES_USBTRANSP_MASK (31 << SAM_FUSES_USBTRANSP_SHIFT) +# define SAM_FUSES_USBTRANSP(n) ((uint32_t)(n) << SAM_FUSES_USBTRANSP_SHIFT) + +#define SAM_FUSES_USBTRIM_ADDR SAM_NVMCALIB_AREA0 +#define SAM_FUSES_USBTRIM_SHIFT (23) /* Bits 23-25: USB TRIM Calibration */ +#define SAM_FUSES_USBTRIM_MASK (7 << SAM_FUSES_USBTRIM_SHIFT) +# define SAM_FUSES_USBTRIM(n) ((uint32_t)(n) << SAM_FUSES_USBTRIM_SHIFT) + +#define SAM_FUSES_DFLL48MCC_ADDR SAM_NVMCALIB_AREA0 +#define SAM_FUSES_DFLL48MCC_SHIFT (26) /* Bits 26-31: DFLL48M Coarse Calibration */ +#define SAM_FUSES_DFLL48MCC_MASK (0x3f << SAM_FUSES_DFLL48MCC_SHIFT) +# define SAM_FUSES_DFLL48MCC(n) ((uint32_t)(n) << SAM_FUSES_DFLL48MCC_SHIFT) + +/* NVM Software Calibration Area bits 32-63 - Reserved */ +/* NVM Software Calibration Area bits 64-95 - Reserved */ +/* NVM Software Calibration Area bits 96-127 - Reserved */ + +/******************************************************************************************** + * Public Types + ********************************************************************************************/ + +/******************************************************************************************** + * Public Data + ********************************************************************************************/ + +/******************************************************************************************** + * Public Functions + ********************************************************************************************/ + +#endif /* CONFIG_ARCH_FAMILY_SAML21 */ +#endif /* __ARCH_ARM_SRC_SAMDL_CHIP_SAML_FUSES_H */ diff --git a/arch/arm/src/samdl/sam_fuses.h b/arch/arm/src/samdl/sam_fuses.h new file mode 100644 index 0000000000..97c00ed6b5 --- /dev/null +++ b/arch/arm/src/samdl/sam_fuses.h @@ -0,0 +1,91 @@ +/**************************************************************************** + * arch/arm/src/samdl/sam_fuses.h + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_SAMDL_SAM_FUSES_H +#define __ARCH_ARM_SRC_SAMDL_SAM_FUSES_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include "sam_config.h" + +#if defined(CONFIG_ARCH_FAMILY_SAMD20) +# include "chip/samd_fuses.h" +#elif defined(CONFIG_ARCH_FAMILY_SAML21) +# include "chip/saml_fuses.h" +#else +# error Unrecognized SAMD/L architecture +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Inline Functions + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif +#endif /* __ASSEMBLY__ */ +#endif /* __ARCH_ARM_SRC_SAMDL_SAM_FUSES_H */ diff --git a/arch/arm/src/samdl/samd_clockconfig.c b/arch/arm/src/samdl/samd_clockconfig.c index f4407c00a0..51bf680f6a 100644 --- a/arch/arm/src/samdl/samd_clockconfig.c +++ b/arch/arm/src/samdl/samd_clockconfig.c @@ -58,7 +58,7 @@ #include "chip/samd_sysctrl.h" #include "chip/samd_gclk.h" #include "chip/samd_nvmctrl.h" -#include "chip/sam_fuses.h" +#include "sam_fuses.h" #include