drivers/pinctrl/pinctrl-th1520.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/pinctrl-th1520.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/pinctrl-th1520.c- Extension
.c- Size
- 31687 bytes
- Lines
- 919
- 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/array_size.hlinux/bits.hlinux/cleanup.hlinux/clk.hlinux/device.hlinux/io.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/of.hlinux/platform_device.hlinux/seq_file.hlinux/spinlock.hlinux/of_address.hlinux/of_device.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.hcore.hpinmux.hpinconf.h
Detected Declarations
struct th1520_pad_groupstruct th1520_pinctrlenum th1520_muxtypefunction th1520_padcfg_shiftfunction th1520_muxcfg_shiftfunction th1520_muxtype_getfunction th1520_pad_muxdatafunction th1520_pad_no_padcfgfunction th1520_pinctrl_get_groups_countfunction th1520_pinctrl_get_group_pinsfunction th1520_pin_dbg_showfunction scoped_guardfunction th1520_pinctrl_dt_free_mapfunction th1520_pinctrl_dt_node_to_mapfunction of_property_for_each_stringfunction th1520_drive_strength_from_mafunction th1520_padcfg_rmwfunction scoped_guardfunction th1520_pinconf_getfunction th1520_pinconf_group_getfunction th1520_pinconf_setfunction th1520_pinconf_group_setfunction th1520_pinconf_dbg_showfunction th1520_pinmux_setfunction scoped_guardfunction th1520_pinmux_set_muxfunction th1520_gpio_request_enablefunction th1520_gpio_set_directionfunction th1520_pinctrl_probe
Annotated Snippet
struct th1520_pad_group {
const char *name;
const struct pinctrl_pin_desc *pins;
unsigned int npins;
};
struct th1520_pinctrl {
struct pinctrl_desc desc;
struct mutex mutex; /* serialize adding functions */
raw_spinlock_t lock; /* serialize register access */
void __iomem *base;
struct pinctrl_dev *pctl;
};
static void __iomem *th1520_padcfg(struct th1520_pinctrl *thp,
unsigned int pin)
{
return thp->base + 4 * (pin / 2);
}
static unsigned int th1520_padcfg_shift(unsigned int pin)
{
return 16 * (pin & BIT(0));
}
static void __iomem *th1520_muxcfg(struct th1520_pinctrl *thp,
unsigned int pin)
{
return thp->base + 0x400 + 4 * (pin / 8);
}
static unsigned int th1520_muxcfg_shift(unsigned int pin)
{
return 4 * (pin & GENMASK(2, 0));
}
enum th1520_muxtype {
TH1520_MUX_____,
TH1520_MUX_GPIO,
TH1520_MUX_PWM,
TH1520_MUX_UART,
TH1520_MUX_IR,
TH1520_MUX_I2C,
TH1520_MUX_SPI,
TH1520_MUX_QSPI,
TH1520_MUX_SDIO,
TH1520_MUX_AUD,
TH1520_MUX_I2S,
TH1520_MUX_MAC0,
TH1520_MUX_MAC1,
TH1520_MUX_DPU0,
TH1520_MUX_DPU1,
TH1520_MUX_ISP,
TH1520_MUX_HDMI,
TH1520_MUX_BSEL,
TH1520_MUX_DBG,
TH1520_MUX_CLK,
TH1520_MUX_JTAG,
TH1520_MUX_ISO,
TH1520_MUX_FUSE,
TH1520_MUX_RST,
};
static const char *const th1520_muxtype_string[] = {
[TH1520_MUX_GPIO] = "gpio",
[TH1520_MUX_PWM] = "pwm",
[TH1520_MUX_UART] = "uart",
[TH1520_MUX_IR] = "ir",
[TH1520_MUX_I2C] = "i2c",
[TH1520_MUX_SPI] = "spi",
[TH1520_MUX_QSPI] = "qspi",
[TH1520_MUX_SDIO] = "sdio",
[TH1520_MUX_AUD] = "audio",
[TH1520_MUX_I2S] = "i2s",
[TH1520_MUX_MAC0] = "gmac0",
[TH1520_MUX_MAC1] = "gmac1",
[TH1520_MUX_DPU0] = "dpu0",
[TH1520_MUX_DPU1] = "dpu1",
[TH1520_MUX_ISP] = "isp",
[TH1520_MUX_HDMI] = "hdmi",
[TH1520_MUX_BSEL] = "bootsel",
[TH1520_MUX_DBG] = "debug",
[TH1520_MUX_CLK] = "clock",
[TH1520_MUX_JTAG] = "jtag",
[TH1520_MUX_ISO] = "iso7816",
[TH1520_MUX_FUSE] = "efuse",
[TH1520_MUX_RST] = "reset",
};
static enum th1520_muxtype th1520_muxtype_get(const char *str)
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bits.h`, `linux/cleanup.h`, `linux/clk.h`, `linux/device.h`, `linux/io.h`, `linux/mod_devicetable.h`, `linux/module.h`.
- Detected declarations: `struct th1520_pad_group`, `struct th1520_pinctrl`, `enum th1520_muxtype`, `function th1520_padcfg_shift`, `function th1520_muxcfg_shift`, `function th1520_muxtype_get`, `function th1520_pad_muxdata`, `function th1520_pad_no_padcfg`, `function th1520_pinctrl_get_groups_count`, `function th1520_pinctrl_get_group_pins`.
- 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.