drivers/pinctrl/pinctrl-k230.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/pinctrl-k230.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/pinctrl-k230.c- Extension
.c- Size
- 17069 bytes
- Lines
- 652
- 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/module.hlinux/device.hlinux/of.hlinux/of_address.hlinux/of_device.hlinux/platform_device.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinconf-generic.hlinux/regmap.hlinux/seq_file.hcore.hpinconf.h
Detected Declarations
struct k230_pin_confstruct k230_pin_groupstruct k230_pmx_funcstruct k230_pinctrlfunction k230_get_groups_countfunction k230_get_group_pinsfunction k230_pinctrl_pin_dbg_showfunction k230_dt_node_to_mapfunction k230_dt_free_mapfunction k230_pinconf_getfunction k230_pinconf_set_paramfunction k230_pinconf_setfunction k230_pconf_dbg_showfunction k230_get_functions_countfunction k230_get_groupsfunction k230_set_muxfunction k230_pinctrl_parse_groupsfunction k230_pinctrl_parse_functionsfunction for_each_child_of_node_scopedfunction k230_pinctrl_child_countfunction k230_pinctrl_parse_dtfunction for_each_child_of_node_scopedfunction k230_pinctrl_probe
Annotated Snippet
struct k230_pin_conf {
unsigned int func;
unsigned long *configs;
unsigned int nconfigs;
};
struct k230_pin_group {
const char *name;
unsigned int *pins;
unsigned int num_pins;
struct k230_pin_conf *data;
};
struct k230_pmx_func {
const char *name;
const char **groups;
unsigned int *group_idx;
unsigned int ngroups;
};
struct k230_pinctrl {
struct device *dev;
struct pinctrl_desc pctl;
struct pinctrl_dev *pctl_dev;
struct regmap *regmap_base;
void __iomem *base;
struct k230_pin_group *groups;
unsigned int ngroups;
struct k230_pmx_func *functions;
unsigned int nfunctions;
};
static const struct regmap_config k230_regmap_config = {
.name = "canaan,pinctrl",
.reg_bits = 32,
.val_bits = 32,
.max_register = 0x100,
.reg_stride = 4,
};
static int k230_get_groups_count(struct pinctrl_dev *pctldev)
{
struct k230_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
return info->ngroups;
}
static const char *k230_get_group_name(struct pinctrl_dev *pctldev,
unsigned int selector)
{
struct k230_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
return info->groups[selector].name;
}
static int k230_get_group_pins(struct pinctrl_dev *pctldev,
unsigned int selector,
const unsigned int **pins,
unsigned int *num_pins)
{
struct k230_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
if (selector >= info->ngroups)
return -EINVAL;
*pins = info->groups[selector].pins;
*num_pins = info->groups[selector].num_pins;
return 0;
}
static inline const struct k230_pmx_func *k230_name_to_funtion(
const struct k230_pinctrl *info, const char *name)
{
unsigned int i;
for (i = 0; i < info->nfunctions; i++) {
if (!strcmp(info->functions[i].name, name))
return &info->functions[i];
}
return NULL;
}
static struct pinctrl_pin_desc k230_pins[] = {
PINCTRL_PIN(0, "IO0"), PINCTRL_PIN(1, "IO1"), PINCTRL_PIN(2, "IO2"),
PINCTRL_PIN(3, "IO3"), PINCTRL_PIN(4, "IO4"), PINCTRL_PIN(5, "IO5"),
PINCTRL_PIN(6, "IO6"), PINCTRL_PIN(7, "IO7"), PINCTRL_PIN(8, "IO8"),
PINCTRL_PIN(9, "IO9"), PINCTRL_PIN(10, "IO10"), PINCTRL_PIN(11, "IO11"),
Annotation
- Immediate include surface: `linux/module.h`, `linux/device.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_device.h`, `linux/platform_device.h`, `linux/pinctrl/pinctrl.h`, `linux/pinctrl/pinmux.h`.
- Detected declarations: `struct k230_pin_conf`, `struct k230_pin_group`, `struct k230_pmx_func`, `struct k230_pinctrl`, `function k230_get_groups_count`, `function k230_get_group_pins`, `function k230_pinctrl_pin_dbg_show`, `function k230_dt_node_to_map`, `function k230_dt_free_map`, `function k230_pinconf_get`.
- 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.