drivers/gpio/gpio-mb86s7x.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-mb86s7x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-mb86s7x.c- Extension
.c- Size
- 5592 bytes
- Lines
- 237
- 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.
- 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/acpi.hlinux/io.hlinux/init.hlinux/clk.hlinux/mod_devicetable.hlinux/module.hlinux/err.hlinux/errno.hlinux/ioport.hlinux/gpio/driver.hlinux/platform_device.hlinux/spinlock.hlinux/slab.hgpiolib-acpi.h
Detected Declarations
struct mb86s70_gpio_chipfunction mb86s70_gpio_requestfunction mb86s70_gpio_freefunction mb86s70_gpio_direction_inputfunction mb86s70_gpio_direction_outputfunction mb86s70_gpio_getfunction mb86s70_gpio_setfunction mb86s70_gpio_to_irqfunction mb86s70_gpio_probefunction mb86s70_gpio_remove
Annotated Snippet
struct mb86s70_gpio_chip {
struct gpio_chip gc;
void __iomem *base;
spinlock_t lock;
};
static int mb86s70_gpio_request(struct gpio_chip *gc, unsigned gpio)
{
struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc);
unsigned long flags;
u32 val;
spin_lock_irqsave(&gchip->lock, flags);
val = readl(gchip->base + PFR(gpio));
val &= ~OFFSET(gpio);
writel(val, gchip->base + PFR(gpio));
spin_unlock_irqrestore(&gchip->lock, flags);
return 0;
}
static void mb86s70_gpio_free(struct gpio_chip *gc, unsigned gpio)
{
struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc);
unsigned long flags;
u32 val;
spin_lock_irqsave(&gchip->lock, flags);
val = readl(gchip->base + PFR(gpio));
val |= OFFSET(gpio);
writel(val, gchip->base + PFR(gpio));
spin_unlock_irqrestore(&gchip->lock, flags);
}
static int mb86s70_gpio_direction_input(struct gpio_chip *gc, unsigned gpio)
{
struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc);
unsigned long flags;
unsigned char val;
spin_lock_irqsave(&gchip->lock, flags);
val = readl(gchip->base + DDR(gpio));
val &= ~OFFSET(gpio);
writel(val, gchip->base + DDR(gpio));
spin_unlock_irqrestore(&gchip->lock, flags);
return 0;
}
static int mb86s70_gpio_direction_output(struct gpio_chip *gc,
unsigned gpio, int value)
{
struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc);
unsigned long flags;
unsigned char val;
spin_lock_irqsave(&gchip->lock, flags);
val = readl(gchip->base + PDR(gpio));
if (value)
val |= OFFSET(gpio);
else
val &= ~OFFSET(gpio);
writel(val, gchip->base + PDR(gpio));
val = readl(gchip->base + DDR(gpio));
val |= OFFSET(gpio);
writel(val, gchip->base + DDR(gpio));
spin_unlock_irqrestore(&gchip->lock, flags);
return 0;
}
static int mb86s70_gpio_get(struct gpio_chip *gc, unsigned gpio)
{
struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc);
return !!(readl(gchip->base + PDR(gpio)) & OFFSET(gpio));
}
static int mb86s70_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value)
{
struct mb86s70_gpio_chip *gchip = gpiochip_get_data(gc);
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/io.h`, `linux/init.h`, `linux/clk.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/err.h`, `linux/errno.h`.
- Detected declarations: `struct mb86s70_gpio_chip`, `function mb86s70_gpio_request`, `function mb86s70_gpio_free`, `function mb86s70_gpio_direction_input`, `function mb86s70_gpio_direction_output`, `function mb86s70_gpio_get`, `function mb86s70_gpio_set`, `function mb86s70_gpio_to_irq`, `function mb86s70_gpio_probe`, `function mb86s70_gpio_remove`.
- 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.
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.