summaryrefslogtreecommitdiff
path: root/drivers/memory/tegra/tegra-emc-common.h
blob: 157e27024342bfa4c2a97b523310bb0b8f628d7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef TEGRA_EMC_COMMON_H
#define TEGRA_EMC_COMMON_H

#include <linux/device.h>
#include <linux/mutex.h>

/**
 * enum tegra_emc_rate_request_type - source of rate request
 * @TEGRA_EMC_RATE_DEVFREQ: rate requested by devfreq governor
 * @TEGRA_EMC_RATE_DEBUG: rate requested through debugfs knobs
 * @TEGRA_EMC_RATE_ICC: rate requested by ICC framework
 * @TEGRA_EMC_RATE_TYPE_MAX: number of valid request types
 */
enum tegra_emc_rate_request_type {
	TEGRA_EMC_RATE_DEVFREQ,
	TEGRA_EMC_RATE_DEBUG,
	TEGRA_EMC_RATE_ICC,
	TEGRA_EMC_RATE_TYPE_MAX,
};

struct tegra_emc_rate_request {
	unsigned long min_rate;
	unsigned long max_rate;
};

struct tegra_emc_rate_requests {
	struct tegra_emc_rate_request requested_rate[TEGRA_EMC_RATE_TYPE_MAX];
	/* Protects @requested_rate. */
	struct mutex rate_lock;
	struct device *dev;
};

void tegra_emc_rate_requests_init(struct tegra_emc_rate_requests *reqs,
				  struct device *dev);

int tegra_emc_set_min_rate(struct tegra_emc_rate_requests *reqs,
			   unsigned long rate,
			   enum tegra_emc_rate_request_type type);

int tegra_emc_set_max_rate(struct tegra_emc_rate_requests *reqs,
			   unsigned long rate,
			   enum tegra_emc_rate_request_type type);

#endif /* TEGRA_EMC_COMMON_H */