drivers/pinctrl/intel/pinctrl-intel.c

Source file repositories/reference/linux-study-clean/drivers/pinctrl/intel/pinctrl-intel.c

File Facts

System
Linux kernel
Corpus path
drivers/pinctrl/intel/pinctrl-intel.c
Extension
.c
Size
51462 bytes
Lines
1969
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

struct intel_pad_context {
	u32 padcfg0;
	u32 padcfg1;
	u32 padcfg2;
};

struct intel_community_context {
	u32 *intmask;
	u32 *hostown;
};

#define pin_to_padno(c, p)	((p) - (c)->pin_base)
#define padgroup_offset(g, p)	((p) - (g)->base)

#define for_each_intel_pin_community(pctrl, community)					\
	for (unsigned int __ci = 0;							\
	     __ci < pctrl->ncommunities && (community = &pctrl->communities[__ci]);	\
	     __ci++)									\

#define for_each_intel_community_pad_group(community, grp)			\
	for (unsigned int __gi = 0;						\
	     __gi < community->ngpps && (grp = &community->gpps[__gi]);		\
	     __gi++)								\

#define for_each_intel_pad_group(pctrl, community, grp)			\
	for_each_intel_pin_community(pctrl, community)			\
		for_each_intel_community_pad_group(community, grp)

#define for_each_intel_gpio_group(pctrl, community, grp)		\
	for_each_intel_pad_group(pctrl, community, grp)			\
		if (grp->gpio_base == INTEL_GPIO_BASE_NOMAP) {} else

const struct intel_community *intel_get_community(const struct intel_pinctrl *pctrl,
						  unsigned int pin)
{
	const struct intel_community *community;

	for_each_intel_pin_community(pctrl, community) {
		if (pin >= community->pin_base &&
		    pin < community->pin_base + community->npins)
			return community;
	}

	dev_warn(pctrl->dev, "failed to find community for pin %u\n", pin);
	return NULL;
}
EXPORT_SYMBOL_NS_GPL(intel_get_community, "PINCTRL_INTEL");

static const struct intel_padgroup *
intel_community_get_padgroup(const struct intel_community *community,
			     unsigned int pin)
{
	const struct intel_padgroup *padgrp;

	for_each_intel_community_pad_group(community, padgrp) {
		if (pin >= padgrp->base && pin < padgrp->base + padgrp->size)
			return padgrp;
	}

	return NULL;
}

static void __iomem *intel_get_padcfg(struct intel_pinctrl *pctrl,
				      unsigned int pin, unsigned int reg)
{
	const struct intel_community *community;
	unsigned int padno;
	size_t nregs;

	community = intel_get_community(pctrl, pin);
	if (!community)
		return NULL;

	padno = pin_to_padno(community, pin);
	nregs = (community->features & PINCTRL_FEATURE_DEBOUNCE) ? 4 : 2;

	if (reg >= nregs * 4)
		return NULL;

	return community->pad_regs + reg + padno * nregs * 4;
}

static bool intel_pad_owned_by_host(const struct intel_pinctrl *pctrl, unsigned int pin)
{
	const struct intel_community *community;
	const struct intel_padgroup *padgrp;
	unsigned int gpp, offset, gpp_offset;
	void __iomem *padown;

	community = intel_get_community(pctrl, pin);

Annotation

Implementation Notes