drivers/pinctrl/pxa/pinctrl-pxa2xx.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/pxa/pinctrl-pxa2xx.c- Extension
.c- Size
- 11247 bytes
- Lines
- 426
- 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/bitops.hlinux/io.hlinux/of.hlinux/of_address.hlinux/module.hlinux/pinctrl/machine.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinmux.hlinux/pinctrl/pinctrl.hlinux/platform_device.hlinux/slab.h../pinctrl-utils.hpinctrl-pxa2xx.h
Detected Declarations
function Copyrightfunction pxa2xx_pctrl_get_group_pinsfunction pxa_desc_by_func_groupfunction pxa2xx_pmx_gpio_set_directionfunction pxa2xx_get_functions_countfunction pxa2xx_pmx_get_func_groupsfunction pxa2xx_pmx_set_muxfunction pxa2xx_pconf_group_getfunction pxa2xx_pconf_group_setfunction pxa2xx_build_functionsfunction pxa2xx_build_groupsfunction pxa2xx_build_statefunction pxa2xx_pinctrl_initexport pxa2xx_pinctrl_init
Annotated Snippet
switch (pinconf_to_config_param(configs[i])) {
case PIN_CONFIG_MODE_LOW_POWER:
is_set = pinconf_to_config_argument(configs[i]);
break;
default:
return -EINVAL;
}
}
dev_dbg(pctl->dev, "set sleep gpio state(pin=%d) %d\n",
pin, is_set);
spin_lock_irqsave(&pctl->lock, flags);
val = readl_relaxed(pgsr);
val = (val & ~BIT(pin % 32)) | (is_set ? BIT(pin % 32) : 0);
writel_relaxed(val, pgsr);
spin_unlock_irqrestore(&pctl->lock, flags);
return 0;
}
static const struct pinconf_ops pxa2xx_pconf_ops = {
.pin_config_group_get = pxa2xx_pconf_group_get,
.pin_config_group_set = pxa2xx_pconf_group_set,
.is_generic = true,
};
static struct pinctrl_desc pxa2xx_pinctrl_desc = {
.confops = &pxa2xx_pconf_ops,
.pctlops = &pxa2xx_pctl_ops,
.pmxops = &pxa2xx_pinmux_ops,
};
static const struct pinfunction *pxa2xx_find_function(struct pxa_pinctrl *pctl,
const char *fname,
const struct pinfunction *functions)
{
const struct pinfunction *func;
for (func = functions; func->name; func++)
if (!strcmp(fname, func->name))
return func;
return NULL;
}
static int pxa2xx_build_functions(struct pxa_pinctrl *pctl)
{
struct pinfunction *functions;
int i;
struct pxa_desc_function *df;
/*
* Each pin can have at most 6 alternate functions, and 2 gpio functions
* which are common to each pin. As there are more than 2 pins without
* alternate function, 6 * npins is an absolute high limit of the number
* of functions.
*/
functions = devm_kcalloc(pctl->dev, pctl->npins * 6,
sizeof(*functions), GFP_KERNEL);
if (!functions)
return -ENOMEM;
for (i = 0; i < pctl->npins; i++)
for (df = pctl->ppins[i].functions; df->name; df++)
if (!pxa2xx_find_function(pctl, df->name, functions))
(functions + pctl->nfuncs++)->name = df->name;
pctl->functions = devm_kmemdup_array(pctl->dev, functions, pctl->nfuncs,
sizeof(*functions), GFP_KERNEL);
if (!pctl->functions)
return -ENOMEM;
devm_kfree(pctl->dev, functions);
return 0;
}
static int pxa2xx_build_groups(struct pxa_pinctrl *pctl)
{
int i, j, ngroups;
struct pxa_desc_function *df;
struct pinfunction *func;
const char **gtmp;
gtmp = devm_kmalloc_array(pctl->dev, pctl->npins, sizeof(*gtmp),
GFP_KERNEL);
if (!gtmp)
return -ENOMEM;
for (i = 0; i < pctl->nfuncs; i++) {
ngroups = 0;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/io.h`, `linux/of.h`, `linux/of_address.h`, `linux/module.h`, `linux/pinctrl/machine.h`, `linux/pinctrl/pinconf.h`, `linux/pinctrl/pinconf-generic.h`.
- Detected declarations: `function Copyright`, `function pxa2xx_pctrl_get_group_pins`, `function pxa_desc_by_func_group`, `function pxa2xx_pmx_gpio_set_direction`, `function pxa2xx_get_functions_count`, `function pxa2xx_pmx_get_func_groups`, `function pxa2xx_pmx_set_mux`, `function pxa2xx_pconf_group_get`, `function pxa2xx_pconf_group_set`, `function pxa2xx_build_functions`.
- 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.