drivers/mmc/core/pwrseq_sd8787.c
Source file repositories/reference/linux-study-clean/drivers/mmc/core/pwrseq_sd8787.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/core/pwrseq_sd8787.c- Extension
.c- Size
- 3864 bytes
- Lines
- 135
- 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/delay.hlinux/init.hlinux/kernel.hlinux/platform_device.hlinux/module.hlinux/of.hlinux/slab.hlinux/device.hlinux/err.hlinux/gpio/consumer.hlinux/mmc/host.hpwrseq.h
Detected Declarations
struct mmc_pwrseq_sd8787function mmc_pwrseq_sd8787_pre_power_onfunction mmc_pwrseq_sd8787_power_offfunction mmc_pwrseq_wilc1000_pre_power_onfunction mmc_pwrseq_wilc1000_power_offfunction mmc_pwrseq_sd8787_probefunction mmc_pwrseq_sd8787_remove
Annotated Snippet
struct mmc_pwrseq_sd8787 {
struct mmc_pwrseq pwrseq;
struct gpio_desc *reset_gpio;
struct gpio_desc *pwrdn_gpio;
};
#define to_pwrseq_sd8787(p) container_of(p, struct mmc_pwrseq_sd8787, pwrseq)
static void mmc_pwrseq_sd8787_pre_power_on(struct mmc_host *host)
{
struct mmc_pwrseq_sd8787 *pwrseq = to_pwrseq_sd8787(host->pwrseq);
gpiod_set_value_cansleep(pwrseq->reset_gpio, 1);
msleep(300);
gpiod_set_value_cansleep(pwrseq->pwrdn_gpio, 1);
}
static void mmc_pwrseq_sd8787_power_off(struct mmc_host *host)
{
struct mmc_pwrseq_sd8787 *pwrseq = to_pwrseq_sd8787(host->pwrseq);
gpiod_set_value_cansleep(pwrseq->pwrdn_gpio, 0);
gpiod_set_value_cansleep(pwrseq->reset_gpio, 0);
}
static void mmc_pwrseq_wilc1000_pre_power_on(struct mmc_host *host)
{
struct mmc_pwrseq_sd8787 *pwrseq = to_pwrseq_sd8787(host->pwrseq);
/* The pwrdn_gpio is really CHIP_EN, reset_gpio is RESETN */
gpiod_set_value_cansleep(pwrseq->pwrdn_gpio, 1);
msleep(5);
gpiod_set_value_cansleep(pwrseq->reset_gpio, 1);
}
static void mmc_pwrseq_wilc1000_power_off(struct mmc_host *host)
{
struct mmc_pwrseq_sd8787 *pwrseq = to_pwrseq_sd8787(host->pwrseq);
gpiod_set_value_cansleep(pwrseq->reset_gpio, 0);
gpiod_set_value_cansleep(pwrseq->pwrdn_gpio, 0);
}
static const struct mmc_pwrseq_ops mmc_pwrseq_sd8787_ops = {
.pre_power_on = mmc_pwrseq_sd8787_pre_power_on,
.power_off = mmc_pwrseq_sd8787_power_off,
};
static const struct mmc_pwrseq_ops mmc_pwrseq_wilc1000_ops = {
.pre_power_on = mmc_pwrseq_wilc1000_pre_power_on,
.power_off = mmc_pwrseq_wilc1000_power_off,
};
static const struct of_device_id mmc_pwrseq_sd8787_of_match[] = {
{ .compatible = "mmc-pwrseq-sd8787", .data = &mmc_pwrseq_sd8787_ops },
{ .compatible = "mmc-pwrseq-wilc1000", .data = &mmc_pwrseq_wilc1000_ops },
{/* sentinel */},
};
MODULE_DEVICE_TABLE(of, mmc_pwrseq_sd8787_of_match);
static int mmc_pwrseq_sd8787_probe(struct platform_device *pdev)
{
struct mmc_pwrseq_sd8787 *pwrseq;
struct device *dev = &pdev->dev;
const struct of_device_id *match;
pwrseq = devm_kzalloc(dev, sizeof(*pwrseq), GFP_KERNEL);
if (!pwrseq)
return -ENOMEM;
match = of_match_node(mmc_pwrseq_sd8787_of_match, pdev->dev.of_node);
pwrseq->pwrdn_gpio = devm_gpiod_get(dev, "powerdown", GPIOD_OUT_LOW);
if (IS_ERR(pwrseq->pwrdn_gpio))
return PTR_ERR(pwrseq->pwrdn_gpio);
pwrseq->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(pwrseq->reset_gpio))
return PTR_ERR(pwrseq->reset_gpio);
pwrseq->pwrseq.dev = dev;
pwrseq->pwrseq.ops = match->data;
pwrseq->pwrseq.owner = THIS_MODULE;
platform_set_drvdata(pdev, pwrseq);
return mmc_pwrseq_register(&pwrseq->pwrseq);
}
static void mmc_pwrseq_sd8787_remove(struct platform_device *pdev)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/init.h`, `linux/kernel.h`, `linux/platform_device.h`, `linux/module.h`, `linux/of.h`, `linux/slab.h`, `linux/device.h`.
- Detected declarations: `struct mmc_pwrseq_sd8787`, `function mmc_pwrseq_sd8787_pre_power_on`, `function mmc_pwrseq_sd8787_power_off`, `function mmc_pwrseq_wilc1000_pre_power_on`, `function mmc_pwrseq_wilc1000_power_off`, `function mmc_pwrseq_sd8787_probe`, `function mmc_pwrseq_sd8787_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.