#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/bitops.h>
#include <linux/platform_device.h>
#include <linux/gpio/driver.h>
#include <linux/mfd/kempld.h>
#define KEMPLD_GPIO_MAX_NUM 16
#define KEMPLD_GPIO_MASK(x) (BIT((x) % 8))
#define KEMPLD_GPIO_DIR_NUM(x) (0x40 + (x) / 8)
#define KEMPLD_GPIO_LVL_NUM(x) (0x42 + (x) / 8)
#define KEMPLD_GPIO_EVT_LVL_EDGE 0x46
#define KEMPLD_GPIO_IEN 0x4A
struct kempld_gpio_data {
struct kempld_device_data *pld;
static void kempld_gpio_bitop(struct kempld_device_data *pld,
status = kempld_read8(pld, reg);
status |= KEMPLD_GPIO_MASK(bit);
status &= ~KEMPLD_GPIO_MASK(bit);
kempld_write8(pld, reg, status);
static int kempld_gpio_get_bit(struct kempld_device_data *pld, u8 reg, u8 bit)
status = kempld_read8(pld, reg);
kempld_release_mutex(pld);
return !!(status & KEMPLD_GPIO_MASK(bit));