temp revert rk change
[firefly-linux-kernel-4.4.55.git] / drivers / video / tegra / host / nvhost_cpuaccess.h
1 /*
2  * drivers/video/tegra/host/nvhost_cpuaccess.h
3  *
4  * Tegra Graphics Host Cpu Register Access
5  *
6  * Copyright (c) 2010, 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 __NVHOST_CPUACCESS_H
24 #define __NVHOST_CPUACCESS_H
25
26 #include "nvhost_hardware.h"
27 #include <linux/platform_device.h>
28 #include <linux/io.h>
29
30 enum nvhost_module_id {
31         NVHOST_MODULE_DISPLAY_A = 0,
32         NVHOST_MODULE_DISPLAY_B,
33         NVHOST_MODULE_VI,
34         NVHOST_MODULE_ISP,
35         NVHOST_MODULE_MPE,
36 #if 0
37         /* TODO: [ahatala 2010-07-02] find out if these are needed */
38         NVHOST_MODULE_FUSE,
39         NVHOST_MODULE_APB_MISC,
40         NVHOST_MODULE_CLK_RESET,
41 #endif
42         NVHOST_MODULE_NUM
43 };
44
45 struct nvhost_cpuaccess {
46         struct resource *reg_mem[NVHOST_MODULE_NUM];
47         void __iomem *regs[NVHOST_MODULE_NUM];
48 };
49
50 int nvhost_cpuaccess_init(struct nvhost_cpuaccess *ctx,
51                         struct platform_device *pdev);
52
53 void nvhost_cpuaccess_deinit(struct nvhost_cpuaccess *ctx);
54
55 int nvhost_mutex_try_lock(struct nvhost_cpuaccess *ctx, unsigned int idx);
56
57 void nvhost_mutex_unlock(struct nvhost_cpuaccess *ctx, unsigned int idx);
58
59 static inline bool nvhost_access_module_regs(
60         struct nvhost_cpuaccess *ctx, u32 module)
61 {
62         return (module < NVHOST_MODULE_NUM);
63 }
64
65 void nvhost_read_module_regs(struct nvhost_cpuaccess *ctx, u32 module,
66                         u32 offset, size_t size, void *values);
67
68 void nvhost_write_module_regs(struct nvhost_cpuaccess *ctx, u32 module,
69                         u32 offset, size_t size, const void *values);
70
71 #endif