1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 #ifndef TEGRA_EMC_COMMON_H 4 #define TEGRA_EMC_COMMON_H 5 6 #include <linux/device.h> 7 #include <linux/mutex.h> 8 9 /** 10 * enum tegra_emc_rate_request_type - source of rate request 11 * @TEGRA_EMC_RATE_DEVFREQ: rate requested by devfreq governor 12 * @TEGRA_EMC_RATE_DEBUG: rate requested through debugfs knobs 13 * @TEGRA_EMC_RATE_ICC: rate requested by ICC framework 14 * @TEGRA_EMC_RATE_TYPE_MAX: number of valid request types 15 */ 16 enum tegra_emc_rate_request_type { 17 TEGRA_EMC_RATE_DEVFREQ, 18 TEGRA_EMC_RATE_DEBUG, 19 TEGRA_EMC_RATE_ICC, 20 TEGRA_EMC_RATE_TYPE_MAX, 21 }; 22 23 struct tegra_emc_rate_request { 24 unsigned long min_rate; 25 unsigned long max_rate; 26 }; 27 28 struct tegra_emc_rate_requests { 29 struct tegra_emc_rate_request requested_rate[TEGRA_EMC_RATE_TYPE_MAX]; 30 /* Protects @requested_rate. */ 31 struct mutex rate_lock; 32 struct device *dev; 33 }; 34 35 void tegra_emc_rate_requests_init(struct tegra_emc_rate_requests *reqs, 36 struct device *dev); 37 38 int tegra_emc_set_min_rate(struct tegra_emc_rate_requests *reqs, 39 unsigned long rate, 40 enum tegra_emc_rate_request_type type); 41 42 int tegra_emc_set_max_rate(struct tegra_emc_rate_requests *reqs, 43 unsigned long rate, 44 enum tegra_emc_rate_request_type type); 45 46 #endif /* TEGRA_EMC_COMMON_H */ 47