Lines Matching +full:active +full:- +full:channel

4  * SPDX-License-Identifier: Apache-2.0
11 * initialization, interrupt handling, and any other module-wide tasks. The current implementation
34 (*(struct nxp_mrt_channel_data *const *const)dev->data)
36 /* Device config->data is an array of data pointers ordered by channel number,
37 * dev->data is a pointer to one of these pointers in that array,
38 * so the value of the dev->data - dev->config->data is the channel index
41 (((struct nxp_mrt_channel_data *const *)dev->data) - \
42 ((const struct nxp_mrt_config *)dev->config)->data)
44 /* Specific for each channel */
65 const struct nxp_mrt_config *config = dev->config; in nxp_mrt_stop()
66 MRT_Type *base = config->base; in nxp_mrt_stop()
69 LOG_DBG("MRT@%p channel %d stopped", base, channel_id); in nxp_mrt_stop()
70 LOG_WRN("MRT channel resets upon stopping"); in nxp_mrt_stop()
73 base->CHANNEL[channel_id].INTVAL = MRT_CHANNEL_INTVAL_LOAD(1); in nxp_mrt_stop()
80 const struct nxp_mrt_config *config = dev->config; in nxp_mrt_start()
81 MRT_Type *base = config->base; in nxp_mrt_start()
85 if (data->top <= 1) { in nxp_mrt_start()
87 LOG_INF("\"Started\" MRT@%p channel %d with default value %d", in nxp_mrt_start()
88 base, channel_id, config->info.max_top_value); in nxp_mrt_start()
89 data->top = config->info.max_top_value; in nxp_mrt_start()
93 base->CHANNEL[channel_id].INTVAL = data->top; in nxp_mrt_start()
95 LOG_DBG("MRT@%p channel %d started with top value %d", base, channel_id, data->top); in nxp_mrt_start()
102 const struct nxp_mrt_config *config = dev->config; in nxp_mrt_get_value()
103 MRT_Type *base = config->base; in nxp_mrt_get_value()
106 *ticks = base->CHANNEL[channel_id].TIMER & MRT_CHANNEL_TIMER_VALUE_MASK; in nxp_mrt_get_value()
114 const struct nxp_mrt_config *config = dev->config; in nxp_mrt_set_top_value()
115 MRT_Type *base = config->base; in nxp_mrt_set_top_value()
119 bool reset = !(cfg->flags & COUNTER_TOP_CFG_DONT_RESET); in nxp_mrt_set_top_value()
120 bool active = base->CHANNEL[channel_id].STAT & MRT_CHANNEL_STAT_RUN_MASK; in nxp_mrt_set_top_value() local
121 uint32_t current_val = base->CHANNEL[channel_id].TIMER & MRT_CHANNEL_TIMER_VALUE_MASK; in nxp_mrt_set_top_value()
125 data->top = cfg->ticks; in nxp_mrt_set_top_value()
128 data->cb = cfg->callback; in nxp_mrt_set_top_value()
129 data->user_data = cfg->user_data; in nxp_mrt_set_top_value()
133 if (!active) { in nxp_mrt_set_top_value()
134 LOG_DBG("Set MRT@%p channel %d top value to %d", base, channel_id, data->top); in nxp_mrt_set_top_value()
139 if (cfg->ticks < current_val) { in nxp_mrt_set_top_value()
140 LOG_WRN("MRT@%p channel %d received requested top value %d which is " in nxp_mrt_set_top_value()
142 base, channel_id, cfg->ticks, current_val); in nxp_mrt_set_top_value()
146 ret = reset ? 0 : -ETIME; in nxp_mrt_set_top_value()
148 reset |= cfg->flags & COUNTER_TOP_CFG_RESET_WHEN_LATE; in nxp_mrt_set_top_value()
152 base->CHANNEL[channel_id].INTVAL = MRT_CHANNEL_INTVAL_IVALUE(cfg->ticks) | in nxp_mrt_set_top_value()
155 LOG_DBG("Changed MRT@%p channel %d top value while active to %d", in nxp_mrt_set_top_value()
157 base->CHANNEL[channel_id].INTVAL & MRT_CHANNEL_INTVAL_IVALUE_MASK); in nxp_mrt_set_top_value()
164 const struct nxp_mrt_config *config = dev->config; in nxp_mrt_get_top_value()
165 MRT_Type *base = config->base; in nxp_mrt_get_top_value()
168 return base->CHANNEL[channel_id].INTVAL & MRT_CHANNEL_INTVAL_IVALUE_MASK; in nxp_mrt_get_top_value()
173 const struct nxp_mrt_config *config = dev->config; in nxp_mrt_get_pending_int()
174 MRT_Type *base = config->base; in nxp_mrt_get_pending_int()
177 return base->CHANNEL[channel_id].STAT & MRT_CHANNEL_STAT_INTFLAG_MASK; in nxp_mrt_get_pending_int()
189 return -ENOTSUP; in nxp_mrt_set_alarm()
198 return -ENOTSUP; in nxp_mrt_cancel_alarm()
203 const struct nxp_mrt_config *config = dev->config; in nxp_mrt_get_freq()
206 clock_control_get_rate(config->clock_dev, config->clock_subsys, &freq); in nxp_mrt_get_freq()
213 const struct nxp_mrt_config *config = dev->config; in nxp_mrt_init()
214 MRT_Type *base = config->base; in nxp_mrt_init()
215 uint32_t num_channels = (base->MODCFG & MRT_MODCFG_NOC_MASK) >> MRT_MODCFG_NOC_SHIFT; in nxp_mrt_init()
218 if (!device_is_ready(config->reset.dev)) { in nxp_mrt_init()
220 return -ENODEV; in nxp_mrt_init()
223 ret = reset_line_toggle(config->reset.dev, config->reset.id); in nxp_mrt_init()
228 clock_control_on(config->clock_dev, config->clock_subsys); in nxp_mrt_init()
230 config->irq_config_func(dev); in nxp_mrt_init()
234 if (config->channels[i]) { in nxp_mrt_init()
235 base->CHANNEL[i].CTRL = MRT_CHANNEL_CTRL_INTEN_MASK; in nxp_mrt_init()
244 const struct nxp_mrt_config *config = dev->config; in nxp_mrt_isr()
245 MRT_Type *base = config->base; in nxp_mrt_isr()
246 uint32_t irq_pends = base->IRQ_FLAG; in nxp_mrt_isr()
247 uint32_t num_channels = (base->MODCFG & MRT_MODCFG_NOC_MASK) >> MRT_MODCFG_NOC_SHIFT; in nxp_mrt_isr()
250 /* Channel IRQ pending flags lowest order bits in IRQ_FLAG register */ in nxp_mrt_isr()
255 LOG_DBG("Handling interrupt for MRT%p channel %d", base, i); in nxp_mrt_isr()
258 base->CHANNEL[i].STAT |= MRT_CHANNEL_STAT_INTFLAG_MASK; in nxp_mrt_isr()
260 /* Channel devs & pointer path to channel cbs is in shared config */ in nxp_mrt_isr()
261 if (config->data[i]->cb) { in nxp_mrt_isr()
262 config->data[i]->cb(config->channels[i], config->data[i]->user_data); in nxp_mrt_isr()
279 /* Creates a device for a channel (needed for counter API) */
288 /* Creates a data struct for a channel device */
293 /* Initializes an element of the channel data pointer array */
298 /* Initializes an element of the channel device pointer array */
311 /* Initialize all the data structs for active channels */ \
324 /* Create all the channel/counter devices */ \
327 /* This channel device array is needed by the module device ISR */ \
338 GENMASK(DT_INST_PROP(n, num_bits) - 1, 0), \