drivers/gpio/gpio-max77759.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-max77759.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-max77759.c- Extension
.c- Size
- 14243 bytes
- Lines
- 525
- 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/dev_printk.hlinux/device.hlinux/device/driver.hlinux/gpio/driver.hlinux/interrupt.hlinux/irq.hlinux/irqreturn.hlinux/lockdep.hlinux/mfd/max77759.hlinux/mod_devicetable.hlinux/module.hlinux/overflow.hlinux/platform_device.hlinux/regmap.hlinux/seq_file.h
Detected Declarations
struct max77759_gpio_chipenum max77759_trigger_gpio_typeenum max77759_control_gpio_dirfunction max77759_gpio_maxq_gpio_trigger_readfunction max77759_gpio_maxq_gpio_trigger_writefunction max77759_gpio_maxq_gpio_control_readfunction max77759_gpio_maxq_gpio_control_writefunction max77759_gpio_direction_from_controlfunction max77759_gpio_get_directionfunction max77759_gpio_direction_helperfunction max77759_gpio_direction_inputfunction max77759_gpio_direction_outputfunction max77759_gpio_get_valuefunction max77759_gpio_set_valuefunction max77759_gpio_irq_maskfunction max77759_gpio_irq_unmaskfunction max77759_gpio_set_irq_typefunction max77759_gpio_bus_lockfunction max77759_gpio_bus_sync_unlock_helperfunction max77759_gpio_bus_sync_unlockfunction scoped_guardfunction max77759_gpio_irq_print_chipfunction max77759_gpio_irqhandlerfunction for_each_set_bitfunction max77759_gpio_probe
Annotated Snippet
struct max77759_gpio_chip {
struct regmap *map;
struct max77759 *max77759;
struct gpio_chip gc;
struct mutex maxq_lock; /* protect MaxQ r/m/w operations */
struct mutex irq_lock; /* protect irq bus */
int irq_mask;
int irq_mask_changed;
int irq_trig;
int irq_trig_changed;
};
#define MAX77759_GPIOx_TRIGGER(offs, val) (((val) & 1) << (offs))
#define MAX77759_GPIOx_TRIGGER_MASK(offs) MAX77759_GPIOx_TRIGGER(offs, ~0)
enum max77759_trigger_gpio_type {
MAX77759_GPIO_TRIGGER_RISING = 0,
MAX77759_GPIO_TRIGGER_FALLING = 1
};
#define MAX77759_GPIOx_DIR(offs, dir) (((dir) & 1) << (2 + (3 * (offs))))
#define MAX77759_GPIOx_DIR_MASK(offs) MAX77759_GPIOx_DIR(offs, ~0)
enum max77759_control_gpio_dir {
MAX77759_GPIO_DIR_IN = 0,
MAX77759_GPIO_DIR_OUT = 1
};
#define MAX77759_GPIOx_OUTVAL(offs, val) (((val) & 1) << (3 + (3 * (offs))))
#define MAX77759_GPIOx_OUTVAL_MASK(offs) MAX77759_GPIOx_OUTVAL(offs, ~0)
#define MAX77759_GPIOx_INVAL_MASK(offs) (BIT(4) << (3 * (offs)))
static int max77759_gpio_maxq_gpio_trigger_read(struct max77759_gpio_chip *chip)
{
DEFINE_FLEX(struct max77759_maxq_command, cmd, cmd, length, 1);
DEFINE_FLEX(struct max77759_maxq_response, rsp, rsp, length, 2);
int ret;
cmd->cmd[0] = MAX77759_MAXQ_OPCODE_GPIO_TRIGGER_READ;
ret = max77759_maxq_command(chip->max77759, cmd, rsp);
if (ret < 0)
return ret;
return rsp->rsp[1];
}
static int max77759_gpio_maxq_gpio_trigger_write(struct max77759_gpio_chip *chip,
u8 trigger)
{
DEFINE_FLEX(struct max77759_maxq_command, cmd, cmd, length, 2);
cmd->cmd[0] = MAX77759_MAXQ_OPCODE_GPIO_TRIGGER_WRITE;
cmd->cmd[1] = trigger;
return max77759_maxq_command(chip->max77759, cmd, NULL);
}
static int max77759_gpio_maxq_gpio_control_read(struct max77759_gpio_chip *chip)
{
DEFINE_FLEX(struct max77759_maxq_command, cmd, cmd, length, 1);
DEFINE_FLEX(struct max77759_maxq_response, rsp, rsp, length, 2);
int ret;
cmd->cmd[0] = MAX77759_MAXQ_OPCODE_GPIO_CONTROL_READ;
ret = max77759_maxq_command(chip->max77759, cmd, rsp);
if (ret < 0)
return ret;
return rsp->rsp[1];
}
static int max77759_gpio_maxq_gpio_control_write(struct max77759_gpio_chip *chip,
u8 ctrl)
{
DEFINE_FLEX(struct max77759_maxq_command, cmd, cmd, length, 2);
cmd->cmd[0] = MAX77759_MAXQ_OPCODE_GPIO_CONTROL_WRITE;
cmd->cmd[1] = ctrl;
return max77759_maxq_command(chip->max77759, cmd, NULL);
}
static int
max77759_gpio_direction_from_control(int ctrl, unsigned int offset)
{
enum max77759_control_gpio_dir dir;
dir = !!(ctrl & MAX77759_GPIOx_DIR_MASK(offset));
Annotation
- Immediate include surface: `linux/dev_printk.h`, `linux/device.h`, `linux/device/driver.h`, `linux/gpio/driver.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/irqreturn.h`, `linux/lockdep.h`.
- Detected declarations: `struct max77759_gpio_chip`, `enum max77759_trigger_gpio_type`, `enum max77759_control_gpio_dir`, `function max77759_gpio_maxq_gpio_trigger_read`, `function max77759_gpio_maxq_gpio_trigger_write`, `function max77759_gpio_maxq_gpio_control_read`, `function max77759_gpio_maxq_gpio_control_write`, `function max77759_gpio_direction_from_control`, `function max77759_gpio_get_direction`, `function max77759_gpio_direction_helper`.
- Atlas domain: Driver Families / drivers/gpio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.