drivers/pinctrl/bcm/pinctrl-brcmstb.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/bcm/pinctrl-brcmstb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/bcm/pinctrl-brcmstb.c- Extension
.c- Size
- 11722 bytes
- Lines
- 443
- 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/device.hlinux/err.hlinux/init.hlinux/io.hlinux/of.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.hlinux/pinctrl/pinconf-generic.hlinux/seq_file.hlinux/slab.hlinux/spinlock.hlinux/cleanup.hpinctrl-brcmstb.h
Detected Declarations
struct brcmstb_pinctrlfunction brcmstb_pinctrl_fsel_getfunction brcmstb_pinctrl_fsel_setfunction brcmstb_pctl_get_groups_countfunction brcmstb_pctl_get_group_pinsfunction brcmstb_pctl_pin_dbg_showfunction brcmstb_pctl_dt_free_mapfunction brcmstb_pmx_freefunction brcmstb_pmx_get_functions_countfunction brcmstb_pmx_get_function_groupsfunction brcmstb_pmx_setfunction brcmstb_pmx_gpio_request_enablefunction brcmstb_pmx_gpio_disable_freefunction brcmstb_pmx_function_is_gpiofunction brcmstb_pull_config_getfunction brcmstb_pull_config_setfunction brcmstb_pinconf_getfunction brcmstb_pinconf_setfunction brcmstb_pinctrl_probeexport brcmstb_pinctrl_probe
Annotated Snippet
struct brcmstb_pinctrl {
struct device *dev;
void __iomem *base;
struct pinctrl_dev *pctl_dev;
struct pinctrl_desc pctl_desc;
const struct pin_regs *pin_regs;
const struct brcmstb_pin_funcs *pin_funcs;
const char * const *func_names;
unsigned int func_count;
unsigned int func_gpio;
const char *const *gpio_groups;
struct pinctrl_gpio_range gpio_range;
/* Protect FSEL registers */
spinlock_t fsel_lock;
};
static unsigned int brcmstb_pinctrl_fsel_get(struct brcmstb_pinctrl *pc,
unsigned int pin)
{
u32 bit = pc->pin_regs[pin].mux_bit;
unsigned int func;
int fsel;
u32 val;
if (!bit)
return pc->func_gpio;
bit &= ~MUX_BIT_VALID;
val = readl(pc->base + BIT_TO_REG(bit));
fsel = (val >> BIT_TO_SHIFT(bit)) & pc->pin_funcs[pin].func_mask;
func = pc->pin_funcs[pin].funcs[fsel];
if (func >= pc->func_count)
func = fsel;
dev_dbg(pc->dev, "get %04x: %08x (%u => %s)\n",
BIT_TO_REG(bit), val, pin,
pc->func_names[func]);
return func;
}
static int brcmstb_pinctrl_fsel_set(struct brcmstb_pinctrl *pc,
unsigned int pin, unsigned int func)
{
u32 bit = pc->pin_regs[pin].mux_bit, val, fsel_mask;
const u8 *pin_funcs;
int fsel;
int cur;
int i;
if (!bit || func >= pc->func_count)
return -EINVAL;
bit &= ~MUX_BIT_VALID;
fsel = pc->pin_funcs[pin].n_funcs + 1;
fsel_mask = pc->pin_funcs[pin].func_mask;
if (func >= fsel) {
/* Convert to an fsel number */
pin_funcs = pc->pin_funcs[pin].funcs;
for (i = 1; i < fsel; i++) {
if (pin_funcs[i - 1] == func) {
fsel = i;
break;
}
}
} else {
fsel = func;
}
if (fsel >= pc->pin_funcs[pin].n_funcs + 1)
return -EINVAL;
guard(spinlock_irqsave)(&pc->fsel_lock);
val = readl(pc->base + BIT_TO_REG(bit));
cur = (val >> BIT_TO_SHIFT(bit)) & fsel_mask;
dev_dbg(pc->dev, "read %04x: %08x (%u => %s)\n",
BIT_TO_REG(bit), val, pin,
pc->func_names[cur]);
if (cur != fsel) {
val &= ~(fsel_mask << BIT_TO_SHIFT(bit));
val |= fsel << BIT_TO_SHIFT(bit);
dev_dbg(pc->dev, "write %04x: %08x (%u <= %s)\n",
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/init.h`, `linux/io.h`, `linux/of.h`, `linux/pinctrl/pinconf.h`, `linux/pinctrl/pinctrl.h`, `linux/pinctrl/pinmux.h`.
- Detected declarations: `struct brcmstb_pinctrl`, `function brcmstb_pinctrl_fsel_get`, `function brcmstb_pinctrl_fsel_set`, `function brcmstb_pctl_get_groups_count`, `function brcmstb_pctl_get_group_pins`, `function brcmstb_pctl_pin_dbg_show`, `function brcmstb_pctl_dt_free_map`, `function brcmstb_pmx_free`, `function brcmstb_pmx_get_functions_count`, `function brcmstb_pmx_get_function_groups`.
- 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.