Lines Matching +full:dead +full:- +full:battery
4 * SPDX-License-Identifier: Apache-2.0
36 * by Timer-trigger EADC. To implement this interconnection, TCPC node_id
39 * NOTE: EADC and Timer interrupts needn't enable for Timer-triggered EADC.
49 * (1) DPM-supplied callback
76 #define NUMAKER_SYS_REG_DUMP(dev, reg_name) LOG_INF("SYS: %8s: 0x%08x", #reg_name, SYS->reg_name);
82 LOG_INF("%s: %8s: 0x%08x", #port, #reg_name, port->reg_name);
98 utcpd_base->reg_name = (val); \
110 LOG_ERR("UTCPD register (%s) write timeout, force-write", #reg_name); \
112 utcpd_base->reg_name = (val); \
137 LOG_ERR("UTCPD register (0x%04x) write timeout, force-write", reg_offset); \
146 #define NUMAKER_UTCPD_REG_READ_BY_NAME(dev, reg_name) ({ utcpd_base->reg_name; })
220 /* Rate of timer-triggered voltage measurement (Hz) */
235 /* One-slot Rx FIFO */
268 * @retval -EIO on failure
272 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_reg_write_wait_ready()
273 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_reg_write_wait_ready()
275 if (!WAIT_FOR((utcpd_base->CLKINFO & UTCPD_CLKINFO_ReadyFlag_Msk), in numaker_utcpd_reg_write_wait_ready()
277 return -EIO; in numaker_utcpd_reg_write_wait_ready()
290 * @note UTCPD VBVOL.VBVOL = MSB 10-bit of EADC DAT.RESULT[11:0],
291 * that is, discarding LSB 2-bit.
295 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_vbus_volt_bit2mv()
296 struct numaker_tcpc_data *data = dev->data; in numaker_utcpd_vbus_volt_bit2mv()
298 __ASSERT_NO_MSG(data->vref_mv); in numaker_utcpd_vbus_volt_bit2mv()
299 return (uint32_t)(((uint64_t)bit) * data->vref_mv * config->utcpd.vbvol.vbscale.value / in numaker_utcpd_vbus_volt_bit2mv()
310 * @note UTCPD VBVOL.VBVOL = MSB 10-bit of EADC DAT.RESULT[11:0],
311 * that is, discarding LSB 2-bit.
315 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_vbus_volt_mv2bit()
316 struct numaker_tcpc_data *data = dev->data; in numaker_utcpd_vbus_volt_mv2bit()
318 __ASSERT_NO_MSG(data->vref_mv); in numaker_utcpd_vbus_volt_mv2bit()
319 return mv * BIT_MASK(10) / data->vref_mv / config->utcpd.vbvol.vbscale.value; in numaker_utcpd_vbus_volt_mv2bit()
329 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_dump_regs()
330 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_dump_regs()
383 const struct numaker_tcpc_config *const config = dev->config; in numaker_eadc_vref_init()
384 struct numaker_tcpc_data *data = dev->data; in numaker_eadc_vref_init()
388 if (data->vref_mv) { in numaker_eadc_vref_init()
400 spec = config->eadc.spec_vbus ? config->eadc.spec_vbus : config->eadc.spec_vconn; in numaker_eadc_vref_init()
407 return -ENODEV; in numaker_eadc_vref_init()
411 if (!spec->channel_cfg_dt_node_exists) { in numaker_eadc_vref_init()
413 return -ENODEV; in numaker_eadc_vref_init()
416 reference = spec->channel_cfg.reference; in numaker_eadc_vref_init()
418 SYS->VREFCTL &= ~SYS_VREFCTL_VREFCTL_Msk; in numaker_eadc_vref_init()
420 SYS->VREFCTL |= SYS_VREFCTL_VREF_PIN; in numaker_eadc_vref_init()
422 switch (spec->vref_mv) { in numaker_eadc_vref_init()
424 SYS->VREFCTL |= SYS_VREFCTL_VREF_1_6V; in numaker_eadc_vref_init()
427 SYS->VREFCTL |= SYS_VREFCTL_VREF_2_0V; in numaker_eadc_vref_init()
430 SYS->VREFCTL |= SYS_VREFCTL_VREF_2_5V; in numaker_eadc_vref_init()
433 SYS->VREFCTL |= SYS_VREFCTL_VREF_3_0V; in numaker_eadc_vref_init()
437 return -ENOTSUP; in numaker_eadc_vref_init()
441 return -ENOTSUP; in numaker_eadc_vref_init()
444 data->vref_mv = spec->vref_mv; in numaker_eadc_vref_init()
453 * @retval -EIO on failure
457 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_vbus_measure()
458 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_vbus_measure()
462 return -EINVAL; in numaker_utcpd_vbus_measure()
466 if (config->eadc.spec_vbus == NULL) { in numaker_utcpd_vbus_measure()
467 return -ENOTSUP; in numaker_utcpd_vbus_measure()
489 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_vbus_is_present()
490 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_vbus_is_present()
508 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_vbus_is_source()
509 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_vbus_is_source()
527 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_vbus_is_sink()
528 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_vbus_is_sink()
542 * @retval -EIO on failure
546 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_vbus_set_discharge()
547 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_vbus_set_discharge()
549 const struct gpio_dt_spec *vbus_discharge_spec = &config->utcpd.gpios.vbus_discharge; in numaker_utcpd_vbus_set_discharge()
553 if (vbus_discharge_spec->port != NULL) { in numaker_utcpd_vbus_set_discharge()
575 * @retval -EIO on failure
579 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_bist_test_mode_set_enable()
580 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_bist_test_mode_set_enable()
606 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_bist_test_mode_is_enabled()
607 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_bist_test_mode_is_enabled()
624 struct numaker_tcpc_data *data = dev->data; in numaker_utcpd_rx_fifo_clear()
626 data->rx_msg_ready = false; in numaker_utcpd_rx_fifo_clear()
635 * @retval -EIO on failure
640 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_rx_read_data()
641 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_rx_read_data()
647 /* 32-bit aligned */ in numaker_utcpd_rx_read_data()
655 data_rmn -= 4; in numaker_utcpd_rx_read_data()
658 /* Remaining non-32-bit aligned */ in numaker_utcpd_rx_read_data()
668 data_rmn -= 3; in numaker_utcpd_rx_read_data()
674 data_rmn -= 2; in numaker_utcpd_rx_read_data()
680 data_rmn -= 1; in numaker_utcpd_rx_read_data()
694 * @retval -EIO on failure
699 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_tx_write_data()
700 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_tx_write_data()
707 /* 32-bit aligned */ in numaker_utcpd_tx_write_data()
718 data_rmn -= 4; in numaker_utcpd_tx_write_data()
721 /* Remaining non-32-bit aligned */ in numaker_utcpd_tx_write_data()
728 data_rmn -= 3; in numaker_utcpd_tx_write_data()
734 data_rmn -= 2; in numaker_utcpd_tx_write_data()
740 data_rmn -= 1; in numaker_utcpd_tx_write_data()
759 * @retval -EIO on failure
763 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_rx_fifo_enqueue()
764 struct numaker_tcpc_data *data = dev->data; in numaker_utcpd_rx_fifo_enqueue()
765 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_rx_fifo_enqueue()
772 struct pd_msg *msg = &data->rx_msg; in numaker_utcpd_rx_fifo_enqueue()
782 rc = -EIO; in numaker_utcpd_rx_fifo_enqueue()
785 rx_data_size = rxbcnt - 3; in numaker_utcpd_rx_fifo_enqueue()
792 rc = -EIO; in numaker_utcpd_rx_fifo_enqueue()
797 if (data->rx_msg_ready) { in numaker_utcpd_rx_fifo_enqueue()
803 msg->type = (rxftype & UTCPD_RXFTYPE_RXFTYPE_Msk) >> UTCPD_RXFTYPE_RXFTYPE_Pos; in numaker_utcpd_rx_fifo_enqueue()
806 msg->header.raw_value = (uint16_t)rxhead; in numaker_utcpd_rx_fifo_enqueue()
809 msg->len = rx_data_size; in numaker_utcpd_rx_fifo_enqueue()
812 rc = numaker_utcpd_rx_read_data(dev, msg->data, rx_data_size); in numaker_utcpd_rx_fifo_enqueue()
818 data->rx_msg_ready = true; in numaker_utcpd_rx_fifo_enqueue()
833 struct numaker_tcpc_data *data = dev->data; in numaker_utcpd_notify_tcpc_alert()
834 tcpc_alert_handler_cb_t alert_handler = data->tcpc_alert.handler; in numaker_utcpd_notify_tcpc_alert()
835 void *alert_data = data->tcpc_alert.data; in numaker_utcpd_notify_tcpc_alert()
847 struct numaker_tcpc_data *data = dev->data; in numaker_utcpd_notify_ppc_event()
848 usbc_ppc_event_cb_t event_handler = data->ppc_event.handler; in numaker_utcpd_notify_ppc_event()
849 void *event_data = data->ppc_event.data; in numaker_utcpd_notify_ppc_event()
860 * interrupt bits not cleared. To avoid that, we use "force-write"
865 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_isr()
866 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_isr()
952 /* NOTE: FUTSTSIE will restore to default on Hard Reset. We may re-enter in numaker_utcpd_isr()
1001 const struct numaker_tcpc_config *const config = dev->config; in numaker_eadc_smplmod_init()
1002 EADC_T *eadc_base = config->eadc_base; in numaker_eadc_smplmod_init()
1012 return -ENODEV; in numaker_eadc_smplmod_init()
1016 if (!spec->channel_cfg_dt_node_exists) { in numaker_eadc_smplmod_init()
1018 return -ENODEV; in numaker_eadc_smplmod_init()
1021 acquisition_time = spec->channel_cfg.acquisition_time; in numaker_eadc_smplmod_init()
1026 return -ENOTSUP; in numaker_eadc_smplmod_init()
1030 EADC_ConfigSampleModule(eadc_base, spec->channel_id, trgsel, spec->channel_id); in numaker_eadc_smplmod_init()
1032 EADC_SetExtendSampleTime(eadc_base, spec->channel_id, acq_time_value); in numaker_eadc_smplmod_init()
1041 * @retval -EIO on failure
1045 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_vbus_init()
1046 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_vbus_init()
1053 vbvol |= config->utcpd.vbvol.vbscale.bit; in numaker_utcpd_vbus_init()
1059 if (config->eadc.spec_vbus != NULL) { in numaker_utcpd_vbus_init()
1103 if (config->eadc.spec_vbus != NULL) { in numaker_utcpd_vbus_init()
1110 /* Disable UTCPD VBUS auto-discharge on disconnect in numaker_utcpd_vbus_init()
1122 * @retval -EIO on failure
1126 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_gpios_init()
1131 spec = &config->utcpd.gpios.vbus_detect; in numaker_utcpd_gpios_init()
1132 if (spec->port == NULL) { in numaker_utcpd_gpios_init()
1134 return -ENODEV; in numaker_utcpd_gpios_init()
1138 return -ENODEV; in numaker_utcpd_gpios_init()
1147 spec = &config->utcpd.gpios.vbus_discharge; in numaker_utcpd_gpios_init()
1148 if (spec->port != NULL) { in numaker_utcpd_gpios_init()
1151 return -ENODEV; in numaker_utcpd_gpios_init()
1161 spec = &config->utcpd.gpios.vconn_discharge; in numaker_utcpd_gpios_init()
1162 if (spec->port != NULL) { in numaker_utcpd_gpios_init()
1165 return -ENODEV; in numaker_utcpd_gpios_init()
1181 * @retval -EIO on failure
1185 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_phy_init()
1186 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_phy_init()
1193 SYS->UTCPDCTL |= SYS_UTCPDCTL_POREN0_Msk; in numaker_utcpd_phy_init()
1199 * @brief Checks if UTCPD Dead Battery mode is enabled
1201 * @retval true Dead Battery mode is enabled
1202 * @retval false Dead Battery mode is not enabled
1206 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_deadbattery_query_enable()
1207 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_deadbattery_query_enable()
1210 /* 0 = Dead Battery circuit controls internal Rd/Rp. in numaker_utcpd_deadbattery_query_enable()
1217 * @brief Enables or disables UTCPD Dead Battery mode
1220 * @retval -EIO on failure
1224 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_deadbattery_set_enable()
1225 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_deadbattery_set_enable()
1229 /* Dead Battery circuit controls internal Rd/Rp */ in numaker_utcpd_deadbattery_set_enable()
1239 * @brief Initializes UTCPD Dead Battery mode
1242 * @retval -EIO on failure
1246 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_deadbattery_init()
1248 return numaker_utcpd_deadbattery_set_enable(dev, config->utcpd.dead_battery); in numaker_utcpd_deadbattery_init()
1255 * @retval -EIO on failure
1259 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_interrupts_init()
1260 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_interrupts_init()
1307 * @retval -EIO on failure
1311 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_init_recycle()
1312 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_init_recycle()
1352 * @retval -EIO on failure
1356 const struct numaker_tcpc_config *const config = dev->config; in numaker_utcpd_init_startup()
1357 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_utcpd_init_startup()
1375 /* UTCPD Dead Battery */ in numaker_utcpd_init_startup()
1382 pinpl = config->utcpd.pinpl.bit; in numaker_utcpd_init_startup()
1397 * 1. VBUS force-off in numaker_utcpd_init_startup()
1409 * NOTE: Just configure CC2FRSS/CC2VCENS/CC1FRSS/CC1VCENS to non-merged in numaker_utcpd_init_startup()
1414 /* NOTE: For absence of EADC channel measurement for VCONN, we configure with all-one which in numaker_utcpd_init_startup()
1418 if (config->eadc.spec_vbus != NULL) { in numaker_utcpd_init_startup()
1419 muxsel |= (config->eadc.spec_vbus->channel_id << UTCPD_MUXSEL_ADCSELVB_Pos); in numaker_utcpd_init_startup()
1423 if (config->eadc.spec_vconn != NULL) { in numaker_utcpd_init_startup()
1424 muxsel |= (config->eadc.spec_vconn->channel_id << UTCPD_MUXSEL_ADCSELVC_Pos); in numaker_utcpd_init_startup()
1440 config->irq_config_func_utcpd(dev); in numaker_utcpd_init_startup()
1446 * @brief Initializes EADC to be timer-triggered for measuring
1450 * @retval -EIO on failure
1454 const struct numaker_tcpc_config *const config = dev->config; in numaker_eadc_init_startup()
1455 EADC_T *eadc_base = config->eadc_base; in numaker_eadc_init_startup()
1465 /* Set input mode as single-end and enable the A/D converter */ in numaker_eadc_init_startup()
1474 spec = config->eadc.spec_vbus; in numaker_eadc_init_startup()
1476 rc = numaker_eadc_smplmod_init(dev, spec, config->eadc.trgsel_vbus); in numaker_eadc_init_startup()
1488 spec = config->eadc.spec_vconn; in numaker_eadc_init_startup()
1490 rc = numaker_eadc_smplmod_init(dev, spec, config->eadc.trgsel_vconn); in numaker_eadc_init_startup()
1507 const struct numaker_tcpc_config *const config = dev->config; in numaker_timer_init_startup()
1508 TIMER_T *timer_base = config->timer_base; in numaker_timer_init_startup()
1511 TIMER_Open(timer_base, TIMER_PERIODIC_MODE, config->eadc.timer_trigger_rate); in numaker_timer_init_startup()
1523 * @retval -EIO on failure
1527 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_init_recycle()
1536 /* The fields below must (re-)initialize for tcpc_init(). */ in numaker_tcpc_init_recycle()
1537 data->rp = TC_RP_USB; in numaker_tcpc_init_recycle()
1538 data->rx_sop_prime_enabled = false; in numaker_tcpc_init_recycle()
1539 data->rx_msg_ready = false; in numaker_tcpc_init_recycle()
1540 memset(&data->rx_msg, 0x00, sizeof(data->rx_msg)); in numaker_tcpc_init_recycle()
1549 * @retval -EIO on failure
1553 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_init_startup()
1559 rc = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); in numaker_tcpc_init_startup()
1567 rc = clock_control_on(config->clkctrl_dev, (clock_control_subsys_t)&config->pcc_utcpd); in numaker_tcpc_init_startup()
1571 rc = clock_control_on(config->clkctrl_dev, (clock_control_subsys_t)&config->pcc_timer); in numaker_tcpc_init_startup()
1577 rc = clock_control_configure(config->clkctrl_dev, in numaker_tcpc_init_startup()
1578 (clock_control_subsys_t)&config->pcc_utcpd, NULL); in numaker_tcpc_init_startup()
1582 rc = clock_control_configure(config->clkctrl_dev, in numaker_tcpc_init_startup()
1583 (clock_control_subsys_t)&config->pcc_timer, NULL); in numaker_tcpc_init_startup()
1590 rc = reset_line_toggle_dt(&config->reset_utcpd); in numaker_tcpc_init_startup()
1594 rc = reset_line_toggle_dt(&config->reset_timer); in numaker_tcpc_init_startup()
1605 if (config->eadc.spec_vbus != NULL || config->eadc.spec_vconn != NULL) { in numaker_tcpc_init_startup()
1626 * @retval -EIO on failure
1631 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_get_cc()
1632 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_get_cc()
1708 * @retval -EIO on failure
1712 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_select_rp_value()
1714 data->rp = rp; in numaker_tcpc_select_rp_value()
1723 * @retval -EIO on failure
1727 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_get_rp_value()
1729 *rp = data->rp; in numaker_tcpc_get_rp_value()
1738 * @retval -EIO on failure
1742 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_set_cc()
1743 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_set_cc()
1744 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_set_cc()
1748 /* Disable Dead Battery mode if it is active, so that in numaker_tcpc_set_cc()
1750 * from Dead Battery circuit. in numaker_tcpc_set_cc()
1760 switch (data->rp) { in numaker_tcpc_set_cc()
1774 LOG_ERR("Invalid Rp value: %d", data->rp); in numaker_tcpc_set_cc()
1775 return -EINVAL; in numaker_tcpc_set_cc()
1798 return -EINVAL; in numaker_tcpc_set_cc()
1818 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_set_vconn_discharge_cb()
1820 data->dpm.vconn_discharge_cb = cb; in numaker_tcpc_set_vconn_discharge_cb()
1830 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_set_vconn_cb()
1832 data->dpm.vconn_cb = vconn_cb; in numaker_tcpc_set_vconn_cb()
1839 * @retval -EIO on failure
1843 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_vconn_discharge()
1844 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_vconn_discharge()
1845 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_vconn_discharge()
1846 const struct gpio_dt_spec *vconn_discharge_spec = &config->utcpd.gpios.vconn_discharge; in numaker_tcpc_vconn_discharge()
1853 if (data->dpm.vconn_discharge_cb) { in numaker_tcpc_vconn_discharge()
1854 return data->dpm.vconn_discharge_cb(dev, polarity, enable); in numaker_tcpc_vconn_discharge()
1858 if (vconn_discharge_spec->port != NULL) { in numaker_tcpc_vconn_discharge()
1875 * @retval -EIO on failure
1879 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_set_vconn()
1880 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_set_vconn()
1881 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_set_vconn()
1888 if (data->dpm.vconn_cb) { in numaker_tcpc_set_vconn()
1889 return data->dpm.vconn_cb(dev, polarity, enable); in numaker_tcpc_set_vconn()
1905 * @retval -EIO on failure
1910 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_set_roles()
1911 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_set_roles()
1914 /* Power role for auto-reply GoodCRC */ in numaker_tcpc_set_roles()
1922 /* Data role for auto-reply GoodCRC */ in numaker_tcpc_set_roles()
1930 /* Message Header for auto-reply GoodCRC */ in numaker_tcpc_set_roles()
1937 * -ENODATA means there is no pending message.
1941 * @retval -EIO on failure
1942 * @retval -ENODATA if no message is pending
1946 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_get_rx_pending_msg()
1949 if (!data->rx_msg_ready) { in numaker_tcpc_get_rx_pending_msg()
1950 return -ENODATA; in numaker_tcpc_get_rx_pending_msg()
1959 *msg = data->rx_msg; in numaker_tcpc_get_rx_pending_msg()
1960 data->rx_msg_ready = false; in numaker_tcpc_get_rx_pending_msg()
1970 * @retval -EIO on failure
1974 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_set_rx_enable()
1975 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_set_rx_enable()
1976 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_set_rx_enable()
1985 if (data->rx_sop_prime_enabled) { in numaker_tcpc_set_rx_enable()
2001 * @retval -EIO on failure
2005 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_set_cc_polarity()
2006 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_set_cc_polarity()
2021 return -EINVAL; in numaker_tcpc_set_cc_polarity()
2030 * @retval -EIO on failure
2034 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_transmit_data()
2035 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_transmit_data()
2042 if (msg->len > (PD_MAX_EXTENDED_MSG_LEGACY_LEN + 2)) { in numaker_tcpc_transmit_data()
2045 msg->len); in numaker_tcpc_transmit_data()
2046 return -EIO; in numaker_tcpc_transmit_data()
2050 rc = NUMAKER_UTCPD_REG_WRITE_BY_NAME(dev, TXBCNT, msg->len + 2); in numaker_tcpc_transmit_data()
2056 rc = NUMAKER_UTCPD_REG_WRITE_BY_NAME(dev, TXHEAD, msg->header.raw_value); in numaker_tcpc_transmit_data()
2062 rc = numaker_utcpd_tx_write_data(dev, msg->data, msg->len); in numaker_tcpc_transmit_data()
2068 if (msg->type < PD_PACKET_TX_HARD_RESET) { in numaker_tcpc_transmit_data()
2071 } else if (msg->type <= PD_PACKET_TX_BIST_MODE_2) { in numaker_tcpc_transmit_data()
2072 /* Per TCPCI spec, no retry for non-SOP* transmission */ in numaker_tcpc_transmit_data()
2075 LOG_ERR("Invalid PD packet type: %d", msg->type); in numaker_tcpc_transmit_data()
2076 return -EINVAL; in numaker_tcpc_transmit_data()
2079 txctl_txstype = ((uint32_t)msg->type) << UTCPD_TXCTL_TXSTYPE_Pos; in numaker_tcpc_transmit_data()
2088 * @retval -EIO on failure
2103 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_get_snk_ctrl()
2104 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_get_snk_ctrl()
2118 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_get_src_ctrl()
2119 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_get_src_ctrl()
2129 * @retval -EIO on failure
2133 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_sop_prime_enable()
2135 data->rx_sop_prime_enabled = enable; in numaker_tcpc_sop_prime_enable()
2145 * @retval -EIO on failure
2162 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_set_alert_handler_cb()
2164 data->tcpc_alert.handler = alert_handler; in numaker_tcpc_set_alert_handler_cb()
2165 data->tcpc_alert.data = alert_data; in numaker_tcpc_set_alert_handler_cb()
2194 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_ppc_set_snk_ctrl()
2195 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_ppc_set_snk_ctrl()
2208 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_ppc_set_src_ctrl()
2209 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_ppc_set_src_ctrl()
2234 struct numaker_tcpc_data *data = dev->data; in numaker_tcpc_ppc_set_event_handler()
2236 data->ppc_event.handler = event_handler; in numaker_tcpc_ppc_set_event_handler()
2237 data->ppc_event.data = event_data; in numaker_tcpc_ppc_set_event_handler()
2253 const struct numaker_tcpc_config *const config = dev->config; in numaker_tcpc_vbus_check_level()
2254 UTCPD_T *utcpd_base = config->utcpd_base; in numaker_tcpc_vbus_check_level()
2281 return -EINVAL; in numaker_tcpc_vbus_measure()
2301 /* VBUS measurement is made automatic through Timer-triggered EADC. */ in numaker_tcpc_vbus_enable()
2387 (vbus-divide error))