#include <linux/module.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/bitfield.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/hid.h>
#include <linux/hidraw.h>
#include <linux/i2c.h>
#include <linux/gpio/driver.h>
#include <linux/iio/iio.h>
#include "hid-ids.h"
enum { … };
enum { … };
enum { … };
#define MCP_NGPIO …
struct mcp_set_gpio { … } __packed;
struct mcp_get_gpio { … } __packed;
struct mcp2221 { … };
struct mcp2221_iio { … };
static uint i2c_clk_freq = …;
static int mcp_send_report(struct mcp2221 *mcp,
u8 *out_report, size_t len)
{ … }
static int mcp_send_data_req_status(struct mcp2221 *mcp,
u8 *out_report, int len)
{ … }
static int mcp_chk_last_cmd_status(struct mcp2221 *mcp)
{ … }
static int mcp_cancel_last_cmd(struct mcp2221 *mcp)
{ … }
static int mcp_chk_last_cmd_status_free_bus(struct mcp2221 *mcp)
{ … }
static int mcp_set_i2c_speed(struct mcp2221 *mcp)
{ … }
static int mcp_i2c_write(struct mcp2221 *mcp,
struct i2c_msg *msg, int type, u8 last_status)
{ … }
static int mcp_i2c_smbus_read(struct mcp2221 *mcp,
struct i2c_msg *msg, int type, u16 smbus_addr,
u8 smbus_len, u8 *smbus_buf)
{ … }
static int mcp_i2c_xfer(struct i2c_adapter *adapter,
struct i2c_msg msgs[], int num)
{ … }
static int mcp_smbus_write(struct mcp2221 *mcp, u16 addr,
u8 command, u8 *buf, u8 len, int type,
u8 last_status)
{ … }
static int mcp_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
unsigned short flags, char read_write,
u8 command, int size,
union i2c_smbus_data *data)
{ … }
static u32 mcp_i2c_func(struct i2c_adapter *adapter)
{ … }
static const struct i2c_algorithm mcp_i2c_algo = …;
#if IS_REACHABLE(CONFIG_GPIOLIB)
static int mcp_gpio_get(struct gpio_chip *gc,
unsigned int offset)
{ … }
static void mcp_gpio_set(struct gpio_chip *gc,
unsigned int offset, int value)
{ … }
static int mcp_gpio_dir_set(struct mcp2221 *mcp,
unsigned int offset, u8 val)
{ … }
static int mcp_gpio_direction_input(struct gpio_chip *gc,
unsigned int offset)
{ … }
static int mcp_gpio_direction_output(struct gpio_chip *gc,
unsigned int offset, int value)
{ … }
static int mcp_gpio_get_direction(struct gpio_chip *gc,
unsigned int offset)
{ … }
#endif
static int mcp_get_i2c_eng_state(struct mcp2221 *mcp,
u8 *data, u8 idx)
{ … }
static int mcp2221_raw_event(struct hid_device *hdev,
struct hid_report *report, u8 *data, int size)
{ … }
static void mcp2221_hid_unregister(void *ptr)
{ … }
static void mcp2221_remove(struct hid_device *hdev)
{ … }
#if IS_REACHABLE(CONFIG_IIO)
static int mcp2221_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *channel, int *val,
int *val2, long mask)
{ … }
static int mcp2221_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{ … }
static const struct iio_info mcp2221_info = …;
static int mcp_iio_channels(struct mcp2221 *mcp)
{ … }
static void mcp_init_work(struct work_struct *work)
{ … }
#endif
static int mcp2221_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{ … }
static const struct hid_device_id mcp2221_devices[] = …;
MODULE_DEVICE_TABLE(hid, mcp2221_devices);
static struct hid_driver mcp2221_driver = …;
module_hid_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;