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

            Line data    Source code
       1            1 : /**
       2              :  * @file
       3              :  * @brief DMA Devicetree macro public API header file.
       4              :  */
       5              : 
       6              : /*
       7              :  * Copyright (c) 2020, Linaro Ltd.
       8              :  *
       9              :  * SPDX-License-Identifier: Apache-2.0
      10              :  */
      11              : 
      12              : #ifndef ZEPHYR_INCLUDE_DEVICETREE_DMAS_H_
      13              : #define ZEPHYR_INCLUDE_DEVICETREE_DMAS_H_
      14              : 
      15              : #ifdef __cplusplus
      16              : extern "C" {
      17              : #endif
      18              : 
      19              : /**
      20              :  * @defgroup devicetree-dmas Devicetree DMA API
      21              :  * @ingroup devicetree
      22              :  * @ingroup dma_interface
      23              :  * @{
      24              :  */
      25              : 
      26              : /**
      27              :  * @brief Get the node identifier for the DMA controller from a
      28              :  *        dmas property at an index
      29              :  *
      30              :  * Example devicetree fragment:
      31              :  *
      32              :  *     dma1: dma@... { ... };
      33              :  *
      34              :  *     dma2: dma@... { ... };
      35              :  *
      36              :  *     n: node {
      37              :  *              dmas = <&dma1 1 2 0x400 0x3>,
      38              :  *                      <&dma2 6 3 0x404 0x5>;
      39              :  *     };
      40              :  *
      41              :  * Example usage:
      42              :  *
      43              :  *     DT_DMAS_CTLR_BY_IDX(DT_NODELABEL(n), 0) // DT_NODELABEL(dma1)
      44              :  *     DT_DMAS_CTLR_BY_IDX(DT_NODELABEL(n), 1) // DT_NODELABEL(dma2)
      45              :  *
      46              :  * @param node_id node identifier for a node with a dmas property
      47              :  * @param idx logical index into dmas property
      48              :  * @return the node identifier for the DMA controller referenced at
      49              :  *         index "idx"
      50              :  * @see DT_PROP_BY_PHANDLE_IDX()
      51              :  */
      52            1 : #define DT_DMAS_CTLR_BY_IDX(node_id, idx) DT_PHANDLE_BY_IDX(node_id, dmas, idx)
      53              : 
      54              : /**
      55              :  * @brief Get the node identifier for the DMA controller from a
      56              :  *        dmas property by name
      57              :  *
      58              :  * Example devicetree fragment:
      59              :  *
      60              :  *     dma1: dma@... { ... };
      61              :  *
      62              :  *     dma2: dma@... { ... };
      63              :  *
      64              :  *     n: node {
      65              :  *              dmas = <&dma1 1 2 0x400 0x3>,
      66              :  *                      <&dma2 6 3 0x404 0x5>;
      67              :  *              dma-names = "tx", "rx";
      68              :  *     };
      69              :  *
      70              :  * Example usage:
      71              :  *
      72              :  *     DT_DMAS_CTLR_BY_NAME(DT_NODELABEL(n), tx) // DT_NODELABEL(dma1)
      73              :  *     DT_DMAS_CTLR_BY_NAME(DT_NODELABEL(n), rx) // DT_NODELABEL(dma2)
      74              :  *
      75              :  * @param node_id node identifier for a node with a dmas property
      76              :  * @param name lowercase-and-underscores name of a dmas element
      77              :  *             as defined by the node's dma-names property
      78              :  * @return the node identifier for the DMA controller in the named element
      79              :  * @see DT_PHANDLE_BY_NAME()
      80              :  */
      81            1 : #define DT_DMAS_CTLR_BY_NAME(node_id, name) \
      82              :         DT_PHANDLE_BY_NAME(node_id, dmas, name)
      83              : 
      84              : /**
      85              :  * @brief Equivalent to DT_DMAS_CTLR_BY_IDX(node_id, 0)
      86              :  * @param node_id node identifier for a node with a dmas property
      87              :  * @return the node identifier for the DMA controller at index 0
      88              :  *         in the node's "dmas" property
      89              :  * @see DT_DMAS_CTLR_BY_IDX()
      90              :  */
      91            1 : #define DT_DMAS_CTLR(node_id) DT_DMAS_CTLR_BY_IDX(node_id, 0)
      92              : 
      93              : /**
      94              :  * @brief Get the node identifier for the DMA controller from a
      95              :  *        DT_DRV_COMPAT instance's dmas property at an index
      96              :  *
      97              :  * @param inst DT_DRV_COMPAT instance number
      98              :  * @param idx logical index into dmas property
      99              :  * @return the node identifier for the DMA controller referenced at
     100              :  *         index "idx"
     101              :  * @see DT_DMAS_CTLR_BY_IDX()
     102              :  */
     103            1 : #define DT_INST_DMAS_CTLR_BY_IDX(inst, idx) \
     104              :         DT_DMAS_CTLR_BY_IDX(DT_DRV_INST(inst), idx)
     105              : 
     106              : /**
     107              :  * @brief Get the node identifier for the DMA controller from a
     108              :  *        DT_DRV_COMPAT instance's dmas property by name
     109              :  * @param inst DT_DRV_COMPAT instance number
     110              :  * @param name lowercase-and-underscores name of a dmas element
     111              :  *             as defined by the node's dma-names property
     112              :  * @return the node identifier for the DMA controller in the named element
     113              :  * @see DT_DMAS_CTLR_BY_NAME()
     114              :  */
     115            1 : #define DT_INST_DMAS_CTLR_BY_NAME(inst, name) \
     116              :         DT_DMAS_CTLR_BY_NAME(DT_DRV_INST(inst), name)
     117              : 
     118              : /**
     119              :  * @brief Equivalent to DT_INST_DMAS_CTLR_BY_IDX(inst, 0)
     120              :  * @param inst DT_DRV_COMPAT instance number
     121              :  * @return the node identifier for the DMA controller at index 0
     122              :  *         in the instance's "dmas" property
     123              :  * @see DT_DMAS_CTLR_BY_IDX()
     124              :  */
     125            1 : #define DT_INST_DMAS_CTLR(inst) DT_INST_DMAS_CTLR_BY_IDX(inst, 0)
     126              : 
     127              : /**
     128              :  * @brief Get a DMA specifier's cell value at an index
     129              :  *
     130              :  * Example devicetree fragment:
     131              :  *
     132              :  *     dma1: dma@... {
     133              :  *             compatible = "vnd,dma";
     134              :  *             #dma-cells = <2>;
     135              :  *     };
     136              :  *
     137              :  *     dma2: dma@... {
     138              :  *             compatible = "vnd,dma";
     139              :  *             #dma-cells = <2>;
     140              :  *     };
     141              :  *
     142              :  *     n: node {
     143              :  *              dmas = <&dma1 1 0x400>,
     144              :  *                     <&dma2 6 0x404>;
     145              :  *     };
     146              :  *
     147              :  * Bindings fragment for the vnd,dma compatible:
     148              :  *
     149              :  *     dma-cells:
     150              :  *       - channel
     151              :  *       - config
     152              :  *
     153              :  * Example usage:
     154              :  *
     155              :  *     DT_DMAS_CELL_BY_IDX(DT_NODELABEL(n), 0, channel) // 1
     156              :  *     DT_DMAS_CELL_BY_IDX(DT_NODELABEL(n), 1, channel) // 6
     157              :  *     DT_DMAS_CELL_BY_IDX(DT_NODELABEL(n), 0, config) // 0x400
     158              :  *     DT_DMAS_CELL_BY_IDX(DT_NODELABEL(n), 1, config) // 0x404
     159              :  *
     160              :  * @param node_id node identifier for a node with a dmas property
     161              :  * @param idx logical index into dmas property
     162              :  * @param cell lowercase-and-underscores cell name
     163              :  * @return the cell value at index "idx"
     164              :  * @see DT_PHA_BY_IDX()
     165              :  */
     166            1 : #define DT_DMAS_CELL_BY_IDX(node_id, idx, cell) \
     167              :         DT_PHA_BY_IDX(node_id, dmas, idx, cell)
     168              : 
     169              : /**
     170              :  * @brief Get a DT_DRV_COMPAT instance's DMA specifier's cell value at an index
     171              :  * @param inst DT_DRV_COMPAT instance number
     172              :  * @param idx logical index into dmas property
     173              :  * @param cell lowercase-and-underscores cell name
     174              :  * @return the cell value at index "idx"
     175              :  * @see DT_DMAS_CELL_BY_IDX()
     176              :  */
     177            1 : #define DT_INST_DMAS_CELL_BY_IDX(inst, idx, cell) \
     178              :         DT_PHA_BY_IDX(DT_DRV_INST(inst), dmas, idx, cell)
     179              : 
     180              : /**
     181              :  * @brief Get a DMA specifier's cell value by name
     182              :  *
     183              :  * Example devicetree fragment:
     184              :  *
     185              :  *     dma1: dma@... {
     186              :  *             compatible = "vnd,dma";
     187              :  *             #dma-cells = <2>;
     188              :  *     };
     189              :  *
     190              :  *     dma2: dma@... {
     191              :  *             compatible = "vnd,dma";
     192              :  *             #dma-cells = <2>;
     193              :  *     };
     194              :  *
     195              :  *     n: node {
     196              :  *              dmas = <&dma1 1 0x400>,
     197              :  *                     <&dma2 6 0x404>;
     198              :  *              dma-names = "tx", "rx";
     199              :  *     };
     200              :  *
     201              :  * Bindings fragment for the vnd,dma compatible:
     202              :  *
     203              :  *     dma-cells:
     204              :  *       - channel
     205              :  *       - config
     206              :  *
     207              :  * Example usage:
     208              :  *
     209              :  *     DT_DMAS_CELL_BY_NAME(DT_NODELABEL(n), tx, channel) // 1
     210              :  *     DT_DMAS_CELL_BY_NAME(DT_NODELABEL(n), rx, channel) // 6
     211              :  *     DT_DMAS_CELL_BY_NAME(DT_NODELABEL(n), tx, config) // 0x400
     212              :  *     DT_DMAS_CELL_BY_NAME(DT_NODELABEL(n), rx, config) // 0x404
     213              :  *
     214              :  * @param node_id node identifier for a node with a dmas property
     215              :  * @param name lowercase-and-underscores name of a dmas element
     216              :  *             as defined by the node's dma-names property
     217              :  * @param cell lowercase-and-underscores cell name
     218              :  * @return the cell value in the specifier at the named element
     219              :  * @see DT_PHA_BY_NAME()
     220              :  */
     221            1 : #define DT_DMAS_CELL_BY_NAME(node_id, name, cell) \
     222              :         DT_PHA_BY_NAME(node_id, dmas, name, cell)
     223              : 
     224              : /**
     225              :  * @brief Like DT_DMAS_CELL_BY_NAME(), but with a fallback to @p default_value
     226              :  *
     227              :  * If the value exists, this expands to DT_DMAS_CELL_BY_NAME(node_id,
     228              :  * name, cell). The @p default_value parameter is not expanded in this case.
     229              :  *
     230              :  * Otherwise, this expands to @p default_value.
     231              :  *
     232              :  * @param node_id node identifier for a node with a dmas property
     233              :  * @param name lowercase-and-underscores name of a dmas element
     234              :  *             as defined by the node's dma-names property
     235              :  * @param cell lowercase-and-underscores cell name
     236              :  * @param default_value a fallback value to expand to
     237              :  * @return the cell's value or @p default_value
     238              :  * @see DT_PHA_BY_NAME_OR()
     239              :  */
     240            1 : #define DT_DMAS_CELL_BY_NAME_OR(node_id, name, cell, default_value) \
     241              :         DT_PHA_BY_NAME_OR(node_id, dmas, name, cell, default_value)
     242              : 
     243              : /**
     244              :  * @brief Get a DT_DRV_COMPAT instance's DMA specifier's cell value by name
     245              :  * @param inst DT_DRV_COMPAT instance number
     246              :  * @param name lowercase-and-underscores name of a dmas element
     247              :  *             as defined by the node's dma-names property
     248              :  * @param cell lowercase-and-underscores cell name
     249              :  * @return the cell value in the specifier at the named element
     250              :  * @see DT_DMAS_CELL_BY_NAME()
     251              :  */
     252            1 : #define DT_INST_DMAS_CELL_BY_NAME(inst, name, cell) \
     253              :         DT_DMAS_CELL_BY_NAME(DT_DRV_INST(inst), name, cell)
     254              : 
     255              : /**
     256              :  * @brief Is index "idx" valid for a dmas property?
     257              :  * @param node_id node identifier for a node with a dmas property
     258              :  * @param idx logical index into dmas property
     259              :  * @return 1 if the "dmas" property has index "idx", 0 otherwise
     260              :  */
     261            1 : #define DT_DMAS_HAS_IDX(node_id, idx) \
     262              :         IS_ENABLED(DT_CAT4(node_id, _P_dmas_IDX_, idx, _EXISTS))
     263              : 
     264              : /**
     265              :  * @brief Is index "idx" valid for a DT_DRV_COMPAT instance's dmas property?
     266              :  * @param inst DT_DRV_COMPAT instance number
     267              :  * @param idx logical index into dmas property
     268              :  * @return 1 if the "dmas" property has a specifier at index "idx", 0 otherwise
     269              :  */
     270            1 : #define DT_INST_DMAS_HAS_IDX(inst, idx) \
     271              :         DT_DMAS_HAS_IDX(DT_DRV_INST(inst), idx)
     272              : 
     273              : /**
     274              :  * @brief Does a dmas property have a named element?
     275              :  * @param node_id node identifier for a node with a dmas property
     276              :  * @param name lowercase-and-underscores name of a dmas element
     277              :  *             as defined by the node's dma-names property
     278              :  * @return 1 if the dmas property has the named element, 0 otherwise
     279              :  */
     280            1 : #define DT_DMAS_HAS_NAME(node_id, name) \
     281              :         DT_PROP_HAS_NAME(node_id, dmas, name)
     282              : 
     283              : /**
     284              :  * @brief Does a DT_DRV_COMPAT instance's dmas property have a named element?
     285              :  * @param inst DT_DRV_COMPAT instance number
     286              :  * @param name lowercase-and-underscores name of a dmas element
     287              :  *             as defined by the node's dma-names property
     288              :  * @return 1 if the dmas property has the named element, 0 otherwise
     289              :  */
     290            1 : #define DT_INST_DMAS_HAS_NAME(inst, name) \
     291              :         DT_DMAS_HAS_NAME(DT_DRV_INST(inst), name)
     292              : 
     293              : /**
     294              :  * @}
     295              :  */
     296              : 
     297              : #ifdef __cplusplus
     298              : }
     299              : #endif
     300              : 
     301              : #endif  /* ZEPHYR_INCLUDE_DEVICETREE_DMAS_H_ */
        

Generated by: LCOV version 2.0-1