drivers/pinctrl/spacemit/pinctrl-k1.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/spacemit/pinctrl-k1.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/spacemit/pinctrl-k1.c- Extension
.c- Size
- 40526 bytes
- Lines
- 1451
- 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/bits.hlinux/clk.hlinux/cleanup.hlinux/io.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/seq_file.hlinux/spinlock.hlinux/mfd/syscon.hlinux/module.hlinux/mutex.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.h../core.h../pinctrl-utils.h../pinconf.h../pinmux.hpinctrl-k1.h
Detected Declarations
struct spacemit_pin_drv_strengthstruct spacemit_pinctrl_dconfstruct spacemit_pinstruct spacemit_pinctrlstruct spacemit_pinctrl_datafunction spacemit_k1_pin_to_offsetfunction spacemit_k3_pin_to_offsetfunction spacemit_k1_pin_to_io_pd_offsetfunction spacemit_k3_pin_to_io_pd_offsetfunction spacemit_to_pin_io_typefunction spacemit_pctrl_dbg_showfunction spacemit_get_ds_valuefunction spacemit_get_ds_mAfunction spacemit_get_driver_strengthfunction spacemit_get_drive_strength_mAfunction spacemit_set_io_pwr_domainfunction spacemit_pmx_set_muxfunction spacemit_request_gpiofunction spacemit_pinconf_getfunction spacemit_pinconf_generate_configfunction spacemit_pin_set_configfunction spacemit_pinconf_setfunction spacemit_pinconf_group_setfunction spacemit_pinconf_dbg_pullfunction spacemit_pinconf_dbg_showfunction spacemit_pinctrl_probe
Annotated Snippet
struct spacemit_pin_drv_strength {
u8 val;
u32 mA;
};
struct spacemit_pinctrl_dconf {
u64 schmitt_mask;
u64 drive_mask;
struct spacemit_pin_drv_strength *ds_1v8_tbl;
size_t ds_1v8_tbl_num;
struct spacemit_pin_drv_strength *ds_3v3_tbl;
size_t ds_3v3_tbl_num;
};
struct spacemit_pin {
u16 pin;
u16 flags;
u8 gpiofunc;
};
struct spacemit_pinctrl {
struct device *dev;
struct pinctrl_dev *pctl_dev;
const struct spacemit_pinctrl_data *data;
struct pinctrl_desc pdesc;
struct mutex mutex;
raw_spinlock_t lock;
void __iomem *regs;
struct regmap *regmap_apbc;
};
struct spacemit_pinctrl_data {
const struct pinctrl_pin_desc *pins;
const struct spacemit_pin *data;
u16 npins;
unsigned int (*pin_to_offset)(unsigned int pin);
unsigned int (*pin_to_io_pd_offset)(unsigned int pin);
const struct spacemit_pinctrl_dconf *dconf;
};
/* map pin id to pinctrl register offset, refer MFPR definition */
static unsigned int spacemit_k1_pin_to_offset(unsigned int pin)
{
unsigned int offset = 0;
switch (pin) {
case 0 ... 85:
offset = pin + 1;
break;
case 86 ... 92:
offset = pin + 37;
break;
case 93 ... 97:
offset = pin + 24;
break;
case 98:
offset = 93;
break;
case 99:
offset = 92;
break;
case 100:
offset = 91;
break;
case 101:
offset = 90;
break;
case 102:
offset = 95;
break;
case 103:
offset = 94;
break;
case 104 ... 110:
offset = pin + 6;
break;
case 111 ... 127:
offset = pin + 20;
break;
default:
break;
}
return offset << 2;
}
Annotation
- Immediate include surface: `linux/bits.h`, `linux/clk.h`, `linux/cleanup.h`, `linux/io.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/seq_file.h`.
- Detected declarations: `struct spacemit_pin_drv_strength`, `struct spacemit_pinctrl_dconf`, `struct spacemit_pin`, `struct spacemit_pinctrl`, `struct spacemit_pinctrl_data`, `function spacemit_k1_pin_to_offset`, `function spacemit_k3_pin_to_offset`, `function spacemit_k1_pin_to_io_pd_offset`, `function spacemit_k3_pin_to_io_pd_offset`, `function spacemit_to_pin_io_type`.
- 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.