drivers/pinctrl/sophgo/pinctrl-sophgo-common.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/sophgo/pinctrl-sophgo-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/sophgo/pinctrl-sophgo-common.c- Extension
.c- Size
- 10767 bytes
- Lines
- 452
- 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/bsearch.hlinux/cleanup.hlinux/export.hlinux/io.hlinux/of.hlinux/module.hlinux/platform_device.hlinux/seq_file.hlinux/spinlock.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinctrl.h../pinctrl-utils.h../pinconf.h../pinmux.hpinctrl-sophgo.h
Detected Declarations
function Copyrightfunction sophgo_cmp_pinfunction sophgo_verify_pinmux_configfunction sophgo_verify_pin_groupfunction sophgo_dt_node_to_map_postfunction sophgo_pctrl_dt_node_to_mapfunction sophgo_pmx_set_muxfunction sophgo_pin_set_configfunction sophgo_pconf_setfunction sophgo_pconf_group_setfunction sophgo_pinctrl_typical_pull_downfunction sophgo_pinctrl_typical_pull_upfunction sophgo_pinctrl_oc2regfunction sophgo_pinctrl_reg2ocfunction sophgo_pinctrl_schmitt2regfunction sophgo_pinctrl_reg2schmittfunction sophgo_pinctrl_probeexport sophgo_pinctrl_probe
Annotated Snippet
if (npins < 1) {
dev_err(dev, "invalid pinctrl group %pOFn.%pOFn\n",
np, child);
ret = -EINVAL;
goto dt_failed;
}
grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn",
np, child);
if (!grpname) {
ret = -ENOMEM;
goto dt_failed;
}
grpnames[ngroups++] = grpname;
pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL);
if (!pins) {
ret = -ENOMEM;
goto dt_failed;
}
pinmuxs = devm_kcalloc(dev, npins, sizeof(*pinmuxs), GFP_KERNEL);
if (!pinmuxs) {
ret = -ENOMEM;
goto dt_failed;
}
for (i = 0; i < npins; i++) {
ret = of_property_read_u32_index(child, "pinmux",
i, &config);
if (ret)
goto dt_failed;
pins[i] = sophgo_dt_get_pin(config);
pinmuxs[i].config = config;
pinmuxs[i].pin = sophgo_get_pin(pctrl, pins[i]);
if (!pinmuxs[i].pin) {
dev_err(dev, "failed to get pin %d\n", pins[i]);
ret = -ENODEV;
goto dt_failed;
}
ret = sophgo_verify_pinmux_config(pctrl, &pinmuxs[i]);
if (ret) {
dev_err(dev, "group %s pin %d is invalid\n",
grpname, i);
goto dt_failed;
}
}
ret = sophgo_verify_pin_group(pctrl, pinmuxs, npins);
if (ret) {
dev_err(dev, "group %s is invalid\n", grpname);
goto dt_failed;
}
ret = sophgo_dt_node_to_map_post(child, pctrl, pinmuxs, npins);
if (ret)
goto dt_failed;
map[nmaps].type = PIN_MAP_TYPE_MUX_GROUP;
map[nmaps].data.mux.function = np->name;
map[nmaps].data.mux.group = grpname;
nmaps += 1;
ret = pinconf_generic_parse_dt_config(child, pctldev,
&map[nmaps].data.configs.configs,
&map[nmaps].data.configs.num_configs);
if (ret) {
dev_err(dev, "failed to parse pin config of group %s: %d\n",
grpname, ret);
goto dt_failed;
}
ret = pinctrl_generic_add_group(pctldev, grpname,
pins, npins, pinmuxs);
if (ret < 0) {
dev_err(dev, "failed to add group %s: %d\n", grpname, ret);
goto dt_failed;
}
/* don't create a map if there are no pinconf settings */
if (map[nmaps].data.configs.num_configs == 0)
continue;
map[nmaps].type = PIN_MAP_TYPE_CONFIGS_GROUP;
map[nmaps].data.configs.group_or_pin = grpname;
nmaps += 1;
Annotation
- Immediate include surface: `linux/bsearch.h`, `linux/cleanup.h`, `linux/export.h`, `linux/io.h`, `linux/of.h`, `linux/module.h`, `linux/platform_device.h`, `linux/seq_file.h`.
- Detected declarations: `function Copyright`, `function sophgo_cmp_pin`, `function sophgo_verify_pinmux_config`, `function sophgo_verify_pin_group`, `function sophgo_dt_node_to_map_post`, `function sophgo_pctrl_dt_node_to_map`, `function sophgo_pmx_set_mux`, `function sophgo_pin_set_config`, `function sophgo_pconf_set`, `function sophgo_pconf_group_set`.
- 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.