drivers/pinctrl/stm32/pinctrl-stm32.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/stm32/pinctrl-stm32.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/stm32/pinctrl-stm32.c- Extension
.c- Size
- 53496 bytes
- Lines
- 2117
- Domain
- Driver Families
- Bucket
- drivers/pinctrl
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitfield.hlinux/clk.hlinux/export.hlinux/gpio/driver.hlinux/hwspinlock.hlinux/io.hlinux/irq.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/reset.hlinux/seq_file.hlinux/slab.hlinux/string_choices.hlinux/pinctrl/consumer.hlinux/pinctrl/machine.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.h../core.h../pinconf.h../pinctrl-utils.hpinctrl-stm32.h
Detected Declarations
struct stm32_pinctrl_groupstruct stm32_pin_backupstruct stm32_gpio_bankstruct stm32_pinctrlfunction stm32_gpio_pinfunction stm32_gpio_get_modefunction stm32_gpio_get_altfunction stm32_gpio_backup_valuefunction stm32_gpio_backup_modefunction stm32_gpio_backup_drivingfunction stm32_gpio_backup_speedfunction stm32_gpio_backup_biasfunction stm32_gpio_backup_advcfgfunction stm32_gpio_backup_skew_delayfunction stm32_gpio_rif_validfunction stm32_gpio_rif_acquire_semaphorefunction stm32_gpio_rif_release_semaphorefunction __stm32_gpio_setfunction stm32_gpio_requestfunction stm32_gpio_freefunction stm32_gpio_getfunction stm32_gpio_setfunction stm32_gpio_direction_outputfunction stm32_gpio_to_irqfunction stm32_gpio_get_directionfunction stm32_gpio_init_valid_maskfunction stm32_gpio_irq_triggerfunction stm32_gpio_irq_eoifunction stm32_gpio_set_typefunction stm32_gpio_irq_request_resourcesfunction stm32_gpio_irq_release_resourcesfunction stm32_gpio_irq_unmaskfunction stm32_gpio_domain_translatefunction stm32_gpio_domain_activatefunction stm32_gpio_domain_allocfunction stm32_gpio_domain_freefunction stm32_pctrl_find_group_by_pinfunction stm32_pctrl_is_function_validfunction stm32_pctrl_dt_node_to_map_funcfunction stm32_pctrl_dt_subnode_to_mapfunction stm32_pctrl_dt_node_to_mapfunction for_each_child_of_node_scopedfunction stm32_pctrl_get_groups_countfunction stm32_pctrl_get_group_pinsfunction stm32_pmx_get_funcs_cntfunction stm32_pmx_get_func_groupsfunction stm32_pmx_set_modefunction stm32_pmx_get_mode
Annotated Snippet
struct stm32_pinctrl_group {
const char *name;
unsigned long config;
unsigned pin;
};
struct stm32_pin_backup {
unsigned int alt:4;
unsigned int mode:2;
unsigned int bias:2;
unsigned int speed:2;
unsigned int drive:1;
unsigned int value:1;
unsigned int advcfg:4;
unsigned int skew_delay:4;
};
struct stm32_gpio_bank {
void __iomem *base;
struct reset_control *rstc;
spinlock_t lock;
struct gpio_chip gpio_chip;
struct pinctrl_gpio_range range;
struct fwnode_handle *fwnode;
struct irq_domain *domain;
u32 bank_nr;
u32 bank_ioport_nr;
struct stm32_pin_backup pin_backup[STM32_GPIO_PINS_PER_BANK];
u8 irq_type[STM32_GPIO_PINS_PER_BANK];
bool secure_control;
bool io_sync_control;
bool rif_control;
};
struct stm32_pinctrl {
struct device *dev;
struct pinctrl_dev *pctl_dev;
struct pinctrl_desc pctl_desc;
struct stm32_pinctrl_group *groups;
unsigned ngroups;
const char **grp_names;
struct stm32_gpio_bank *banks;
struct clk_bulk_data *clks;
unsigned nbanks;
const struct stm32_pinctrl_match_data *match_data;
struct irq_domain *domain;
struct regmap *regmap;
struct regmap_field *irqmux[STM32_GPIO_PINS_PER_BANK];
struct hwspinlock *hwlock;
struct stm32_desc_pin *pins;
u32 npins;
u32 pkg;
u16 irqmux_map;
spinlock_t irqmux_lock;
};
static void stm32_pmx_get_mode(struct stm32_gpio_bank *bank, int pin, u32 *mode, u32 *alt);
static inline int stm32_gpio_pin(int gpio)
{
return gpio % STM32_GPIO_PINS_PER_BANK;
}
static inline u32 stm32_gpio_get_mode(u32 function)
{
switch (function) {
case STM32_PIN_GPIO:
return 0;
case STM32_PIN_AF(0) ... STM32_PIN_AF(15):
return 2;
case STM32_PIN_ANALOG:
return 3;
}
return 0;
}
static inline u32 stm32_gpio_get_alt(u32 function)
{
switch (function) {
case STM32_PIN_GPIO:
return 0;
case STM32_PIN_AF(0) ... STM32_PIN_AF(15):
return function - 1;
case STM32_PIN_ANALOG:
return 0;
}
return 0;
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/export.h`, `linux/gpio/driver.h`, `linux/hwspinlock.h`, `linux/io.h`, `linux/irq.h`, `linux/mfd/syscon.h`.
- Detected declarations: `struct stm32_pinctrl_group`, `struct stm32_pin_backup`, `struct stm32_gpio_bank`, `struct stm32_pinctrl`, `function stm32_gpio_pin`, `function stm32_gpio_get_mode`, `function stm32_gpio_get_alt`, `function stm32_gpio_backup_value`, `function stm32_gpio_backup_mode`, `function stm32_gpio_backup_driving`.
- Atlas domain: Driver Families / drivers/pinctrl.
- Implementation status: integration 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.