drivers/mmc/core/pwrseq_simple.c
Source file repositories/reference/linux-study-clean/drivers/mmc/core/pwrseq_simple.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/core/pwrseq_simple.c- Extension
.c- Size
- 5232 bytes
- Lines
- 191
- Domain
- Driver Families
- Bucket
- drivers/mmc
- 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/clk.hlinux/init.hlinux/kernel.hlinux/platform_device.hlinux/module.hlinux/slab.hlinux/device.hlinux/err.hlinux/gpio/consumer.hlinux/delay.hlinux/property.hlinux/of.hlinux/reset.hlinux/mmc/host.hpwrseq.h
Detected Declarations
struct mmc_pwrseq_simplefunction mmc_pwrseq_simple_set_gpios_valuefunction mmc_pwrseq_simple_pre_power_onfunction mmc_pwrseq_simple_post_power_onfunction mmc_pwrseq_simple_power_offfunction mmc_pwrseq_simple_probefunction mmc_pwrseq_simple_remove
Annotated Snippet
struct mmc_pwrseq_simple {
struct mmc_pwrseq pwrseq;
bool clk_enabled;
u32 post_power_on_delay_ms;
u32 power_off_delay_us;
struct clk *ext_clk;
struct gpio_descs *reset_gpios;
struct reset_control *reset_ctrl;
};
#define to_pwrseq_simple(p) container_of(p, struct mmc_pwrseq_simple, pwrseq)
static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq,
int value)
{
struct gpio_descs *reset_gpios = pwrseq->reset_gpios;
if (!IS_ERR(reset_gpios)) {
unsigned long *values;
int nvalues = reset_gpios->ndescs;
values = bitmap_alloc(nvalues, GFP_KERNEL);
if (!values)
return;
if (value)
bitmap_fill(values, nvalues);
else
bitmap_zero(values, nvalues);
gpiod_multi_set_value_cansleep(reset_gpios, values);
bitmap_free(values);
}
}
static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host)
{
struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq);
if (!IS_ERR(pwrseq->ext_clk) && !pwrseq->clk_enabled) {
clk_prepare_enable(pwrseq->ext_clk);
pwrseq->clk_enabled = true;
}
if (pwrseq->reset_ctrl) {
reset_control_deassert(pwrseq->reset_ctrl);
reset_control_assert(pwrseq->reset_ctrl);
} else
mmc_pwrseq_simple_set_gpios_value(pwrseq, 1);
}
static void mmc_pwrseq_simple_post_power_on(struct mmc_host *host)
{
struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq);
if (pwrseq->reset_ctrl)
reset_control_deassert(pwrseq->reset_ctrl);
else
mmc_pwrseq_simple_set_gpios_value(pwrseq, 0);
if (pwrseq->post_power_on_delay_ms)
msleep(pwrseq->post_power_on_delay_ms);
}
static void mmc_pwrseq_simple_power_off(struct mmc_host *host)
{
struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq);
if (pwrseq->reset_ctrl)
reset_control_assert(pwrseq->reset_ctrl);
else
mmc_pwrseq_simple_set_gpios_value(pwrseq, 1);
if (pwrseq->power_off_delay_us)
usleep_range(pwrseq->power_off_delay_us,
2 * pwrseq->power_off_delay_us);
if (!IS_ERR(pwrseq->ext_clk) && pwrseq->clk_enabled) {
clk_disable_unprepare(pwrseq->ext_clk);
pwrseq->clk_enabled = false;
}
}
static const struct mmc_pwrseq_ops mmc_pwrseq_simple_ops = {
.pre_power_on = mmc_pwrseq_simple_pre_power_on,
.post_power_on = mmc_pwrseq_simple_post_power_on,
.power_off = mmc_pwrseq_simple_power_off,
};
Annotation
- Immediate include surface: `linux/clk.h`, `linux/init.h`, `linux/kernel.h`, `linux/platform_device.h`, `linux/module.h`, `linux/slab.h`, `linux/device.h`, `linux/err.h`.
- Detected declarations: `struct mmc_pwrseq_simple`, `function mmc_pwrseq_simple_set_gpios_value`, `function mmc_pwrseq_simple_pre_power_on`, `function mmc_pwrseq_simple_post_power_on`, `function mmc_pwrseq_simple_power_off`, `function mmc_pwrseq_simple_probe`, `function mmc_pwrseq_simple_remove`.
- Atlas domain: Driver Families / drivers/mmc.
- 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.