Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* MCP23S08 SPI/I2C GPIO driver */
0003 
0004 #include <linux/gpio/driver.h>
0005 #include <linux/irq.h>
0006 #include <linux/mutex.h>
0007 #include <linux/pinctrl/pinctrl.h>
0008 #include <linux/types.h>
0009 
0010 /*
0011  * MCP types supported by driver
0012  */
0013 #define MCP_TYPE_S08    1
0014 #define MCP_TYPE_S17    2
0015 #define MCP_TYPE_008    3
0016 #define MCP_TYPE_017    4
0017 #define MCP_TYPE_S18    5
0018 #define MCP_TYPE_018    6
0019 
0020 struct device;
0021 struct regmap;
0022 
0023 struct pinctrl_dev;
0024 
0025 struct mcp23s08 {
0026     u8          addr;
0027     bool            irq_active_high;
0028     bool            reg_shift;
0029 
0030     u16         irq_rise;
0031     u16         irq_fall;
0032     int         irq;
0033     bool            irq_controller;
0034     int         cached_gpio;
0035     /* lock protects regmap access with bypass/cache flags */
0036     struct mutex        lock;
0037 
0038     struct gpio_chip    chip;
0039     struct irq_chip     irq_chip;
0040 
0041     struct regmap       *regmap;
0042     struct device       *dev;
0043 
0044     struct pinctrl_dev  *pctldev;
0045     struct pinctrl_desc pinctrl_desc;
0046     struct gpio_desc        *reset_gpio;
0047 };
0048 
0049 extern const struct regmap_config mcp23x08_regmap;
0050 extern const struct regmap_config mcp23x17_regmap;
0051 
0052 int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
0053                unsigned int addr, unsigned int type, unsigned int base);