drivers/pinctrl/pinctrl-apple-gpio.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/pinctrl-apple-gpio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/pinctrl-apple-gpio.c- Extension
.c- Size
- 15324 bytes
- Lines
- 545
- Domain
- Driver Families
- Bucket
- drivers/pinctrl
- 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.
- 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
dt-bindings/pinctrl/apple.hlinux/bitfield.hlinux/bits.hlinux/gpio/driver.hlinux/interrupt.hlinux/irq.hlinux/module.hlinux/of.hlinux/of_irq.hlinux/platform_device.hlinux/regmap.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.hpinctrl-utils.hcore.hpinmux.h
Detected Declarations
struct apple_gpio_pinctrlfunction apple_gpio_set_regfunction apple_gpio_get_regfunction apple_gpio_dt_node_to_mapfunction apple_gpio_pinmux_func_is_gpiofunction apple_gpio_pinmux_setfunction apple_gpio_get_directionfunction apple_gpio_getfunction apple_gpio_setfunction apple_gpio_direction_inputfunction apple_gpio_direction_outputfunction apple_gpio_irq_ackfunction apple_gpio_irq_typefunction apple_gpio_irq_maskfunction apple_gpio_irq_unmaskfunction apple_gpio_irq_startupfunction apple_gpio_irq_set_typefunction apple_gpio_irq_handlerfunction apple_gpio_registerfunction apple_gpio_pinctrl_probe
Annotated Snippet
struct apple_gpio_pinctrl {
struct device *dev;
struct pinctrl_dev *pctldev;
void __iomem *base;
struct regmap *map;
struct pinctrl_desc pinctrl_desc;
struct gpio_chip gpio_chip;
u8 irqgrps[];
};
#define REG_GPIO(x) (4 * (x))
#define REG_GPIOx_DATA BIT(0)
#define REG_GPIOx_MODE GENMASK(3, 1)
#define REG_GPIOx_OUT 1
#define REG_GPIOx_IN_IRQ_HI 2
#define REG_GPIOx_IN_IRQ_LO 3
#define REG_GPIOx_IN_IRQ_UP 4
#define REG_GPIOx_IN_IRQ_DN 5
#define REG_GPIOx_IN_IRQ_ANY 6
#define REG_GPIOx_IN_IRQ_OFF 7
#define REG_GPIOx_PERIPH GENMASK(6, 5)
#define REG_GPIOx_PULL GENMASK(8, 7)
#define REG_GPIOx_PULL_OFF 0
#define REG_GPIOx_PULL_DOWN 1
#define REG_GPIOx_PULL_UP_STRONG 2
#define REG_GPIOx_PULL_UP 3
#define REG_GPIOx_INPUT_ENABLE BIT(9)
#define REG_GPIOx_DRIVE_STRENGTH0 GENMASK(11, 10)
#define REG_GPIOx_SCHMITT BIT(15)
#define REG_GPIOx_GRP GENMASK(18, 16)
#define REG_GPIOx_LOCK BIT(21)
#define REG_GPIOx_DRIVE_STRENGTH1 GENMASK(23, 22)
#define REG_IRQ(g, x) (0x800 + 0x40 * (g) + 4 * ((x) >> 5))
static const struct regmap_config regmap_config = {
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
.cache_type = REGCACHE_FLAT,
.max_register = 512 * sizeof(u32),
.num_reg_defaults_raw = 512,
.use_relaxed_mmio = true,
.use_raw_spinlock = true,
};
/* No locking needed to mask/unmask IRQs as the interrupt mode is per pin-register. */
static void apple_gpio_set_reg(struct apple_gpio_pinctrl *pctl,
unsigned int pin, u32 mask, u32 value)
{
regmap_update_bits(pctl->map, REG_GPIO(pin), mask, value);
}
static u32 apple_gpio_get_reg(struct apple_gpio_pinctrl *pctl,
unsigned int pin)
{
int ret;
u32 val;
ret = regmap_read(pctl->map, REG_GPIO(pin), &val);
if (ret)
return 0;
return val;
}
/* Pin controller functions */
static int apple_gpio_dt_node_to_map(struct pinctrl_dev *pctldev,
struct device_node *node,
struct pinctrl_map **map,
unsigned int *num_maps)
{
unsigned int reserved_maps;
struct apple_gpio_pinctrl *pctl;
u32 pinfunc, pin, func;
int num_pins, i, ret;
const char *group_name;
const char *function_name;
*map = NULL;
*num_maps = 0;
reserved_maps = 0;
pctl = pinctrl_dev_get_drvdata(pctldev);
ret = of_property_count_u32_elems(node, "pinmux");
if (ret <= 0) {
dev_err(pctl->dev,
Annotation
- Immediate include surface: `dt-bindings/pinctrl/apple.h`, `linux/bitfield.h`, `linux/bits.h`, `linux/gpio/driver.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct apple_gpio_pinctrl`, `function apple_gpio_set_reg`, `function apple_gpio_get_reg`, `function apple_gpio_dt_node_to_map`, `function apple_gpio_pinmux_func_is_gpio`, `function apple_gpio_pinmux_set`, `function apple_gpio_get_direction`, `function apple_gpio_get`, `function apple_gpio_set`, `function apple_gpio_direction_input`.
- Atlas domain: Driver Families / drivers/pinctrl.
- Implementation status: source implementation candidate.
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.