|
7 | 7 | #ifndef _NUVOTON_NPCX_SOC_DT_H_ |
8 | 8 | #define _NUVOTON_NPCX_SOC_DT_H_ |
9 | 9 |
|
| 10 | +/** |
| 11 | + * @brief Like DT_PROP(), but expand parameters with |
| 12 | + * DT_ENUM_UPPER_TOKEN not DT_PROP |
| 13 | + * |
| 14 | + * If the prop exists, this expands to DT_ENUM_UPPER_TOKEN(node_id, prop). |
| 15 | + * The default_value parameter is not expanded in this case. |
| 16 | + * |
| 17 | + * Otherwise, this expands to default_value. |
| 18 | + * |
| 19 | + * @param node_id node identifier |
| 20 | + * @param prop lowercase-and-underscores property name |
| 21 | + * @param default_value a fallback value to expand to |
| 22 | + * @return the property's enum upper token value or default_value |
| 23 | + */ |
| 24 | +#define NPCX_DT_PROP_ENUM_OR(node_id, prop, default_value) \ |
| 25 | + COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \ |
| 26 | + (DT_ENUM_UPPER_TOKEN(node_id, prop)), (default_value)) |
| 27 | + |
| 28 | +/** |
| 29 | + * @brief Like DT_INST_PROP_OR(), but expand parameters with |
| 30 | + * NPCX_DT_PROP_ENUM_OR not DT_PROP_OR |
| 31 | + * @param inst instance number |
| 32 | + * @param prop lowercase-and-underscores property name |
| 33 | + * @param default_value a fallback value to expand to |
| 34 | + * @return the property's enum upper token value or default_value |
| 35 | + */ |
| 36 | +#define NPCX_DT_INST_PROP_ENUM_OR(inst, prop, default_value) \ |
| 37 | + NPCX_DT_PROP_ENUM_OR(DT_DRV_INST(inst), prop, default_value) |
| 38 | + |
10 | 39 | /** |
11 | 40 | * @brief Construct a npcx_clk_cfg item from first item in 'clocks' prop which |
12 | 41 | * type is 'phandle-array' to handle "clock-cells" in current driver. |
|
27 | 56 | */ |
28 | 57 | #define NPCX_DT_CLK_CFG_ITEM(inst) \ |
29 | 58 | { \ |
30 | | - .bus = DT_PHA(DT_DRV_INST(inst), clocks, bus), \ |
| 59 | + .bus = NPCX_DT_INST_PROP_ENUM_OR(inst, clock_bus, \ |
| 60 | + DT_PHA(DT_DRV_INST(inst), clocks, bus)), \ |
31 | 61 | .ctrl = DT_PHA(DT_DRV_INST(inst), clocks, ctl), \ |
32 | 62 | .bit = DT_PHA(DT_DRV_INST(inst), clocks, bit), \ |
33 | 63 | } |
|
0 commit comments