drivers/gpio/gpio-zynq.c
Source file repositories/reference/linux-study-clean/drivers/gpio/gpio-zynq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpio/gpio-zynq.c- Extension
.c- Size
- 32535 bytes
- Lines
- 1047
- 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/bitops.hlinux/clk.hlinux/gpio/driver.hlinux/init.hlinux/interrupt.hlinux/spinlock.hlinux/io.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/of.h
Detected Declarations
struct gpio_regsstruct zynq_gpiostruct zynq_platform_datafunction zynq_gpio_is_zynqfunction gpio_data_ro_bugfunction zynq_gpio_get_bank_pinfunction zynq_gpio_get_valuefunction offsetfunction zynq_gpio_dir_infunction zynq_gpio_dir_outfunction zynq_gpio_get_directionfunction zynq_gpio_irq_maskfunction zynq_gpio_irq_unmaskfunction zynq_gpio_irq_ackfunction zynq_gpio_irq_enablefunction zynq_gpio_set_irq_typefunction zynq_gpio_set_wakefunction zynq_gpio_irq_reqresfunction zynq_gpio_irq_relresfunction zynq_gpio_handle_bank_irqfunction zynq_gpio_irqhandlerfunction zynq_gpio_save_contextfunction zynq_gpio_restore_contextfunction zynq_gpio_suspendfunction zynq_gpio_resumefunction zynq_gpio_runtime_suspendfunction zynq_gpio_runtime_resumefunction zynq_gpio_requestfunction zynq_gpio_freefunction zynq_gpio_probefunction zynq_gpio_remove
Annotated Snippet
struct gpio_regs {
u32 datamsw[ZYNQMP_GPIO_MAX_BANK];
u32 datalsw[ZYNQMP_GPIO_MAX_BANK];
u32 dirm[ZYNQMP_GPIO_MAX_BANK];
u32 outen[ZYNQMP_GPIO_MAX_BANK];
u32 int_en[ZYNQMP_GPIO_MAX_BANK];
u32 int_dis[ZYNQMP_GPIO_MAX_BANK];
u32 int_type[ZYNQMP_GPIO_MAX_BANK];
u32 int_polarity[ZYNQMP_GPIO_MAX_BANK];
u32 int_any[ZYNQMP_GPIO_MAX_BANK];
};
/**
* struct zynq_gpio - gpio device private data structure
* @chip: instance of the gpio_chip
* @base_addr: base address of the GPIO device
* @clk: clock resource for this controller
* @irq: interrupt for the GPIO device
* @p_data: pointer to platform data
* @context: context registers
* @dirlock: lock used for direction in/out synchronization
*/
struct zynq_gpio {
struct gpio_chip chip;
void __iomem *base_addr;
struct clk *clk;
int irq;
const struct zynq_platform_data *p_data;
struct gpio_regs context;
spinlock_t dirlock; /* lock */
};
/**
* struct zynq_platform_data - zynq gpio platform data structure
* @label: string to store in gpio->label
* @quirks: Flags is used to identify the platform
* @ngpio: max number of gpio pins
* @max_bank: maximum number of gpio banks
* @bank_min: this array represents bank's min pin
* @bank_max: this array represents bank's max pin
*/
struct zynq_platform_data {
const char *label;
u32 quirks;
u16 ngpio;
int max_bank;
int bank_min[ZYNQMP_GPIO_MAX_BANK];
int bank_max[ZYNQMP_GPIO_MAX_BANK];
};
static const struct irq_chip zynq_gpio_level_irqchip;
static const struct irq_chip zynq_gpio_edge_irqchip;
/**
* zynq_gpio_is_zynq - test if HW is zynq or zynqmp
* @gpio: Pointer to driver data struct
*
* Return: 0 if zynqmp, 1 if zynq.
*/
static int zynq_gpio_is_zynq(struct zynq_gpio *gpio)
{
return !!(gpio->p_data->quirks & ZYNQ_GPIO_QUIRK_IS_ZYNQ);
}
/**
* gpio_data_ro_bug - test if HW bug exists or not
* @gpio: Pointer to driver data struct
*
* Return: 0 if bug doesnot exist, 1 if bug exists.
*/
static int gpio_data_ro_bug(struct zynq_gpio *gpio)
{
return !!(gpio->p_data->quirks & GPIO_QUIRK_DATA_RO_BUG);
}
/**
* zynq_gpio_get_bank_pin - Get the bank number and pin number within that bank
* for a given pin in the GPIO device
* @pin_num: gpio pin number within the device
* @bank_num: an output parameter used to return the bank number of the gpio
* pin
* @bank_pin_num: an output parameter used to return pin number within a bank
* for the given gpio pin
* @gpio: gpio device data structure
*
* Returns the bank number and pin offset within the bank.
*/
static inline void zynq_gpio_get_bank_pin(unsigned int pin_num,
unsigned int *bank_num,
unsigned int *bank_pin_num,
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/gpio/driver.h`, `linux/init.h`, `linux/interrupt.h`, `linux/spinlock.h`, `linux/io.h`, `linux/module.h`.
- Detected declarations: `struct gpio_regs`, `struct zynq_gpio`, `struct zynq_platform_data`, `function zynq_gpio_is_zynq`, `function gpio_data_ro_bug`, `function zynq_gpio_get_bank_pin`, `function zynq_gpio_get_value`, `function offset`, `function zynq_gpio_dir_in`, `function zynq_gpio_dir_out`.
- 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.