drivers/pinctrl/pinctrl-microchip-sgpio.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/pinctrl-microchip-sgpio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/pinctrl-microchip-sgpio.c- Extension
.c- Size
- 26238 bytes
- Lines
- 1014
- 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/bitfield.hlinux/bits.hlinux/clk.hlinux/gpio/driver.hlinux/io.hlinux/mfd/ocelot.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/reset.hlinux/spinlock.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinmux.hcore.hpinconf.h
Detected Declarations
struct sgpio_propertiesstruct sgpio_bankstruct sgpio_privstruct sgpio_port_addrfunction sgpio_pin_to_addrfunction sgpio_addr_to_pinfunction sgpio_get_addrfunction sgpio_readlfunction sgpio_writelfunction sgpio_clrsetbitsfunction sgpio_configure_bitstreamfunction sgpio_configure_clockfunction sgpio_single_shotfunction sgpio_output_setfunction sgpio_output_getfunction sgpio_input_getfunction sgpio_pinconf_getfunction sgpio_pinconf_setfunction sgpio_get_functions_countfunction sgpio_get_function_groupsfunction sgpio_pinmux_set_muxfunction sgpio_gpio_set_directionfunction sgpio_gpio_request_enablefunction sgpio_pctl_get_groups_countfunction sgpio_pctl_get_group_pinsfunction microchip_sgpio_direction_inputfunction microchip_sgpio_direction_outputfunction microchip_sgpio_get_directionfunction microchip_sgpio_set_valuefunction microchip_sgpio_get_valuefunction microchip_sgpio_of_xlatefunction microchip_sgpio_get_portsfunction microchip_sgpio_irq_settypefunction microchip_sgpio_irq_setregfunction microchip_sgpio_irq_maskfunction microchip_sgpio_irq_unmaskfunction microchip_sgpio_irq_ackfunction microchip_sgpio_irq_set_typefunction sgpio_irq_handlerfunction for_each_set_bitfunction microchip_sgpio_register_bankfunction microchip_sgpio_probe
Annotated Snippet
struct sgpio_properties {
int arch;
int flags;
u8 regoff[MAXREG];
};
#define SGPIO_LUTON_AUTO_REPEAT BIT(5)
#define SGPIO_LUTON_PORT_WIDTH GENMASK(3, 2)
#define SGPIO_LUTON_CLK_FREQ GENMASK(11, 0)
#define SGPIO_LUTON_BIT_SOURCE GENMASK(11, 0)
#define SGPIO_OCELOT_AUTO_REPEAT BIT(10)
#define SGPIO_OCELOT_SINGLE_SHOT BIT(11)
#define SGPIO_OCELOT_PORT_WIDTH GENMASK(8, 7)
#define SGPIO_OCELOT_CLK_FREQ GENMASK(19, 8)
#define SGPIO_OCELOT_BIT_SOURCE GENMASK(23, 12)
#define SGPIO_SPARX5_AUTO_REPEAT BIT(6)
#define SGPIO_SPARX5_SINGLE_SHOT BIT(7)
#define SGPIO_SPARX5_PORT_WIDTH GENMASK(4, 3)
#define SGPIO_SPARX5_CLK_FREQ GENMASK(19, 8)
#define SGPIO_SPARX5_BIT_SOURCE GENMASK(23, 12)
#define SGPIO_MASTER_INTR_ENA BIT(0)
#define SGPIO_INT_TRG_LEVEL 0
#define SGPIO_INT_TRG_EDGE 1
#define SGPIO_INT_TRG_EDGE_FALL 2
#define SGPIO_INT_TRG_EDGE_RISE 3
#define SGPIO_TRG_LEVEL_HIGH 0
#define SGPIO_TRG_LEVEL_LOW 1
static const struct sgpio_properties properties_luton = {
.arch = SGPIO_ARCH_LUTON,
.regoff = { 0x00, 0x09, 0x29, 0x2a, 0x2b },
};
static const struct sgpio_properties properties_ocelot = {
.arch = SGPIO_ARCH_OCELOT,
.regoff = { 0x00, 0x06, 0x26, 0x04, 0x05 },
};
static const struct sgpio_properties properties_sparx5 = {
.arch = SGPIO_ARCH_SPARX5,
.flags = SGPIO_FLAGS_HAS_IRQ,
.regoff = { 0x00, 0x06, 0x26, 0x04, 0x05, 0x2a, 0x32, 0x3a, 0x3e, 0x42 },
};
static const char * const functions[] = { "gpio" };
struct sgpio_bank {
struct sgpio_priv *priv;
bool is_input;
struct gpio_chip gpio;
struct pinctrl_desc pctl_desc;
};
struct sgpio_priv {
struct device *dev;
struct sgpio_bank in;
struct sgpio_bank out;
u32 bitcount;
u32 ports;
u32 clock;
struct regmap *regs;
const struct sgpio_properties *properties;
spinlock_t lock;
/* protects the config register and single shot mode */
struct mutex poll_lock;
};
struct sgpio_port_addr {
u8 port;
u8 bit;
};
static inline void sgpio_pin_to_addr(struct sgpio_priv *priv, int pin,
struct sgpio_port_addr *addr)
{
addr->port = pin / priv->bitcount;
addr->bit = pin % priv->bitcount;
}
static inline int sgpio_addr_to_pin(struct sgpio_priv *priv, int port, int bit)
{
return bit + port * priv->bitcount;
}
static inline u32 sgpio_get_addr(struct sgpio_priv *priv, u32 rno, u32 off)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/clk.h`, `linux/gpio/driver.h`, `linux/io.h`, `linux/mfd/ocelot.h`, `linux/mod_devicetable.h`, `linux/module.h`.
- Detected declarations: `struct sgpio_properties`, `struct sgpio_bank`, `struct sgpio_priv`, `struct sgpio_port_addr`, `function sgpio_pin_to_addr`, `function sgpio_addr_to_pin`, `function sgpio_get_addr`, `function sgpio_readl`, `function sgpio_writel`, `function sgpio_clrsetbits`.
- 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.