diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /include/linux/nvhost.h | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'include/linux/nvhost.h')
-rw-r--r-- | include/linux/nvhost.h | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/include/linux/nvhost.h b/include/linux/nvhost.h new file mode 100644 index 00000000000..da5e1e6862c --- /dev/null +++ b/include/linux/nvhost.h | |||
@@ -0,0 +1,145 @@ | |||
1 | /* | ||
2 | * include/linux/nvhost.h | ||
3 | * | ||
4 | * Tegra graphics host driver | ||
5 | * | ||
6 | * Copyright (c) 2009-2012, NVIDIA Corporation. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
16 | * more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License along | ||
19 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
21 | */ | ||
22 | |||
23 | #ifndef __LINUX_NVHOST_H | ||
24 | #define __LINUX_NVHOST_H | ||
25 | |||
26 | #include <linux/device.h> | ||
27 | #include <linux/types.h> | ||
28 | |||
29 | struct nvhost_master; | ||
30 | |||
31 | #define NVHOST_MODULE_MAX_CLOCKS 3 | ||
32 | #define NVHOST_MODULE_MAX_POWERGATE_IDS 2 | ||
33 | #define NVHOST_MODULE_NO_POWERGATE_IDS .powergate_ids = {-1, -1} | ||
34 | #define NVHOST_DEFAULT_CLOCKGATE_DELAY .clockgate_delay = 25 | ||
35 | |||
36 | struct nvhost_clock { | ||
37 | char *name; | ||
38 | long default_rate; | ||
39 | }; | ||
40 | |||
41 | enum nvhost_device_powerstate_t { | ||
42 | NVHOST_POWER_STATE_DEINIT, | ||
43 | NVHOST_POWER_STATE_RUNNING, | ||
44 | NVHOST_POWER_STATE_CLOCKGATED, | ||
45 | NVHOST_POWER_STATE_POWERGATED | ||
46 | }; | ||
47 | |||
48 | struct nvhost_device { | ||
49 | const char *name; /* Device name */ | ||
50 | struct device dev; /* Linux device struct */ | ||
51 | int id; /* Separates clients of same hw */ | ||
52 | int index; /* Hardware channel number */ | ||
53 | u32 num_resources; /* Number of resources following */ | ||
54 | struct resource *resource; /* Resources (IOMEM in particular) */ | ||
55 | struct resource *reg_mem; | ||
56 | void __iomem *aperture; /* Iomem mapped to kernel */ | ||
57 | |||
58 | u32 syncpts; /* Bitfield of sync points used */ | ||
59 | u32 waitbases; /* Bit field of wait bases */ | ||
60 | u32 modulemutexes; /* Bit field of module mutexes */ | ||
61 | u32 moduleid; /* Module id for user space API */ | ||
62 | |||
63 | u32 class; /* Device class */ | ||
64 | bool exclusive; /* True if only one user at a time */ | ||
65 | bool keepalive; /* Do not power gate when opened */ | ||
66 | bool waitbasesync; /* Force sync of wait bases */ | ||
67 | |||
68 | int powergate_ids[NVHOST_MODULE_MAX_POWERGATE_IDS]; | ||
69 | bool can_powergate; /* True if module can be power gated */ | ||
70 | int clockgate_delay;/* Delay before clock gated */ | ||
71 | int powergate_delay;/* Delay before power gated */ | ||
72 | struct nvhost_clock clocks[NVHOST_MODULE_MAX_CLOCKS];/* Clock names */ | ||
73 | |||
74 | struct delayed_work powerstate_down;/* Power state management */ | ||
75 | int num_clks; /* Number of clocks opened for dev */ | ||
76 | struct clk *clk[NVHOST_MODULE_MAX_CLOCKS]; | ||
77 | struct mutex lock; /* Power management lock */ | ||
78 | int powerstate; /* Current power state */ | ||
79 | int refcount; /* Number of tasks active */ | ||
80 | wait_queue_head_t idle_wq; /* Work queue for idle */ | ||
81 | struct list_head client_list; /* List of clients and rate requests */ | ||
82 | |||
83 | struct nvhost_channel *channel; /* Channel assigned for the module */ | ||
84 | |||
85 | /* Allocates a context handler for the device */ | ||
86 | struct nvhost_hwctx_handler *(*alloc_hwctx_handler)(u32 syncpt, | ||
87 | u32 waitbase, struct nvhost_channel *ch); | ||
88 | /* Preparing for power off. Used for context save. */ | ||
89 | int (*prepare_poweroff)(struct nvhost_device *dev); | ||
90 | /* Finalize power on. Can be used for context restore. */ | ||
91 | void (*finalize_poweron)(struct nvhost_device *dev); | ||
92 | /* Device is busy. */ | ||
93 | void (*busy)(struct nvhost_device *); | ||
94 | /* Device is idle. */ | ||
95 | void (*idle)(struct nvhost_device *); | ||
96 | /* Device is going to be suspended */ | ||
97 | void (*suspend)(struct nvhost_device *); | ||
98 | /* Device is initialized */ | ||
99 | void (*init)(struct nvhost_device *dev); | ||
100 | /* Device is de-initialized. */ | ||
101 | void (*deinit)(struct nvhost_device *dev); | ||
102 | }; | ||
103 | |||
104 | /* Register device to nvhost bus */ | ||
105 | extern int nvhost_device_register(struct nvhost_device *); | ||
106 | |||
107 | /* Deregister device from nvhost bus */ | ||
108 | extern void nvhost_device_unregister(struct nvhost_device *); | ||
109 | |||
110 | extern struct bus_type nvhost_bus_type; | ||
111 | |||
112 | struct nvhost_driver { | ||
113 | int (*probe)(struct nvhost_device *); | ||
114 | int (*remove)(struct nvhost_device *); | ||
115 | void (*shutdown)(struct nvhost_device *); | ||
116 | int (*suspend)(struct nvhost_device *, pm_message_t state); | ||
117 | int (*resume)(struct nvhost_device *); | ||
118 | struct device_driver driver; | ||
119 | }; | ||
120 | |||
121 | extern int nvhost_driver_register(struct nvhost_driver *); | ||
122 | extern void nvhost_driver_unregister(struct nvhost_driver *); | ||
123 | extern struct resource *nvhost_get_resource(struct nvhost_device *, | ||
124 | unsigned int, unsigned int); | ||
125 | extern int nvhost_get_irq(struct nvhost_device *, unsigned int); | ||
126 | extern struct resource *nvhost_get_resource_byname(struct nvhost_device *, | ||
127 | unsigned int, const char *); | ||
128 | extern int nvhost_get_irq_byname(struct nvhost_device *, const char *); | ||
129 | |||
130 | #define to_nvhost_device(x) container_of((x), struct nvhost_device, dev) | ||
131 | #define to_nvhost_driver(drv) (container_of((drv), struct nvhost_driver, \ | ||
132 | driver)) | ||
133 | |||
134 | #define nvhost_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev) | ||
135 | #define nvhost_set_drvdata(_dev, data) dev_set_drvdata(&(_dev)->dev, (data)) | ||
136 | static inline struct nvhost_master *nvhost_get_host(struct nvhost_device *_dev) | ||
137 | { | ||
138 | return (_dev->dev.parent) ? \ | ||
139 | ((struct nvhost_master *) dev_get_drvdata(_dev->dev.parent)) : \ | ||
140 | ((struct nvhost_master *) dev_get_drvdata(&(_dev->dev))); | ||
141 | } | ||
142 | |||
143 | int nvhost_bus_add_host(struct nvhost_master *host); | ||
144 | |||
145 | #endif | ||