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.

Dependency Surface

Detected Declarations

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

Implementation Notes