Lines Matching +full:dead +full:- +full:time
4 * SPDX-License-Identifier: Apache-2.0
26 * Need to fill to this array at runtime, cannot do at build time like
94 return -EINVAL; in pwm_nxp_s32_set_cycles_internal_timebase()
106 return -EIO; in pwm_nxp_s32_set_cycles_internal_timebase()
128 return -EINVAL; in pwm_nxp_s32_set_cycles_external_timebase()
140 return -EIO; in pwm_nxp_s32_set_cycles_external_timebase()
147 return -EIO; in pwm_nxp_s32_set_cycles_external_timebase()
159 const struct pwm_nxp_s32_config *config = dev->config; in pwm_nxp_s32_set_cycles()
160 struct pwm_nxp_s32_data *data = dev->data; in pwm_nxp_s32_set_cycles()
167 return -EINVAL; in pwm_nxp_s32_set_cycles()
170 if (eMios_Pwm_Ip_IndexInChState[config->instance][channel] >= in pwm_nxp_s32_set_cycles()
173 return -EINVAL; in pwm_nxp_s32_set_cycles()
176 logic_ch = eMios_Pwm_Ip_IndexInChState[config->instance][channel] - data->start_pwm_ch; in pwm_nxp_s32_set_cycles()
177 pwm_info = &config->pulse_info->pwm_info[logic_ch]; in pwm_nxp_s32_set_cycles()
179 if ((flags & PWM_POLARITY_MASK) == pwm_info->OutputPolarity) { in pwm_nxp_s32_set_cycles()
180 LOG_ERR("Only support configuring output polarity at boot time"); in pwm_nxp_s32_set_cycles()
181 return -ENOTSUP; in pwm_nxp_s32_set_cycles()
184 switch (pwm_info->Mode) { in pwm_nxp_s32_set_cycles()
187 return pwm_nxp_s32_set_cycles_internal_timebase(config->instance, channel, in pwm_nxp_s32_set_cycles()
196 return -EINVAL; in pwm_nxp_s32_set_cycles()
199 return pwm_nxp_s32_set_cycles_external_timebase(config->instance, channel, in pwm_nxp_s32_set_cycles()
206 if ((Emios_Pwm_Ip_GetPhaseShift(config->instance, channel) + in pwm_nxp_s32_set_cycles()
209 return -EINVAL; in pwm_nxp_s32_set_cycles()
212 return pwm_nxp_s32_set_cycles_external_timebase(config->instance, channel, in pwm_nxp_s32_set_cycles()
230 return second_cnt - first_cnt; in pwm_nxp_s32_capture_calc()
234 return EMIOS_ICU_IP_COUNTER_MASK - first_cnt + second_cnt; in pwm_nxp_s32_capture_calc()
262 const struct pwm_nxp_s32_config *config = dev->config; in pwm_nxp_s32_capture_configure()
263 struct pwm_nxp_s32_data *data = dev->data; in pwm_nxp_s32_capture_configure()
267 return -EINVAL; in pwm_nxp_s32_capture_configure()
272 return -EINVAL; in pwm_nxp_s32_capture_configure()
275 if (eMios_Icu_Ip_IndexInChState[config->instance][channel] >= in pwm_nxp_s32_capture_configure()
278 return -EINVAL; in pwm_nxp_s32_capture_configure()
281 /* If interrupt is enabled --> channel is on-going */ in pwm_nxp_s32_capture_configure()
282 if (config->base->CH.UC[channel].C & eMIOS_C_FEN_MASK) { in pwm_nxp_s32_capture_configure()
284 return -EBUSY; in pwm_nxp_s32_capture_configure()
287 data->capture[channel].continuous = (flags & PWM_CAPTURE_MODE_MASK); in pwm_nxp_s32_capture_configure()
288 data->capture[channel].inverted = (flags & PWM_POLARITY_MASK); in pwm_nxp_s32_capture_configure()
289 data->capture[channel].pulse_capture = (flags & PWM_CAPTURE_TYPE_PULSE); in pwm_nxp_s32_capture_configure()
290 data->capture[channel].period_capture = (flags & PWM_CAPTURE_TYPE_PERIOD); in pwm_nxp_s32_capture_configure()
291 data->capture[channel].callback = cb; in pwm_nxp_s32_capture_configure()
292 data->capture[channel].user_data = user_data; in pwm_nxp_s32_capture_configure()
299 const struct pwm_nxp_s32_config *config = dev->config; in pwm_nxp_s32_capture_enable()
300 struct pwm_nxp_s32_data *data = dev->data; in pwm_nxp_s32_capture_enable()
307 return -EINVAL; in pwm_nxp_s32_capture_enable()
310 if (eMios_Icu_Ip_IndexInChState[config->instance][channel] >= in pwm_nxp_s32_capture_enable()
313 return -EINVAL; in pwm_nxp_s32_capture_enable()
316 if (!data->capture[channel].callback) { in pwm_nxp_s32_capture_enable()
318 return -EINVAL; in pwm_nxp_s32_capture_enable()
321 /* If interrupt is enabled --> channel is on-going */ in pwm_nxp_s32_capture_enable()
322 if (config->base->CH.UC[channel].C & eMIOS_C_FEN_MASK) { in pwm_nxp_s32_capture_enable()
324 return -EBUSY; in pwm_nxp_s32_capture_enable()
328 if (data->capture[channel].period_capture && !data->capture[channel].pulse_capture) { in pwm_nxp_s32_capture_enable()
336 Emios_Icu_Ip_SetActivation(config->instance, channel, edge); in pwm_nxp_s32_capture_enable()
338 Emios_Icu_Ip_EnableNotification(config->instance, channel); in pwm_nxp_s32_capture_enable()
340 Emios_Icu_Ip_StartTimestamp(config->instance, channel, in pwm_nxp_s32_capture_enable()
341 data->capture[channel].edge_buff, in pwm_nxp_s32_capture_enable()
349 const struct pwm_nxp_s32_config *config = dev->config; in pwm_nxp_s32_capture_disable()
353 return -EINVAL; in pwm_nxp_s32_capture_disable()
356 if (eMios_Icu_Ip_IndexInChState[config->instance][channel] >= in pwm_nxp_s32_capture_disable()
359 return -EINVAL; in pwm_nxp_s32_capture_disable()
362 Emios_Icu_Ip_StopTimestamp(config->instance, channel); in pwm_nxp_s32_capture_disable()
369 const struct pwm_nxp_s32_config *config = dev->config; in pwm_nxp_s32_get_master_bus()
372 bus_select = (config->base->CH.UC[channel].C & eMIOS_C_BSL_MASK) >> eMIOS_C_BSL_SHIFT; in pwm_nxp_s32_get_master_bus()
398 const struct pwm_nxp_s32_config *config = dev->config; in pwm_nxp_s32_get_cycles_per_sec()
399 struct pwm_nxp_s32_data *data = dev->data; in pwm_nxp_s32_get_cycles_per_sec()
405 if (eMios_Pwm_Ip_IndexInChState[config->instance][channel] < in pwm_nxp_s32_get_cycles_per_sec()
407 master_bus = Emios_Pwm_Ip_GetMasterBusChannel(config->instance, channel); in pwm_nxp_s32_get_cycles_per_sec()
412 if (eMios_Icu_Ip_IndexInChState[config->instance][channel] < in pwm_nxp_s32_get_cycles_per_sec()
420 return -EINVAL; in pwm_nxp_s32_get_cycles_per_sec()
423 internal_prescaler = (config->base->CH.UC[master_bus].C2 & eMIOS_C2_UCEXTPRE_MASK) >> in pwm_nxp_s32_get_cycles_per_sec()
427 if (config->base->CH.UC[master_bus].C2 & eMIOS_C2_UCPRECLK_MASK) { in pwm_nxp_s32_get_cycles_per_sec()
428 *cycles = data->emios_clk / (internal_prescaler + 1); in pwm_nxp_s32_get_cycles_per_sec()
430 global_prescaler = (config->base->MCR & eMIOS_MCR_GPRE_MASK) >> in pwm_nxp_s32_get_cycles_per_sec()
432 *cycles = data->emios_clk / ((internal_prescaler + 1) * (global_prescaler + 1)); in pwm_nxp_s32_get_cycles_per_sec()
441 const struct pwm_nxp_s32_config *config = dev->config; in pwm_nxp_s32_pulse_gen_init()
442 struct pwm_nxp_s32_data *data = dev->data; in pwm_nxp_s32_pulse_gen_init()
449 data->start_pwm_ch = logic_ch; in pwm_nxp_s32_pulse_gen_init()
451 for (ch_id = 0; ch_id < config->pulse_info->pwm_pulse_channels; ch_id++) { in pwm_nxp_s32_pulse_gen_init()
452 pwm_info = &config->pulse_info->pwm_info[ch_id]; in pwm_nxp_s32_pulse_gen_init()
453 eMios_Pwm_Ip_IndexInChState[config->instance][pwm_info->ChannelId] = logic_ch++; in pwm_nxp_s32_pulse_gen_init()
454 Emios_Pwm_Ip_InitChannel(config->instance, pwm_info); in pwm_nxp_s32_pulse_gen_init()
464 const struct pwm_nxp_s32_config *config = dev->config; in pwm_nxp_s32_pulse_capture_init()
471 for (ch_id = 0; ch_id < config->icu_cfg->nNumChannels; ch_id++) { in pwm_nxp_s32_pulse_capture_init()
472 icu_info = &(*config->icu_cfg->pChannelsConfig)[ch_id]; in pwm_nxp_s32_pulse_capture_init()
473 eMios_Icu_Ip_IndexInChState[config->instance][icu_info->hwChannel] = logic_ch++; in pwm_nxp_s32_pulse_capture_init()
476 if (Emios_Icu_Ip_Init(config->instance, config->icu_cfg)) { in pwm_nxp_s32_pulse_capture_init()
477 return -EINVAL; in pwm_nxp_s32_pulse_capture_init()
485 const struct pwm_nxp_s32_config *config = dev->config; in pwm_nxp_s32_capture_callback()
486 struct pwm_nxp_s32_data *data = dev->data; in pwm_nxp_s32_capture_callback()
490 if (data->capture[channel].period_capture && !data->capture[channel].pulse_capture) { in pwm_nxp_s32_capture_callback()
491 period = pwm_nxp_s32_capture_calc(data->capture[channel].edge_buff[0], in pwm_nxp_s32_capture_callback()
492 data->capture[channel].edge_buff[1]); in pwm_nxp_s32_capture_callback()
494 if (data->capture[channel].pulse_capture) { in pwm_nxp_s32_capture_callback()
495 pulse = pwm_nxp_s32_pulse_calc(data->capture[channel].inverted, in pwm_nxp_s32_capture_callback()
496 data->capture[channel].edge_buff, in pwm_nxp_s32_capture_callback()
497 Emios_Icu_Ip_GetInputLevel(config->instance, in pwm_nxp_s32_capture_callback()
501 if (data->capture[channel].period_capture) { in pwm_nxp_s32_capture_callback()
502 period = pwm_nxp_s32_capture_calc(data->capture[channel].edge_buff[0], in pwm_nxp_s32_capture_callback()
503 data->capture[channel].edge_buff[2]); in pwm_nxp_s32_capture_callback()
507 if (!data->capture[channel].continuous) { in pwm_nxp_s32_capture_callback()
508 Emios_Icu_Ip_StopTimestamp(config->instance, channel); in pwm_nxp_s32_capture_callback()
511 data->capture[channel].callback(dev, channel, period, pulse, 0, in pwm_nxp_s32_capture_callback()
512 data->capture[channel].user_data); in pwm_nxp_s32_capture_callback()
518 const struct pwm_nxp_s32_config *config = dev->config; in pwm_nxp_s32_init()
519 struct pwm_nxp_s32_data *data = dev->data; in pwm_nxp_s32_init()
523 if (!device_is_ready(config->clock_dev)) { in pwm_nxp_s32_init()
524 return -ENODEV; in pwm_nxp_s32_init()
527 if (clock_control_get_rate(config->clock_dev, config->clock_subsys, in pwm_nxp_s32_init()
528 &data->emios_clk)) { in pwm_nxp_s32_init()
529 return -EINVAL; in pwm_nxp_s32_init()
532 err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); in pwm_nxp_s32_init()
565 * If timebase is configured in MCB up/down count mode: pwm period = (2 * master bus's period - 2)
569 (2 * DT_PROP_BY_PHANDLE(node_id, master_bus, period) - 2), \
598 EMIOS_PWM_LOG(node_id, "duty-cycle must be configured")); \
602 EMIOS_PWM_LOG(node_id, "input-filter is not used"));
612 EMIOS_PWM_LOG(node_id, "duty-cycle must <= period")); \
614 EMIOS_PWM_LOG(node_id, "master-bus must not be configured")); \
616 EMIOS_PWM_LOG(node_id, "dead-time is not used")); \
618 EMIOS_PWM_LOG(node_id, "phase-shift is not used"));
624 EMIOS_PWM_LOG(node_id, "master-bus must be configured in MCB up-down")); \
627 EMIOS_PWM_LOG(node_id, "duty-cycle + dead-time must <= period")); \
629 EMIOS_PWM_LOG(node_id, "dead-time must <= duty-cycle")); \
631 EMIOS_PWM_LOG(node_id, "phase-shift is not used")); \
639 EMIOS_PWM_LOG(node_id, "prescaler-src is not used," \
645 EMIOS_PWM_LOG(node_id, "master-bus must be configured in MCB up")); \
651 EMIOS_PWM_LOG(node_id, "duty-cycle + phase-shift must <= period")); \
653 EMIOS_PWM_LOG(node_id, "dead-time is not used")); \
657 EMIOS_PWM_LOG(node_id, "prescaler-src is not used," \
664 EMIOS_PWM_LOG(node_id, "master-bus must be configured in MCB up"));)) \
667 EMIOS_PWM_LOG(node_id, "master-bus period must be 0xFFFF"));)) \
671 EMIOS_PWM_LOG(node_id, "master-bus must be chosen," \
678 EMIOS_PWM_LOG(node_id, "duty-cycle is not used")); \
684 EMIOS_PWM_LOG(node_id, "prescaler-src is not used," \
720 DT_PROP_BY_PHANDLE(node_id, master_bus, prescaler)) - 1,\
786 (DT_PROP(node_id, prescaler))) - 1, \