drivers/pinctrl/berlin/berlin.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/berlin/berlin.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/berlin/berlin.c- Extension
.c- Size
- 8519 bytes
- Lines
- 344
- Domain
- Driver Families
- Bucket
- drivers/pinctrl
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/io.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_device.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.hlinux/platform_device.hlinux/regmap.hlinux/slab.h../core.h../pinctrl-utils.hberlin.h
Detected Declarations
struct berlin_pinctrlfunction berlin_pinctrl_get_group_countfunction berlin_pinctrl_dt_node_to_mapfunction of_property_for_each_stringfunction berlin_pinmux_get_functions_countfunction berlin_pinmux_get_function_groupsfunction berlin_pinctrl_find_function_by_namefunction berlin_pinmux_setfunction berlin_pinctrl_add_functionfunction berlin_pinctrl_build_statefunction berlin_pinctrl_probe_regmapfunction berlin_pinctrl_probe
Annotated Snippet
struct berlin_pinctrl {
struct regmap *regmap;
struct device *dev;
const struct berlin_pinctrl_desc *desc;
struct pinfunction *functions;
unsigned nfunctions;
struct pinctrl_dev *pctrl_dev;
};
static int berlin_pinctrl_get_group_count(struct pinctrl_dev *pctrl_dev)
{
struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
return pctrl->desc->ngroups;
}
static const char *berlin_pinctrl_get_group_name(struct pinctrl_dev *pctrl_dev,
unsigned group)
{
struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
return pctrl->desc->groups[group].name;
}
static int berlin_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrl_dev,
struct device_node *node,
struct pinctrl_map **map,
unsigned *num_maps)
{
struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
struct property *prop;
const char *function_name, *group_name;
unsigned reserved_maps = 0;
int ret, ngroups;
*map = NULL;
*num_maps = 0;
ret = of_property_read_string(node, "function", &function_name);
if (ret) {
dev_err(pctrl->dev,
"missing function property in node %pOFn\n", node);
return -EINVAL;
}
ngroups = of_property_count_strings(node, "groups");
if (ngroups < 0) {
dev_err(pctrl->dev,
"missing groups property in node %pOFn\n", node);
return -EINVAL;
}
ret = pinctrl_utils_reserve_map(pctrl_dev, map, &reserved_maps,
num_maps, ngroups);
if (ret) {
dev_err(pctrl->dev, "can't reserve map: %d\n", ret);
return ret;
}
of_property_for_each_string(node, "groups", prop, group_name) {
ret = pinctrl_utils_add_map_mux(pctrl_dev, map, &reserved_maps,
num_maps, group_name,
function_name);
if (ret) {
dev_err(pctrl->dev, "can't add map: %d\n", ret);
return ret;
}
}
return 0;
}
static const struct pinctrl_ops berlin_pinctrl_ops = {
.get_groups_count = berlin_pinctrl_get_group_count,
.get_group_name = berlin_pinctrl_get_group_name,
.dt_node_to_map = berlin_pinctrl_dt_node_to_map,
.dt_free_map = pinctrl_utils_free_map,
};
static int berlin_pinmux_get_functions_count(struct pinctrl_dev *pctrl_dev)
{
struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
return pctrl->nfunctions;
}
static const char *berlin_pinmux_get_function_name(struct pinctrl_dev *pctrl_dev,
unsigned function)
{
struct berlin_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrl_dev);
Annotation
- Immediate include surface: `linux/io.h`, `linux/mfd/syscon.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_device.h`, `linux/pinctrl/pinctrl.h`, `linux/pinctrl/pinmux.h`.
- Detected declarations: `struct berlin_pinctrl`, `function berlin_pinctrl_get_group_count`, `function berlin_pinctrl_dt_node_to_map`, `function of_property_for_each_string`, `function berlin_pinmux_get_functions_count`, `function berlin_pinmux_get_function_groups`, `function berlin_pinctrl_find_function_by_name`, `function berlin_pinmux_set`, `function berlin_pinctrl_add_function`, `function berlin_pinctrl_build_state`.
- Atlas domain: Driver Families / drivers/pinctrl.
- Implementation status: source implementation candidate.
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.