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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/*
* drivers/video/tegra/host/nvhost_acm.h
*
* Tegra Graphics Host Automatic Clock Management
*
* Copyright (c) 2010-2011, NVIDIA Corporation.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __NVHOST_ACM_H
#define __NVHOST_ACM_H
#include <linux/workqueue.h>
#include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/clk.h>
#define NVHOST_MODULE_MAX_CLOCKS 3
#define NVHOST_MODULE_MAX_POWERGATE_IDS 2
struct nvhost_module;
struct nvhost_master;
struct nvhost_moduledesc_clock {
char *name;
long default_rate;
};
#define NVHOST_MODULE_NO_POWERGATE_IDS .powergate_ids = {-1, -1}
#define NVHOST_DEFAULT_CLOCKGATE_DELAY .clockgate_delay = 25
struct nvhost_moduledesc {
int (*prepare_poweroff)(struct nvhost_module *mod);
void (*finalize_poweron)(struct nvhost_module *mod);
void (*busy)(struct nvhost_module *);
void (*idle)(struct nvhost_module *);
void (*suspend)(struct nvhost_module *);
void (*init)(struct device *dev, struct nvhost_module *);
void (*deinit)(struct device *dev, struct nvhost_module *);
int powergate_ids[NVHOST_MODULE_MAX_POWERGATE_IDS];
bool can_powergate;
int clockgate_delay;
int powergate_delay;
struct nvhost_moduledesc_clock clocks[NVHOST_MODULE_MAX_CLOCKS];
};
enum nvhost_module_powerstate_t {
NVHOST_POWER_STATE_DEINIT,
NVHOST_POWER_STATE_RUNNING,
NVHOST_POWER_STATE_CLOCKGATED,
NVHOST_POWER_STATE_POWERGATED
};
struct nvhost_module {
const char *name;
struct delayed_work powerstate_down;
int num_clks;
struct clk *clk[NVHOST_MODULE_MAX_CLOCKS];
struct mutex lock;
int powerstate;
atomic_t refcount;
wait_queue_head_t idle;
struct nvhost_module *parent;
const struct nvhost_moduledesc *desc;
struct list_head client_list;
};
/* Sets clocks and powergating state for a module */
void nvhost_module_preinit(const char *name, const struct nvhost_moduledesc *desc);
int nvhost_module_init(struct nvhost_module *mod, const char *name,
const struct nvhost_moduledesc *desc,
struct nvhost_module *parent,
struct device *dev);
void nvhost_module_deinit(struct device *dev, struct nvhost_module *mod);
void nvhost_module_suspend(struct nvhost_module *mod, bool system_suspend);
void nvhost_module_reset(struct device *dev, struct nvhost_module *mod);
void nvhost_module_busy(struct nvhost_module *mod);
void nvhost_module_idle_mult(struct nvhost_module *mod, int refs);
int nvhost_module_add_client(struct nvhost_master *host,
struct nvhost_module *mod,
void *priv);
void nvhost_module_remove_client(struct nvhost_master *host,
struct nvhost_module *mod,
void *priv);
int nvhost_module_get_rate(struct nvhost_master *host,
struct nvhost_module *mod,
unsigned long *rate,
int index);
int nvhost_module_set_rate(struct nvhost_master *host,
struct nvhost_module *mod, void *priv,
unsigned long rate, int index);
static inline bool nvhost_module_powered(struct nvhost_module *mod)
{
return mod->powerstate == NVHOST_POWER_STATE_RUNNING;
}
static inline void nvhost_module_idle(struct nvhost_module *mod)
{
nvhost_module_idle_mult(mod, 1);
}
#endif
|