#include <linux/array_size.h>
#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/bug.h>
#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/devm-helpers.h>
#include <linux/errno.h>
#include <linux/gpio/driver.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
#include <linux/types.h>
#include <linux/workqueue.h>
#include <asm/unaligned.h>
#include <linux/turris-omnia-mcu-interface.h>
#include "turris-omnia-mcu.h"
#define OMNIA_CMD_INT_ARG_LEN …
#define FRONT_BUTTON_RELEASE_DELAY_MS …
static const char * const omnia_mcu_gpio_templates[64] = …;
struct omnia_gpio { … };
#define OMNIA_GPIO_INVALID_INT_BIT …
#define _DEF_GPIO(_cmd, _ctl_cmd, _bit, _ctl_bit, _int_bit, _feat, _feat_mask) …
#define _DEF_GPIO_STS(_name) …
#define _DEF_GPIO_CTL(_name) …
#define _DEF_GPIO_EXT_STS(_name, _feat) …
#define _DEF_GPIO_EXT_STS_LED(_name, _ledext) …
#define _DEF_GPIO_EXT_STS_LEDALL(_name) …
#define _DEF_GPIO_EXT_CTL(_name, _feat) …
#define _DEF_INT(_name) …
static inline bool is_int_bit_valid(const struct omnia_gpio *gpio)
{ … }
static const struct omnia_gpio omnia_gpios[64] = …;
const u8 omnia_int_to_gpio_idx[32] = …;
#define OMNIA_GPIO_PHY_SFP_OFFSET …
static int omnia_ctl_cmd_locked(struct omnia_mcu *mcu, u8 cmd, u16 val, u16 mask)
{ … }
static int omnia_ctl_cmd(struct omnia_mcu *mcu, u8 cmd, u16 val, u16 mask)
{ … }
static int omnia_gpio_request(struct gpio_chip *gc, unsigned int offset)
{ … }
static int omnia_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
{ … }
static int omnia_gpio_direction_input(struct gpio_chip *gc, unsigned int offset)
{ … }
static int omnia_gpio_direction_output(struct gpio_chip *gc,
unsigned int offset, int value)
{ … }
static int omnia_gpio_get(struct gpio_chip *gc, unsigned int offset)
{ … }
static unsigned long *
_relevant_field_for_sts_cmd(u8 cmd, unsigned long *sts, unsigned long *ext_sts,
unsigned long *ext_ctl)
{ … }
static int omnia_gpio_get_multiple(struct gpio_chip *gc, unsigned long *mask,
unsigned long *bits)
{ … }
static void omnia_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
{ … }
static void omnia_gpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
unsigned long *bits)
{ … }
static bool omnia_gpio_available(struct omnia_mcu *mcu,
const struct omnia_gpio *gpio)
{ … }
static int omnia_gpio_init_valid_mask(struct gpio_chip *gc,
unsigned long *valid_mask,
unsigned int ngpios)
{ … }
static int omnia_gpio_of_xlate(struct gpio_chip *gc,
const struct of_phandle_args *gpiospec,
u32 *flags)
{ … }
static void omnia_irq_shutdown(struct irq_data *d)
{ … }
static void omnia_irq_mask(struct irq_data *d)
{ … }
static void omnia_irq_unmask(struct irq_data *d)
{ … }
static int omnia_irq_set_type(struct irq_data *d, unsigned int type)
{ … }
static void omnia_irq_bus_lock(struct irq_data *d)
{ … }
static void
omnia_mask_interleave(u8 *dst, unsigned long rising, unsigned long falling)
{ … }
static void omnia_mask_deinterleave(const u8 *src, unsigned long *rising,
unsigned long *falling)
{ … }
static void omnia_irq_bus_sync_unlock(struct irq_data *d)
{ … }
static const struct irq_chip omnia_mcu_irq_chip = …;
static void omnia_irq_init_valid_mask(struct gpio_chip *gc,
unsigned long *valid_mask,
unsigned int ngpios)
{ … }
static int omnia_irq_init_hw(struct gpio_chip *gc)
{ … }
static unsigned int
omnia_irq_compute_pending_length(unsigned long rising, unsigned long falling)
{ … }
static bool omnia_irq_read_pending_new(struct omnia_mcu *mcu,
unsigned long *pending)
{ … }
static int omnia_read_status_word_old_fw(struct omnia_mcu *mcu,
unsigned long *status)
{ … }
static void button_release_emul_fn(struct work_struct *work)
{ … }
static void
fill_int_from_sts(unsigned long *rising, unsigned long *falling,
unsigned long rising_sts, unsigned long falling_sts,
unsigned long sts_bit, unsigned long int_bit)
{ … }
static bool omnia_irq_read_pending_old(struct omnia_mcu *mcu,
unsigned long *pending)
{ … }
static bool omnia_irq_read_pending(struct omnia_mcu *mcu,
unsigned long *pending)
{ … }
static irqreturn_t omnia_irq_thread_handler(int irq, void *dev_id)
{ … }
static const char * const front_button_modes[] = …;
static ssize_t front_button_mode_show(struct device *dev,
struct device_attribute *a, char *buf)
{ … }
static ssize_t front_button_mode_store(struct device *dev,
struct device_attribute *a,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(front_button_mode);
static struct attribute *omnia_mcu_gpio_attrs[] = …;
const struct attribute_group omnia_mcu_gpio_group = …;
int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu)
{ … }