drivers/soc/mediatek/mtk-pmic-wrap.c
Source file repositories/reference/linux-study-clean/drivers/soc/mediatek/mtk-pmic-wrap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/mediatek/mtk-pmic-wrap.c- Extension
.c- Size
- 70783 bytes
- Lines
- 2618
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/clk.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/regmap.hlinux/reset.h
Detected Declarations
struct pmic_wrapperstruct pwrap_slv_regopsstruct pwrap_slv_typestruct pmic_wrapperstruct pmic_wrapper_typeenum dew_regsenum pwrap_regsenum pmic_typeenum pwrap_typefunction pwrap_readlfunction pwrap_writelfunction pwrap_get_fsm_statefunction pwrap_is_fsm_idlefunction pwrap_is_fsm_vldclrfunction pwrap_leave_fsm_vldclrfunction pwrap_is_sync_idlefunction pwrap_is_fsm_idle_and_sync_idlefunction pwrap_read16function pwrap_read32function pwrap_readfunction pwrap_write16function pwrap_write32function pwrap_writefunction pwrap_regmap_readfunction pwrap_regmap_writefunction pwrap_pmic_read_testfunction pwrap_reset_spislavefunction pwrap_init_sidlyfunction pwrap_init_dual_iofunction pwrap_init_chip_select_extfunction pwrap_common_init_reg_clockfunction pwrap_mt2701_init_reg_clockfunction pwrap_is_cipher_readyfunction __pwrap_is_pmic_cipher_readyfunction pwrap_is_pmic_cipher_readyfunction pwrap_config_cipherfunction pwrap_init_cipherfunction pwrap_readfunction pwrap_init_securityfunction pwrap_mt8135_init_soc_specificfunction pwrap_writefunction pwrap_mt8173_init_soc_specificfunction pwrap_mt2701_init_soc_specificfunction pwrap_mt6795_init_soc_specificfunction pwrap_mt7622_init_soc_specificfunction pwrap_mt8183_init_soc_specificfunction pwrap_initfunction pwrap_interrupt
Annotated Snippet
struct pwrap_slv_regops {
const struct regmap_config *regmap;
/*
* pwrap operations are highly associated with the PMIC types,
* so the pointers added increases flexibility allowing determination
* which type is used by the detection through device tree.
*/
int (*pwrap_read)(struct pmic_wrapper *wrp, u32 adr, u32 *rdata);
int (*pwrap_write)(struct pmic_wrapper *wrp, u32 adr, u32 wdata);
};
/**
* struct pwrap_slv_type - PMIC device wrapper definitions
* @dew_regs: Device Wrapper (DeW) register offsets
* @type: PMIC Type (model)
* @comp_dew_regs: Device Wrapper (DeW) register offsets for companion device
* @comp_type: Companion PMIC Type (model)
* @regops: Register R/W ops
* @caps: Capability flags for the target device
*/
struct pwrap_slv_type {
const u32 *dew_regs;
enum pmic_type type;
const u32 *comp_dew_regs;
enum pmic_type comp_type;
const struct pwrap_slv_regops *regops;
u32 caps;
};
struct pmic_wrapper {
struct device *dev;
void __iomem *base;
struct regmap *regmap;
const struct pmic_wrapper_type *master;
const struct pwrap_slv_type *slave;
struct reset_control *rstc;
struct reset_control *rstc_bridge;
void __iomem *bridge_base;
};
struct pmic_wrapper_type {
const int *regs;
enum pwrap_type type;
u32 arb_en_all;
u32 int_en_all;
u32 int1_en_all;
u32 spi_w;
u32 wdt_src;
/* Flags indicating the capability for the target pwrap */
u32 caps;
int (*init_reg_clock)(struct pmic_wrapper *wrp);
int (*init_soc_specific)(struct pmic_wrapper *wrp);
};
static u32 pwrap_readl(struct pmic_wrapper *wrp, enum pwrap_regs reg)
{
return readl(wrp->base + wrp->master->regs[reg]);
}
static void pwrap_writel(struct pmic_wrapper *wrp, u32 val, enum pwrap_regs reg)
{
writel(val, wrp->base + wrp->master->regs[reg]);
}
static u32 pwrap_get_fsm_state(struct pmic_wrapper *wrp)
{
u32 val;
val = pwrap_readl(wrp, PWRAP_WACS2_RDATA);
if (HAS_CAP(wrp->master->caps, PWRAP_CAP_ARB))
return PWRAP_GET_WACS_ARB_FSM(val);
else
return PWRAP_GET_WACS_FSM(val);
}
static bool pwrap_is_fsm_idle(struct pmic_wrapper *wrp)
{
return pwrap_get_fsm_state(wrp) == PWRAP_WACS_FSM_IDLE;
}
static bool pwrap_is_fsm_vldclr(struct pmic_wrapper *wrp)
{
return pwrap_get_fsm_state(wrp) == PWRAP_WACS_FSM_WFVLDCLR;
}
/*
* Timeout issue sometimes caused by the last read command
* failed because pmic wrap could not got the FSM_VLDCLR
* in time after finishing WACS2_CMD. It made state machine
Annotation
- Immediate include surface: `linux/clk.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/of_platform.h`, `linux/platform_device.h`.
- Detected declarations: `struct pmic_wrapper`, `struct pwrap_slv_regops`, `struct pwrap_slv_type`, `struct pmic_wrapper`, `struct pmic_wrapper_type`, `enum dew_regs`, `enum pwrap_regs`, `enum pmic_type`, `enum pwrap_type`, `function pwrap_readl`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.