Andy Shevchenko | 0f04a81 | 2020-04-07 20:38:49 +0300 | [diff] [blame] | 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 { |
| 26 | u8 addr; |
| 27 | bool irq_active_high; |
| 28 | bool reg_shift; |
| 29 | |
| 30 | u16 irq_rise; |
| 31 | u16 irq_fall; |
| 32 | int irq; |
| 33 | bool irq_controller; |
| 34 | int cached_gpio; |
| 35 | /* lock protects regmap access with bypass/cache flags */ |
| 36 | struct mutex lock; |
| 37 | |
| 38 | struct gpio_chip chip; |
| 39 | struct irq_chip irq_chip; |
| 40 | |
| 41 | struct regmap *regmap; |
| 42 | struct device *dev; |
| 43 | |
| 44 | struct pinctrl_dev *pctldev; |
| 45 | struct pinctrl_desc pinctrl_desc; |
Andreas Kaessens | 4e73bfa | 2021-06-10 15:24:37 +0200 | [diff] [blame] | 46 | struct gpio_desc *reset_gpio; |
Andy Shevchenko | 0f04a81 | 2020-04-07 20:38:49 +0300 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | extern const struct regmap_config mcp23x08_regmap; |
| 50 | extern const struct regmap_config mcp23x17_regmap; |
| 51 | |
| 52 | int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, |
| 53 | unsigned int addr, unsigned int type, unsigned int base); |