1 /* 2 * Copyright 2024 NXP 3 * SPDX-License-Identifier: Apache-2.0 4 */ 5 6 #ifndef ZEPHYR_INCLUDE_DRIVERS_MFD_ADP5585_H_ 7 #define ZEPHYR_INCLUDE_DRIVERS_MFD_ADP5585_H_ 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 #include <zephyr/device.h> 14 #define ADP5585_ID 0x00 15 #define ADP5585_INT_STATUS 0x01 16 #define ADP5585_STATUS 0x02 17 #define ADP5585_FIFO_1 0x03 18 #define ADP5585_FIFO_2 0x04 19 #define ADP5585_FIFO_3 0x05 20 #define ADP5585_FIFO_4 0x06 21 #define ADP5585_FIFO_5 0x07 22 #define ADP5585_FIFO_6 0x08 23 #define ADP5585_FIFO_7 0x09 24 #define ADP5585_FIFO_8 0x0A 25 #define ADP5585_FIFO_9 0x0B 26 #define ADP5585_FIFO_10 0x0C 27 #define ADP5585_FIFO_11 0x0D 28 #define ADP5585_FIFO_12 0x0E 29 #define ADP5585_FIFO_13 0x0F 30 #define ADP5585_FIFO_14 0x10 31 #define ADP5585_FIFO_15 0x11 32 #define ADP5585_FIFO_16 0x12 33 #define ADP5585_GPI_INT_STAT_A 0x13 34 #define ADP5585_GPI_INT_STAT_B 0x14 35 #define ADP5585_GPI_STATUS_A 0x15 36 #define ADP5585_GPI_STATUS_B 0x16 37 #define ADP5585_RPULL_CONFIG_A 0x17 38 #define ADP5585_RPULL_CONFIG_B 0x18 39 #define ADP5585_RPULL_CONFIG_C 0x19 40 #define ADP5585_RPULL_CONFIG_D 0x1A 41 #define ADP5585_GPI_INT_LEVEL_A 0x1B 42 #define ADP5585_GPI_INT_LEVEL_B 0x1C 43 #define ADP5585_GPI_EVENT_EN_A 0x1D 44 #define ADP5585_GPI_EVENT_EN_B 0x1E 45 #define ADP5585_GPI_INTERRUPT_EN_A 0x1F 46 #define ADP5585_GPI_INTERRUPT_EN_B 0x20 47 #define ADP5585_DEBOUNCE_DIS_A 0x21 48 #define ADP5585_DEBOUNCE_DIS_B 0x22 49 #define ADP5585_GPO_DATA_OUT_A 0x23 50 #define ADP5585_GPO_DATA_OUT_B 0x24 51 #define ADP5585_GPO_OUT_MODE_A 0x25 52 #define ADP5585_GPO_OUT_MODE_B 0x26 53 #define ADP5585_GPIO_DIRECTION_A 0x27 54 #define ADP5585_GPIO_DIRECTION_B 0x28 55 #define ADP5585_RESET1_EVENT_A 0x29 56 #define ADP5585_RESET1_EVENT_B 0x2A 57 #define ADP5585_RESET1_EVENT_C 0x2B 58 #define ADP5585_RESET2_EVENT_A 0x2C 59 #define ADP5585_RESET2_EVENT_B 0x2D 60 #define ADP5585_RESET_CFG 0x2E 61 #define ADP5585_PWM_OFFT_LOW 0x2F 62 #define ADP5585_PWM_OFFT_HIGH 0x30 63 #define ADP5585_PWM_ONT_LOW 0x31 64 #define ADP5585_PWM_ONT_HIGH 0x32 65 #define ADP5585_PWM_CFG 0x33 66 #define ADP5585_LOGIC_CFG 0x34 67 #define ADP5585_LOGIC_FF_CFG 0x35 68 #define ADP5585_LOGIC_INT_EVENT_EN 0x36 69 #define ADP5585_POLL_PTIME_CFG 0x37 70 #define ADP5585_PIN_CONFIG_A 0x38 71 #define ADP5585_PIN_CONFIG_B 0x39 72 #define ADP5585_PIN_CONFIG_C 0x3A 73 #define ADP5585_GENERAL_CFG 0x3B 74 #define ADP5585_INT_EN 0x3C 75 76 /* ID Register */ 77 #define ADP5585_DEVICE_ID_MASK 0xF 78 #define ADP5585_MAN_ID_MASK 0xF 79 #define ADP5585_MAN_ID_SHIFT 4 80 #define ADP5585_MAN_ID 0x02 81 82 #define ADP5585_PWM_CFG_EN 0x1 83 #define ADP5585_PWM_CFG_MODE 0x2 84 #define ADP5585_PIN_CONFIG_R3_PWM 0x8 85 #define ADP5585_PIN_CONFIG_R3_MASK 0xC 86 #define ADP5585_GENERAL_CFG_OSC_EN 0x80 87 88 /* INT_EN and INT_STATUS Register */ 89 #define ADP5585_INT_EVENT (1U << 0) 90 #define ADP5585_INT_GPI (1U << 1) 91 #define ADP5585_INT_OVERFLOW (1U << 2) 92 #define ADP5585_INT_LOGIC (1U << 4) 93 94 #define ADP5585_REG_MASK 0xFF 95 96 struct mfd_adp5585_config { 97 struct gpio_dt_spec reset_gpio; 98 struct gpio_dt_spec nint_gpio; 99 struct i2c_dt_spec i2c_bus; 100 }; 101 102 struct mfd_adp5585_data { 103 struct k_work work; 104 struct k_sem lock; 105 const struct device *dev; 106 struct { 107 #ifdef CONFIG_GPIO_ADP5585 108 const struct device *gpio_dev; 109 #endif /* CONFIG_GPIO_ADP5585 */ 110 } child; 111 struct gpio_callback int_gpio_cb; 112 }; 113 114 /** 115 * @brief Forward declaration of child device interrupt 116 * handler 117 */ 118 #ifdef CONFIG_GPIO_ADP5585 119 void gpio_adp5585_irq_handler(const struct device *dev); 120 #endif /* CONFIG_GPIO_ADP5585 */ 121 122 #ifdef __cplusplus 123 } 124 #endif 125 126 #endif /* ZEPHYR_INCLUDE_DRIVERS_MFD_AD5952_H_ */ 127