summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/pramin_gk20a.c
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2017-03-15 18:49:18 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-03-31 20:21:34 -0400
commitdd88aed5cc3088285c5d0b900aebf705f52178c5 (patch)
tree371ffb74c97305be99fe312b45e30793dab36926 /drivers/gpu/nvgpu/gk20a/pramin_gk20a.c
parent56df8c58088b5c8b4a09ce6f5e195614251bf8d0 (diff)
gpu: nvgpu: Split out pramin code
Split out the pramin interface code in preparation for splitting out the mem_desc code. JIRA NVGPU-12 Change-Id: I3f03447ea213cc15669b0934fa706e7cb22599b7 Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: http://git-master/r/1323323 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/pramin_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/pramin_gk20a.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/pramin_gk20a.c b/drivers/gpu/nvgpu/gk20a/pramin_gk20a.c
new file mode 100644
index 00000000..bed2e9b5
--- /dev/null
+++ b/drivers/gpu/nvgpu/gk20a/pramin_gk20a.c
@@ -0,0 +1,71 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <nvgpu/page_allocator.h>
18
19#include "gk20a/gk20a.h"
20#include "gk20a/mm_gk20a.h"
21#include "gk20a/pramin_gk20a.h"
22
23#include <nvgpu/hw/gk20a/hw_bus_gk20a.h>
24#include <nvgpu/hw/gk20a/hw_pram_gk20a.h>
25
26/* WARNING: returns pramin_window_lock taken, complement with pramin_exit() */
27static u32 gk20a_pramin_enter(struct gk20a *g, struct mem_desc *mem,
28 struct page_alloc_chunk *chunk, u32 w)
29{
30 u64 bufbase = chunk->base;
31 u64 addr = bufbase + w * sizeof(u32);
32 u32 hi = (u32)((addr & ~(u64)0xfffff)
33 >> bus_bar0_window_target_bar0_window_base_shift_v());
34 u32 lo = (u32)(addr & 0xfffff);
35 u32 win = gk20a_aperture_mask(g, mem,
36 bus_bar0_window_target_sys_mem_noncoherent_f(),
37 bus_bar0_window_target_vid_mem_f()) |
38 bus_bar0_window_base_f(hi);
39
40 gk20a_dbg(gpu_dbg_mem,
41 "0x%08x:%08x begin for %p,%p at [%llx,%llx] (sz %llx)",
42 hi, lo, mem, chunk, bufbase,
43 bufbase + chunk->length, chunk->length);
44
45 WARN_ON(!bufbase);
46
47 nvgpu_spinlock_acquire(&g->mm.pramin_window_lock);
48
49 if (g->mm.pramin_window != win) {
50 gk20a_writel(g, bus_bar0_window_r(), win);
51 gk20a_readl(g, bus_bar0_window_r());
52 g->mm.pramin_window = win;
53 }
54
55 return lo;
56}
57
58static void gk20a_pramin_exit(struct gk20a *g, struct mem_desc *mem,
59 struct page_alloc_chunk *chunk)
60{
61 gk20a_dbg(gpu_dbg_mem, "end for %p,%p", mem, chunk);
62
63 nvgpu_spinlock_release(&g->mm.pramin_window_lock);
64}
65
66void gk20a_init_pramin_ops(struct gpu_ops *gops)
67{
68 gops->pramin.enter = gk20a_pramin_enter;
69 gops->pramin.exit = gk20a_pramin_exit;
70 gops->pramin.data032_r = pram_data032_r;
71}