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
|
/*
* drivers/video/tegra/host/nvhost_acm.h
*
* Tegra Graphics Host Automatic Clock Management
*
* Copyright (c) 2010, 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
struct nvhost_module;
enum nvhost_power_action {
NVHOST_POWER_ACTION_OFF,
NVHOST_POWER_ACTION_ON,
};
typedef void (*nvhost_modulef)(struct nvhost_module *mod, enum nvhost_power_action action);
struct nvhost_module_client {
struct list_head node;
unsigned long rate[NVHOST_MODULE_MAX_CLOCKS];
void *priv;
};
struct nvhost_module {
const char *name;
nvhost_modulef func;
struct delayed_work powerdown;
struct clk *clk[NVHOST_MODULE_MAX_CLOCKS];
int num_clks;
struct mutex lock;
bool powered;
atomic_t refcount;
wait_queue_head_t idle;
struct nvhost_module *parent;
int powergate_id;
struct list_head client_list;
};
int nvhost_module_init(struct nvhost_module *mod, const char *name,
nvhost_modulef func, struct nvhost_module *parent,
struct device *dev);
void nvhost_module_deinit(struct nvhost_module *mod);
void nvhost_module_suspend(struct nvhost_module *mod, bool system_suspend);
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_module *mod, void *priv);
void nvhost_module_remove_client(struct nvhost_module *mod, void *priv);
int nvhost_module_get_rate(struct nvhost_module *mod, unsigned long *rate,
int index);
int nvhost_module_set_rate(struct nvhost_module *mod, void *priv,
unsigned long rate, int index);
static inline bool nvhost_module_powered(struct nvhost_module *mod)
{
return mod->powered;
}
static inline void nvhost_module_idle(struct nvhost_module *mod)
{
nvhost_module_idle_mult(mod, 1);
}
#endif
|