1
2
3
4
5
6
7 #ifndef MFD_STMFX_H
8 #define MFD_STMFX_H
9
10 #include <linux/regmap.h>
11
12
13 #define STMFX_REG_CHIP_ID 0x00
14 #define STMFX_REG_FW_VERSION_MSB 0x01
15 #define STMFX_REG_FW_VERSION_LSB 0x02
16 #define STMFX_REG_SYS_CTRL 0x40
17
18 #define STMFX_REG_IRQ_OUT_PIN 0x41
19 #define STMFX_REG_IRQ_SRC_EN 0x42
20 #define STMFX_REG_IRQ_PENDING 0x08
21 #define STMFX_REG_IRQ_ACK 0x44
22
23 #define STMFX_REG_IRQ_GPI_PENDING1 0x0C
24 #define STMFX_REG_IRQ_GPI_PENDING2 0x0D
25 #define STMFX_REG_IRQ_GPI_PENDING3 0x0E
26 #define STMFX_REG_GPIO_STATE1 0x10
27 #define STMFX_REG_GPIO_STATE2 0x11
28 #define STMFX_REG_GPIO_STATE3 0x12
29 #define STMFX_REG_IRQ_GPI_SRC1 0x48
30 #define STMFX_REG_IRQ_GPI_SRC2 0x49
31 #define STMFX_REG_IRQ_GPI_SRC3 0x4A
32 #define STMFX_REG_IRQ_GPI_EVT1 0x4C
33 #define STMFX_REG_IRQ_GPI_EVT2 0x4D
34 #define STMFX_REG_IRQ_GPI_EVT3 0x4E
35 #define STMFX_REG_IRQ_GPI_TYPE1 0x50
36 #define STMFX_REG_IRQ_GPI_TYPE2 0x51
37 #define STMFX_REG_IRQ_GPI_TYPE3 0x52
38 #define STMFX_REG_IRQ_GPI_ACK1 0x54
39 #define STMFX_REG_IRQ_GPI_ACK2 0x55
40 #define STMFX_REG_IRQ_GPI_ACK3 0x56
41 #define STMFX_REG_GPIO_DIR1 0x60
42 #define STMFX_REG_GPIO_DIR2 0x61
43 #define STMFX_REG_GPIO_DIR3 0x62
44 #define STMFX_REG_GPIO_TYPE1 0x64
45 #define STMFX_REG_GPIO_TYPE2 0x65
46 #define STMFX_REG_GPIO_TYPE3 0x66
47 #define STMFX_REG_GPIO_PUPD1 0x68
48 #define STMFX_REG_GPIO_PUPD2 0x69
49 #define STMFX_REG_GPIO_PUPD3 0x6A
50 #define STMFX_REG_GPO_SET1 0x6C
51 #define STMFX_REG_GPO_SET2 0x6D
52 #define STMFX_REG_GPO_SET3 0x6E
53 #define STMFX_REG_GPO_CLR1 0x70
54 #define STMFX_REG_GPO_CLR2 0x71
55 #define STMFX_REG_GPO_CLR3 0x72
56
57 #define STMFX_REG_MAX 0xB0
58
59
60 #define STMFX_BOOT_TIME_MS 10
61
62
63 #define STMFX_REG_CHIP_ID_MASK GENMASK(7, 0)
64
65
66 #define STMFX_REG_SYS_CTRL_GPIO_EN BIT(0)
67 #define STMFX_REG_SYS_CTRL_TS_EN BIT(1)
68 #define STMFX_REG_SYS_CTRL_IDD_EN BIT(2)
69 #define STMFX_REG_SYS_CTRL_ALTGPIO_EN BIT(3)
70 #define STMFX_REG_SYS_CTRL_SWRST BIT(7)
71
72
73 #define STMFX_REG_IRQ_OUT_PIN_TYPE BIT(0)
74 #define STMFX_REG_IRQ_OUT_PIN_POL BIT(1)
75
76
77 enum stmfx_irqs {
78 STMFX_REG_IRQ_SRC_EN_GPIO = 0,
79 STMFX_REG_IRQ_SRC_EN_IDD,
80 STMFX_REG_IRQ_SRC_EN_ERROR,
81 STMFX_REG_IRQ_SRC_EN_TS_DET,
82 STMFX_REG_IRQ_SRC_EN_TS_NE,
83 STMFX_REG_IRQ_SRC_EN_TS_TH,
84 STMFX_REG_IRQ_SRC_EN_TS_FULL,
85 STMFX_REG_IRQ_SRC_EN_TS_OVF,
86 STMFX_REG_IRQ_SRC_MAX,
87 };
88
89 enum stmfx_functions {
90 STMFX_FUNC_GPIO = BIT(0),
91 STMFX_FUNC_ALTGPIO_LOW = BIT(1),
92 STMFX_FUNC_ALTGPIO_HIGH = BIT(2),
93 STMFX_FUNC_TS = BIT(3),
94 STMFX_FUNC_IDD = BIT(4),
95 };
96
97
98
99
100
101
102
103
104
105
106
107
108 struct stmfx {
109 struct device *dev;
110 struct regmap *map;
111 struct regulator *vdd;
112 struct irq_domain *irq_domain;
113 struct mutex lock;
114 u8 irq_src;
115 #ifdef CONFIG_PM
116 u8 bkp_sysctrl;
117 u8 bkp_irqoutpin;
118 #endif
119 };
120
121 int stmfx_function_enable(struct stmfx *stmfx, u32 func);
122 int stmfx_function_disable(struct stmfx *stmfx, u32 func);
123 #endif