drivers/power/sequencing/pwrseq-qcom-wcn.c

Source file repositories/reference/linux-study-clean/drivers/power/sequencing/pwrseq-qcom-wcn.c

File Facts

System
Linux kernel
Corpus path
drivers/power/sequencing/pwrseq-qcom-wcn.c
Extension
.c
Size
15978 bytes
Lines
600
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct pwrseq_qcom_wcn_pdata {
	const char *const *vregs;
	size_t num_vregs;
	unsigned int pwup_delay_ms;
	unsigned int gpio_enable_delay_ms;
	const struct pwrseq_target_data **targets;
	bool has_vddio; /* separate VDD IO regulator */
	int (*match)(struct pwrseq_device *pwrseq, struct device *dev);
};

struct pwrseq_qcom_wcn_ctx {
	struct pwrseq_device *pwrseq;
	struct device_node *of_node;
	const struct pwrseq_qcom_wcn_pdata *pdata;
	struct regulator_bulk_data *regs;
	struct regulator *vddio;
	struct gpio_desc *bt_gpio;
	struct gpio_desc *wlan_gpio;
	struct gpio_desc *xo_clk_gpio;
	struct clk *clk;
	unsigned long last_gpio_enable_jf;
};

static void pwrseq_qcom_wcn_ensure_gpio_delay(struct pwrseq_qcom_wcn_ctx *ctx)
{
	unsigned long diff_jiffies;
	unsigned int diff_msecs;

	if (!ctx->pdata->gpio_enable_delay_ms)
		return;

	diff_jiffies = jiffies - ctx->last_gpio_enable_jf;
	diff_msecs = jiffies_to_msecs(diff_jiffies);

	if (diff_msecs < ctx->pdata->gpio_enable_delay_ms)
		msleep(ctx->pdata->gpio_enable_delay_ms - diff_msecs);
}

static int pwrseq_qcom_wcn_vddio_enable(struct pwrseq_device *pwrseq)
{
	struct pwrseq_qcom_wcn_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);

	return regulator_enable(ctx->vddio);
}

static int pwrseq_qcom_wcn_vddio_disable(struct pwrseq_device *pwrseq)
{
	struct pwrseq_qcom_wcn_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);

	return regulator_disable(ctx->vddio);
}

static const struct pwrseq_unit_data pwrseq_qcom_wcn_vddio_unit_data = {
	.name = "vddio-enable",
	.enable = pwrseq_qcom_wcn_vddio_enable,
	.disable = pwrseq_qcom_wcn_vddio_disable,
};

static int pwrseq_qcom_wcn_vregs_enable(struct pwrseq_device *pwrseq)
{
	struct pwrseq_qcom_wcn_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);

	return regulator_bulk_enable(ctx->pdata->num_vregs, ctx->regs);
}

static int pwrseq_qcom_wcn_vregs_disable(struct pwrseq_device *pwrseq)
{
	struct pwrseq_qcom_wcn_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);

	return regulator_bulk_disable(ctx->pdata->num_vregs, ctx->regs);
}

static const struct pwrseq_unit_data pwrseq_qcom_wcn_vregs_unit_data = {
	.name = "regulators-enable",
	.enable = pwrseq_qcom_wcn_vregs_enable,
	.disable = pwrseq_qcom_wcn_vregs_disable,
};

static int pwrseq_qcom_wcn_clk_enable(struct pwrseq_device *pwrseq)
{
	struct pwrseq_qcom_wcn_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);

	return clk_prepare_enable(ctx->clk);
}

static int pwrseq_qcom_wcn_clk_disable(struct pwrseq_device *pwrseq)
{
	struct pwrseq_qcom_wcn_ctx *ctx = pwrseq_device_get_drvdata(pwrseq);

	clk_disable_unprepare(ctx->clk);

Annotation

Implementation Notes