Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Copyright (C) 2024 Linaro Ltd.
4 */
5
6#ifndef __POWER_SEQUENCING_PROVIDER_H__
7#define __POWER_SEQUENCING_PROVIDER_H__
8
9struct device;
10struct module;
11struct pwrseq_device;
12
13typedef int (*pwrseq_power_state_func)(struct pwrseq_device *);
14typedef int (*pwrseq_match_func)(struct pwrseq_device *, struct device *);
15
16/**
17 * struct pwrseq_unit_data - Configuration of a single power sequencing
18 * unit.
19 * @name: Name of the unit.
20 * @deps: Units that must be enabled before this one and disabled after it
21 * in the order they come in this array. Must be NULL-terminated.
22 * @enable: Callback running the part of the power-on sequence provided by
23 * this unit.
24 * @disable: Callback running the part of the power-off sequence provided
25 * by this unit.
26 */
27struct pwrseq_unit_data {
28 const char *name;
29 const struct pwrseq_unit_data **deps;
30 pwrseq_power_state_func enable;
31 pwrseq_power_state_func disable;
32};
33
34/**
35 * struct pwrseq_target_data - Configuration of a power sequencing target.
36 * @name: Name of the target.
37 * @unit: Final unit that this target must reach in order to be considered
38 * enabled.
39 * @post_enable: Callback run after the target unit has been enabled, *after*
40 * the state lock has been released. It's useful for implementing
41 * boot-up delays without blocking other users from powering up
42 * using the same power sequencer.
43 */
44struct pwrseq_target_data {
45 const char *name;
46 const struct pwrseq_unit_data *unit;
47 pwrseq_power_state_func post_enable;
48};
49
50/**
51 * struct pwrseq_config - Configuration used for registering a new provider.
52 * @parent: Parent device for the sequencer. Must be set.
53 * @owner: Module providing this device.
54 * @drvdata: Private driver data.
55 * @match: Provider callback used to match the consumer device to the sequencer.
56 * @targets: Array of targets for this power sequencer. Must be NULL-terminated.
57 */
58struct pwrseq_config {
59 struct device *parent;
60 struct module *owner;
61 void *drvdata;
62 pwrseq_match_func match;
63 const struct pwrseq_target_data **targets;
64};
65
66struct pwrseq_device *
67pwrseq_device_register(const struct pwrseq_config *config);
68void pwrseq_device_unregister(struct pwrseq_device *pwrseq);
69struct pwrseq_device *
70devm_pwrseq_device_register(struct device *dev,
71 const struct pwrseq_config *config);
72
73void *pwrseq_device_get_drvdata(struct pwrseq_device *pwrseq);
74
75#endif /* __POWER_SEQUENCING_PROVIDER_H__ */