Line data Source code
1 0 : /* 2 : * Copyright (c) 2024 SILA Embedded Solutions GmbH 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : #ifndef ZEPHYR_INCLUDE_DRIVERS_MFD_TLE9104_H_ 7 : #define ZEPHYR_INCLUDE_DRIVERS_MFD_TLE9104_H_ 8 : 9 : #include <stdbool.h> 10 : #include <zephyr/device.h> 11 : 12 0 : #define TLE9104_GPIO_COUNT 4 13 : 14 0 : enum tle9104_on_state_diagnostics { 15 : /* overtemperature */ 16 : TLE9104_ONDIAG_OT = 5, 17 : /* overcurrent timeout */ 18 : TLE9104_ONDIAG_OCTIME = 4, 19 : /* overtemperature during overcurrent */ 20 : TLE9104_ONDIAG_OCOT = 3, 21 : /* short to battery */ 22 : TLE9104_ONDIAG_SCB = 2, 23 : /* no failure */ 24 : TLE9104_ONDIAG_NOFAIL = 1, 25 : /* no diagnosis done */ 26 : TLE9104_ONDIAG_UNKNOWN = 0, 27 : }; 28 : 29 0 : enum tle9104_off_state_diagnostics { 30 : /* short to ground */ 31 : TLE9104_OFFDIAG_SCG = 3, 32 : /* open load */ 33 : TLE9104_OFFDIAG_OL = 2, 34 : /* no failure */ 35 : TLE9104_OFFDIAG_NOFAIL = 1, 36 : /* no diagnosis done */ 37 : TLE9104_OFFDIAG_UNKNOWN = 0, 38 : }; 39 : 40 0 : struct gpio_tle9104_channel_diagnostics { 41 0 : enum tle9104_on_state_diagnostics on: 3; 42 0 : enum tle9104_off_state_diagnostics off: 2; 43 : }; 44 : 45 : /** 46 : * @brief get the diagnostics of the outputs 47 : * 48 : * @param dev instance of TLE9104 49 : * @param diag destination where the result is written to 50 : * 51 : * @retval 0 If successful. 52 : */ 53 1 : int tle9104_get_diagnostics(const struct device *dev, 54 : struct gpio_tle9104_channel_diagnostics diag[TLE9104_GPIO_COUNT]); 55 : /** 56 : * @brief clear the diagnostics of the outputs 57 : * 58 : * @param dev instance of TLE9104 59 : * 60 : * @retval 0 If successful. 61 : */ 62 1 : int tle9104_clear_diagnostics(const struct device *dev); 63 : /*! 64 : * @brief write output state 65 : * 66 : * @param dev instance of TLE9104 67 : * @param state output state, each bit represents on output 68 : * 69 : * @retval 0 If successful. 70 : */ 71 1 : int tle9104_write_state(const struct device *dev, uint8_t state); 72 : 73 : #endif /* ZEPHYR_INCLUDE_DRIVERS_MFD_TLE9104_H_ */