1 /* 2 * Copyright (c) 2023 Google Inc 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef __ZEPHYR_INCLUDE_DRIVERS_FLASH_STM32_FLASH_API_EXTENSIONS_H__ 8 #define __ZEPHYR_INCLUDE_DRIVERS_FLASH_STM32_FLASH_API_EXTENSIONS_H__ 9 10 #include <zephyr/drivers/flash.h> 11 12 enum stm32_ex_ops { 13 /* 14 * STM32 sector write protection control. 15 * 16 * As an input this operation takes a structure with two sector masks, 17 * first mask is used to enable protection on sectors, while second mask 18 * is used to do the opposite. If both masks are 0, then protection will 19 * remain unchanged. If same sector is set on both masks, protection 20 * will be enabled. 21 * 22 * As an output, sector mask with enabled protection is returned. 23 * Input can be NULL if we only want to get protected sectors. 24 * Output can be NULL if not needed. 25 */ 26 FLASH_STM32_EX_OP_SECTOR_WP = FLASH_EX_OP_VENDOR_BASE, 27 /* 28 * STM32 sector readout protection control. 29 * 30 * As an input this operation takes structure with information about 31 * desired RDP state. As an output the status after applying changes 32 * is returned. 33 */ 34 FLASH_STM32_EX_OP_RDP, 35 /* 36 * STM32 block option register. 37 * 38 * This operation causes option register to be locked until next boot. 39 * After calling, it's not possible to change option bytes (WP, RDP, 40 * user bytes). 41 */ 42 FLASH_STM32_EX_OP_BLOCK_OPTION_REG, 43 /* 44 * STM32 block control register. 45 * 46 * This operation causes control register to be locked until next boot. 47 * After calling, it's not possible to perform basic operation like 48 * erasing or writing. 49 */ 50 FLASH_STM32_EX_OP_BLOCK_CONTROL_REG, 51 /* 52 * STM32 option bytes read. 53 * 54 * Read the option bytes content, out takes a *uint32_t, in is unused. 55 */ 56 FLASH_STM32_EX_OP_OPTB_READ, 57 /* 58 * STM32 option bytes write. 59 * 60 * Write the option bytes content, in takes the new value, out is 61 * unused. Note that the new value only takes effect after the device 62 * is restarted. 63 */ 64 FLASH_STM32_EX_OP_OPTB_WRITE, 65 }; 66 67 #if defined(CONFIG_FLASH_STM32_WRITE_PROTECT) 68 struct flash_stm32_ex_op_sector_wp_in { 69 uint64_t enable_mask; 70 uint64_t disable_mask; 71 }; 72 73 struct flash_stm32_ex_op_sector_wp_out { 74 uint64_t protected_mask; 75 }; 76 #endif /* CONFIG_FLASH_STM32_WRITE_PROTECT */ 77 78 #if defined(CONFIG_FLASH_STM32_READOUT_PROTECTION) 79 struct flash_stm32_ex_op_rdp { 80 bool enable; 81 bool permanent; 82 }; 83 #endif /* CONFIG_FLASH_STM32_READOUT_PROTECTION */ 84 85 #endif /* __ZEPHYR_INCLUDE_DRIVERS_FLASH_STM32_FLASH_API_EXTENSIONS_H__ */ 86