1 /* 2 * Copyright (c) 2024, STRIM, ALC 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_DRIVERS_MISC_NXP_FLEXIO_NXP_FLEXIO_H_ 8 #define ZEPHYR_DRIVERS_MISC_NXP_FLEXIO_NXP_FLEXIO_H_ 9 10 #include <zephyr/device.h> 11 12 /** 13 * @struct nxp_flexio_child_res 14 * @brief Structure containing information about the required 15 * resources for a FlexIO child. 16 */ 17 struct nxp_flexio_child_res { 18 uint8_t *shifter_index; 19 uint8_t shifter_count; 20 uint8_t *timer_index; 21 uint8_t timer_count; 22 }; 23 24 /** 25 * @typedef nxp_flexio_child_isr_t 26 * @brief Callback API to inform API user that FlexIO triggered interrupt 27 * 28 * This callback is called from IRQ context. 29 */ 30 typedef int (*nxp_flexio_child_isr_t)(void *user_data); 31 32 /** 33 * @struct nxp_flexio_child 34 * @brief Structure containing the required child data for FlexIO 35 */ 36 struct nxp_flexio_child { 37 nxp_flexio_child_isr_t isr; 38 void *user_data; 39 struct nxp_flexio_child_res res; 40 }; 41 42 /** 43 * @brief Enable FlexIO IRQ 44 * @param dev Pointer to the device structure for the FlexIO driver instance 45 */ 46 void nxp_flexio_irq_enable(const struct device *dev); 47 48 /** 49 * @brief Disable FlexIO IRQ 50 * @param dev Pointer to the device structure for the FlexIO driver instance 51 */ 52 void nxp_flexio_irq_disable(const struct device *dev); 53 54 /** 55 * @brief Lock FlexIO mutex. 56 * @param dev Pointer to the device structure for the FlexIO driver instance 57 */ 58 void nxp_flexio_lock(const struct device *dev); 59 60 /** 61 * @brief Unlock FlexIO mutex. 62 * @param dev Pointer to the device structure for the FlexIO driver instance 63 */ 64 void nxp_flexio_unlock(const struct device *dev); 65 66 /** 67 * @brief Obtain the clock rate of sub-system used by the FlexIO 68 * @param dev Pointer to the device structure for the FlexIO driver instance 69 * @param[out] rate Subsystem clock rate 70 * @retval 0 on successful rate reading. 71 * @retval -EAGAIN if rate cannot be read. Some drivers do not support returning the rate when the 72 * clock is off. 73 * @retval -ENOTSUP if reading the clock rate is not supported for the given sub-system. 74 * @retval -ENOSYS if the interface is not implemented. 75 */ 76 int nxp_flexio_get_rate(const struct device *dev, uint32_t *rate); 77 78 /** 79 * @brief Attach flexio child to flexio controller 80 * @param dev Pointer to the device structure for the FlexIO driver instance 81 * @param child Pointer to flexio child 82 * @retval 0 if successful 83 * @retval -ENOBUFS if there are not enough available resources 84 */ 85 int nxp_flexio_child_attach(const struct device *dev, 86 const struct nxp_flexio_child *child); 87 88 #endif /* ZEPHYR_DRIVERS_MISC_NXP_FLEXIO_NXP_FLEXIO_H_ */ 89