1a2ff95e0SMark Pearson /* SPDX-License-Identifier: GPL-2.0-or-later */ 2a2ff95e0SMark Pearson /* 3a2ff95e0SMark Pearson * Platform profile sysfs interface 4a2ff95e0SMark Pearson * 5ee62c89cSMauro Carvalho Chehab * See Documentation/userspace-api/sysfs-platform_profile.rst for more 6a2ff95e0SMark Pearson * information. 7a2ff95e0SMark Pearson */ 8a2ff95e0SMark Pearson 9a2ff95e0SMark Pearson #ifndef _PLATFORM_PROFILE_H_ 10a2ff95e0SMark Pearson #define _PLATFORM_PROFILE_H_ 11a2ff95e0SMark Pearson 12d960f148SKurt Borja #include <linux/device.h> 13a2ff95e0SMark Pearson #include <linux/bitops.h> 14a2ff95e0SMark Pearson 15a2ff95e0SMark Pearson /* 166120484eSMaximilian Luz * If more options are added please update profile_names array in 176120484eSMaximilian Luz * platform_profile.c and sysfs-platform_profile documentation. 18a2ff95e0SMark Pearson */ 19a2ff95e0SMark Pearson 20a2ff95e0SMark Pearson enum platform_profile_option { 21a2ff95e0SMark Pearson PLATFORM_PROFILE_LOW_POWER, 22a2ff95e0SMark Pearson PLATFORM_PROFILE_COOL, 23a2ff95e0SMark Pearson PLATFORM_PROFILE_QUIET, 24a2ff95e0SMark Pearson PLATFORM_PROFILE_BALANCED, 256c0b5e3fSMaximilian Luz PLATFORM_PROFILE_BALANCED_PERFORMANCE, 26a2ff95e0SMark Pearson PLATFORM_PROFILE_PERFORMANCE, 27494637cfSMario Limonciello PLATFORM_PROFILE_CUSTOM, 28a2ff95e0SMark Pearson PLATFORM_PROFILE_LAST, /*must always be last */ 29a2ff95e0SMark Pearson }; 30a2ff95e0SMark Pearson 31ee7f3e2bSKurt Borja /** 32ee7f3e2bSKurt Borja * struct platform_profile_ops - platform profile operations 33ee7f3e2bSKurt Borja * @probe: Callback to setup choices available to the new class device. These 34ee7f3e2bSKurt Borja * choices will only be enforced when setting a new profile, not when 35ee7f3e2bSKurt Borja * getting the current one. 36*778b94d7SMario Limonciello * @hidden_choices: Callback to setup choices that are not visible to the user 37*778b94d7SMario Limonciello * but can be set by the driver. 38ee7f3e2bSKurt Borja * @profile_get: Callback that will be called when showing the current platform 39ee7f3e2bSKurt Borja * profile in sysfs. 40ee7f3e2bSKurt Borja * @profile_set: Callback that will be called when storing a new platform 41ee7f3e2bSKurt Borja * profile in sysfs. 42ee7f3e2bSKurt Borja */ 43b5ca1a44SKurt Borja struct platform_profile_ops { 4458d5629dSKurt Borja int (*probe)(void *drvdata, unsigned long *choices); 45*778b94d7SMario Limonciello int (*hidden_choices)(void *drvdata, unsigned long *choices); 46b5ca1a44SKurt Borja int (*profile_get)(struct device *dev, enum platform_profile_option *profile); 47b5ca1a44SKurt Borja int (*profile_set)(struct device *dev, enum platform_profile_option profile); 48b5ca1a44SKurt Borja }; 49b5ca1a44SKurt Borja 5007f531b3SKurt Borja struct device *platform_profile_register(struct device *dev, const char *name, 5107f531b3SKurt Borja void *drvdata, 5207f531b3SKurt Borja const struct platform_profile_ops *ops); 5307f531b3SKurt Borja void platform_profile_remove(struct device *dev); 5407f531b3SKurt Borja struct device *devm_platform_profile_register(struct device *dev, const char *name, 5507f531b3SKurt Borja void *drvdata, 5607f531b3SKurt Borja const struct platform_profile_ops *ops); 57ba95eb44SGergo Koteles int platform_profile_cycle(void); 5807f531b3SKurt Borja void platform_profile_notify(struct device *dev); 59a2ff95e0SMark Pearson 60a2ff95e0SMark Pearson #endif /*_PLATFORM_PROFILE_H_*/ 61