drivers/pinctrl/pinctrl-loongson2.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/pinctrl-loongson2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/pinctrl-loongson2.c- Extension
.c- Size
- 9007 bytes
- Lines
- 313
- 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.
- 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/init.hlinux/module.hlinux/platform_device.hlinux/mod_devicetable.hlinux/pinctrl/pinmux.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinctrl.hlinux/bitops.hlinux/io.hlinux/seq_file.hcore.hpinctrl-utils.h
Detected Declarations
struct loongson2_pinctrlstruct loongson2_pmx_groupstruct loongson2_pmx_funcfunction loongson2_get_groups_countfunction loongson2_get_group_pinsfunction loongson2_pin_dbg_showfunction loongson2_pmx_set_muxfunction loongson2_pmx_get_funcs_countfunction loongson2_pmx_get_groupsfunction loongson2_pinctrl_probefunction loongson2_pinctrl_initfunction loongson2_pinctrl_exit
Annotated Snippet
struct loongson2_pinctrl {
struct device *dev;
struct pinctrl_dev *pcdev;
struct pinctrl_desc desc;
struct device_node *of_node;
spinlock_t lock;
void __iomem *reg_base;
};
struct loongson2_pmx_group {
struct pingroup grp;
unsigned int reg;
unsigned int bit;
};
struct loongson2_pmx_func {
const char *name;
const char * const *groups;
unsigned int num_groups;
};
#define LOONGSON2_PIN(x) PINCTRL_PIN(x, "gpio"#x)
static const struct pinctrl_pin_desc loongson2_pctrl_pins[] = {
LOONGSON2_PIN(0), LOONGSON2_PIN(1), LOONGSON2_PIN(2), LOONGSON2_PIN(3),
LOONGSON2_PIN(4), LOONGSON2_PIN(5), LOONGSON2_PIN(6), LOONGSON2_PIN(7),
LOONGSON2_PIN(8), LOONGSON2_PIN(9), LOONGSON2_PIN(10), LOONGSON2_PIN(11),
LOONGSON2_PIN(12), LOONGSON2_PIN(13), LOONGSON2_PIN(14),
LOONGSON2_PIN(16), LOONGSON2_PIN(17), LOONGSON2_PIN(18), LOONGSON2_PIN(19),
LOONGSON2_PIN(20), LOONGSON2_PIN(21), LOONGSON2_PIN(22), LOONGSON2_PIN(23),
LOONGSON2_PIN(24), LOONGSON2_PIN(25), LOONGSON2_PIN(26), LOONGSON2_PIN(27),
LOONGSON2_PIN(28), LOONGSON2_PIN(29), LOONGSON2_PIN(30),
LOONGSON2_PIN(32), LOONGSON2_PIN(33), LOONGSON2_PIN(34), LOONGSON2_PIN(35),
LOONGSON2_PIN(36), LOONGSON2_PIN(37), LOONGSON2_PIN(38), LOONGSON2_PIN(39),
LOONGSON2_PIN(40), LOONGSON2_PIN(41),
LOONGSON2_PIN(44), LOONGSON2_PIN(45), LOONGSON2_PIN(46), LOONGSON2_PIN(47),
LOONGSON2_PIN(48), LOONGSON2_PIN(49), LOONGSON2_PIN(50), LOONGSON2_PIN(51),
LOONGSON2_PIN(52), LOONGSON2_PIN(53), LOONGSON2_PIN(54), LOONGSON2_PIN(55),
LOONGSON2_PIN(56), LOONGSON2_PIN(57), LOONGSON2_PIN(58), LOONGSON2_PIN(59),
LOONGSON2_PIN(60), LOONGSON2_PIN(61), LOONGSON2_PIN(62), LOONGSON2_PIN(63),
};
static const unsigned int gpio_pins[] = {0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30,
32, 33, 34, 35, 36, 37, 38, 39,
40, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 46, 55,
56, 57, 58, 59, 60, 61, 62, 63};
static const unsigned int sdio_pins[] = {36, 37, 38, 39, 40, 41};
static const unsigned int can1_pins[] = {34, 35};
static const unsigned int can0_pins[] = {32, 33};
static const unsigned int pwm3_pins[] = {23};
static const unsigned int pwm2_pins[] = {22};
static const unsigned int pwm1_pins[] = {21};
static const unsigned int pwm0_pins[] = {20};
static const unsigned int i2c1_pins[] = {18, 19};
static const unsigned int i2c0_pins[] = {16, 17};
static const unsigned int nand_pins[] = {44, 45, 46, 47, 48, 49, 50, 51,
52, 53, 54, 55, 56, 57, 58, 59, 60,
61, 62, 63};
static const unsigned int sata_led_pins[] = {14};
static const unsigned int i2s_pins[] = {24, 25, 26, 27, 28};
static const unsigned int hda_pins[] = {24, 25, 26, 27, 28, 29, 30};
static struct loongson2_pmx_group loongson2_pmx_groups[] = {
PMX_GROUP(gpio, 0x0, 64),
PMX_GROUP(sdio, 0x0, 20),
PMX_GROUP(can1, 0x0, 17),
PMX_GROUP(can0, 0x0, 16),
PMX_GROUP(pwm3, 0x0, 15),
PMX_GROUP(pwm2, 0x0, 14),
PMX_GROUP(pwm1, 0x0, 13),
PMX_GROUP(pwm0, 0x0, 12),
PMX_GROUP(i2c1, 0x0, 11),
PMX_GROUP(i2c0, 0x0, 10),
PMX_GROUP(nand, 0x0, 9),
PMX_GROUP(sata_led, 0x0, 8),
PMX_GROUP(i2s, 0x0, 6),
PMX_GROUP(hda, 0x0, 4),
};
SPECIFIC_GROUP(sdio);
SPECIFIC_GROUP(can1);
SPECIFIC_GROUP(can0);
SPECIFIC_GROUP(pwm3);
SPECIFIC_GROUP(pwm2);
SPECIFIC_GROUP(pwm1);
SPECIFIC_GROUP(pwm0);
SPECIFIC_GROUP(i2c1);
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/platform_device.h`, `linux/mod_devicetable.h`, `linux/pinctrl/pinmux.h`, `linux/pinctrl/pinconf-generic.h`, `linux/pinctrl/pinctrl.h`, `linux/bitops.h`.
- Detected declarations: `struct loongson2_pinctrl`, `struct loongson2_pmx_group`, `struct loongson2_pmx_func`, `function loongson2_get_groups_count`, `function loongson2_get_group_pins`, `function loongson2_pin_dbg_show`, `function loongson2_pmx_set_mux`, `function loongson2_pmx_get_funcs_count`, `function loongson2_pmx_get_groups`, `function loongson2_pinctrl_probe`.
- Atlas domain: Driver Families / drivers/pinctrl.
- Implementation status: source 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.