#include <linux/gpio/driver.h>
#include <linux/of_platform.h>
u8 bit_per_gpio[MAX_GPIO];
const struct creg_layout *layout;
static void creg_gpio_set(struct gpio_chip *gc, unsigned int offset, int val)
struct creg_gpio *hcg = gpiochip_get_data(gc);
const struct creg_layout *layout = hcg->layout;
u32 reg, reg_shift, value;
value = val ? hcg->layout->on[offset] : hcg->layout->off[offset];
reg_shift = layout->shift[offset];
for (i = 0; i < offset; i++)
reg_shift += layout->bit_per_gpio[i] + layout->shift[i];
spin_lock_irqsave(&hcg->lock, flags);
reg &= ~(GENMASK(layout->bit_per_gpio[i] - 1, 0) << reg_shift);
reg |= (value << reg_shift);
spin_unlock_irqrestore(&hcg->lock, flags);
static int creg_gpio_dir_out(struct gpio_chip *gc, unsigned int offset, int val)
creg_gpio_set(gc, offset, val);
static int creg_gpio_validate_pg(struct device *dev, struct creg_gpio *hcg,
const struct creg_layout *layout = hcg->layout;