1 /* 2 * Copyright (c) 2024 Texas Instruments Incorporated 3 * Copyright (c) 2024 BayLibre, SAS 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #include <zephyr/kernel.h> 9 10 #include <inc/hw_ccfg.h> 11 12 #define CC23_CCFG_FLASH DT_INST(0, ti_cc23x0_ccfg_flash) 13 #define CC23_CCFG_FLASH_PROP(prop) DT_PROP(CC23_CCFG_FLASH, prop) 14 15 #define CC23_TO_PERM_VAL(en) ((en) ? CCFG_PERMISSION_ALLOW : CCFG_PERMISSION_FORBID) 16 17 #if CONFIG_CC23X0_BLDR_VTOR_TYPE_UNDEF 18 #define CC23X0_BLDR_VTOR 0xffffffff 19 #elif CONFIG_CC23X0_BLDR_VTOR_TYPE_FORBID 20 #define CC23X0_BLDR_VTOR 0xfffffffc 21 #elif CONFIG_CC23X0_BLDR_VTOR_TYPE_USE_FCFG 22 #define CC23X0_BLDR_VTOR 0xfffffff0 23 #else 24 #define CC23X0_BLDR_VTOR CC23_CCFG_FLASH_PROP(ti_bldr_vtor_flash) 25 #endif 26 27 #define CC23X0_P_APP_VTOR DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition)) 28 29 #if CC23_CCFG_FLASH_PROP(ti_chip_erase) == 0 30 #warning ti,chip-erase property is NOT PRESENT in your device tree, \ 31 flashing this firmware will LOCK YOUR DEVICE. 32 #endif 33 34 /* Default CCFG */ 35 const ccfg_t ccfg __attribute__((section(".ti_ccfg"))) __attribute__((used)) = { 36 .bootCfg.pBldrVtor = (void *)CC23X0_BLDR_VTOR, 37 .bootCfg.bldrParam.serialRomBldrParamStruct.bldrEnabled = 38 IS_ENABLED(CONFIG_CC23X0_BLDR_ENABLED), 39 .bootCfg.bldrParam.serialRomBldrParamStruct.serialIoCfgIndex = 40 CC23_CCFG_FLASH_PROP(ti_serial_io_cfg_index), 41 .bootCfg.bldrParam.serialRomBldrParamStruct.pinTriggerEnabled = 42 CC23_CCFG_FLASH_PROP(ti_pin_trigger), 43 .bootCfg.bldrParam.serialRomBldrParamStruct.pinTriggerDio = 44 CC23_CCFG_FLASH_PROP(ti_pin_trigger_dio), 45 .bootCfg.bldrParam.serialRomBldrParamStruct.pinTriggerLevel = 46 CC23_CCFG_FLASH_PROP(ti_pin_trigger_level_hi), 47 .bootCfg.pAppVtor = (void *)CC23X0_P_APP_VTOR, 48 49 .hwOpts = {0xffffffff, 0xffffffff}, 50 51 .permissions.allowDebugPort = CC23_TO_PERM_VAL(CC23_CCFG_FLASH_PROP(ti_debug_port)), 52 .permissions.allowEnergyTrace = CC23_TO_PERM_VAL(CC23_CCFG_FLASH_PROP(ti_energy_trace)), 53 .permissions.allowFlashVerify = CC23_TO_PERM_VAL(CC23_CCFG_FLASH_PROP(ti_flash_verify)), 54 .permissions.allowFlashProgram = CC23_TO_PERM_VAL(CC23_CCFG_FLASH_PROP(ti_flash_program)), 55 .permissions.allowChipErase = CC23_TO_PERM_VAL(CC23_CCFG_FLASH_PROP(ti_chip_erase)), 56 .permissions.allowToolsClientMode = CCFG_PERMISSION_ALLOW, 57 .permissions.allowReturnToFactory = 58 CC23_TO_PERM_VAL(CC23_CCFG_FLASH_PROP(ti_ret_to_factory)), 59 .permissions.allowFakeStby = CCFG_PERMISSION_ALLOW, 60 61 .misc.saciTimeoutOverride = 0, 62 .misc.saciTimeoutExp = XCFG_MISC_SACITOEXP_8SEC, 63 64 .flashProt.writeEraseProt.mainSectors0_31 = CC23_CCFG_FLASH_PROP(ti_wr_er_prot_sect0_31), 65 .flashProt.writeEraseProt.mainSectors32_255 = 66 CC23_CCFG_FLASH_PROP(ti_wr_er_prot_sect32_255), 67 .flashProt.writeEraseProt.ccfgSector = CC23_CCFG_FLASH_PROP(ti_wr_er_prot_ccfg_sect), 68 .flashProt.writeEraseProt.fcfgSector = CC23_CCFG_FLASH_PROP(ti_wr_er_prot_fcfg_sect), 69 .flashProt.writeEraseProt.engrSector = CC23_CCFG_FLASH_PROP(ti_wr_er_prot_engr_sect), 70 71 .flashProt.res = 0xffffffff, 72 73 .flashProt.chipEraseRetain.mainSectors0_31 = 74 CC23_CCFG_FLASH_PROP(ti_chip_er_retain_sect0_31), 75 .flashProt.chipEraseRetain.mainSectors32_255 = 76 CC23_CCFG_FLASH_PROP(ti_chip_er_retain_sect32_255), 77 78 .debugCfg.authorization = CCFG_DBGAUTH_DBGOPEN, 79 .debugCfg.allowBldr = CCFG_DBGBLDR_ALLOW, 80 }; 81