drivers/power/reset/atc260x-poweroff.c
Source file repositories/reference/linux-study-clean/drivers/power/reset/atc260x-poweroff.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/reset/atc260x-poweroff.c- Extension
.c- Size
- 6518 bytes
- Lines
- 248
- Domain
- Driver Families
- Bucket
- drivers/power
- 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.
- 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/delay.hlinux/mfd/atc260x/core.hlinux/module.hlinux/platform_device.hlinux/power_supply.hlinux/reboot.hlinux/regmap.h
Detected Declarations
struct atc260x_pwrcfunction atc2603c_do_powerofffunction atc2609a_do_powerofffunction atc2603c_initfunction atc2609a_initfunction atc260x_pwrc_pm_handlerfunction atc260x_pwrc_restart_handlerfunction atc260x_pwrc_probe
Annotated Snippet
struct atc260x_pwrc {
struct device *dev;
struct regmap *regmap;
int (*do_poweroff)(const struct atc260x_pwrc *pwrc, bool restart);
};
static int atc2603c_do_poweroff(const struct atc260x_pwrc *pwrc, bool restart)
{
int ret, deep_sleep = 0;
uint reg_mask, reg_val;
/* S4-Deep Sleep Mode is NOT available for WALL/USB power */
if (!restart && !power_supply_is_system_supplied()) {
deep_sleep = 1;
dev_info(pwrc->dev, "Enabling S4-Deep Sleep Mode");
}
/* Update wakeup sources */
reg_val = ATC2603C_PMU_SYS_CTL0_ONOFF_LONG_WK_EN |
(restart ? ATC2603C_PMU_SYS_CTL0_RESET_WK_EN
: ATC2603C_PMU_SYS_CTL0_ONOFF_SHORT_WK_EN);
ret = regmap_update_bits(pwrc->regmap, ATC2603C_PMU_SYS_CTL0,
ATC2603C_PMU_SYS_CTL0_WK_ALL, reg_val);
if (ret)
dev_warn(pwrc->dev, "failed to write SYS_CTL0: %d\n", ret);
/* Update power mode */
reg_mask = ATC2603C_PMU_SYS_CTL3_EN_S2 | ATC2603C_PMU_SYS_CTL3_EN_S3;
ret = regmap_update_bits(pwrc->regmap, ATC2603C_PMU_SYS_CTL3, reg_mask,
deep_sleep ? 0 : ATC2603C_PMU_SYS_CTL3_EN_S3);
if (ret) {
dev_err(pwrc->dev, "failed to write SYS_CTL3: %d\n", ret);
return ret;
}
/* Trigger poweroff / restart sequence */
reg_mask = restart ? ATC2603C_PMU_SYS_CTL0_RESTART_EN
: ATC2603C_PMU_SYS_CTL1_EN_S1;
reg_val = restart ? ATC2603C_PMU_SYS_CTL0_RESTART_EN : 0;
ret = regmap_update_bits(pwrc->regmap,
restart ? ATC2603C_PMU_SYS_CTL0 : ATC2603C_PMU_SYS_CTL1,
reg_mask, reg_val);
if (ret) {
dev_err(pwrc->dev, "failed to write SYS_CTL%d: %d\n",
restart ? 0 : 1, ret);
return ret;
}
/* Wait for trigger completion */
mdelay(200);
return 0;
}
static int atc2609a_do_poweroff(const struct atc260x_pwrc *pwrc, bool restart)
{
int ret, deep_sleep = 0;
uint reg_mask, reg_val;
/* S4-Deep Sleep Mode is NOT available for WALL/USB power */
if (!restart && !power_supply_is_system_supplied()) {
deep_sleep = 1;
dev_info(pwrc->dev, "Enabling S4-Deep Sleep Mode");
}
/* Update wakeup sources */
reg_val = ATC2609A_PMU_SYS_CTL0_ONOFF_LONG_WK_EN |
(restart ? ATC2609A_PMU_SYS_CTL0_RESET_WK_EN
: ATC2609A_PMU_SYS_CTL0_ONOFF_SHORT_WK_EN);
ret = regmap_update_bits(pwrc->regmap, ATC2609A_PMU_SYS_CTL0,
ATC2609A_PMU_SYS_CTL0_WK_ALL, reg_val);
if (ret)
dev_warn(pwrc->dev, "failed to write SYS_CTL0: %d\n", ret);
/* Update power mode */
reg_mask = ATC2609A_PMU_SYS_CTL3_EN_S2 | ATC2609A_PMU_SYS_CTL3_EN_S3;
ret = regmap_update_bits(pwrc->regmap, ATC2609A_PMU_SYS_CTL3, reg_mask,
deep_sleep ? 0 : ATC2609A_PMU_SYS_CTL3_EN_S3);
if (ret) {
dev_err(pwrc->dev, "failed to write SYS_CTL3: %d\n", ret);
return ret;
}
/* Trigger poweroff / restart sequence */
reg_mask = restart ? ATC2609A_PMU_SYS_CTL0_RESTART_EN
Annotation
- Immediate include surface: `linux/delay.h`, `linux/mfd/atc260x/core.h`, `linux/module.h`, `linux/platform_device.h`, `linux/power_supply.h`, `linux/reboot.h`, `linux/regmap.h`.
- Detected declarations: `struct atc260x_pwrc`, `function atc2603c_do_poweroff`, `function atc2609a_do_poweroff`, `function atc2603c_init`, `function atc2609a_init`, `function atc260x_pwrc_pm_handler`, `function atc260x_pwrc_restart_handler`, `function atc260x_pwrc_probe`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
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.