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