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 9 struct device; 10 struct module; 11 struct pwrseq_device; 12 13 typedef int (*pwrseq_power_state_func)(struct pwrseq_device *); 14 typedef 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 */ 27 struct 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 */ 44 struct 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 */ 58 struct 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 66 struct pwrseq_device * 67 pwrseq_device_register(const struct pwrseq_config *config); 68 void pwrseq_device_unregister(struct pwrseq_device *pwrseq); 69 struct pwrseq_device * 70 devm_pwrseq_device_register(struct device *dev, 71 const struct pwrseq_config *config); 72 73 void *pwrseq_device_get_drvdata(struct pwrseq_device *pwrseq); 74 75 #endif /* __POWER_SEQUENCING_PROVIDER_H__ */ 76
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.