LCOV - code coverage report
Current view: top level - zephyr/drivers/flash - stm32_flash_api_extensions.h Coverage Total Hit
Test: new.info Lines: 100.0 % 11 11
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            1 : /*
       2              :  * Copyright (c) 2023 Google Inc
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              :  /**
       8              :   * @file
       9              :   * @brief Header file for STM32 flash extended operations.
      10              :   * @ingroup stm32_flash_ex_op
      11              :   */
      12              : 
      13              : #ifndef __ZEPHYR_INCLUDE_DRIVERS_FLASH_STM32_FLASH_API_EXTENSIONS_H__
      14              : #define __ZEPHYR_INCLUDE_DRIVERS_FLASH_STM32_FLASH_API_EXTENSIONS_H__
      15              : 
      16              : /**
      17              :  * @brief Extended operations for STM32 flash controllers.
      18              :  * @defgroup stm32_flash_ex_op STM32
      19              :  * @ingroup flash_ex_op
      20              :  * @{
      21              :  */
      22              : 
      23              : #include <zephyr/drivers/flash.h>
      24              : 
      25              : /**
      26              :  * @brief Enumeration for STM32 flash extended operations.
      27              :  */
      28            1 : enum stm32_ex_ops {
      29              :         /**
      30              :          * STM32 sector write protection control.
      31              :          *
      32              :          * @kconfig_dep{CONFIG_FLASH_STM32_WRITE_PROTECT}
      33              :          *
      34              :          * As an input, this operation takes a flash_stm32_ex_op_sector_wp_in
      35              :          * with two sector masks:
      36              :          * first mask is used to enable protection on sectors, while second mask
      37              :          * is used to do the opposite. If both masks are 0, then protection will
      38              :          * remain unchanged. If same sector is set on both masks, protection
      39              :          * will be enabled.
      40              :          *
      41              :          * As an output, sector mask with enabled protection is returned.
      42              :          * Input can be NULL if we only want to get protected sectors.
      43              :          * Output can be NULL if not needed.
      44              :          */
      45              :         FLASH_STM32_EX_OP_SECTOR_WP = FLASH_EX_OP_VENDOR_BASE,
      46              :         /**
      47              :          * STM32 sector readout protection control.
      48              :          *
      49              :          * @kconfig_dep{CONFIG_FLASH_STM32_READOUT_PROTECTION}
      50              :          *
      51              :          * As an input, this operation takes a flash_stm32_ex_op_rdp with information
      52              :          * about desired RDP state. As an output, the status after applying changes
      53              :          * is returned.
      54              :          */
      55              :         FLASH_STM32_EX_OP_RDP,
      56              :         /**
      57              :          * STM32 block option register.
      58              :          *
      59              :          * This operation causes option register to be locked until next boot.
      60              :          * After calling, it's not possible to change option bytes (WP, RDP,
      61              :          * user bytes).
      62              :          */
      63              :         FLASH_STM32_EX_OP_BLOCK_OPTION_REG,
      64              :         /**
      65              :          * STM32 block control register.
      66              :          *
      67              :          * This operation causes control register to be locked until next boot.
      68              :          * After calling, it's not possible to perform basic operation like
      69              :          * erasing or writing.
      70              :          */
      71              :         FLASH_STM32_EX_OP_BLOCK_CONTROL_REG,
      72              :         /**
      73              :          * STM32 option bytes read.
      74              :          *
      75              :          * Read the option bytes content, out takes a *uint32_t, in is unused.
      76              :          */
      77              :         FLASH_STM32_EX_OP_OPTB_READ,
      78              :         /**
      79              :          * STM32 option bytes write.
      80              :          *
      81              :          * Write the option bytes content, in takes the new value, out is
      82              :          * unused. Note that the new value only takes effect after the device
      83              :          * is restarted.
      84              :          */
      85              :         FLASH_STM32_EX_OP_OPTB_WRITE,
      86              : };
      87              : 
      88              : /**
      89              :  * @brief Enumeration for STM32 QSPI extended operations.
      90              :  */
      91            1 : enum stm32_qspi_ex_ops {
      92              :         /**
      93              :          * QSPI generic read command.
      94              :          *
      95              :          * Transmit the custom command and read the result to the user-provided
      96              :          * buffer.
      97              :          */
      98              :         FLASH_STM32_QSPI_EX_OP_GENERIC_READ,
      99              :         /**
     100              :          * QSPI generic write command.
     101              :          *
     102              :          * Transmit the custom command and then write data taken from the
     103              :          * user-provided buffer.
     104              :          */
     105              :         FLASH_STM32_QSPI_EX_OP_GENERIC_WRITE,
     106              : };
     107              : 
     108              : /**
     109              :  * @brief Input structure for @ref FLASH_STM32_EX_OP_SECTOR_WP operation.
     110              :  */
     111            1 : struct flash_stm32_ex_op_sector_wp_in {
     112              :         /** Mask of sectors to enable protection on. */
     113            1 :         uint64_t enable_mask;
     114              :         /** Mask of sectors to disable protection on. */
     115            1 :         uint64_t disable_mask;
     116              : };
     117              : 
     118              : /**
     119              :  * @brief Output structure for @ref FLASH_STM32_EX_OP_SECTOR_WP operation.
     120              :  */
     121            1 : struct flash_stm32_ex_op_sector_wp_out {
     122              :         /** Mask of protected sectors. */
     123            1 :         uint64_t protected_mask;
     124              : };
     125              : 
     126              : /**
     127              :  * @brief Input structure for @ref FLASH_STM32_EX_OP_RDP operation.
     128              :  */
     129            1 : struct flash_stm32_ex_op_rdp {
     130              :         /** Whether to enable or disable the readout protection. */
     131            1 :         bool enable;
     132              :         /** Whether to make the readout protection permanent. */
     133            1 :         bool permanent;
     134              : };
     135              : 
     136              : /**
     137              :  * @}
     138              :  */
     139              : 
     140              : #endif /* __ZEPHYR_INCLUDE_DRIVERS_FLASH_STM32_FLASH_API_EXTENSIONS_H__ */
        

Generated by: LCOV version 2.0-1