Lines Matching +full:power +full:- +full:role

3  * SPDX-License-Identifier: Apache-2.0
8 * @brief USBC Type-C Port Controller device APIs
10 * This file contains the USB Type-C Port Controller device APIs.
11 * All Type-C Port Controller device drivers should implement the
19 * @brief USB Type-C Port Controller API
20 * @defgroup usb_type_c_port_controller_api USB Type-C Port Controller API
44 /** Power status changed */
59 /** A high-voltage alarm has occurred */
61 /** A low-voltage alarm has occurred */
90 /** The Power Status register */
233 * @retval -EIO on failure
234 * @retval -EAGAIN if initialization should be postponed
238 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_init()
240 __ASSERT(api->init != NULL, "Callback pointer should not be NULL"); in tcpc_init()
242 return api->init(dev); in tcpc_init()
253 * @retval -EIO on failure
254 * @retval -ENOSYS if not implemented
259 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_get_cc()
261 if (api->get_cc == NULL) { in tcpc_get_cc()
262 return -ENOSYS; in tcpc_get_cc()
265 return api->get_cc(dev, cc1, cc2); in tcpc_get_cc()
272 * @param rp Value of the Pull-Up Resistor.
275 * @retval -ENOSYS
276 * @retval -EIO on failure
280 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_select_rp_value()
282 if (api->select_rp_value == NULL) { in tcpc_select_rp_value()
283 return -ENOSYS; in tcpc_select_rp_value()
286 return api->select_rp_value(dev, rp); in tcpc_select_rp_value()
293 * @param rp pointer where the value of the Pull-Up Resistor is stored
296 * @retval -ENOSYS
297 * @retval -EIO on failure
301 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_get_rp_value()
303 if (api->get_rp_value == NULL) { in tcpc_get_rp_value()
304 return -ENOSYS; in tcpc_get_rp_value()
307 return api->get_rp_value(dev, rp); in tcpc_get_rp_value()
311 * @brief Sets the CC pull resistor and sets the role as either Source or Sink
317 * @retval -EIO on failure
321 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_cc()
323 __ASSERT(api->set_cc != NULL, "Callback pointer should not be NULL"); in tcpc_set_cc()
325 return api->set_cc(dev, pull); in tcpc_set_cc()
340 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_vconn_cb()
342 __ASSERT(api->set_vconn_cb != NULL, "Callback pointer should not be NULL"); in tcpc_set_vconn_cb()
344 api->set_vconn_cb(dev, vconn_cb); in tcpc_set_vconn_cb()
360 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_vconn_discharge_cb()
362 __ASSERT(api->set_vconn_discharge_cb != NULL, "Callback pointer should not be NULL"); in tcpc_set_vconn_discharge_cb()
364 api->set_vconn_discharge_cb(dev, cb); in tcpc_set_vconn_discharge_cb()
377 * @retval -EIO on failure
378 * @retval -ENOSYS if not implemented
382 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_vconn_discharge()
384 if (api->vconn_discharge == NULL) { in tcpc_vconn_discharge()
385 return -ENOSYS; in tcpc_vconn_discharge()
388 return api->vconn_discharge(dev, enable); in tcpc_vconn_discharge()
401 * @retval -EIO on failure
402 * @retval -ENOSYS if not implemented
406 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_vconn()
408 if (api->set_vconn == NULL) { in tcpc_set_vconn()
409 return -ENOSYS; in tcpc_set_vconn()
412 return api->set_vconn(dev, enable); in tcpc_set_vconn()
416 * @brief Sets the Power and Data Role of the PD message header
418 * This function only needs to be called once per data / power role change
421 * @param power_role current power role
422 * @param data_role current data role
425 * @retval -EIO on failure
426 * @retval -ENOSYS if not implemented
431 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_roles()
433 if (api->set_roles == NULL) { in tcpc_set_roles()
434 return -ENOSYS; in tcpc_set_roles()
437 return api->set_roles(dev, power_role, data_role); in tcpc_set_roles()
441 * @brief Retrieves the Power Delivery message from the TCPC.
443 * -ENODATA means there is no pending message.
450 * @retval -EIO on failure
451 * @retval -ENODATA if no message is pending
455 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_get_rx_pending_msg()
457 __ASSERT(api->get_rx_pending_msg != NULL, "Callback pointer should not be NULL"); in tcpc_get_rx_pending_msg()
459 return api->get_rx_pending_msg(dev, buf); in tcpc_get_rx_pending_msg()
466 * @param enable Enable Power Delivery when true, else it's
470 * @retval -EIO on failure
471 * @retval -ENOSYS if not implemented
475 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_rx_enable()
477 if (api->set_rx_enable == NULL) { in tcpc_set_rx_enable()
478 return -ENOSYS; in tcpc_set_rx_enable()
481 return api->set_rx_enable(dev, enable); in tcpc_set_rx_enable()
491 * @retval -EIO on failure
495 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_cc_polarity()
497 __ASSERT(api->set_cc_polarity != NULL, "Callback pointer should not be NULL"); in tcpc_set_cc_polarity()
499 return api->set_cc_polarity(dev, polarity); in tcpc_set_cc_polarity()
503 * @brief Transmits a Power Delivery message
506 * @param msg Power Delivery message to transmit
509 * @retval -EIO on failure
510 * @retval -ENOSYS if not implemented
514 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_transmit_data()
516 if (api->transmit_data == NULL) { in tcpc_transmit_data()
517 return -ENOSYS; in tcpc_transmit_data()
520 return api->transmit_data(dev, msg); in tcpc_transmit_data()
529 * @retval -EIO on failure
530 * @retval -ENOSYS if not implemented
534 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_dump_std_reg()
536 if (api->dump_std_reg == NULL) { in tcpc_dump_std_reg()
537 return -ENOSYS; in tcpc_dump_std_reg()
540 return api->dump_std_reg(dev); in tcpc_dump_std_reg()
554 * @retval -EINVAL on failure
559 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_alert_handler_cb()
561 __ASSERT(api->set_alert_handler_cb != NULL, "Callback pointer should not be NULL"); in tcpc_set_alert_handler_cb()
563 return api->set_alert_handler_cb(dev, handler, data); in tcpc_set_alert_handler_cb()
574 * @retval -EIO on failure
575 * @retval -ENOSYS if not implemented
580 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_get_status_register()
582 if (api->get_status_register == NULL) { in tcpc_get_status_register()
583 return -ENOSYS; in tcpc_get_status_register()
586 return api->get_status_register(dev, reg, status); in tcpc_get_status_register()
598 * @retval -EIO on failure
599 * @retval -ENOSYS if not implemented
604 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_clear_status_register()
606 if (api->clear_status_register == NULL) { in tcpc_clear_status_register()
607 return -ENOSYS; in tcpc_clear_status_register()
610 return api->clear_status_register(dev, reg, mask); in tcpc_clear_status_register()
622 * @retval -EIO on failure
623 * @retval -ENOSYS if not implemented
628 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_mask_status_register()
630 if (api->mask_status_register == NULL) { in tcpc_mask_status_register()
631 return -ENOSYS; in tcpc_mask_status_register()
634 return api->mask_status_register(dev, reg, mask); in tcpc_mask_status_register()
644 * @retval -EIO on failure
645 * @retval -ENOSYS if not implemented
649 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_debug_accessory()
651 if (api->set_debug_accessory == NULL) { in tcpc_set_debug_accessory()
652 return -ENOSYS; in tcpc_set_debug_accessory()
655 return api->set_debug_accessory(dev, enable); in tcpc_set_debug_accessory()
664 * @retval -EIO on failure
665 * @retval -ENOSYS if not implemented
669 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_debug_detach()
671 if (api->set_debug_detach == NULL) { in tcpc_set_debug_detach()
672 return -ENOSYS; in tcpc_set_debug_detach()
675 return api->set_debug_detach(dev); in tcpc_set_debug_detach()
679 * @brief Enable TCPC auto dual role toggle
682 * @param enable Auto dual role toggle is active when true, else it's disabled
685 * @retval -EIO on failure
686 * @retval -ENOSYS if not implemented
690 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_drp_toggle()
692 if (api->set_drp_toggle == NULL) { in tcpc_set_drp_toggle()
693 return -ENOSYS; in tcpc_set_drp_toggle()
696 return api->set_drp_toggle(dev, enable); in tcpc_set_drp_toggle()
704 * @retval true if sinking power
705 * @retval false if not sinking power
706 * @retval -ENOSYS if not implemented
710 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_get_snk_ctrl()
712 if (api->get_snk_ctrl == NULL) { in tcpc_get_snk_ctrl()
713 return -ENOSYS; in tcpc_get_snk_ctrl()
716 return api->get_snk_ctrl(dev); in tcpc_get_snk_ctrl()
725 * @retval -ENOSYS if not implemented
729 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_snk_ctrl()
731 if (api->set_snk_ctrl == NULL) { in tcpc_set_snk_ctrl()
732 return -ENOSYS; in tcpc_set_snk_ctrl()
735 return api->set_snk_ctrl(dev, enable); in tcpc_set_snk_ctrl()
743 * @retval true if sourcing power
744 * @retval false if not sourcing power
745 * @retval -ENOSYS if not implemented
749 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_get_src_ctrl()
751 if (api->get_src_ctrl == NULL) { in tcpc_get_src_ctrl()
752 return -ENOSYS; in tcpc_get_src_ctrl()
755 return api->get_src_ctrl(dev); in tcpc_get_src_ctrl()
764 * @retval -ENOSYS if not implemented
768 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_src_ctrl()
770 if (api->set_src_ctrl == NULL) { in tcpc_set_src_ctrl()
771 return -ENOSYS; in tcpc_set_src_ctrl()
774 return api->set_src_ctrl(dev, enable); in tcpc_set_src_ctrl()
785 * @retval -EIO on failure
786 * @retval -ENOSYS if not implemented
790 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_bist_test_mode()
792 if (api->set_bist_test_mode == NULL) { in tcpc_set_bist_test_mode()
793 return -ENOSYS; in tcpc_set_bist_test_mode()
796 return api->set_bist_test_mode(dev, enable); in tcpc_set_bist_test_mode()
806 * @retval -EIO on failure
807 * @retval -ENOSYS if not implemented
811 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_get_chip_info()
813 if (api->get_chip_info == NULL) { in tcpc_get_chip_info()
814 return -ENOSYS; in tcpc_get_chip_info()
817 return api->get_chip_info(dev, chip_info); in tcpc_get_chip_info()
821 * @brief Instructs the TCPC to enter or exit low power mode
824 * @param enable The TCPC enters low power mode when true, else it exits it
827 * @retval -EIO on failure
828 * @retval -ENOSYS if not implemented
832 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_set_low_power_mode()
834 if (api->set_low_power_mode == NULL) { in tcpc_set_low_power_mode()
835 return -ENOSYS; in tcpc_set_low_power_mode()
838 return api->set_low_power_mode(dev, enable); in tcpc_set_low_power_mode()
849 * @retval -EIO on failure
850 * @retval -ENOSYS if not implemented
854 const struct tcpc_driver_api *api = (const struct tcpc_driver_api *)dev->api; in tcpc_sop_prime_enable()
856 if (api->sop_prime_enable == NULL) { in tcpc_sop_prime_enable()
857 return -ENOSYS; in tcpc_sop_prime_enable()
860 return api->sop_prime_enable(dev, enable); in tcpc_sop_prime_enable()