xref: /linux/drivers/pinctrl/pinctrl-mcp23s08.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* MCP23S08 SPI/I2C GPIO driver */
3 
4 #include <linux/gpio/driver.h>
5 #include <linux/irq.h>
6 #include <linux/mutex.h>
7 #include <linux/pinctrl/pinctrl.h>
8 #include <linux/types.h>
9 
10 /*
11  * MCP types supported by driver
12  */
13 #define MCP_TYPE_S08	1
14 #define MCP_TYPE_S17	2
15 #define MCP_TYPE_008	3
16 #define MCP_TYPE_017	4
17 #define MCP_TYPE_S18	5
18 #define MCP_TYPE_018	6
19 
20 struct device;
21 struct regmap;
22 
23 struct pinctrl_dev;
24 
25 struct mcp23s08_info {
26 	const struct regmap_config *regmap;
27 	const char *label;
28 	unsigned int type;
29 	u16 ngpio;
30 	bool reg_shift;
31 };
32 
33 struct mcp23s08 {
34 	u8			addr;
35 	bool			irq_active_high;
36 	bool			reg_shift;
37 
38 	u16			irq_rise;
39 	u16			irq_fall;
40 	int			irq;
41 	bool			irq_controller;
42 	int			cached_gpio;
43 	/* lock protects regmap access with bypass/cache flags */
44 	struct mutex		lock;
45 
46 	struct gpio_chip	chip;
47 
48 	struct regmap		*regmap;
49 	struct device		*dev;
50 
51 	struct pinctrl_dev	*pctldev;
52 	struct pinctrl_desc	pinctrl_desc;
53 	struct gpio_desc        *reset_gpio;
54 };
55 
56 extern const struct regmap_config mcp23x08_regmap;
57 extern const struct regmap_config mcp23x17_regmap;
58 
59 int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
60 		       unsigned int addr, unsigned int type, unsigned int base);
61