drivers/misc/tps6594-esm.c
Source file repositories/reference/linux-study-clean/drivers/misc/tps6594-esm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/tps6594-esm.c- Extension
.c- Size
- 3872 bytes
- Lines
- 147
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/mfd/tps6594.h
Detected Declarations
function ESMfunction tps6594_esm_probefunction tps6594_esm_removefunction tps6594_esm_suspendfunction tps6594_esm_resume
Annotated Snippet
if (irq == platform_get_irq_byname(pdev, pdev->resource[i].name)) {
dev_err(pdev->dev.parent, "%s error detected\n", pdev->resource[i].name);
return IRQ_HANDLED;
}
}
return IRQ_NONE;
}
static int tps6594_esm_probe(struct platform_device *pdev)
{
struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent);
struct device *dev = &pdev->dev;
unsigned int rev;
int irq;
int ret;
int i;
/*
* Due to a bug in revision 1 of the PMIC, the GPIO3 used for the
* SoC ESM function is used to power the load switch instead.
* As a consequence, ESM can not be used on those PMIC.
* Check the version and return an error in case of revision 1.
*/
ret = regmap_read(tps->regmap, TPS6594_REG_DEV_REV, &rev);
if (ret)
return dev_err_probe(dev, ret,
"Failed to read PMIC revision\n");
if (rev == TPS6594_DEV_REV_1)
return dev_err_probe(dev, -ENODEV,
"ESM not supported for revision 1 PMIC\n");
for (i = 0; i < pdev->num_resources; i++) {
irq = platform_get_irq_byname(pdev, pdev->resource[i].name);
if (irq < 0)
return irq;
ret = devm_request_threaded_irq(dev, irq, NULL,
tps6594_esm_isr, IRQF_ONESHOT,
pdev->resource[i].name, pdev);
if (ret)
return dev_err_probe(dev, ret, "Failed to request irq\n");
}
ret = regmap_set_bits(tps->regmap, TPS6594_REG_ESM_SOC_MODE_CFG,
TPS6594_BIT_ESM_SOC_EN | TPS6594_BIT_ESM_SOC_ENDRV);
if (ret)
return dev_err_probe(dev, ret, "Failed to configure ESM\n");
ret = regmap_set_bits(tps->regmap, TPS6594_REG_ESM_SOC_START_REG,
TPS6594_BIT_ESM_SOC_START);
if (ret)
return dev_err_probe(dev, ret, "Failed to start ESM\n");
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
return 0;
}
static void tps6594_esm_remove(struct platform_device *pdev)
{
struct tps6594 *tps = dev_get_drvdata(pdev->dev.parent);
struct device *dev = &pdev->dev;
int ret;
ret = regmap_clear_bits(tps->regmap, TPS6594_REG_ESM_SOC_START_REG,
TPS6594_BIT_ESM_SOC_START);
if (ret) {
dev_err(dev, "Failed to stop ESM\n");
goto out;
}
ret = regmap_clear_bits(tps->regmap, TPS6594_REG_ESM_SOC_MODE_CFG,
TPS6594_BIT_ESM_SOC_EN | TPS6594_BIT_ESM_SOC_ENDRV);
if (ret)
dev_err(dev, "Failed to unconfigure ESM\n");
out:
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
}
static int tps6594_esm_suspend(struct device *dev)
{
struct tps6594 *tps = dev_get_drvdata(dev->parent);
int ret;
ret = regmap_clear_bits(tps->regmap, TPS6594_REG_ESM_SOC_START_REG,
TPS6594_BIT_ESM_SOC_START);
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/regmap.h`, `linux/mfd/tps6594.h`.
- Detected declarations: `function ESM`, `function tps6594_esm_probe`, `function tps6594_esm_remove`, `function tps6594_esm_suspend`, `function tps6594_esm_resume`.
- Atlas domain: Driver Families / drivers/misc.
- 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.