drivers/gpio/gpio-max77650.c

Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-max77650.c

File Facts

System
Linux kernel
Corpus path
drivers/gpio/gpio-max77650.c
Extension
.c
Size
5078 bytes
Lines
190
Domain
Driver Families
Bucket
drivers/gpio
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct max77650_gpio_chip {
	struct regmap *map;
	struct gpio_chip gc;
	int irq;
};

static int max77650_gpio_direction_input(struct gpio_chip *gc,
					 unsigned int offset)
{
	struct max77650_gpio_chip *chip = gpiochip_get_data(gc);

	return regmap_update_bits(chip->map,
				  MAX77650_REG_CNFG_GPIO,
				  MAX77650_GPIO_DIR_MASK,
				  MAX77650_GPIO_DIR_IN);
}

static int max77650_gpio_direction_output(struct gpio_chip *gc,
					  unsigned int offset, int value)
{
	struct max77650_gpio_chip *chip = gpiochip_get_data(gc);
	int mask, regval;

	mask = MAX77650_GPIO_DIR_MASK | MAX77650_GPIO_OUTVAL_MASK;
	regval = value ? MAX77650_GPIO_OUT_HIGH : MAX77650_GPIO_OUT_LOW;
	regval |= MAX77650_GPIO_DIR_OUT;

	return regmap_update_bits(chip->map,
				  MAX77650_REG_CNFG_GPIO, mask, regval);
}

static int max77650_gpio_set_value(struct gpio_chip *gc,
				   unsigned int offset, int value)
{
	struct max77650_gpio_chip *chip = gpiochip_get_data(gc);
	int regval;

	regval = value ? MAX77650_GPIO_OUT_HIGH : MAX77650_GPIO_OUT_LOW;

	return regmap_update_bits(chip->map, MAX77650_REG_CNFG_GPIO,
				  MAX77650_GPIO_OUTVAL_MASK, regval);
}

static int max77650_gpio_get_value(struct gpio_chip *gc,
				   unsigned int offset)
{
	struct max77650_gpio_chip *chip = gpiochip_get_data(gc);
	unsigned int val;
	int rv;

	rv = regmap_read(chip->map, MAX77650_REG_CNFG_GPIO, &val);
	if (rv)
		return rv;

	return MAX77650_GPIO_INVAL_BITS(val);
}

static int max77650_gpio_get_direction(struct gpio_chip *gc,
				       unsigned int offset)
{
	struct max77650_gpio_chip *chip = gpiochip_get_data(gc);
	unsigned int val;
	int rv;

	rv = regmap_read(chip->map, MAX77650_REG_CNFG_GPIO, &val);
	if (rv)
		return rv;

	return MAX77650_GPIO_DIR_BITS(val);
}

static int max77650_gpio_set_config(struct gpio_chip *gc,
				    unsigned int offset, unsigned long cfg)
{
	struct max77650_gpio_chip *chip = gpiochip_get_data(gc);

	switch (pinconf_to_config_param(cfg)) {
	case PIN_CONFIG_DRIVE_OPEN_DRAIN:
		return regmap_update_bits(chip->map,
					  MAX77650_REG_CNFG_GPIO,
					  MAX77650_GPIO_DRV_MASK,
					  MAX77650_GPIO_DRV_OPEN_DRAIN);
	case PIN_CONFIG_DRIVE_PUSH_PULL:
		return regmap_update_bits(chip->map,
					  MAX77650_REG_CNFG_GPIO,
					  MAX77650_GPIO_DRV_MASK,
					  MAX77650_GPIO_DRV_PUSH_PULL);
	case PIN_CONFIG_INPUT_DEBOUNCE:
		return regmap_update_bits(chip->map,
					  MAX77650_REG_CNFG_GPIO,

Annotation

Implementation Notes