LCOV - code coverage report
Current view: top level - zephyr/drivers/firmware/scmi - clk.h Coverage Total Hit
Test: new.info Lines: 39.1 % 23 9
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            1 : /*
       2              :  * Copyright 2024 NXP
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : /**
       8              :  * @file
       9              :  * @brief SCMI clock protocol helpers
      10              :  */
      11              : 
      12              : #ifndef _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_CLK_H_
      13              : #define _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_CLK_H_
      14              : 
      15              : #include <zephyr/drivers/firmware/scmi/protocol.h>
      16              : 
      17            0 : #define SCMI_CLK_CONFIG_DISABLE_ENABLE_MASK GENMASK(1, 0)
      18            0 : #define SCMI_CLK_CONFIG_ENABLE_DISABLE(x)\
      19              :         ((uint32_t)(x) & SCMI_CLK_CONFIG_DISABLE_ENABLE_MASK)
      20              : 
      21            0 : #define SCMI_CLK_ATTRIBUTES_CLK_NUM(x) ((x) & GENMASK(15, 0))
      22              : 
      23            0 : #define SCMI_CLK_RATE_SET_FLAGS_ASYNC                BIT(0)
      24            0 : #define SCMI_CLK_RATE_SET_FLAGS_IGNORE_DELEAYED_RESP BIT(1)
      25            0 : #define SCMI_CLK_RATE_SET_FLAGS_ROUNDS_UP_DOWN       BIT(2)
      26            0 : #define SCMI_CLK_RATE_SET_FLAGS_ROUNDS_AUTO          BIT(3)
      27              : 
      28              : /**
      29              :  * @struct scmi_clock_config
      30              :  *
      31              :  * @brief Describes the parameters for the CLOCK_CONFIG_SET
      32              :  * command
      33              :  */
      34            1 : struct scmi_clock_config {
      35            0 :         uint32_t clk_id;
      36            0 :         uint32_t attributes;
      37            0 :         uint32_t extended_cfg_val;
      38              : };
      39              : 
      40              : /**
      41              :  * @struct scmi_clock_rate_config
      42              :  *
      43              :  * @brief Describes the parameters for the CLOCK_RATE_SET
      44              :  * command
      45              :  */
      46            1 : struct scmi_clock_rate_config {
      47            0 :         uint32_t flags;
      48            0 :         uint32_t clk_id;
      49            0 :         uint32_t rate[2];
      50              : };
      51              : 
      52              : /**
      53              :  * @brief Clock protocol command message IDs
      54              :  */
      55            0 : enum scmi_clock_message {
      56              :         SCMI_CLK_MSG_PROTOCOL_VERSION = 0x0,
      57              :         SCMI_CLK_MSG_PROTOCOL_ATTRIBUTES = 0x1,
      58              :         SCMI_CLK_MSG_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
      59              :         SCMI_CLK_MSG_CLOCK_ATTRIBUTES = 0x3,
      60              :         SCMI_CLK_MSG_CLOCK_DESCRIBE_RATES = 0x4,
      61              :         SCMI_CLK_MSG_CLOCK_RATE_SET = 0x5,
      62              :         SCMI_CLK_MSG_CLOCK_RATE_GET = 0x6,
      63              :         SCMI_CLK_MSG_CLOCK_CONFIG_SET = 0x7,
      64              :         SCMI_CLK_MSG_CLOCK_NAME_GET = 0x8,
      65              :         SCMI_CLK_MSG_CLOCK_RATE_NOTIFY = 0x9,
      66              :         SCMI_CLK_MSG_CLOCK_RATE_CHANGE_REQUESTED_NOTIFY = 0xa,
      67              :         SCMI_CLK_MSG_CLOCK_CONFIG_GET = 0xb,
      68              :         SCMI_CLK_MSG_CLOCK_POSSIBLE_PARENTS_GET = 0xc,
      69              :         SCMI_CLK_MSG_CLOCK_PARENT_SET = 0xd,
      70              :         SCMI_CLK_MSG_CLOCK_PARENT_GET = 0xe,
      71              :         SCMI_CLK_MSG_CLOCK_GET_PERMISSIONS = 0xf,
      72              :         SCMI_CLK_MSG_NEGOTIATE_PROTOCOL_VERSION = 0x10,
      73              : };
      74              : 
      75              : /**
      76              :  * @brief Send the PROTOCOL_ATTRIBUTES command and get its reply
      77              :  *
      78              :  * @param proto pointer to SCMI clock protocol data
      79              :  * @param attributes pointer to attributes to be set via
      80              :  * this command
      81              :  *
      82              :  * @retval 0 if successful
      83              :  * @retval negative errno if failure
      84              :  */
      85            1 : int scmi_clock_protocol_attributes(struct scmi_protocol *proto,
      86              :                                    uint32_t *attributes);
      87              : 
      88              : /**
      89              :  * @brief Send the CLOCK_CONFIG_SET command and get its reply
      90              :  *
      91              :  * @param proto pointer to SCMI clock protocol data
      92              :  * @param cfg pointer to structure containing configuration
      93              :  * to be set
      94              :  *
      95              :  * @retval 0 if successful
      96              :  * @retval negative errno if failure
      97              :  */
      98            1 : int scmi_clock_config_set(struct scmi_protocol *proto,
      99              :                           struct scmi_clock_config *cfg);
     100              : /**
     101              :  * @brief Query the rate of a clock
     102              :  *
     103              :  * @param proto pointer to SCMI clock protocol data
     104              :  * @param clk_id ID of the clock for which the query is done
     105              :  * @param rate pointer to rate to be set via this command
     106              :  *
     107              :  * @retval 0 if successful
     108              :  * @retval negative errno if failure
     109              :  */
     110            1 : int scmi_clock_rate_get(struct scmi_protocol *proto,
     111              :                         uint32_t clk_id, uint32_t *rate);
     112              : 
     113              : /**
     114              :  * @brief Send the CLOCK_RATE_SET command and get its reply
     115              :  *
     116              :  * @param proto pointer to SCMI clock protocol data
     117              :  * @param cfg pointer to structure containing configuration
     118              :  * to be set
     119              :  *
     120              :  * @retval 0 if successful
     121              :  * @retval negative errno if failure
     122              :  */
     123            1 : int scmi_clock_rate_set(struct scmi_protocol *proto, struct scmi_clock_rate_config *cfg);
     124              : 
     125              : /**
     126              :  * @brief Query the parent of a clock
     127              :  *
     128              :  * @param proto pointer to SCMI clock protocol data
     129              :  * @param clk_id ID of the clock for which the query is done
     130              :  * @param parent_id pointer to be set via this command
     131              :  *
     132              :  * @retval 0 if successful
     133              :  * @retval negative errno if failure
     134              :  */
     135            1 : int scmi_clock_parent_get(struct scmi_protocol *proto, uint32_t clk_id, uint32_t *parent_id);
     136              : 
     137              : /**
     138              :  * @brief Send the CLOCK_PARENT_SET command and get its reply
     139              :  *
     140              :  * @param proto pointer to SCMI clock protocol data
     141              :  * @param clk_id ID of the clock for which the query is done
     142              :  * @param parent_id to be set via this command
     143              :  * to be set
     144              :  *
     145              :  * @retval 0 if successful
     146              :  * @retval negative errno if failure
     147              :  */
     148            1 : int scmi_clock_parent_set(struct scmi_protocol *proto, uint32_t clk_id, uint32_t parent_id);
     149              : 
     150              : #endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_CLK_H_ */
        

Generated by: LCOV version 2.0-1